Files
Bubberstation/code/modules/events/grid_check.dm
SkyratBot bff17d1eb4 [MIRROR] Fixed fake grid check events failing to announce [MDB IGNORE] (#21149)
* Fixed fake grid check events failing to announce (#75393)

```
Exception has occurred: Cannot read null.announcement_spam_protection
 - proc name: announce (/datum/round_event/grid_check/announce)
 -   source file: grid_check.dm,20
 -   usr: null
 -   src: /datum/round_event/grid_check (/datum/round_event/grid_check)
 -   call stack:
 - /datum/round_event/grid_check (/datum/round_event/grid_check): announce(1)
 - /datum/round_event/falsealarm (/datum/round_event/falsealarm): announce(0)
 - /datum/round_event/falsealarm (/datum/round_event/falsealarm): process(2)
 - Events (/datum/controller/subsystem/events): fire(0)
 - Events (/datum/controller/subsystem/events): ignite(0)
 - Master (/datum/controller/master): RunQueue()
 - Master (/datum/controller/master): Loop(2)
 - Master (/datum/controller/master): StartProcessing(0)
```
Caused by #73277
Fake events don't have controllers.

🆑 ShizCalev
fix: Fixed fake grid check events failing to announce properly.
/🆑

* Fixed fake grid check events failing to announce

---------

Co-authored-by: ShizCalev <ShizCalev@users.noreply.github.com>
2023-05-15 00:39:45 +01:00

31 lines
1.2 KiB
Plaintext

/datum/round_event_control/grid_check
name = "Grid Check"
typepath = /datum/round_event/grid_check
weight = 10
max_occurrences = 3
category = EVENT_CATEGORY_ENGINEERING
description = "Turns off all APCs for a while, or until they are manually rebooted."
min_wizard_trigger_potency = 0
max_wizard_trigger_potency = 4
/// Cooldown for the announement associated with this event.
/// Necessary due to the fact that this event is player triggerable.
COOLDOWN_DECLARE(announcement_spam_protection)
/datum/round_event/grid_check
announce_when = 1
start_when = 1
/datum/round_event/grid_check/announce(fake)
var/datum/round_event_control/grid_check/controller = control
if(!fake)
if(!controller)
CRASH("event started without controller!")
if(!COOLDOWN_FINISHED(controller, announcement_spam_protection))
return
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", ANNOUNCER_POWEROFF)
if(!fake) // Only start the CD if we're real
COOLDOWN_START(controller, announcement_spam_protection, 30 SECONDS)
/datum/round_event/grid_check/start()
power_fail(30, 120)