diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm
index a763d3fea8b..d52a085065f 100644
--- a/code/__HELPERS/unsorted.dm
+++ b/code/__HELPERS/unsorted.dm
@@ -1339,3 +1339,20 @@ proc/pick_closest_path(value, list/matches = get_fancy_list_of_atom_types())
. = "gigantic"
else
. = ""
+
+//can a window be here, or is there a window blocking it?
+/proc/valid_window_location(turf/T, dir_to_check)
+ if(!T)
+ return FALSE
+ for(var/obj/O in T)
+ if(istype(O, /obj/machinery/door/window) && (O.dir == dir_to_check || dir_to_check == FULLTILE_WINDOW_DIR))
+ return FALSE
+ if(istype(O, /obj/structure/windoor_assembly))
+ var/obj/structure/windoor_assembly/W = O
+ if(W.ini_dir == dir_to_check || dir_to_check == FULLTILE_WINDOW_DIR)
+ return FALSE
+ if(istype(O, /obj/structure/window))
+ var/obj/structure/window/W = O
+ if(W.ini_dir == dir_to_check || W.ini_dir == FULLTILE_WINDOW_DIR || dir_to_check == FULLTILE_WINDOW_DIR)
+ return FALSE
+ return TRUE
diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm
index bbc8aeff386..9e5ea61eb69 100644
--- a/code/game/machinery/doors/windowdoor.dm
+++ b/code/game/machinery/doors/windowdoor.dm
@@ -93,6 +93,16 @@
return 1
if(get_dir(loc, target) == dir) //Make sure looking at appropriate border
return !density
+ if(istype(mover, /obj/structure/window))
+ var/obj/structure/window/W = mover
+ if(!valid_window_location(loc, W.ini_dir))
+ return FALSE
+ else if(istype(mover, /obj/structure/windoor_assembly))
+ var/obj/structure/windoor_assembly/W = mover
+ if(!valid_window_location(loc, W.ini_dir))
+ return FALSE
+ else if(istype(mover, /obj/machinery/door/window) && !valid_window_location(loc, mover.dir))
+ return FALSE
else
return 1
diff --git a/code/game/objects/items/stacks/sheets/glass.dm b/code/game/objects/items/stacks/sheets/glass.dm
index d98c1ed8f84..53186c02d02 100644
--- a/code/game/objects/items/stacks/sheets/glass.dm
+++ b/code/game/objects/items/stacks/sheets/glass.dm
@@ -8,6 +8,11 @@
/*
* Glass sheets
*/
+var/global/list/datum/stack_recipe/glass_recipes = list ( \
+ new/datum/stack_recipe("directional window", /obj/structure/window/unanchored, time = 0, on_floor = TRUE, window_checks = TRUE), \
+ new/datum/stack_recipe("fulltile window", /obj/structure/window/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) \
+)
+
/obj/item/stack/sheet/glass
name = "glass"
desc = "HOLY SHEET! That is a lot of glass."
@@ -27,8 +32,9 @@
/obj/item/stack/sheet/glass/fifty
amount = 50
-/obj/item/stack/sheet/glass/attack_self(mob/user)
- construct_window(user)
+/obj/item/stack/sheet/glass/New(loc, amount)
+ recipes = glass_recipes
+ ..()
/obj/item/stack/sheet/glass/attackby(obj/item/W, mob/user, params)
add_fingerprint(user)
@@ -60,79 +66,18 @@
else
return ..()
-/obj/item/stack/sheet/glass/proc/construct_window(mob/user)
- if(!user || !src)
- return 0
- if(!isturf(user.loc))
- return 0
- if(!user.IsAdvancedToolUser())
- user << "You don't have the dexterity to do this!"
- return 0
- if(zero_amount())
- return 0
- var/title = "Sheet-Glass"
- title += " ([src.get_amount()] sheet\s left)"
- switch(alert(title, "Would you like full tile glass or one direction?", "One Direction", "Full Window", "Cancel", null))
- if("One Direction")
- if(!src)
- return 1
- if(src.loc != user)
- return 1
-
- var/list/directions = new/list(cardinal)
- var/i = 0
- for (var/obj/structure/window/win in user.loc)
- i++
- if(i >= 4)
- user << "There are too many windows in this location."
- return 1
- directions-=win.dir
- if(!(win.ini_dir in cardinal))
- user << "Can't let you do that."
- return 1
-
- //Determine the direction. It will first check in the direction the person making the window is facing, if it finds an already made window it will try looking at the next cardinal direction, etc.
- var/dir_to_set = 2
- for(var/direction in list( user.dir, turn(user.dir,90), turn(user.dir,180), turn(user.dir,270) ))
- var/found = 0
- for(var/obj/structure/window/WT in user.loc)
- if(WT.dir == direction)
- found = 1
- if(!found)
- dir_to_set = direction
- break
-
- var/obj/structure/window/W
- W = new /obj/structure/window( user.loc, 0 )
- W.setDir(dir_to_set)
- W.ini_dir = W.dir
- W.anchored = 0
- W.air_update_turf(1)
- src.use(1)
- W.add_fingerprint(user)
- if("Full Window")
- if(!src)
- return 1
- if(src.loc != user)
- return 1
- if(src.get_amount() < 2)
- user << "You need more glass to do that!"
- return 1
- if(locate(/obj/structure/window) in user.loc)
- user << "There is a window in the way!"
- return 1
- var/obj/structure/window/W
- W = new /obj/structure/window/fulltile( user.loc, 0 )
- W.anchored = 0
- W.air_update_turf(1)
- W.add_fingerprint(user)
- src.use(2)
- return 0
-
/*
* Reinforced glass sheets
*/
+var/global/list/datum/stack_recipe/reinforced_glass_recipes = list ( \
+ new/datum/stack_recipe("windoor frame", /obj/structure/windoor_assembly, 5, time = 0, on_floor = TRUE, window_checks = TRUE), \
+ null, \
+ new/datum/stack_recipe("directional reinforced window", /obj/structure/window/reinforced/unanchored, time = 0, on_floor = TRUE, window_checks = TRUE), \
+ new/datum/stack_recipe("fulltile reinforced window", /obj/structure/window/reinforced/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE) \
+)
+
+
/obj/item/stack/sheet/rglass
name = "reinforced glass"
desc = "Glass which seems to have rods or something stuck in them."
@@ -161,116 +106,9 @@
source.add_charge(amount * metcost)
glasource.add_charge(amount * glacost)
-/obj/item/stack/sheet/rglass/attack_self(mob/user)
- construct_window(user)
-
-/obj/item/stack/sheet/rglass/proc/construct_window(mob/user)
- if(!user || !src)
- return 0
- if(!isturf(user.loc))
- return 0
- if(!user.IsAdvancedToolUser())
- user << "You don't have the dexterity to do this!"
- return 0
- var/title = "Sheet Reinf. Glass"
- title += " ([src.get_amount()] sheet\s left)"
- switch(input(title, "Would you like full tile glass a one direction glass pane or a windoor?") in list("One Direction", "Full Window", "Windoor", "Cancel"))
- if("One Direction")
- if(!src)
- return 1
- if(src.loc != user)
- return 1
- var/list/directions = new/list(cardinal)
- var/i = 0
- for (var/obj/structure/window/win in user.loc)
- i++
- if(i >= 4)
- user << "There are too many windows in this location."
- return 1
- directions-=win.dir
- if(!(win.ini_dir in cardinal))
- user << "Can't let you do that."
- return 1
-
- //Determine the direction. It will first check in the direction the person making the window is facing, if it finds an already made window it will try looking at the next cardinal direction, etc.
- var/dir_to_set = 2
- for(var/direction in list( user.dir, turn(user.dir,90), turn(user.dir,180), turn(user.dir,270) ))
- var/found = 0
- for(var/obj/structure/window/WT in user.loc)
- if(WT.dir == direction)
- found = 1
- if(!found)
- dir_to_set = direction
- break
-
- var/obj/structure/window/W
- W = new /obj/structure/window/reinforced( user.loc, 1 )
- W.state = 0
- W.setDir(dir_to_set)
- W.ini_dir = W.dir
- W.anchored = 0
- W.add_fingerprint(user)
- src.use(1)
-
- if("Full Window")
- if(!src)
- return 1
- if(src.loc != user)
- return 1
- if(src.get_amount() < 2)
- user << "You need more glass to do that!"
- return 1
- if(locate(/obj/structure/window) in user.loc)
- user << "There is a window in the way!"
- return 1
- var/obj/structure/window/W
- W = new /obj/structure/window/reinforced/fulltile(user.loc, 1)
- W.state = 0
- W.anchored = 0
- W.add_fingerprint(user)
- src.use(2)
-
- if("Windoor")
- if(!src || src.loc != user || !isturf(user.loc))
- return 1
-
- for(var/obj/structure/windoor_assembly/WA in user.loc)
- if(WA.dir == user.dir)
- user << "There is already a windoor assembly in that location!"
- return 1
-
- for(var/obj/machinery/door/window/W in user.loc)
- if(W.dir == user.dir)
- user << "There is already a windoor in that location!"
- return 1
-
- if(src.get_amount() < 5)
- user << "You need more glass to do that!"
- return 1
-
- var/obj/structure/windoor_assembly/WD = new(user.loc)
- WD.state = "01"
- WD.anchored = 0
- WD.add_fingerprint(user)
- src.use(5)
- switch(user.dir)
- if(SOUTH)
- WD.setDir(SOUTH)
- WD.ini_dir = SOUTH
- if(EAST)
- WD.setDir(EAST)
- WD.ini_dir = EAST
- if(WEST)
- WD.setDir(WEST)
- WD.ini_dir = WEST
- else //If the user is facing northeast. northwest, southeast, southwest or north, default to north
- WD.setDir(NORTH)
- WD.ini_dir = NORTH
- else
- return 1
-
-
- return 0
+/obj/item/stack/sheet/rglass/New(loc, amount)
+ recipes = reinforced_glass_recipes
+ ..()
/obj/item/weapon/shard
diff --git a/code/game/objects/items/stacks/sheets/sheet_types.dm b/code/game/objects/items/stacks/sheets/sheet_types.dm
index a9ec6798d3f..caa570c7df5 100644
--- a/code/game/objects/items/stacks/sheets/sheet_types.dm
+++ b/code/game/objects/items/stacks/sheets/sheet_types.dm
@@ -287,15 +287,15 @@ var/global/list/datum/stack_recipe/runed_metal_recipes = list ( \
* Brass
*/
var/global/list/datum/stack_recipe/brass_recipes = list ( \
- new/datum/stack_recipe("wall gear", /obj/structure/destructible/clockwork/wall_gear, 3, time = 30, one_per_turf = 1, on_floor = 1), \
+ new/datum/stack_recipe("wall gear", /obj/structure/destructible/clockwork/wall_gear, 3, time = 30, one_per_turf = TRUE, on_floor = TRUE), \
null,
- new/datum/stack_recipe("pinion airlock", /obj/machinery/door/airlock/clockwork, 5, time = 50, one_per_turf = 1, on_floor = 1), \
- new/datum/stack_recipe("brass pinion airlock", /obj/machinery/door/airlock/clockwork/brass, 5, time = 50, one_per_turf = 1, on_floor = 1), \
- new/datum/stack_recipe("brass windoor", /obj/machinery/door/window/clockwork, 2, time = 30, one_per_turf = 1, on_floor = 1), \
+ new/datum/stack_recipe("pinion airlock", /obj/machinery/door/airlock/clockwork, 5, time = 50, one_per_turf = TRUE, on_floor = TRUE), \
+ new/datum/stack_recipe("brass pinion airlock", /obj/machinery/door/airlock/clockwork/brass, 5, time = 50, one_per_turf = TRUE, on_floor = TRUE), \
+ new/datum/stack_recipe("brass windoor", /obj/machinery/door/window/clockwork, 2, time = 30, on_floor = TRUE, window_checks = TRUE), \
null,
- new/datum/stack_recipe("directional brass window", /obj/structure/window/reinforced/clockwork, time = 15, one_per_turf = 1, on_floor = 1), \
- new/datum/stack_recipe("brass window", /obj/structure/window/reinforced/clockwork/fulltile, 2, time = 30, one_per_turf = 1, on_floor = 1), \
- new/datum/stack_recipe("brass table frame", /obj/structure/table_frame/brass, 1, time = 5, one_per_turf = 1, on_floor = 1) \
+ new/datum/stack_recipe("directional brass window", /obj/structure/window/reinforced/clockwork/unanchored, time = 0, on_floor = TRUE, window_checks = TRUE), \
+ new/datum/stack_recipe("fulltile brass window", /obj/structure/window/reinforced/clockwork/fulltile/unanchored, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \
+ new/datum/stack_recipe("brass table frame", /obj/structure/table_frame/brass, 1, time = 5, one_per_turf = TRUE, on_floor = TRUE) \
)
/obj/item/stack/tile/brass
diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm
index 1eb48f9dc6c..4ec6ec17785 100644
--- a/code/game/objects/items/stacks/stack.dm
+++ b/code/game/objects/items/stacks/stack.dm
@@ -127,6 +127,15 @@
O.setDir(usr.dir)
use(R.req_amount * multiplier)
+ //START: oh fuck i'm so sorry
+ if(istype(O, /obj/structure/windoor_assembly))
+ var/obj/structure/windoor_assembly/W = O
+ W.ini_dir = W.dir
+ else if(istype(O, /obj/structure/window))
+ var/obj/structure/window/W = O
+ W.ini_dir = W.dir
+ //END: oh fuck i'm so sorry
+
//is it a stack ?
if (R.max_res_amount > 1)
var/obj/item/stack/new_item = O
@@ -159,7 +168,10 @@
else
usr << "You haven't got enough [src] to build \the [R.title]!"
return 0
- if (R.one_per_turf && (locate(R.result_type) in usr.loc))
+ if(R.window_checks && !valid_window_location(usr.loc, usr.dir))
+ usr << "The [R.title] won't fit here!"
+ return 0
+ if(R.one_per_turf && (locate(R.result_type) in usr.loc))
usr << "There is another [R.title] here!"
return 0
if(R.on_floor && !isfloorturf(usr.loc))
@@ -275,7 +287,7 @@
/obj/item/stack/microwave_act(obj/machinery/microwave/M)
if(M && M.dirty < 100)
M.dirty += amount
-
+
/*
* Recipe datum
*/
@@ -286,10 +298,11 @@
var/res_amount = 1
var/max_res_amount = 1
var/time = 0
- var/one_per_turf = 0
- var/on_floor = 0
+ var/one_per_turf = FALSE
+ var/on_floor = FALSE
+ var/window_checks = FALSE
-/datum/stack_recipe/New(title, result_type, req_amount = 1, res_amount = 1, max_res_amount = 1, time = 0, one_per_turf = 0, on_floor = 0)
+/datum/stack_recipe/New(title, result_type, req_amount = 1, res_amount = 1, max_res_amount = 1, time = 0, one_per_turf = FALSE, on_floor = FALSE, window_checks = FALSE)
src.title = title
src.result_type = result_type
src.req_amount = req_amount
@@ -298,3 +311,4 @@
src.time = time
src.one_per_turf = one_per_turf
src.on_floor = on_floor
+ src.window_checks = window_checks
diff --git a/code/game/objects/structures/windoor_assembly.dm b/code/game/objects/structures/windoor_assembly.dm
index 0d51499463b..cb2a2af8662 100644
--- a/code/game/objects/structures/windoor_assembly.dm
+++ b/code/game/objects/structures/windoor_assembly.dm
@@ -16,7 +16,7 @@
icon_state = "l_windoor_assembly01"
anchored = 0
density = 0
- setDir(NORTH)
+ dir = NORTH
var/ini_dir
var/obj/item/weapon/electronics/airlock/electronics = null
@@ -32,8 +32,10 @@
..()
user << "Alt-click to rotate it clockwise."
-/obj/structure/windoor_assembly/New(dir=NORTH)
+/obj/structure/windoor_assembly/New(loc, set_dir)
..()
+ if(set_dir)
+ dir = set_dir
ini_dir = dir
air_update_turf(1)
@@ -45,6 +47,7 @@
/obj/structure/windoor_assembly/Move()
var/turf/T = loc
..()
+ setDir(ini_dir)
move_update_air(T)
/obj/structure/windoor_assembly/update_icon()
@@ -55,8 +58,17 @@
return 1
if(get_dir(loc, target) == dir) //Make sure looking at appropriate border
return !density
- else
- return 1
+ if(istype(mover, /obj/structure/window))
+ var/obj/structure/window/W = mover
+ if(!valid_window_location(loc, W.ini_dir))
+ return FALSE
+ else if(istype(mover, /obj/structure/windoor_assembly))
+ var/obj/structure/windoor_assembly/W = mover
+ if(!valid_window_location(loc, W.ini_dir))
+ return FALSE
+ else if(istype(mover, /obj/machinery/door/window) && !valid_window_location(loc, mover.dir))
+ return FALSE
+ return 1
/obj/structure/windoor_assembly/CanAtmosPass(turf/T)
if(get_dir(loc, T) == dir)
@@ -313,20 +325,21 @@
set src in oview(1)
if(usr.stat || !usr.canmove || usr.restrained())
return
- if (anchored)
+ if(anchored)
usr << "[src] cannot be rotated while it is fastened to the floor!"
- return 0
- //if(state != "01")
- //update_nearby_tiles(need_rebuild=1) //Compel updates before
+ return FALSE
- setDir(turn(dir, 270))
+ var/target_dir = turn(dir, 270)
- //if(state != "01")
- //update_nearby_tiles(need_rebuild=1)
+ if(!valid_window_location(loc, target_dir))
+ usr << "[src] cannot be rotated in that direction!"
+ return FALSE
+
+ setDir(target_dir)
ini_dir = dir
update_icon()
- return
+ return TRUE
/obj/structure/windoor_assembly/AltClick(mob/user)
..()
diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm
index 298547d658e..72e9e899dbe 100644
--- a/code/game/objects/structures/window.dm
+++ b/code/game/objects/structures/window.dm
@@ -55,7 +55,6 @@
if(rods)
debris += new /obj/item/stack/rods(src, rods)
-
/obj/structure/window/narsie_act()
add_atom_colour(NARSIE_WINDOW_COLOUR, FIXED_COLOUR_PRIORITY)
for(var/obj/item/weapon/shard/shard in debris)
@@ -85,9 +84,17 @@
return 0 //full tile window, you can't move into it!
if(get_dir(loc, target) == dir)
return !density
- else
- return 1
-
+ if(istype(mover, /obj/structure/window))
+ var/obj/structure/window/W = mover
+ if(!valid_window_location(loc, W.ini_dir))
+ return FALSE
+ else if(istype(mover, /obj/structure/windoor_assembly))
+ var/obj/structure/windoor_assembly/W = mover
+ if(!valid_window_location(loc, W.ini_dir))
+ return FALSE
+ else if(istype(mover, /obj/machinery/door/window) && !valid_window_location(loc, mover.dir))
+ return FALSE
+ return 1
/obj/structure/window/CheckExit(atom/movable/O as mob|obj, target)
if(istype(O) && O.checkpass(PASSGLASS))
@@ -251,13 +258,19 @@
if(anchored)
usr << "[src] cannot be rotated while it is fastened to the floor!"
- return 0
+ return FALSE
- setDir(turn(dir, 90))
+ var/target_dir = turn(dir, 90)
+
+ if(!valid_window_location(loc, target_dir))
+ usr << "[src] cannot be rotated in that direction!"
+ return FALSE
+
+ setDir(target_dir)
air_update_turf(1)
ini_dir = dir
add_fingerprint(usr)
- return
+ return TRUE
/obj/structure/window/verb/revrotate()
@@ -270,13 +283,19 @@
if(anchored)
usr << "[src] cannot be rotated while it is fastened to the floor!"
- return 0
+ return FALSE
- setDir(turn(dir, 270))
+ var/target_dir = turn(dir, 270)
+
+ if(!valid_window_location(loc, target_dir))
+ usr << "[src] cannot be rotated in that direction!"
+ return FALSE
+
+ setDir(target_dir)
air_update_turf(1)
ini_dir = dir
add_fingerprint(usr)
- return
+ return TRUE
/obj/structure/window/AltClick(mob/user)
..()
@@ -348,6 +367,9 @@
return 1
+/obj/structure/window/unanchored
+ anchored = FALSE
+
/obj/structure/window/reinforced
name = "reinforced window"
icon_state = "rwindow"
@@ -357,6 +379,9 @@
explosion_block = 1
glass_type = /obj/item/stack/sheet/rglass
+/obj/structure/window/reinforced/unanchored
+ anchored = FALSE
+
/obj/structure/window/reinforced/tinted
name = "tinted window"
icon_state = "twindow"
@@ -379,6 +404,9 @@
canSmoothWith = list(/obj/structure/window/fulltile, /obj/structure/window/reinforced/fulltile, /obj/structure/window/reinforced/tinted/fulltile)
glass_amount = 2
+/obj/structure/window/fulltile/unanchored
+ anchored = FALSE
+
/obj/structure/window/reinforced/fulltile
icon = 'icons/obj/smooth_structures/reinforced_window.dmi'
icon_state = "r_window"
@@ -390,6 +418,9 @@
level = 3
glass_amount = 2
+/obj/structure/window/reinforced/fulltile/unanchored
+ anchored = FALSE
+
/obj/structure/window/reinforced/tinted/fulltile
icon = 'icons/obj/smooth_structures/tinted_window.dmi'
icon_state = "tinted_window"
@@ -455,6 +486,7 @@
if(direct)
var/obj/effect/E = PoolOrNew(/obj/effect/overlay/temp/ratvar/window/single, get_turf(src))
setDir(direct)
+ ini_dir = direct
E.setDir(direct)
made_glow = TRUE
else
@@ -488,6 +520,9 @@
animate(src, color = previouscolor, time = 8)
addtimer(CALLBACK(src, /atom/proc/update_atom_colour), 8)
+/obj/structure/window/reinforced/clockwork/unanchored
+ anchored = FALSE
+
/obj/structure/window/reinforced/clockwork/fulltile
icon_state = "clockwork_window"
smooth = SMOOTH_TRUE
@@ -498,3 +533,6 @@
level = 3
glass_amount = 2
made_glow = TRUE
+
+/obj/structure/window/reinforced/clockwork/fulltile/unanchored
+ anchored = FALSE