diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 284001de2bf..d5dccaf0d03 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -146,6 +146,7 @@ return ..() /obj/structure/grille/proc/build_window(obj/item/stack/sheet/S, mob/user) + var/dir_to_set = NORTH if(!istype(S) || !user) return if(broken) @@ -160,59 +161,40 @@ if(!getRelativeDirection(src, user) && (user.loc != loc)) //essentially a cardinal direction adjacent or sharing same loc check to_chat(user, "You can't reach.") return - if(/obj/structure/window/full in loc) //check for a full window already present (blocks the whole tile) - to_chat(user, "There is already a full window there.") - return - var/selection = alert(user, "What type of window would you like to place?", "Window Construction", "One Direction", "Full", "Cancel") - if(selection == "Cancel") - return - if(selection == "Full") - if(S.get_amount() < 2) - to_chat(user, "You need at least two sheets of glass for that!") + if(loc == user.loc) + dir_to_set = user.dir + else + if(x == user.x) + if(y > user.y) + dir_to_set = SOUTH + else + dir_to_set = NORTH + else if(y == user.y) + if(x > user.x) + dir_to_set = WEST + else + dir_to_set = EAST + for(var/obj/structure/window/WINDOW in loc) + if(WINDOW.dir == dir_to_set) + to_chat(user, "There is already a window facing this way there.") return - if(do_after(user, 20, target = src)) //glass doesn't have a toolspeed, so no multiplier - if(broken || !anchored || !src) //make sure the grille is still intact, anchored, and exists! - return - if(S.get_amount() < 2) //make sure we still have enough for this! - return - if(!getRelativeDirection(src, user) && (user.loc != loc)) //make sure we can still do this from our location - return - var/obj/structure/window/W = new S.full_window(get_turf(src)) - S.use(2) - W.anchored = 0 - W.state = 0 - to_chat(user, "You place [W] on [src].") - W.update_icon() - return - if(selection == "One Direction") - var/dir_selection = input("Which direction will this window face?", "Direction") as null|anything in list("north", "east", "south", "west") - if(!dir_selection) + to_chat(user, "You start placing the window...") + if(do_after(user, 20, target = src)) + if(!loc || !anchored) //Grille destroyed or unanchored while waiting return - var/temp_dir = text2dir(dir_selection) - for(var/obj/structure/window/W in loc) - if(istype(W, /obj/structure/window/full)) //double checking in case a full window was created while selecting direction - to_chat(user, "There is already a full window there.") + for(var/obj/structure/window/WINDOW in loc) + if(WINDOW.dir == dir_to_set)//checking this for a 2nd time to check if a window was made while we were waiting. + to_chat(user, "There is already a window facing this way there.") return - if(W.dir == temp_dir) //to avoid building a window on top of an existing window - to_chat(user, "There is already a window facing this direction there.") - return - if(do_after(user, 20, target = src)) - if(broken || !anchored || !src) //make sure the grille is still intact, anchored, and exists! - return - if(S.get_amount() < 1) //make sure we still have enough fir this! - to_chat(user, "You need at least one sheet of glass for that!") - return - if(!getRelativeDirection(src, user) && (user.loc != loc)) //make sure we can still do this from our location - return - var/obj/structure/window/W = new S.created_window(get_turf(src)) - S.use(1) - W.setDir(temp_dir) - W.ini_dir = temp_dir - W.anchored = 0 - W.state = 0 - to_chat(user, "You place [W] on [src].") - W.update_icon() - return + var/obj/structure/window/W = new S.created_window(get_turf(src)) + S.use(1) + W.setDir(dir_to_set) + W.ini_dir = dir_to_set + W.anchored = 0 + W.state = 0 + to_chat(user, "You place the [W] on [src].") + W.update_icon() + return /obj/structure/grille/attacked_by(obj/item/I, mob/living/user) user.changeNext_move(CLICK_CD_MELEE)