Skip to content

Commit

Permalink
Emags no longer have a permanent effect on airlocks (#9688)
Browse files Browse the repository at this point in the history
* Emags no longer have a permanent effect on airlocks

* Door bumping ignores emagged too.

* Semi-permanent depower

* cleans up a couple of missed emag references

* fix clamp
  • Loading branch information
Rukofamicom authored Oct 22, 2023
1 parent cb1e73f commit b51cb61
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 43 deletions.
17 changes: 8 additions & 9 deletions code/datums/wires/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
var/list/status = list()
status += "The door bolts [A.locked ? "have fallen!" : "look up."]"
status += "The test light is [A.hasPower() ? (A.isElectrified() ? "bright and flicking" : "on") : "off"]."
status += "The AI connection light is [A.aiControlDisabled || (A.obj_flags & EMAGGED) ? "off" : "on"]."
status += "The AI connection light is [A.aiControlDisabled ? "off" : "on"]."
status += "The check wiring light is [A.safe ? "off" : "on"]."
status += "The timer is powered [A.autoclose ? "on" : "off"]."
status += "The speed light is [A.normalspeed ? "on" : "off"]."
Expand All @@ -68,15 +68,14 @@
if(isliving(usr) && A.hasPower() && A.isElectrified())
if (A.shock(usr, 100))
return
if(A.hasPower()) //Multitool has no effect at all if the door has lost power
switch(wire)
if(WIRE_POWER1, WIRE_POWER2) // Pulse to lose power, or reset the delay before restoring power if already lost
A.loseMainPower()
if(WIRE_BACKUP1, WIRE_BACKUP2) // Pulse to lose backup power, or reset the delay before restoring power if already lost
A.loseBackupPower()
if(A.hasPower()) //Multitool has no effect on other wires if the door has no power
switch(wire)
if(WIRE_POWER1, WIRE_POWER2) // Pulse to loose power.
A.loseMainPower()
if(WIRE_BACKUP1, WIRE_BACKUP2) // Pulse to loose backup power.
A.loseBackupPower()
if(WIRE_OPEN) // Pulse to open door (only works not emagged and ID wire is cut or no access is required).
if(A.obj_flags & EMAGGED)
return
if(WIRE_OPEN) // Pulse to open door
if(A.id_scan_hacked() || A.check_access(null))
if(A.density)
INVOKE_ASYNC(A, TYPE_PROC_REF(/obj/machinery/door/airlock, open))
Expand Down
46 changes: 14 additions & 32 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
update_icon()

/obj/machinery/door/airlock/Bumped(atom/movable/AM)
if(operating || (obj_flags & EMAGGED))
if(operating)
return
if(ismecha(AM))
var/obj/mecha/mecha = AM
Expand Down Expand Up @@ -493,19 +493,20 @@
ui_update()
update_icon()

/obj/machinery/door/airlock/proc/loseMainPower()
if(secondsMainPowerLost <= 0)
/obj/machinery/door/airlock/proc/loseMainPower(emagged_powerloss)
if(emagged_powerloss)
secondsMainPowerLost = 36000 //Ten hours, effectively indefinite - may be reset by power cycling the airlock with a multitool or wirecutters
secondsBackupPowerLost = 36000
else
secondsMainPowerLost = 60
if(secondsBackupPowerLost < 10)
secondsBackupPowerLost = 10
secondsBackupPowerLost = clamp(10, secondsBackupPowerLost, 60)
if(!spawnPowerRestoreRunning)
spawnPowerRestoreRunning = TRUE
handlePowerRestoreLoop()
update_icon()

/obj/machinery/door/airlock/proc/loseBackupPower()
if(secondsBackupPowerLost < 60)
secondsBackupPowerLost = 60
secondsBackupPowerLost = 60
if(!spawnPowerRestoreRunning)
spawnPowerRestoreRunning = TRUE
handlePowerRestoreLoop()
Expand Down Expand Up @@ -710,8 +711,6 @@

/obj/machinery/door/airlock/examine(mob/user)
. = ..()
if(obj_flags & EMAGGED)
. += "<span class='warning'>Its access panel is smoking slightly.</span>"
if(charge && !panel_open && in_range(user, src))
. += "<span class='warning'>The maintenance panel seems haphazardly fastened.</span>"
if(charge && panel_open)
Expand Down Expand Up @@ -758,9 +757,6 @@
return
else
to_chat(user, "<span class='warning'>Airlock AI control has been blocked with a firewall. Unable to hack.</span>")
if(obj_flags & EMAGGED)
to_chat(user, "<span class='warning'>Unable to interface: Airlock is unresponsive.</span>")
return
if(detonated)
to_chat(user, "<span class='warning'>Unable to interface. Airlock control panel damaged.</span>")
return
Expand Down Expand Up @@ -1047,8 +1043,6 @@
if(!panel_open || security_level)
to_chat(user, "<span class='warning'>The maintenance panel must be open to apply [C]!</span>")
return
if(obj_flags & EMAGGED)
return
if(charge && !detonated)
to_chat(user, "<span class='warning'>There's already a charge hooked up to this door!</span>")
return
Expand Down Expand Up @@ -1151,7 +1145,7 @@
charge.forceMove(get_turf(user))
charge = null
return
if(!security_level && (beingcrowbarred && panel_open && ((obj_flags & EMAGGED) || (density && welded && !operating && !hasPower() && !locked))))
if(!security_level && (beingcrowbarred && panel_open && (density && welded && !operating && !hasPower() && !locked)))
user.visible_message("[user] removes the electronics from the airlock assembly.", \
"<span class='notice'>You start to remove electronics from the airlock assembly...</span>")
if(I.use_tool(src, user, 40, volume=100))
Expand All @@ -1170,7 +1164,7 @@
INVOKE_ASYNC(src, (density ? PROC_REF(open) : PROC_REF(close)), 2)


/obj/machinery/door/airlock/open(forced=0, ignore_emagged = FALSE)
/obj/machinery/door/airlock/open(forced=0)
if( operating || welded || locked )
return FALSE
if(!forced)
Expand All @@ -1191,8 +1185,6 @@
H.apply_damage(40, BRUTE, BODY_ZONE_CHEST)
return
if(forced < 2)
if(!ignore_emagged && (obj_flags & EMAGGED))
return FALSE
if(!protected_door)
use_power(50)
playsound(src, doorOpen, 30, 1)
Expand Down Expand Up @@ -1243,8 +1235,6 @@
return

if(forced < 2)
if(obj_flags & EMAGGED)
return
if(!protected_door)
use_power(50)
playsound(src, doorClose, 30, TRUE)
Expand Down Expand Up @@ -1286,8 +1276,6 @@
return TRUE

/obj/machinery/door/airlock/proc/prison_open()
if(obj_flags & EMAGGED)
return
locked = FALSE
open()
locked = TRUE
Expand Down Expand Up @@ -1329,9 +1317,8 @@
//Airlock is passable if it is open (!density), bot has access, and is not bolted shut or powered off)
return !density || (check_access(ID) && !locked && hasPower())

///This does not call parent because airlocks should be possible to emag multiple times. We only care that the door is closed, not protected and has power.
/obj/machinery/door/airlock/should_emag(mob/user)
if(!..())
return FALSE
if(protected_door)
to_chat(user, "<span class='warning'>[src] has no maintenance panel!</span>")
return FALSE
Expand All @@ -1351,12 +1338,10 @@
if(QDELETED(src))
return
operating = FALSE
if(!open(ignore_emagged = TRUE))
if(!open())
update_icon(AIRLOCK_CLOSED, 1)
lights = FALSE
locked = TRUE
loseMainPower()
loseBackupPower()
bolt()
loseMainPower(TRUE)

/obj/machinery/door/airlock/attack_alien(mob/living/carbon/alien/humanoid/user)
add_fingerprint(user)
Expand Down Expand Up @@ -1451,9 +1436,6 @@
if(!disassembled)
if(A)
A.obj_integrity = A.max_integrity * 0.5
else if(obj_flags & EMAGGED)
if(user)
to_chat(user, "<span class='warning'>You discard the damaged electronics.</span>")
else
if(user)
to_chat(user, "<span class='notice'>You remove the airlock electronics.</span>")
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

/obj/machinery/door/Bumped(atom/movable/AM)
. = ..()
if(operating || (obj_flags & EMAGGED))
if(operating)
return
if(ismob(AM))
var/mob/B = AM
Expand Down Expand Up @@ -148,7 +148,7 @@
/// Helper method for bumpopen() and try_to_activate_door(). Don't override.
/obj/machinery/door/proc/activate_door_base(mob/user, can_close_door)
add_fingerprint(user)
if(operating || (obj_flags & EMAGGED))
if(operating)
return
// Cutting WIRE_IDSCAN disables normal entry
if(!id_scan_hacked() && allowed(user))
Expand Down

0 comments on commit b51cb61

Please sign in to comment.