Skip to content

Commit

Permalink
Blast door refactor and fix (tgstation#58231)
Browse files Browse the repository at this point in the history
* - 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>
  • Loading branch information
norill authored Apr 13, 2021
1 parent d52a9be commit 97c1924
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
4 changes: 1 addition & 3 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -51,8 +50,7 @@
. += "<span class='notice'>Due to a security threat, its access requirements have been lifted!</span>"
else
. += "<span class='notice'>In the event of a red alert, its access requirements will automatically lift.</span>"
if(!poddoor)
. += "<span class='notice'>Its maintenance panel is <b>screwed</b> in place.</span>"
. += "<span class='notice'>Its maintenance panel is <b>screwed</b> in place.</span>"
if(safety_mode)
. += "<span class='notice'>It has labels indicating that it has an emergency mechanism to open it with <b>just your hands</b> if there's no power.</span>"

Expand Down
48 changes: 29 additions & 19 deletions code/game/machinery/doors/poddoor.dm
Original file line number Diff line number Diff line change
@@ -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."
Expand All @@ -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, "<span class='warning'>This shutter has a different kind of screw, you cannot unscrew the panel open.</span>")
return

if(W.tool_behaviour == TOOL_SCREWDRIVER)
if(density)
Expand All @@ -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, "<span class='notice'>You change the ID to [id].</span>")

if(W.tool_behaviour == TOOL_CROWBAR && deconstruction == INTACT)
else if(W.tool_behaviour == TOOL_CROWBAR && deconstruction == BLASTDOOR_FINISHED)
to_chat(user, "<span class='notice'>You start to remove the airlock electronics.</span>")
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, "<span class='notice'>You start to remove the internal cables.</span>")
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, "<span class='notice'>You start tearing apart the [src].</span>")
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)
. += "<span class='<span class='notice'>The maintenance panel is [panel_open ? "opened" : "closed"].</span>"
if(deconstruction == BLASTDOOR_FINISHED)
. += "<span class='notice'>The maintenance panel is opened and the electronics could be <b>pried</b> out.</span>"
else if(deconstruction == BLASTDOOR_NEEDS_ELECTRONICS)
. += "<span class='notice'>The <i>electronics</i> are missing and there are some <b>wires</b> sticking out.</span>"
else if(deconstruction == BLASTDOOR_NEEDS_WIRES)
. += "<span class='notice'>The <i>wires</i> have been removed and it's ready to be <b>sliced apart</b>.</span>"

/obj/machinery/door/poddoor/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock)
id = "[port.id]_[id]"
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion code/game/machinery/doors/shutters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -51,3 +51,6 @@
/obj/machinery/door/poddoor/shutters/window/preopen
icon_state = "open"
density = FALSE

/obj/machinery/door/poddoor/shutters/bumpopen()
return

0 comments on commit 97c1924

Please sign in to comment.