makes door code more OOP: reduced copypasta in shutter and poddoor code, they have their own icon files, changed name of icon_states in the maps

added a few defines and helpers
do_after family supports callbacks
added airlock security levels to airlocks
obj_integrity for doors, door assemblies, firelock frames
vault door assembly is 8 plasteel up from 6
explosion_block works better
heavy firelocks block explosions, firelock (de)construction uses crowbar instead of welder
xenos can open airlocks
minor change to attacking obj message
This commit is contained in:
uraniummeltdown
2018-02-11 17:51:02 +05:00
parent 8f26d5b8b6
commit a2038d40b3
36 changed files with 1580 additions and 1268 deletions
+7 -7
View File
@@ -80,9 +80,9 @@
if(T.density && T.explosion_block)
cached_exp_block[T] += T.explosion_block
for(var/obj/machinery/door/D in T)
if(D.density && D.explosion_block)
cached_exp_block[T] += D.explosion_block
for(var/obj/O in T)
var/the_block = O.explosion_block
cached_exp_block[T] += the_block == EXPLOSION_BLOCK_PROC ? O.GetExplosionBlock() : the_block
CHECK_TICK
for(var/A in affected_turfs)
@@ -212,12 +212,12 @@
var/turf/TT = T
while(TT != epicenter)
TT = get_step_towards(TT,epicenter)
if(TT.density && TT.explosion_block)
if(TT.density)
dist += TT.explosion_block
for(var/obj/machinery/door/D in TT)
if(D.density && D.explosion_block)
dist += D.explosion_block
for(var/obj/O in T)
var/the_block = O.explosion_block
dist += the_block == EXPLOSION_BLOCK_PROC ? O.GetExplosionBlock() : the_block
if(dist < dev)
T.color = "red"
@@ -133,9 +133,9 @@ var/global/list/datum/stack_recipe/plasteel_recipes = list(
new /datum/stack_recipe("Mass Driver frame", /obj/machinery/mass_driver_frame, 3, time = 50, one_per_turf = 1),
null,
new /datum/stack_recipe_list("airlock assemblies", list(
new /datum/stack_recipe("vault door assembly", /obj/structure/door_assembly/door_assembly_vault, 6, time = 50, one_per_turf = 1, on_floor = 1),
new /datum/stack_recipe("high security airlock assembly", /obj/structure/door_assembly/door_assembly_highsecurity, 6, time = 50, one_per_turf = 1, on_floor = 1),
), 4),
new /datum/stack_recipe("vault door assembly", /obj/structure/door_assembly/door_assembly_vault, 8, time = 50, one_per_turf = 1, on_floor = 1),
)),
)
/obj/item/stack/sheet/plasteel
+4 -1
View File
@@ -52,7 +52,6 @@
/obj/ex_act(severity, target)
if(resistance_flags & INDESTRUCTIBLE)
return
..() //contents explosion
if(target == src)
obj_integrity = 0
qdel(src)
@@ -203,3 +202,7 @@
obj_break(damage_type)
return TRUE
return FALSE
//returns how much the object blocks an explosion
/obj/proc/GetExplosionBlock()
CRASH("Unimplemented GetExplosionBlock()")
+12 -11
View File
@@ -4,15 +4,16 @@
icon_state = "construction"
anchored = FALSE
density = TRUE
max_integrity = 200
var/overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
var/state = AIRLOCK_ASSEMBLY_NEEDS_WIRES
var/mineral = null
var/mineral
var/base_name = "airlock"
var/obj/item/weapon/airlock_electronics/electronics = null
var/obj/item/weapon/airlock_electronics/electronics
var/airlock_type = /obj/machinery/door/airlock //the type path of the airlock once completed
var/glass_type = /obj/machinery/door/airlock/glass
var/glass = 0 // 0 = glass can be installed. 1 = glass is already installed.
var/created_name = null
var/created_name
var/heat_proof_finished = 0 //whether to heat-proof the finished airlock
var/previous_assembly = /obj/structure/door_assembly
var/noglass = FALSE //airlocks with no glass version, also cannot be modified with sheets
@@ -116,12 +117,12 @@
else if(iscoil(W) && state == AIRLOCK_ASSEMBLY_NEEDS_WIRES && anchored)
var/obj/item/stack/cable_coil/coil = W
if (coil.amount < 1)
if(coil.get_amount() < 1)
to_chat(user, "<span class='warning'>You need one length of cable to wire the airlock assembly!</span>")
return
user.visible_message("[user] wires the airlock assembly.", "You start to wire the airlock assembly...")
if(do_after(user, 40 * coil.toolspeed, target = src))
if(coil.amount < 1 || state != AIRLOCK_ASSEMBLY_NEEDS_WIRES)
if(coil.get_amount() < 1 || state != AIRLOCK_ASSEMBLY_NEEDS_WIRES)
return
coil.use(1)
state = AIRLOCK_ASSEMBLY_NEEDS_ELECTRONICS
@@ -173,14 +174,14 @@
else if(istype(W, /obj/item/stack/sheet) && (!glass || !mineral))
var/obj/item/stack/sheet/S = W
if(S)
if(S.amount>=1)
if(S.get_amount() >= 1)
if(!noglass)
if(!glass)
if(istype(S, /obj/item/stack/sheet/rglass) || istype(S, /obj/item/stack/sheet/glass))
playsound(loc, S.usesound, 100, 1)
user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly...")
if(do_after(user, 40 * S.toolspeed, target = src))
if(S.amount < 1 || glass)
if(S.get_amount() < 1 || glass)
return
if(S.type == /obj/item/stack/sheet/rglass)
to_chat(user, "<span class='notice'>You install reinforced glass windows into the airlock assembly.</span>")
@@ -192,11 +193,11 @@
if(!mineral)
if(istype(S, /obj/item/stack/sheet/mineral) && S.sheettype)
var/M = S.sheettype
if(S.amount>=2)
if(S.get_amount() >= 2)
playsound(loc, S.usesound, 100, 1)
user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly...")
if(do_after(user, 40 * S.toolspeed, target = src))
if(S.amount < 2 || mineral)
if(S.get_amount() < 2 || mineral)
return
to_chat(user, "<span class='notice'>You install [M] plating into the airlock assembly.</span>")
S.use(2)
@@ -204,7 +205,7 @@
var/obj/structure/door_assembly/MA = new mineralassembly(loc)
transfer_assembly_vars(src, MA, TRUE)
else
to_chat(user, "<span class='warning'>You need at least two sheets add a mineral cover!</span>")
to_chat(user, "<span class='warning'>You need at least two sheets to add a mineral cover!</span>")
else
to_chat(user, "<span class='warning'>You cannot add [S] to [src]!</span>")
else
@@ -239,7 +240,7 @@
electronics.forceMove(door)
qdel(src)
else
..()
return ..()
update_name()
update_icon()
+126 -130
View File
@@ -9,38 +9,41 @@
*/
obj/structure/windoor_assembly
/obj/structure/windoor_assembly
icon = 'icons/obj/doors/windoor.dmi'
name = "windoor Assembly"
name = "windoor assembly"
icon_state = "l_windoor_assembly01"
anchored = 0
density = 0
desc = "A small glass and wire assembly for windoors."
anchored = FALSE
density = FALSE
dir = NORTH
max_integrity = 300
var/ini_dir
var/obj/item/weapon/airlock_electronics/electronics = null
var/created_name = null
var/obj/item/weapon/airlock_electronics/electronics
var/created_name
//Vars to help with the icon's name
var/facing = "l" //Does the windoor open to the left or right?
var/secure = 0 //Whether or not this creates a secure windoor
var/secure = FALSE //Whether or not this creates a secure windoor
var/state = "01" //How far the door assembly has progressed
obj/structure/windoor_assembly/New(dir=NORTH)
obj/structure/windoor_assembly/New(loc, set_dir)
..()
src.ini_dir = src.dir
if(set_dir)
dir = set_dir
ini_dir = dir
air_update_turf(1)
obj/structure/windoor_assembly/Destroy()
density = 0
density = FALSE
QDEL_NULL(electronics)
air_update_turf(1)
return ..()
/obj/structure/windoor_assembly/Move()
var/turf/T = loc
..()
. = ..()
setDir(ini_dir)
move_update_air(T)
/obj/structure/windoor_assembly/update_icon()
@@ -54,13 +57,13 @@ obj/structure/windoor_assembly/Destroy()
else
return 1
/obj/structure/windoor_assembly/CanAtmosPass(var/turf/T)
/obj/structure/windoor_assembly/CanAtmosPass(turf/T)
if(get_dir(loc, T) == dir)
return !density
else
return 1
/obj/structure/windoor_assembly/CheckExit(atom/movable/mover as mob|obj, turf/target as turf)
/obj/structure/windoor_assembly/CheckExit(atom/movable/mover, turf/target)
if(istype(mover) && mover.checkpass(PASSGLASS))
return 1
if(get_dir(loc, target) == dir)
@@ -69,166 +72,166 @@ obj/structure/windoor_assembly/Destroy()
return 1
/obj/structure/windoor_assembly/attackby(obj/item/W as obj, mob/user as mob, params)
/obj/structure/windoor_assembly/attackby(obj/item/W, mob/user, params)
//I really should have spread this out across more states but thin little windoors are hard to sprite.
add_fingerprint(user)
switch(state)
if("01")
if(istype(W, /obj/item/weapon/weldingtool) && !anchored )
if(iswelder(W) && !anchored)
var/obj/item/weapon/weldingtool/WT = W
if(WT.remove_fuel(0,user))
user.visible_message("<span class='warning'>[user] dissassembles the windoor assembly.</span>", "<span class='notice'>You start to dissassemble the windoor assembly.</span>")
playsound(src.loc, WT.usesound, 50, 1)
user.visible_message("<span class='warning'>[user] disassembles the windoor assembly.</span>", "<span class='notice'>You start to disassemble the windoor assembly...</span>")
playsound(loc, 'sound/items/welder2.ogg', 50, 1)
if(do_after(user, 40 * WT.toolspeed, target = src))
if(!src || !WT.isOn()) return
to_chat(user, "<span class='notice'>You dissasembled the windoor assembly!</span>")
if(!src || !WT.isOn())
return
to_chat(user, "<span class='notice'>You disasemble the windoor assembly.</span>")
var/obj/item/stack/sheet/rglass/RG = new (get_turf(src), 5)
RG.add_fingerprint(user)
if(secure)
var/obj/item/stack/rods/R = new (get_turf(src), 4)
R.add_fingerprint(user)
qdel(src)
else
return
//Wrenching an unsecure assembly anchors it in place. Step 4 complete
if(istype(W, /obj/item/weapon/wrench) && !anchored)
for(var/obj/machinery/door/window/WD in src.loc)
if(WD.dir == src.dir)
to_chat(user, "<span class='warning'>There is already a windoor in that location.</span>")
if(iswrench(W) && !anchored)
for(var/obj/machinery/door/window/WD in loc)
if(WD.dir == dir)
to_chat(user, "<span class='warning'>There is already a windoor in that location!</span>")
return
playsound(src.loc, W.usesound, 100, 1)
user.visible_message("[user] secures the windoor assembly to the floor.", "You start to secure the windoor assembly to the floor.")
playsound(loc, W.usesound, 100, 1)
user.visible_message("[user] secures the windoor assembly to the floor.", "You start to secure the windoor assembly to the floor...")
if(do_after(user, 40 * W.toolspeed, target = src))
if(!src || src.anchored)
if(!src || anchored)
return
for(var/obj/machinery/door/window/WD in src.loc)
if(WD.dir == src.dir)
to_chat(user, "<span class='warning'>There is already a windoor in that location.</span>")
for(var/obj/machinery/door/window/WD in loc)
if(WD.dir == dir)
to_chat(user, "<span class='warning'>There is already a windoor in that location!</span>")
return
to_chat(user, "<span class='notice'>You've secured the windoor assembly!</span>")
src.anchored = 1
if(src.secure)
src.name = "secure anchored windoor assembly"
to_chat(user, "<span class='notice'>You secure the windoor assembly.</span>")
anchored = TRUE
if(secure)
name = "secure anchored windoor assembly"
else
src.name = "anchored windoor assembly"
name = "anchored windoor assembly"
//Unwrenching an unsecure assembly un-anchors it. Step 4 undone
else if(istype(W, /obj/item/weapon/wrench) && anchored)
else if(iswrench(W) && anchored)
playsound(loc, W.usesound, 100, 1)
user.visible_message("[user] unsecures the windoor assembly to the floor.", "You start to unsecure the windoor assembly to the floor.")
user.visible_message("[user] unsecures the windoor assembly from the floor.", "You start to unsecure the windoor assembly from the floor...")
if(do_after(user, 40 * W.toolspeed, target = src))
if(!src || !src.anchored)
if(!src || !anchored)
return
to_chat(user, "<span class='notice'>You've unsecured the windoor assembly!</span>")
src.anchored = 0
if(src.secure)
src.name = "secure windoor assembly"
to_chat(user, "<span class='notice'>You unsecure the windoor assembly.</span>")
anchored = FALSE
if(secure)
name = "secure windoor assembly"
else
src.name = "windoor assembly"
name = "windoor assembly"
//Adding plasteel makes the assembly a secure windoor assembly. Step 2 (optional) complete.
else if(istype(W, /obj/item/stack/sheet/plasteel) && !secure)
var/obj/item/stack/sheet/plasteel/P = W
if(P.amount < 2)
to_chat(user, "<span class='danger'>You need more plasteel to do this.</span>")
if(P.get_amount() < 2)
to_chat(user, "<span class='warning'>You need more plasteel to do this!</span>")
return
to_chat(user, "<span class='notice'>You start to reinforce the windoor with plasteel.</span>")
to_chat(user, "<span class='notice'>You start to reinforce the windoor with plasteel...</span>")
if(do_after(user, 40 * P.toolspeed, target = src))
if(!src || secure)
if(!src || secure || P.get_amount() < 2)
return
playsound(loc, P.usesound, 100, 1)
P.use(2)
to_chat(user, "<span class='notice'>You reinforce the windoor.</span>")
src.secure = 1
if(src.anchored)
src.name = "secure anchored windoor assembly"
secure = TRUE
if(anchored)
name = "secure anchored windoor assembly"
else
src.name = "secure windoor assembly"
name = "secure windoor assembly"
//Adding cable to the assembly. Step 5 complete.
else if(istype(W, /obj/item/stack/cable_coil) && anchored)
user.visible_message("[user] wires the windoor assembly.", "You start to wire the windoor assembly.")
else if(iscoil(W) && anchored)
user.visible_message("[user] wires the windoor assembly.", "You start to wire the windoor assembly...")
if(do_after(user, 40 * W.toolspeed, target = src))
if(!src || !src.anchored || src.state != "01")
if(!src || !anchored || state != "01")
return
var/obj/item/stack/cable_coil/CC = W
CC.use(1)
to_chat(user, "<span class='notice'>You wire the windoor!</span>")
to_chat(user, "<span class='notice'>You wire the windoor.</span>")
playsound(loc, CC.usesound, 100, 1)
src.state = "02"
if(src.secure)
src.name = "secure wired windoor assembly"
state = "02"
if(secure)
name = "secure wired windoor assembly"
else
src.name = "wired windoor assembly"
name = "wired windoor assembly"
else
..()
return ..()
if("02")
//Removing wire from the assembly. Step 5 undone.
if(istype(W, /obj/item/weapon/wirecutters))
playsound(src.loc, W.usesound, 100, 1)
user.visible_message("[user] cuts the wires from the airlock assembly.", "You start to cut the wires from airlock assembly.")
if(iswirecutter(W))
playsound(loc, W.usesound, 100, 1)
user.visible_message("[user] cuts the wires from the airlock assembly.", "You start to cut the wires from airlock assembly...")
if(do_after(user, 40 * W.toolspeed, target = src))
if(!src || src.state != "02")
if(!src || state != "02")
return
to_chat(user, "<span class='notice'>You cut the windoor wires!</span>")
to_chat(user, "<span class='notice'>You cut the windoor wires.</span>")
new/obj/item/stack/cable_coil(get_turf(user), 1)
src.state = "01"
if(src.secure)
src.name = "secure anchored windoor assembly"
state = "01"
if(secure)
name = "secure anchored windoor assembly"
else
src.name = "anchored windoor assembly"
name = "anchored windoor assembly"
//Adding airlock electronics for access. Step 6 complete.
else if(istype(W, /obj/item/weapon/airlock_electronics))
playsound(src.loc, W.usesound, 100, 1)
user.visible_message("[user] installs the electronics into the airlock assembly.", "You start to install electronics into the airlock assembly.")
playsound(loc, W.usesound, 100, 1)
user.visible_message("[user] installs the electronics into the airlock assembly.", "You start to install electronics into the airlock assembly...")
user.drop_item()
W.loc = src
W.forceMove(src)
if(do_after(user, 40 * W.toolspeed, target = src))
if(!src || src.electronics)
W.loc = src.loc
if(!src || electronics)
W.forceMove(loc)
return
to_chat(user, "<span class='notice'>You've installed the airlock electronics!</span>")
src.name = "near finished windoor assembly"
src.electronics = W
to_chat(user, "<span class='notice'>You install the airlock electronics.</span>")
name = "near finished windoor assembly"
electronics = W
else
W.loc = src.loc
W.forceMove(loc)
//Screwdriver to remove airlock electronics. Step 6 undone.
else if(istype(W, /obj/item/weapon/screwdriver))
else if(isscrewdriver(W))
if(!electronics)
return
playsound(src.loc, W.usesound, 100, 1)
user.visible_message("[user] removes the electronics from the airlock assembly.", "You start to uninstall electronics from the airlock assembly.")
playsound(loc, W.usesound, 100, 1)
user.visible_message("[user] removes the electronics from the airlock assembly.", "You start to uninstall electronics from the airlock assembly...")
if(do_after(user, 40 * W.toolspeed, target = src))
if(!src || !electronics)
return
to_chat(user, "<span class='notice'>You've removed the airlock electronics!</span>")
src.name = "wired windoor assembly"
to_chat(user, "<span class='notice'>You remove the airlock electronics.</span>")
name = "wired windoor assembly"
var/obj/item/weapon/airlock_electronics/ae
ae = electronics
electronics = null
ae.loc = src.loc
ae.forceMove(loc)
else if(istype(W, /obj/item/weapon/pen))
var/t = stripped_input(user, "Enter the name for the door.", src.name, src.created_name,MAX_NAME_LEN)
var/t = stripped_input(user, "Enter the name for the door.", name, created_name,MAX_NAME_LEN)
if(!t)
return
if(!in_range(src, usr) && src.loc != usr)
if(!in_range(src, usr) && loc != usr)
return
created_name = t
return
@@ -236,70 +239,68 @@ obj/structure/windoor_assembly/Destroy()
//Crowbar to complete the assembly, Step 7 complete.
else if(istype(W, /obj/item/weapon/crowbar))
if(!src.electronics)
to_chat(usr, "<span class='danger'>The assembly is missing electronics.</span>")
else if(iscrowbar(W))
if(!electronics)
to_chat(usr, "<span class='warning'>The assembly is missing electronics!</span>")
return
usr << browse(null, "window=windoor_access")
playsound(src.loc, W.usesound, 100, 1)
user.visible_message("[user] pries the windoor into the frame.", "You start prying the windoor into the frame.")
playsound(loc, W.usesound, 100, 1)
user.visible_message("[user] pries the windoor into the frame.", "You start prying the windoor into the frame...")
if(do_after(user, 40 * W.toolspeed, target = src))
if(src.loc && src.electronics)
if(loc && electronics)
for(var/obj/machinery/door/window/WD in loc)
if(WD.dir == dir)
return
density = 1 //Shouldn't matter but just incase
to_chat(user, "<span class='notice'>You finish the windoor!</span>")
density = TRUE //Shouldn't matter but just incase
to_chat(user, "<span class='notice'>You finish the windoor.</span>")
if(secure)
var/obj/machinery/door/window/brigdoor/windoor = new /obj/machinery/door/window/brigdoor(src.loc)
if(src.facing == "l")
if(facing == "l")
windoor.icon_state = "leftsecureopen"
windoor.base_state = "leftsecure"
else
windoor.icon_state = "rightsecureopen"
windoor.base_state = "rightsecure"
windoor.dir = src.dir
windoor.density = 0
windoor.setDir(dir)
windoor.density = FALSE
if(src.electronics.one_access)
windoor.req_one_access = src.electronics.conf_access
if(electronics.one_access)
windoor.req_one_access = electronics.conf_access
else
windoor.req_access = src.electronics.conf_access
windoor.req_access = electronics.conf_access
windoor.electronics = src.electronics
src.electronics.loc = windoor
electronics.forceMove(windoor)
if(created_name)
windoor.name = created_name
qdel(src)
windoor.close()
else
var/obj/machinery/door/window/windoor = new /obj/machinery/door/window(src.loc)
if(src.facing == "l")
var/obj/machinery/door/window/windoor = new /obj/machinery/door/window(loc)
if(facing == "l")
windoor.icon_state = "leftopen"
windoor.base_state = "left"
else
windoor.icon_state = "rightopen"
windoor.base_state = "right"
windoor.dir = src.dir
windoor.density = 0
windoor.setDir(dir)
windoor.density = FALSE
windoor.req_access = src.electronics.conf_access
windoor.req_access = electronics.conf_access
windoor.electronics = src.electronics
src.electronics.loc = windoor
electronics.forceMove(windoor)
if(created_name)
windoor.name = created_name
qdel(src)
windoor.close()
qdel(src)
else
..()
return ..()
//Update to reflect changes(if applicable)
update_icon()
@@ -312,28 +313,23 @@ obj/structure/windoor_assembly/Destroy()
set src in oview(1)
if(usr.stat || !usr.canmove || usr.restrained())
return
if(src.anchored)
if(anchored)
to_chat(usr, "It is fastened to the floor; therefore, you can't rotate it!")
return 0
//if(src.state != "01")
//update_nearby_tiles(need_rebuild=1) //Compel updates before
src.dir = turn(src.dir, 270)
//if(src.state != "01")
//update_nearby_tiles(need_rebuild=1)
src.ini_dir = src.dir
setDir(turn(dir, 270))
ini_dir = dir
update_icon()
return
return TRUE
/obj/structure/windoor_assembly/AltClick(mob/user)
..()
if(user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!Adjacent(user))
if(!in_range(src, user))
return
revrotate()
else
revrotate()
//Flips the windoor assembly, determines whather the door opens to the left or the right
/obj/structure/windoor_assembly/verb/flip()
@@ -343,11 +339,11 @@ obj/structure/windoor_assembly/Destroy()
if(usr.stat || !usr.canmove || usr.restrained())
return
if(src.facing == "l")
if(facing == "l")
to_chat(usr, "The windoor will now slide to the right.")
src.facing = "r"
facing = "r"
else
src.facing = "l"
facing = "l"
to_chat(usr, "The windoor will now slide to the left.")
update_icon()