From 97c19244344799416d79cbf3d2f7645f78f2b03a Mon Sep 17 00:00:00 2001 From: norill Date: Tue, 13 Apr 2021 05:46:05 +0000 Subject: [PATCH] Blast door refactor and fix (#58231) * - refactored blast door code - moved shutters/bumpopen() to shutters.dm - fixed infinite deconstruct blast doors for free airlock electronics * keep recipe as ref * moved recipe variable to a local scope Co-authored-by: norill <4> --- code/game/machinery/doors/door.dm | 4 +-- code/game/machinery/doors/poddoor.dm | 48 ++++++++++++++++----------- code/game/machinery/doors/shutters.dm | 5 ++- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 0e5b44047fb..f616b2831ab 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -38,7 +38,6 @@ var/datum/effect_system/spark_spread/spark_system var/real_explosion_block //ignore this, just use explosion_block var/red_alert_access = FALSE //if TRUE, this door will always open on red alert - var/poddoor = FALSE var/unres_sides = 0 //Unrestricted sides. A bitflag for which direction (if any) can open the door with no access var/safety_mode = FALSE ///Whether or not the airlock can be opened with bare hands while unpowered var/can_crush = TRUE /// Whether or not the door can crush mobs. @@ -51,8 +50,7 @@ . += "Due to a security threat, its access requirements have been lifted!" else . += "In the event of a red alert, its access requirements will automatically lift." - if(!poddoor) - . += "Its maintenance panel is screwed in place." + . += "Its maintenance panel is screwed in place." if(safety_mode) . += "It has labels indicating that it has an emergency mechanism to open it with just your hands if there's no power." diff --git a/code/game/machinery/doors/poddoor.dm b/code/game/machinery/doors/poddoor.dm index a5876d78485..4a25b3bf3d5 100644 --- a/code/game/machinery/doors/poddoor.dm +++ b/code/game/machinery/doors/poddoor.dm @@ -1,3 +1,9 @@ + +//blast door (de)construction states +#define BLASTDOOR_NEEDS_WIRES 0 +#define BLASTDOOR_NEEDS_ELECTRONICS 1 +#define BLASTDOOR_FINISHED 2 + /obj/machinery/door/poddoor name = "blast door" desc = "A heavy duty blast door that opens mechanically." @@ -14,15 +20,11 @@ armor = list(MELEE = 50, BULLET = 100, LASER = 100, ENERGY = 100, BOMB = 50, BIO = 100, RAD = 100, FIRE = 100, ACID = 70) resistance_flags = FIRE_PROOF damage_deflection = 70 - poddoor = TRUE - var/ertblast = FALSE //If this is true the blast door cannot be deconstructed - var/deconstruction = INTACT //For the deconstruction steps + var/datum/crafting_recipe/recipe_type = /datum/crafting_recipe/blast_doors + var/deconstruction = BLASTDOOR_FINISHED // deconstruction step /obj/machinery/door/poddoor/attackby(obj/item/W, mob/user, params) . = ..() - if(ertblast && W.tool_behaviour == TOOL_SCREWDRIVER) // This makes it so ERT members cannot cheese by opening their blast doors. - to_chat(user, "This shutter has a different kind of screw, you cannot unscrew the panel open.") - return if(W.tool_behaviour == TOOL_SCREWDRIVER) if(density) @@ -33,35 +35,48 @@ return TRUE if(panel_open) - if(W.tool_behaviour == TOOL_MULTITOOL) + if(W.tool_behaviour == TOOL_MULTITOOL && deconstruction == BLASTDOOR_FINISHED) var/change_id = input("Set the shutters/blast door/blast door controllers ID. It must be a number between 1 and 100.", "ID", id) as num|null if(change_id) id = clamp(round(change_id, 1), 1, 100) to_chat(user, "You change the ID to [id].") - if(W.tool_behaviour == TOOL_CROWBAR && deconstruction == INTACT) + else if(W.tool_behaviour == TOOL_CROWBAR && deconstruction == BLASTDOOR_FINISHED) to_chat(user, "You start to remove the airlock electronics.") if(do_after(user, 10 SECONDS, target = src)) new /obj/item/electronics/airlock(loc) id = null - deconstruction = FALSE + deconstruction = BLASTDOOR_NEEDS_ELECTRONICS - if(W.tool_behaviour == TOOL_WIRECUTTER && deconstruction == FALSE) + else if(W.tool_behaviour == TOOL_WIRECUTTER && deconstruction == BLASTDOOR_NEEDS_ELECTRONICS) to_chat(user, "You start to remove the internal cables.") if(do_after(user, 10 SECONDS, target = src)) - deconstruction = TRUE + var/datum/crafting_recipe/recipe = locate(recipe_type) in GLOB.crafting_recipes + var/amount = recipe.reqs[/obj/item/stack/cable_coil] + new /obj/item/stack/cable_coil(loc, amount) + deconstruction = BLASTDOOR_NEEDS_WIRES + + else if(W.tool_behaviour == TOOL_WELDER && deconstruction == BLASTDOOR_NEEDS_WIRES) + if(!W.tool_start_check(user, amount=0)) + return - if(W.tool_behaviour == TOOL_WELDER && deconstruction == TRUE) to_chat(user, "You start tearing apart the [src].") playsound(src.loc, 'sound/items/welder.ogg', 50, 1) if(do_after(user, 15 SECONDS, target = src)) - new /obj/item/stack/sheet/plasteel(loc, 5) + var/datum/crafting_recipe/recipe = locate(recipe_type) in GLOB.crafting_recipes + var/amount = recipe.reqs[/obj/item/stack/sheet/plasteel] + new /obj/item/stack/sheet/plasteel(loc, amount) qdel(src) /obj/machinery/door/poddoor/examine(mob/user) . = ..() if(panel_open) - . += "The maintenance panel is [panel_open ? "opened" : "closed"]." + if(deconstruction == BLASTDOOR_FINISHED) + . += "The maintenance panel is opened and the electronics could be pried out." + else if(deconstruction == BLASTDOOR_NEEDS_ELECTRONICS) + . += "The electronics are missing and there are some wires sticking out." + else if(deconstruction == BLASTDOOR_NEEDS_WIRES) + . += "The wires have been removed and it's ready to be sliced apart." /obj/machinery/door/poddoor/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock) id = "[port.id]_[id]" @@ -74,12 +89,10 @@ /obj/machinery/door/poddoor/ert name = "hardened blast door" desc = "A heavy duty blast door that only opens for dire emergencies." - ertblast = TRUE resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF //special poddoors that open when emergency shuttle docks at centcom /obj/machinery/door/poddoor/shuttledock - ertblast = TRUE var/checkdir = 4 //door won't open if turf in this dir is `turftype` var/turftype = /turf/open/space @@ -136,9 +149,6 @@ else return ..() -/obj/machinery/door/poddoor/shutters/bumpopen() - return - //"BLAST" doors are obviously stronger than regular doors when it comes to BLASTS. /obj/machinery/door/poddoor/ex_act(severity, target) if(severity == EXPLODE_LIGHT) diff --git a/code/game/machinery/doors/shutters.dm b/code/game/machinery/doors/shutters.dm index efbd42a7a12..0775b9a0412 100644 --- a/code/game/machinery/doors/shutters.dm +++ b/code/game/machinery/doors/shutters.dm @@ -8,6 +8,7 @@ damage_deflection = 20 armor = list("melee" = 20, "bullet" = 20, "laser" = 20, "energy" = 75, "bomb" = 25, "bio" = 100, "rad" = 100, "fire" = 100, "acid" = 70) max_integrity = 100 + recipe_type = /datum/crafting_recipe/shutters /obj/machinery/door/poddoor/shutters/preopen icon_state = "open" @@ -16,7 +17,6 @@ /obj/machinery/door/poddoor/shutters/indestructible name = "hardened shutters" - ertblast = TRUE resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF /obj/machinery/door/poddoor/shutters/radiation @@ -51,3 +51,6 @@ /obj/machinery/door/poddoor/shutters/window/preopen icon_state = "open" density = FALSE + +/obj/machinery/door/poddoor/shutters/bumpopen() + return