From 08e36394bae543ae55ab1ff93b9d5bc6523440e8 Mon Sep 17 00:00:00 2001 From: Markolie Date: Thu, 17 Sep 2015 22:44:15 +0200 Subject: [PATCH] Consolidate power failure procs --- code/modules/events/grid_check.dm | 63 ++++++++++++++++++++++++++++ code/modules/events/power_failure.dm | 61 --------------------------- paradise.dme | 1 - 3 files changed, 63 insertions(+), 62 deletions(-) delete mode 100644 code/modules/events/power_failure.dm diff --git a/code/modules/events/grid_check.dm b/code/modules/events/grid_check.dm index c485827efbc..ca675306ffa 100644 --- a/code/modules/events/grid_check.dm +++ b/code/modules/events/grid_check.dm @@ -12,3 +12,66 @@ /datum/event/grid_check/end() power_restore() + +/proc/power_failure(var/announce = 1) + if(announce) + command_announcement.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", new_sound = 'sound/AI/poweroff.ogg') + + var/list/skipped_areas = list(/area/turret_protected/ai) + var/list/skipped_areas_apc = list(/area/engine/engineering) + + for(var/obj/machinery/power/smes/S in machines) + var/area/current_area = get_area(S) + if(current_area.type in skipped_areas || !(S.z in config.station_levels)) + continue + S.last_charge = S.charge + S.last_output_attempt = S.output_attempt + S.last_input_attempt = S.input_attempt + S.charge = 0 + S.inputting(0) + S.outputting(0) + S.update_icon() + S.power_change() + + for(var/obj/machinery/power/apc/C in world) + var/area/current_area = get_area(C) + if(current_area.type in skipped_areas_apc || !(C.z in config.station_levels)) + continue + if(C.cell) + C.cell.charge = 0 + +/proc/power_restore(var/announce = 1) + var/list/skipped_areas = list(/area/turret_protected/ai) + var/list/skipped_areas_apc = list(/area/engine/engineering) + + if(announce) + command_announcement.Announce("Power has been restored to [station_name()]. We apologize for the inconvenience.", "Power Systems Nominal", new_sound = 'sound/AI/poweron.ogg') + for(var/obj/machinery/power/apc/C in machines) + var/area/current_area = get_area(C) + if(current_area.type in skipped_areas_apc || !(C.z in config.station_levels)) + continue + if(C.cell) + C.cell.charge = C.cell.maxcharge + for(var/obj/machinery/power/smes/S in machines) + var/area/current_area = get_area(S) + if(current_area.type in skipped_areas || !(S.z in config.station_levels)) + continue + S.charge = S.last_charge + S.output_attempt = S.last_output_attempt + S.input_attempt = S.last_input_attempt + S.update_icon() + S.power_change() + +/proc/power_restore_quick(var/announce = 1) + if(announce) + command_announcement.Announce("All SMESs on [station_name()] have been recharged. We apologize for the inconvenience.", "Power Systems Nominal", new_sound = 'sound/AI/poweron.ogg') + for(var/obj/machinery/power/smes/S in machines) + if(S.z != 1) + continue + S.charge = S.capacity + S.output_level = S.output_level_max + S.output_attempt = 1 + S.input_attempt = 1 + S.update_icon() + S.power_change() + \ No newline at end of file diff --git a/code/modules/events/power_failure.dm b/code/modules/events/power_failure.dm deleted file mode 100644 index aac2c68ca1e..00000000000 --- a/code/modules/events/power_failure.dm +++ /dev/null @@ -1,61 +0,0 @@ -/proc/power_failure(var/announce = 1) - if(announce) - command_announcement.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", new_sound = 'sound/AI/poweroff.ogg') - - var/list/skipped_areas = list(/area/turret_protected/ai) - var/list/skipped_areas_apc = list(/area/engine/engineering) - - for(var/obj/machinery/power/smes/S in machines) - var/area/current_area = get_area(S) - if(current_area.type in skipped_areas || !(S.z in config.station_levels)) - continue - S.last_charge = S.charge - S.last_output_attempt = S.output_attempt - S.last_input_attempt = S.input_attempt - S.charge = 0 - S.inputting(0) - S.outputting(0) - S.update_icon() - S.power_change() - - for(var/obj/machinery/power/apc/C in world) - var/area/current_area = get_area(C) - if(current_area.type in skipped_areas_apc || !(C.z in config.station_levels)) - continue - if(C.cell) - C.cell.charge = 0 - -/proc/power_restore(var/announce = 1) - var/list/skipped_areas = list(/area/turret_protected/ai) - var/list/skipped_areas_apc = list(/area/engine/engineering) - - if(announce) - command_announcement.Announce("Power has been restored to [station_name()]. We apologize for the inconvenience.", "Power Systems Nominal", new_sound = 'sound/AI/poweron.ogg') - for(var/obj/machinery/power/apc/C in machines) - var/area/current_area = get_area(C) - if(current_area.type in skipped_areas_apc || !(C.z in config.station_levels)) - continue - if(C.cell) - C.cell.charge = C.cell.maxcharge - for(var/obj/machinery/power/smes/S in machines) - var/area/current_area = get_area(S) - if(current_area.type in skipped_areas || !(S.z in config.station_levels)) - continue - S.charge = S.last_charge - S.output_attempt = S.last_output_attempt - S.input_attempt = S.last_input_attempt - S.update_icon() - S.power_change() - -/proc/power_restore_quick(var/announce = 1) - if(announce) - command_announcement.Announce("All SMESs on [station_name()] have been recharged. We apologize for the inconvenience.", "Power Systems Nominal", new_sound = 'sound/AI/poweron.ogg') - for(var/obj/machinery/power/smes/S in machines) - if(S.z != 1) - continue - S.charge = S.capacity - S.output_level = S.output_level_max - S.output_attempt = 1 - S.input_attempt = 1 - S.update_icon() - S.power_change() diff --git a/paradise.dme b/paradise.dme index 5e1dea34d7a..9f5f0ab55bd 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1137,7 +1137,6 @@ #include "code\modules\events\money_hacker.dm" #include "code\modules\events\money_lotto.dm" #include "code\modules\events\money_spam.dm" -#include "code\modules\events\power_failure.dm" #include "code\modules\events\prison_break.dm" #include "code\modules\events\radiation_storm.dm" #include "code\modules\events\rogue_drones.dm"