Merge pull request #20028 from Shadowlight213/powerfailure

Adds the grid check random event from baystation.
This commit is contained in:
oranges
2016-08-24 16:06:49 +12:00
committed by GitHub
9 changed files with 162 additions and 98 deletions
+1
View File
@@ -50,6 +50,7 @@
for(var/obj/machinery/power/apc/C in machines)
if(C.cell && C.z == ZLEVEL_STATION)
C.cell.charge = C.cell.maxcharge
C.failure_timer = 0
for(var/obj/machinery/power/smes/S in machines)
if(S.z != ZLEVEL_STATION)
continue
+1
View File
@@ -114,6 +114,7 @@ Class Procs:
var/global/gl_uid = 1
var/panel_open = 0
var/state_open = 0
var/critical_machine = FALSE //If this machine is critical to station operation and should have the area be excempted from power failures.
var/mob/living/occupant = null
var/unsecuring_tool = /obj/item/weapon/wrench
var/interact_open = 0 // Can the machine be interacted with when in maint/when the panel is open.
@@ -31,6 +31,7 @@ var/global/list/obj/machinery/telecomms/telecomms_list = list()
var/long_range_link = 0 // Can you link it across Z levels or on the otherside of the map? (Relay & Hub)
var/hide = 0 // Is it a hidden machine?
var/listening_level = 0 // 0 = auto set in New() - this is the z level that the machine is listening to.
critical_machine = TRUE
/obj/machinery/telecomms/proc/relay_information(datum/signal/signal, filter, copysig, amount = 20)
+19
View File
@@ -0,0 +1,19 @@
/datum/round_event_control/grid_check
name = "Grid Check"
typepath = /datum/round_event/grid_check
weight = 10
max_occurrences = 3
/datum/round_event/grid_check
announceWhen = 1
startWhen = 1
/datum/round_event/grid_check/announce()
priority_announce("Abnormal activity detected in [station_name()]'s powernet. As a precautionary measure, the station's power will be shut off for an indeterminate duration.", "Critical Power Failure", 'sound/AI/poweroff.ogg')
/datum/round_event/grid_check/start()
for(var/P in apcs_list)
var/obj/machinery/power/apc/C = P
if(C.cell && C.z == ZLEVEL_STATION)
C.energy_fail(rand(30,120))
+34 -3
View File
@@ -82,6 +82,8 @@
var/mob/living/silicon/ai/occupier = null
var/longtermpower = 10
var/auto_name = 0
var/failure_timer = 0
var/force_update = 0
var/update_state = -1
var/update_overlay = -1
var/global/status_overlays = 0
@@ -626,13 +628,17 @@
/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
datum/tgui/master_ui = null, datum/ui_state/state = default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "apc", name, 535, 515, master_ui, state)
ui.open()
if(ui)
ui.set_autoupdate(state = (failure_timer ? 1 : 0))
/obj/machinery/power/apc/ui_data(mob/user)
var/list/data = list(
"locked" = locked,
"failTime" = failure_timer,
"isOperating" = operating,
"externalPower" = main_status,
"powerCellStatus" = cell ? cell.percent() : null,
@@ -697,7 +703,7 @@
return "[area.name] : [equipment]/[lighting]/[environ] ([lastused_equip+lastused_light+lastused_environ]) : [cell? cell.percent() : "N/C"] ([charging])"
/obj/machinery/power/apc/proc/update()
if(operating && !shorted)
if(operating && !shorted && !failure_timer)
area.power_light = (lighting > 1)
area.power_equip = (equipment > 1)
area.power_environ = (environ > 1)
@@ -732,7 +738,7 @@
return TRUE
/obj/machinery/power/apc/ui_act(action, params)
if(..() || !can_use(usr, 1) || (locked && !usr.has_unlimited_silicon_privilege))
if(..() || !can_use(usr, 1) || (locked && !usr.has_unlimited_silicon_privilege && !failure_timer))
return
switch(action)
if("lock")
@@ -782,6 +788,11 @@
if("deoccupy")
if(get_malf_status(usr))
malfvacate()
if("reboot")
failure_timer = 0
update_icon()
update()
return 1
/obj/machinery/power/apc/proc/toggle_breaker()
operating = !operating
@@ -874,6 +885,12 @@
return
if(!area.requires_power)
return
if(failure_timer)
update()
queue_icon_update()
failure_timer--
force_update = 1
return
/*
if (equipment > 1) // off=0, off auto=1, on=2, on auto=3
@@ -1013,7 +1030,8 @@
// update icon & area power if anything changed
if(last_lt != lighting || last_eq != equipment || last_en != environ)
if(last_lt != lighting || last_eq != equipment || last_en != environ || force_update)
force_update = 0
queue_icon_update()
update()
else if (last_ch != charging)
@@ -1130,6 +1148,19 @@
else
return 0
/obj/machinery/power/apc/proc/energy_fail(duration)
for(var/obj/machinery/M in area.contents)
if(M.critical_machine)
return
for(var/A in ai_list)
var/mob/living/silicon/ai/I = A
if(get_area(I) == area)
return
failure_timer = max(failure_timer, round(duration))
#undef APC_UPDATE_ICON_COOLDOWN
/*Power module, used for APC construction*/
@@ -159,6 +159,7 @@
var/turf/T = loc
assembled = 0
critical_machine = FALSE
var/obj/structure/particle_accelerator/fuel_chamber/F = locate() in orange(1,src)
if(!F)
@@ -189,6 +190,7 @@
return 0
assembled = 1
critical_machine = TRUE //Only counts if the PA is actually assembled.
return 1
/obj/machinery/particle_accelerator/control_box/proc/check_part(turf/T, type)
+1
View File
@@ -1083,6 +1083,7 @@
#include "code\modules\events\electrical_storm.dm"
#include "code\modules\events\false_alarm.dm"
#include "code\modules\events\ghost_role.dm"
#include "code\modules\events\grid_check.dm"
#include "code\modules\events\immovable_rod.dm"
#include "code\modules\events\ion_storm.dm"
#include "code\modules\events\major_dust.dm"
+14 -14
View File
File diff suppressed because one or more lines are too long
+89 -81
View File
@@ -42,84 +42,92 @@
}
}
</script>
<ui-notice>
{{#if data.siliconUser}}
<ui-section label='Interface Lock'>
<ui-button icon='{{data.locked ? "lock" : "unlock"}}' action='lock'>{{data.locked ? "Engaged" : "Disengaged"}}</ui-button>
</ui-section>
{{else}}
<span>Swipe an ID card to {{data.locked ? "unlock" : "lock"}} this interface.</span>
{{/if}}
</ui-notice>
<ui-display title='Power Status'>
<ui-section label='Main Breaker'>
{{#if data.locked && !data.siliconUser}}
<span class='{{data.isOperating ? "good" : "bad"}}'>{{data.isOperating ? "On" : "Off"}}</span>
{{else}}
<ui-button icon='{{data.isOperating ? "power-off" : "close"}}' style='{{data.isOperating ? "selected" : null}}'
action='breaker'>{{data.isOperating ? "On" : "Off"}}</ui-button>
{{/if}}
</ui-section>
<ui-section label='External Power'>
<span class='{{powerState(data.externalPower)}}'>{{data.externalPower == 2 ? "Good" : data.externalPower == 1 ? "Low" : "None"}}</span>
</ui-section>
<ui-section label='Power Cell'>
{{#if data.powerCellStatus != null}}
<ui-bar min='0' max='100' value='{{data.powerCellStatus}}' state='{{powerCellStatusState}}'>{{Math.fixed(adata.powerCellStatus)}}%</ui-bar>
{{else}}
<span class='bad'>Removed</span>
{{/if}}
</ui-section>
{{#if data.powerCellStatus != null}}
<ui-section label='Charge Mode'>
{{#if data.locked && !data.siliconUser}}
<span class='{{data.chargeMode ? "good" : "bad"}}'>{{data.chargeMode ? "Auto" : "Off"}}</span>
{{else}}
<ui-button icon='{{data.chargeMode ? "refresh" : "close"}}' style='{{data.chargeMode ? "selected" : null}}'
action='charge'>{{data.chargeMode ? "Auto" : "Off"}}</ui-button>
{{/if}}
&nbsp;
[<span class='{{powerState(data.chargingStatus)}}'>{{data.chargingStatus == 2 ? "Fully Charged" : data.chargingStatus == 1 ? "Charging" : "Not Charging"}}</span>]
</ui-section>
{{/if}}
</ui-display>
<ui-display title='Power Channels'>
{{#each data.powerChannels}}
<ui-section label='{{title}}' nowrap>
<div class='content'>{{Math.round(adata.powerChannels[@index].powerLoad)}} W</div>
<div class='content'><span class='{{status >= 2 ? "good" : "bad"}}'>{{status >= 2 ? "On" : "Off"}}</span></div>
<div class='content'>[<span>{{status == 1 || status == 3 ? "Auto" : "Manual"}}</span>]</div>
<div class='content' style='float:right'>
{{#if !data.locked || data.siliconUser}}
<ui-button icon='refresh' state='{{status == 1 || status == 3 ? "selected" : null}}'
action='channel' params='{{topicParams.auto}}'>Auto</ui-button>
<ui-button icon='power-off' state='{{status == 2 ? "selected" : null}}' action='channel'
params='{{topicParams.on}}'>On</ui-button>
<ui-button icon='close' state='{{status == 0 ? "selected" : null}}' action='channel'
params='{{topicParams.off}}'>Off</ui-button>
{{/if}}
</div>
</ui-section>
{{/each}}
<ui-section label='Total Load'>
<span class='bold'>{{Math.round(adata.totalLoad)}} W</span>
</ui-section>
</ui-display>
{{#if data.siliconUser}}
<ui-display title='System Overrides'>
<ui-button icon='lightbulb-o' action='overload'>Overload</ui-button>
{{#if data.malfStatus}}
<ui-button icon='{{malfIcon}}' state='{{data.malfStatus == 4 ? "disabled" : null}}' action='{{malfAction}}'>{{malfButton}}</ui-button>
{{/if}}
</ui-display>
{{/if}}
<ui-notice>
<ui-section label='Cover Lock'>
{{#if data.locked && !data.siliconUser}}
<span>{{data.coverLocked ? "Engaged" : "Disengaged"}}</span>
{{else}}
<ui-button icon='{{data.coverLocked ? "lock" : "unlock"}}' action='cover'>{{data.coverLocked ? "Engaged" : "Disengaged"}}</ui-button>
{{/if}}
</ui-section>
</ui-notice>
{{#if data.failTime}}
<ui-notice>
<b><h3>SYSTEM FAILURE</h3></b>
<i>I/O regulators malfunction detected! Waiting for system reboot...</i><br>
Automatic reboot in {{data.failTime}} seconds...
<ui-button icon='refresh' action='reboot'>Reboot Now</ui-button><br><br><br>
</ui-notice>
{{else}}
<ui-notice>
{{#if data.siliconUser}}
<ui-section label='Interface Lock'>
<ui-button icon='{{data.locked ? "lock" : "unlock"}}' action='lock'>{{data.locked ? "Engaged" : "Disengaged"}}</ui-button>
</ui-section>
{{else}}
<span>Swipe an ID card to {{data.locked ? "unlock" : "lock"}} this interface.</span>
{{/if}}
</ui-notice>
<ui-display title='Power Status'>
<ui-section label='Main Breaker'>
{{#if data.locked && !data.siliconUser}}
<span class='{{data.isOperating ? "good" : "bad"}}'>{{data.isOperating ? "On" : "Off"}}</span>
{{else}}
<ui-button icon='{{data.isOperating ? "power-off" : "close"}}' style='{{data.isOperating ? "selected" : null}}'
action='breaker'>{{data.isOperating ? "On" : "Off"}}</ui-button>
{{/if}}
</ui-section>
<ui-section label='External Power'>
<span class='{{powerState(data.externalPower)}}'>{{data.externalPower == 2 ? "Good" : data.externalPower == 1 ? "Low" : "None"}}</span>
</ui-section>
<ui-section label='Power Cell'>
{{#if data.powerCellStatus != null}}
<ui-bar min='0' max='100' value='{{data.powerCellStatus}}' state='{{powerCellStatusState}}'>{{Math.fixed(adata.powerCellStatus)}}%</ui-bar>
{{else}}
<span class='bad'>Removed</span>
{{/if}}
</ui-section>
{{#if data.powerCellStatus != null}}
<ui-section label='Charge Mode'>
{{#if data.locked && !data.siliconUser}}
<span class='{{data.chargeMode ? "good" : "bad"}}'>{{data.chargeMode ? "Auto" : "Off"}}</span>
{{else}}
<ui-button icon='{{data.chargeMode ? "refresh" : "close"}}' style='{{data.chargeMode ? "selected" : null}}'
action='charge'>{{data.chargeMode ? "Auto" : "Off"}}</ui-button>
{{/if}}
&nbsp;
[<span class='{{powerState(data.chargingStatus)}}'>{{data.chargingStatus == 2 ? "Fully Charged" : data.chargingStatus == 1 ? "Charging" : "Not Charging"}}</span>]
</ui-section>
{{/if}}
</ui-display>
<ui-display title='Power Channels'>
{{#each data.powerChannels}}
<ui-section label='{{title}}' nowrap>
<div class='content'>{{Math.round(adata.powerChannels[@index].powerLoad)}} W</div>
<div class='content'><span class='{{status >= 2 ? "good" : "bad"}}'>{{status >= 2 ? "On" : "Off"}}</span></div>
<div class='content'>[<span>{{status == 1 || status == 3 ? "Auto" : "Manual"}}</span>]</div>
<div class='content' style='float:right'>
{{#if !data.locked || data.siliconUser}}
<ui-button icon='refresh' state='{{status == 1 || status == 3 ? "selected" : null}}'
action='channel' params='{{topicParams.auto}}'>Auto</ui-button>
<ui-button icon='power-off' state='{{status == 2 ? "selected" : null}}' action='channel'
params='{{topicParams.on}}'>On</ui-button>
<ui-button icon='close' state='{{status == 0 ? "selected" : null}}' action='channel'
params='{{topicParams.off}}'>Off</ui-button>
{{/if}}
</div>
</ui-section>
{{/each}}
<ui-section label='Total Load'>
<span class='bold'>{{Math.round(adata.totalLoad)}} W</span>
</ui-section>
</ui-display>
{{#if data.siliconUser}}
<ui-display title='System Overrides'>
<ui-button icon='lightbulb-o' action='overload'>Overload</ui-button>
{{#if data.malfStatus}}
<ui-button icon='{{malfIcon}}' state='{{data.malfStatus == 4 ? "disabled" : null}}' action='{{malfAction}}'>{{malfButton}}</ui-button>
{{/if}}
</ui-display>
{{/if}}
<ui-notice>
<ui-section label='Cover Lock'>
{{#if data.locked && !data.siliconUser}}
<span>{{data.coverLocked ? "Engaged" : "Disengaged"}}</span>
{{else}}
<ui-button icon='{{data.coverLocked ? "lock" : "unlock"}}' action='cover'>{{data.coverLocked ? "Engaged" : "Disengaged"}}</ui-button>
{{/if}}
</ui-section>
</ui-notice>
{{/if}}