NanoUI synth airlock update

This commit is contained in:
Markolie
2015-03-03 18:45:22 +01:00
parent 4dd857e022
commit 1db034a8f8
8 changed files with 156 additions and 115 deletions
+2 -1
View File
@@ -19,6 +19,7 @@
if(istype(door,/obj/machinery/door/airlock/hatch/gamma))
return
if(istype(door,/obj/machinery/door/airlock))
door:unlock(1) //forced because it's magic!
var/obj/machinery/door/airlock/A = door
A.unlock(1) //forced because it's magic!
door.open()
return
+6 -18
View File
@@ -74,8 +74,7 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
if(!mended)
//Cutting this wire also drops the door bolts, and mending it does not raise them. (This is what happens now, except there are a lot more wires going to door bolts at present)
if(A.locked!=1)
A.locked = 1
A.lock(1)
A.update_icon()
if(AIRLOCK_WIRE_AI_CONTROL)
@@ -96,12 +95,9 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
if(AIRLOCK_WIRE_ELECTRIFY)
if(!mended)
//Cutting this wire electrifies the door, so that the next person to touch the door without insulated gloves gets electrocuted.
if(A.electrified_until != -1)
A.shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])")
add_logs(usr, A, "electrified", null, addition="at [A.x],[A.y],[A.z]")
A.electrified_until = -1
A.electrify(-1)
else
A.electrified_until = 0
A.electrify(0)
return // Don't update the dialog.
if (AIRLOCK_WIRE_SAFETY)
@@ -135,13 +131,9 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
//one wire for door bolts. Sending a pulse through this drops door bolts if they're not down (whether power's on or not),
//raises them if they are down (only if power's on)
if(!A.locked)
A.locked = 1
A.audible_message("You hear a click from the bottom of the door.", null, 1)
A.lock()
else
if(A.arePowerSystemsOn()) //only can raise bolts if power's on
A.locked = 0
A.audible_message("You hear a click from the bottom of the door.", null, 1)
A.update_icon()
A.unlock()
if(AIRLOCK_WIRE_BACKUP_POWER1 || AIRLOCK_WIRE_BACKUP_POWER2)
//two wires for backup power. Sending a pulse through either one causes a breaker to trip, but this does not disable it unless main power is down too (in which case it is disabled for 1 minute or however long it takes main power to come back, whichever is shorter).
@@ -161,11 +153,7 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
if(AIRLOCK_WIRE_ELECTRIFY)
//one wire for electrifying the door. Sending a pulse through this electrifies the door for 30 seconds.
if(A.electrified_until >= 0)
A.shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])")
add_logs(usr, A, "electrified", null, addition="at [A.x],[A.y],[A.z]")
A.electrified_until = world.time + SecondsToTicks(30)
return
A.electrify(30)
if(AIRLOCK_WIRE_OPEN_DOOR)
//tries to open the door without ID
//will succeed only if the ID wire is cut or the door requires no access and it's not emagged
+3 -4
View File
@@ -98,17 +98,16 @@
if(specialfunctions & BOLTS)
D.lock()
if(specialfunctions & SHOCK)
D.electrified_until = -1
D.electrify(-1)
if(specialfunctions & SAFE)
D.safe = 0
else
if(specialfunctions & IDSCAN)
D.aiDisabledIdScanner = 0
if(specialfunctions & BOLTS)
if(!D.isWireCut(4) && D.arePowerSystemsOn())
D.unlock()
D.unlock()
if(specialfunctions & SHOCK)
D.electrified_until = 0
D.electrify(0)
if(specialfunctions & SAFE)
D.safe = 1
+89 -36
View File
@@ -28,6 +28,7 @@
explosion_resistance = 15
var/aiControlDisabled = 0 //If 1, AI control is disabled until the AI hacks back in and disables the lock. If 2, the AI has bypassed the lock. If -1, the control is enabled but the AI had bypassed it earlier, so if it is disabled again the AI would have no trouble getting back in.
var/hackProof = 0 // if 1, this door can't be hacked by the AI
var/electrified_until = 0 // World time when the door is no longer electrified. -1 if it is permanently electrified until someone fixes it.
var/main_power_lost_until = 0 //World time when main power is restored.
var/backup_power_lost_until = -1 //World time when backup power is restored.
var/spawnPowerRestoreRunning = 0
@@ -209,23 +210,15 @@
var/last_event = 0
/obj/machinery/door/airlock/process()
// Deliberate no call to parent
if(src.isWireCut(AIRLOCK_WIRE_MAIN_POWER1) || src.isWireCut(AIRLOCK_WIRE_MAIN_POWER2))
main_power_lost_until = -1
else if(main_power_lost_until > 0 && world.time > main_power_lost_until)
// Deliberate no call to parent.
if(main_power_lost_until > 0 && world.time >= main_power_lost_until)
regainMainPower()
if(src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER1) || src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER2))
backup_power_lost_until = -1
if(backup_power_lost_until > 0&& world.time > backup_power_lost_until)
if(backup_power_lost_until > 0 && world.time >= backup_power_lost_until)
regainBackupPower()
if(electrified_until && !arePowerSystemsOn())
electrified_until = 0
else if(isWireCut(AIRLOCK_WIRE_ELECTRIFY))
electrified_until = -1
else if(electrified_until > 0 && world.time > electrified_until)
electrified_until = 0
else if(electrified_until > 0 && world.time >= electrified_until)
electrify(0)
/obj/machinery/door/airlock/uranium/process()
if(world.time > last_event+20)
@@ -390,32 +383,72 @@ About the new airlock wires panel:
return !(src.isWireCut(AIRLOCK_WIRE_IDSCAN) || aiDisabledIdScanner)
/obj/machinery/door/airlock/proc/isAllPowerLoss()
if(stat & NOPOWER)
if(stat & (NOPOWER|BROKEN))
return 1
if(mainPowerCablesCut() && backupPowerCablesCut())
return 1
if(src.isWireCut(AIRLOCK_WIRE_MAIN_POWER1) || src.isWireCut(AIRLOCK_WIRE_MAIN_POWER2))
if(src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER1) || src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER2))
return 1
return 0
/obj/machinery/door/airlock/proc/mainPowerCablesCut()
return src.isWireCut(AIRLOCK_WIRE_MAIN_POWER1) || src.isWireCut(AIRLOCK_WIRE_MAIN_POWER2)
/obj/machinery/door/airlock/proc/backupPowerCablesCut()
return src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER1) || src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER2)
/obj/machinery/door/airlock/proc/loseMainPower()
// process() will handle the case of cut power cables
main_power_lost_until = world.time + SecondsToTicks(60)
backup_power_lost_until = max(backup_power_lost_until, world.time + SecondsToTicks(10))
main_power_lost_until = mainPowerCablesCut() ? -1 : world.time + SecondsToTicks(60)
// If backup power is permanently disabled then activate in 10 seconds if possible, otherwise it's already enabled or a timer is already running
if(backup_power_lost_until == -1 && !backupPowerCablesCut())
backup_power_lost_until = world.time + SecondsToTicks(10)
// Disable electricity if required
if(electrified_until && isAllPowerLoss())
electrify(0)
/obj/machinery/door/airlock/proc/loseBackupPower()
// process() will handle the case of cut power cables
backup_power_lost_until = world.time + SecondsToTicks(60)
backup_power_lost_until = backupPowerCablesCut() ? -1 : world.time + SecondsToTicks(60)
// Disable electricity if required
if(electrified_until && isAllPowerLoss())
electrify(0)
/obj/machinery/door/airlock/proc/regainMainPower()
if(!src.isWireCut(AIRLOCK_WIRE_MAIN_POWER1) && !src.isWireCut(AIRLOCK_WIRE_MAIN_POWER2))
if(!mainPowerCablesCut())
main_power_lost_until = 0
backup_power_lost_until = -1
// If backup power is currently active then disable, otherwise let it count down and disable itself later
if(!backup_power_lost_until)
backup_power_lost_until = -1
update_icon()
/obj/machinery/door/airlock/proc/regainBackupPower()
if(!src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER1) && !src.isWireCut(AIRLOCK_WIRE_BACKUP_POWER2))
backup_power_lost_until = 0
if(!backupPowerCablesCut())
// Restore backup power only if main power is offline, otherwise permanently disable
backup_power_lost_until = main_power_lost_until == 0 ? -1 : 0
update_icon()
/obj/machinery/door/airlock/proc/electrify(var/duration, var/feedback = 0)
var/message = ""
if(src.isWireCut(AIRLOCK_WIRE_ELECTRIFY) && arePowerSystemsOn())
message = text("The electrification wire is cut - Door permanently electrified.")
src.electrified_until = -1
else if(duration && !arePowerSystemsOn())
message = text("The door is unpowered - Cannot electrify the door.")
src.electrified_until = 0
else if(!duration && electrified_until != 0)
message = "The door is now un-electrified."
src.electrified_until = 0
else if(duration) //electrify door for the given duration seconds
if(usr)
shockedby += text("\[[time_stamp()]\] - [usr](ckey:[usr.ckey])")
usr.attack_log += text("\[[time_stamp()]\] <font color='red'>Electrified the [name] at [x] [y] [z]</font>")
else
shockedby += text("\[[time_stamp()]\] - EMP)")
message = "The door is now electrified [duration == -1 ? "permanently" : "for [duration] second\s"]."
src.electrified_until = duration == -1 ? -1 : world.time + SecondsToTicks(duration)
if(feedback && message)
usr << message
// shock user with probability prb (if all connections & power are working)
// returns 1 if shocked, 0 otherwise
@@ -917,23 +950,29 @@ About the new airlock wires panel:
return
/obj/machinery/door/airlock/proc/lock(var/forced=0)
if (operating || src.locked) return
if(locked)
return 0
if (operating && !forced) return 0
src.locked = 1
for(var/mob/M in range(1,src))
M.show_message("You hear a click from the bottom of the door.", 2)
update_icon()
return 1
/obj/machinery/door/airlock/proc/unlock(var/forced=0)
if (operating || !src.locked) return
if(!src.locked)
return
if (forced || (src.arePowerSystemsOn())) //only can raise bolts if power's on
src.locked = 0
for(var/mob/M in range(1,src))
M.show_message("You hear a click from the bottom of the door.", 2)
update_icon()
return 1
return 0
if (!forced)
if(operating || !src.arePowerSystemsOn() || isWireCut(AIRLOCK_WIRE_DOOR_BOLTS)) return
src.locked = 0
for(var/mob/M in range(1,src))
M.show_message("You hear a click from the bottom of the door.", 2)
update_icon()
return 1
/obj/machinery/door/airlock/New()
..()
@@ -1013,7 +1052,21 @@ About the new airlock wires panel:
else
return
/obj/machinery/door/airlock/CanAStarPass(var/obj/item/weapon/card/id/ID)
//Airlock is passable if it is open (!density), bot has access, and is not bolted shut)
return !density || (check_access(ID) && !locked)
/obj/machinery/door/airlock/emp_act(var/severity)
if(prob(40/severity))
var/duration = world.time + SecondsToTicks(30 / severity)
if(duration > electrified_until)
electrify(duration)
..()
/obj/machinery/door/airlock/power_change() //putting this is obj/machinery/door itself makes non-airlock doors turn invisible for some reason
..()
if(stat & NOPOWER)
// If we lost power, disable electrification
// Keeping door lights on, runs on internal battery or something.
electrified_until = 0
update_icon()
-7
View File
@@ -10,7 +10,6 @@
density = 1
layer = 2.7
var/electrified_until = 0 // World time when the door is no longer electrified. -1 if it is permanently electrified until someone fixes it.
var/visible = 1
var/p_open = 0
var/operating = 0
@@ -57,10 +56,6 @@
..()
return
/obj/machinery/door/process()
if(electrified_until > 0 && world.time > electrified_until)
electrified_until = 0
/obj/machinery/door/Bumped(atom/AM)
if(p_open || operating) return
if(ismob(AM))
@@ -184,8 +179,6 @@
/obj/machinery/door/emp_act(severity)
if(prob(20/severity) && (istype(src,/obj/machinery/door/airlock) || istype(src,/obj/machinery/door/window)) )
open()
if(prob(40/severity))
electrified_until = max(electrified_until, world.time + SecondsToTicks(30 / severity))
..()