Refactor announcements. (#19459)

* Refactor announcements.

* Actually make this a unit test

* Dumb

* Remove unnecessary 'as text'

* Reviews:

- Make CSS class a recognizable word
- Flip the defaults for logging

Also:

- Style fixes (default null in fields)
- Fix emergency/crew-transfer shuttle announcement titles
This commit is contained in:
warriorstar-orion
2022-11-02 20:31:37 +01:00
committed by GitHub
parent e63526cfdd
commit 85f4503d33
27 changed files with 278 additions and 178 deletions
+12 -12
View File
@@ -629,32 +629,32 @@ Traitors and the like can also be revived with the previous role mostly intact.
if(type == "Custom")
type = clean_input("What would you like the report type to be?", "Report Type", "Encrypted Transmission")
var/customname = input(usr, "Pick a title for the report.", "Title", MsgType[type]) as text|null
if(!customname)
var/subtitle = input(usr, "Pick a title for the report.", "Title", MsgType[type]) as text|null
if(!subtitle)
return
var/input = input(usr, "Please enter anything you want. Anything. Serious.", "What's the message?") as message|null
if(!input)
var/message = input(usr, "Please enter anything you want. Anything. Serious.", "What's the message?") as message|null
if(!message)
return
switch(alert("Should this be announced to the general population?",,"Yes","No", "Cancel"))
if("Yes")
var/beepsound = input(usr, "What sound should the announcement make?", "Announcement Sound", "") as anything in MsgSound
GLOB.command_announcement.Announce(
message = input,
new_title = customname,
new_sound = MsgSound[beepsound],
from = type
GLOB.major_announcement.Announce(
message,
new_title = type,
new_subtitle = subtitle,
new_sound = MsgSound[beepsound]
)
print_command_report(input, customname)
print_command_report(message, subtitle)
if("No")
//same thing as the blob stuff - it's not public, so it's classified, dammit
GLOB.command_announcer.autosay("A classified message has been printed out at all communication consoles.")
print_command_report(input, "Classified: [customname]")
print_command_report(message, "Classified: [subtitle]")
else
return
log_admin("[key_name(src)] has created a communications report: [input]")
log_admin("[key_name(src)] has created a communications report: [message]")
message_admins("[key_name_admin(src)] has created a communications report", 1)
SSblackbox.record_feedback("tally", "admin_verb", 1, "Create Comms Report") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
+1 -1
View File
@@ -4,7 +4,7 @@
announceWhen = 1
/datum/event/radiation_storm/announce()
GLOB.priority_announcement.Announce("High levels of radiation detected near the station. Maintenance is best shielded from radiation.", "Anomaly Alert", 'sound/AI/radiation.ogg')
GLOB.major_announcement.Announce("High levels of radiation detected near the station. Maintenance is best shielded from radiation.", "Anomaly Alert", 'sound/AI/radiation.ogg')
//sound not longer matches the text, but an audible warning is probably good
/datum/event/radiation_storm/start()
+1 -1
View File
@@ -16,7 +16,7 @@
/datum/event/spider_terror/announce()
if(successSpawn)
GLOB.command_announcement.Announce("Confirmed outbreak of level 3 biohazard aboard [station_name()]. All personnel must contain the outbreak.", "Biohazard Alert", 'sound/effects/siren-spooky.ogg', new_sound2 = 'sound/AI/outbreak3.ogg')
GLOB.major_announcement.Announce("Confirmed outbreak of level 3 biohazard aboard [station_name()]. All personnel must contain the outbreak.", "Biohazard Alert", 'sound/effects/siren-spooky.ogg', new_sound2 = 'sound/AI/outbreak3.ogg')
else
log_and_message_admins("Warning: Could not spawn any mobs for event Terror Spiders")
+5 -7
View File
@@ -91,7 +91,7 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
var/last_paper_seen = null
var/can_shunt = TRUE
var/last_announcement = ""
var/datum/announcement/priority/announcement
var/datum/announcer/announcer
var/mob/living/simple_animal/bot/Bot
var/turf/waypoint //Holds the turf of the currently selected waypoint.
var/waypoint_mode = FALSE //Waypoint mode is for selecting a turf via clicking.
@@ -126,10 +126,8 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
verbs -= silicon_subsystems
/mob/living/silicon/ai/New(loc, datum/ai_laws/L, obj/item/mmi/B, safety = 0)
announcement = new()
announcement.title = "A.I. Announcement"
announcement.announcement_type = "A.I. Announcement"
announcement.announcer = name
announcer = new(config_type = /datum/announcement_configuration/ai)
announcer.author = name
var/list/possibleNames = GLOB.ai_names
@@ -330,7 +328,7 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
return FALSE
if(oldname != real_name)
announcement.announcer = name
announcer.author = name
if(eyeobj)
eyeobj.name = "[newname] (AI Eye)"
@@ -570,7 +568,7 @@ GLOBAL_LIST_INIT(ai_verbs_default, list(
if(check_unable(AI_CHECK_WIRELESS | AI_CHECK_RADIO))
return
announcement.Announce(input)
announcer.Announce(input)
next_text_announcement = world.time + TEXT_ANNOUNCEMENT_COOLDOWN
/mob/living/silicon/ai/proc/ai_call_shuttle()
+1 -1
View File
@@ -27,7 +27,7 @@
if(SSshuttle.emergency.mode == SHUTTLE_STRANDED)
SSshuttle.emergency.mode = SHUTTLE_DOCKED
SSshuttle.emergency.timer = world.time
GLOB.priority_announcement.Announce("Hostile environment resolved. You have 3 minutes to board the Emergency Shuttle.", "Priority Announcement", 'sound/AI/eshuttle_dock.ogg')
GLOB.major_announcement.Announce("Hostile environment resolved. You have 3 minutes to board the Emergency Shuttle.", "Priority Announcement", 'sound/AI/eshuttle_dock.ogg')
qdel(doomsday_device)
if(explosive)
@@ -7,8 +7,7 @@ GLOBAL_VAR_INIT(security_level, 0)
//5 = code delta
//config.alert_desc_blue_downto
GLOBAL_DATUM_INIT(security_announcement_up, /datum/announcement/priority/security, new(do_log = FALSE, new_sound = sound('sound/misc/notice1.ogg')))
GLOBAL_DATUM_INIT(security_announcement_down, /datum/announcement/priority/security, new(do_log = FALSE))
GLOBAL_DATUM_INIT(security_announcement, /datum/announcer, new(config_type = /datum/announcement_configuration/security))
/proc/set_security_level(level)
switch(level)
@@ -33,7 +32,7 @@ GLOBAL_DATUM_INIT(security_announcement_down, /datum/announcement/priority/secur
switch(level)
if(SEC_LEVEL_GREEN)
GLOB.security_announcement_down.Announce("All threats to the station have passed. All weapons need to be holstered and privacy laws are once again fully enforced.","Attention! Security level lowered to green.", 'sound/AI/green.ogg')
GLOB.security_announcement.Announce("All threats to the station have passed. All weapons need to be holstered and privacy laws are once again fully enforced.","Attention! Security level lowered to green.", 'sound/AI/green.ogg')
GLOB.security_level = SEC_LEVEL_GREEN
unset_stationwide_emergency_lighting()
post_status(STATUS_DISPLAY_TRANSFER_SHUTTLE_TIME)
@@ -41,9 +40,9 @@ GLOBAL_DATUM_INIT(security_announcement_down, /datum/announcement/priority/secur
if(SEC_LEVEL_BLUE)
if(GLOB.security_level < SEC_LEVEL_BLUE)
GLOB.security_announcement_up.Announce("The station has received reliable information about possible hostile activity on the station. Security staff may have weapons visible and random searches are permitted.","Attention! Security level elevated to blue.", 'sound/AI/blue.ogg')
GLOB.security_announcement.Announce("The station has received reliable information about possible hostile activity on the station. Security staff may have weapons visible and random searches are permitted.","Attention! Security level elevated to blue.", 'sound/AI/blue.ogg')
else
GLOB.security_announcement_down.Announce("The immediate threat has passed. Security may no longer have weapons drawn at all times, but may continue to have them visible. Random searches are still allowed.","Attention! Security level lowered to blue.", 'sound/AI/blue.ogg')
GLOB.security_announcement.Announce("The immediate threat has passed. Security may no longer have weapons drawn at all times, but may continue to have them visible. Random searches are still allowed.","Attention! Security level lowered to blue.", 'sound/AI/blue.ogg')
GLOB.security_level = SEC_LEVEL_BLUE
post_status(STATUS_DISPLAY_TRANSFER_SHUTTLE_TIME)
@@ -52,9 +51,9 @@ GLOBAL_DATUM_INIT(security_announcement_down, /datum/announcement/priority/secur
if(SEC_LEVEL_RED)
if(GLOB.security_level < SEC_LEVEL_RED)
GLOB.security_announcement_up.Announce("There is an immediate and serious threat to the station. Security may have weapons unholstered at all times. Random searches are allowed and advised.","Attention! Code Red!", 'sound/AI/red.ogg')
GLOB.security_announcement.Announce("There is an immediate and serious threat to the station. Security may have weapons unholstered at all times. Random searches are allowed and advised.","Attention! Code Red!", 'sound/AI/red.ogg')
else
GLOB.security_announcement_down.Announce("The station's self-destruct mechanism has been deactivated, but there is still an immediate and serious threat to the station. Security may have weapons unholstered at all times. Random searches are allowed and advised.","Attention! Code Red!", 'sound/AI/red.ogg')
GLOB.security_announcement.Announce("The station's self-destruct mechanism has been deactivated, but there is still an immediate and serious threat to the station. Security may have weapons unholstered at all times. Random searches are allowed and advised.","Attention! Code Red!", 'sound/AI/red.ogg')
unset_stationwide_emergency_lighting()
GLOB.security_level = SEC_LEVEL_RED
@@ -66,7 +65,7 @@ GLOBAL_DATUM_INIT(security_announcement_down, /datum/announcement/priority/secur
update_firealarms()
if(SEC_LEVEL_GAMMA)
GLOB.security_announcement_up.Announce("Central Command has ordered the Gamma security level on the station. Security is to have weapons equipped at all times, and all civilians are to immediately seek their nearest head for transportation to a secure location.", "Attention! Gamma security level activated!", 'sound/effects/new_siren.ogg', new_sound2 = 'sound/AI/gamma.ogg')
GLOB.security_announcement.Announce("Central Command has ordered the Gamma security level on the station. Security is to have weapons equipped at all times, and all civilians are to immediately seek their nearest head for transportation to a secure location.", "Attention! Gamma security level activated!", 'sound/effects/new_siren.ogg', new_sound2 = 'sound/AI/gamma.ogg')
GLOB.security_level = SEC_LEVEL_GAMMA
if(GLOB.security_level < SEC_LEVEL_RED)
@@ -89,7 +88,7 @@ GLOBAL_DATUM_INIT(security_announcement_down, /datum/announcement/priority/secur
return
if(SEC_LEVEL_DELTA)
GLOB.security_announcement_up.Announce("The station's self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.","Attention! Delta security level reached!", 'sound/effects/deltaalarm.ogg', new_sound2 = 'sound/AI/delta.ogg')
GLOB.security_announcement.Announce("The station's self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.","Attention! Delta security level reached!", 'sound/effects/deltaalarm.ogg', new_sound2 = 'sound/AI/delta.ogg')
GLOB.security_level = SEC_LEVEL_DELTA
post_status(STATUS_DISPLAY_ALERT, "deltaalert")
@@ -204,7 +203,7 @@ GLOBAL_DATUM_INIT(security_announcement_down, /datum/announcement/priority/secur
INVOKE_ASYNC(L, /obj/machinery/light/.proc/update, FALSE)
/proc/epsilon_process()
GLOB.security_announcement_up.Announce("Central Command has ordered the Epsilon security level on the station. Consider all contracts terminated.", "Attention! Epsilon security level activated!", 'sound/effects/purge_siren.ogg')
GLOB.security_announcement.Announce("Central Command has ordered the Epsilon security level on the station. Consider all contracts terminated.", "Attention! Epsilon security level activated!", 'sound/effects/purge_siren.ogg')
GLOB.security_level = SEC_LEVEL_EPSILON
post_status(STATUS_DISPLAY_ALERT, "epsilonalert")
for(var/area/A as anything in GLOB.all_areas)
+37 -17
View File
@@ -202,15 +202,7 @@
travelDir = 0
var/sound_played = 0 //If the launch sound has been sent to all players on the shuttle itself
var/datum/announcement/priority/emergency_shuttle_docked = new(0, new_sound = sound('sound/AI/eshuttle_dock.ogg'))
var/datum/announcement/priority/emergency_shuttle_called = new(0, new_sound = sound('sound/AI/eshuttle_call.ogg'))
var/datum/announcement/priority/emergency_shuttle_recalled = new(0, new_sound = sound('sound/AI/eshuttle_recall.ogg'))
var/canRecall = TRUE //no bad condom, do not recall the crew transfer shuttle!
var/datum/announcement/priority/crew_shuttle_called = new(0, new_sound = sound('sound/AI/cshuttle.ogg'))
var/datum/announcement/priority/crew_shuttle_docked = new(0, new_sound = sound('sound/AI/cshuttle_dock.ogg'))
///State of the emergency shuttles hijack status.
var/hijack_status = NOT_BEGUN
@@ -268,9 +260,17 @@
else
SSshuttle.emergencyLastCallLoc = null
if(canRecall)
emergency_shuttle_called.Announce("The emergency shuttle has been called. [redAlert ? "Red Alert state confirmed: Dispatching priority shuttle. " : "" ]It will arrive in [timeLeft(600)] minutes.[reason][SSshuttle.emergencyLastCallLoc ? "\n\nCall signal traced. Results can be viewed on any communications console." : "" ]")
GLOB.major_announcement.Announce(
"The emergency shuttle has been called. [redAlert ? "Red Alert state confirmed: Dispatching priority shuttle. " : "" ]It will arrive in [timeLeft(600)] minutes.[reason][SSshuttle.emergencyLastCallLoc ? "\n\nCall signal traced. Results can be viewed on any communications console." : "" ]",
new_title = "Priority Announcement",
new_sound = sound('sound/AI/eshuttle_call.ogg')
)
else
crew_shuttle_called.Announce("The crew transfer shuttle has been called. [redAlert ? "Red Alert state confirmed: Dispatching priority shuttle. " : "" ]It will arrive in [timeLeft(600)] minutes.[reason]")
GLOB.major_announcement.Announce(
"The crew transfer shuttle has been called. [redAlert ? "Red Alert state confirmed: Dispatching priority shuttle. " : "" ]It will arrive in [timeLeft(600)] minutes.[reason]",
new_title = "Priority Announcement",
new_sound = sound('sound/AI/cshuttle.ogg')
)
/obj/docking_port/mobile/emergency/cancel(area/signalOrigin)
if(!canRecall)
@@ -286,7 +286,11 @@
SSshuttle.emergencyLastCallLoc = signalOrigin
else
SSshuttle.emergencyLastCallLoc = null
emergency_shuttle_recalled.Announce("The emergency shuttle has been recalled.[SSshuttle.emergencyLastCallLoc ? " Recall signal traced. Results can be viewed on any communications console." : "" ]")
GLOB.major_announcement.Announce(
"The emergency shuttle has been recalled.[SSshuttle.emergencyLastCallLoc ? " Recall signal traced. Results can be viewed on any communications console." : "" ]",
new_title = "Priority Announcement",
new_sound = sound('sound/AI/eshuttle_recall.ogg')
)
/obj/docking_port/mobile/emergency/proc/is_hijacked(fullcheck = FALSE)
if(hijack_status == HIJACKED && !fullcheck) //Don't even bother if it was done via computer.
@@ -355,10 +359,17 @@
mode = SHUTTLE_DOCKED
timer = world.time
if(canRecall)
emergency_shuttle_docked.Announce("The emergency shuttle has docked with the station. You have [timeLeft(600)] minutes to board the emergency shuttle.")
GLOB.major_announcement.Announce(
"The emergency shuttle has docked with the station. You have [timeLeft(600)] minutes to board the emergency shuttle.",
new_title = "Priority Announcement",
new_sound = sound('sound/AI/eshuttle_dock.ogg')
)
else
crew_shuttle_docked.Announce("The crew transfer shuttle has docked with the station. You have [timeLeft(600)] minutes to board the crew transfer shuttle.")
GLOB.major_announcement.Announce(
"The crew transfer shuttle has docked with the station. You have [timeLeft(600)] minutes to board the crew transfer shuttle.",
new_title = "Priority Announcement",
new_sound = sound('sound/AI/cshuttle_dock.ogg')
)
/*
//Gangs only have one attempt left if the shuttle has docked with the station to prevent suffering from dominator delays
for(var/datum/gang/G in ticker.mode.gangs)
@@ -370,7 +381,10 @@
if(SHUTTLE_DOCKED)
if(time_left <= 0 && SSshuttle.emergencyNoEscape)
GLOB.priority_announcement.Announce("Hostile environment detected. Departure has been postponed indefinitely pending conflict resolution.")
GLOB.major_announcement.Announce(
"Hostile environment detected. Departure has been postponed indefinitely pending conflict resolution.",
new_title = "Priority Announcement"
)
sound_played = 0
mode = SHUTTLE_STRANDED
@@ -392,7 +406,10 @@
enterTransit()
mode = SHUTTLE_ESCAPE
timer = world.time
GLOB.priority_announcement.Announce("The Emergency Shuttle has left the station. Estimate [timeLeft(600)] minutes until the shuttle docks at Central Command.")
GLOB.major_announcement.Announce(
"The Emergency Shuttle has left the station. Estimate [timeLeft(600)] minutes until the shuttle docks at Central Command.",
new_title = "Priority Announcement"
)
for(var/mob/M in GLOB.player_list)
if(!isnewplayer(M) && !(M.client.ckey in GLOB.karma_spenders) && !M.get_preference(PREFTOGGLE_DISABLE_KARMA_REMINDER))
to_chat(M, "<i>You have not yet spent your karma for the round; was there a player worthy of receiving your reward? Look under Special Verbs tab, Award Karma.</i>")
@@ -412,7 +429,10 @@
var/destination_dock = "emergency_away"
if(is_hijacked())
destination_dock = "emergency_syndicate"
GLOB.priority_announcement.Announce("Corruption detected in shuttle navigation protocols. Please contact your supervisor.")
GLOB.major_announcement.Announce(
"Corruption detected in shuttle navigation protocols. Please contact your supervisor.",
new_title = "Priority Announcement"
)
dock_id(destination_dock)
+1 -1
View File
@@ -12,7 +12,7 @@
var/report_message = "Complete this goal."
/datum/station_goal/proc/send_report()
GLOB.priority_announcement.Announce("Priority Nanotrasen directive received. Project \"[name]\" details inbound.", "Incoming Priority Message", 'sound/AI/commandreport.ogg')
GLOB.major_announcement.Announce("Priority Nanotrasen directive received. Project \"[name]\" details inbound.", "Incoming Priority Message", 'sound/AI/commandreport.ogg')
print_command_report(get_report(), "Nanotrasen Directive [pick(GLOB.phonetic_alphabet)] \Roman[rand(1,50)]", FALSE)
on_report()
+1
View File
@@ -2,6 +2,7 @@
//Keep this sorted alphabetically
#ifdef UNIT_TESTS
#include "announcements.dm"
#include "component_tests.dm"
#include "config_sanity.dm"
#include "crafting_lists.dm"
+54
View File
@@ -0,0 +1,54 @@
/// This test exists largely to ensure that no runtimes occur when announcements
/// are made, so there are no explicit Fail calls. It either works or runtimes.
/datum/unit_test/announcements
/datum/unit_test/announcements/Run()
GLOB.major_announcement.Announce("Figments from an eldritch god are being summoned into the NSS Cyberiad from an unknown dimension. Disrupt the ritual at all costs, before the station is destroyed! Space law and SOP are suspended. The entire crew must kill cultists on sight.", "Central Command Higher Dimensional Affairs", 'sound/AI/spanomalies.ogg')
GLOB.major_announcement.Announce(
message = "We have removed all access requirements on your station's airlocks. You can thank us later!",
new_title = "Space Wizard Federation Message",
new_subtitle = "Greetings!",
new_sound = 'sound/misc/notice2.ogg'
)
var/datum/announcer/requests_console = new(config_type = /datum/announcement_configuration/requests_console)
requests_console.config.default_title = "Science announcement"
requests_console.Announce("Request console announcement")
var/datum/announcer/comms_console = new(config_type = /datum/announcement_configuration/comms_console)
comms_console.author = "Foo Bar"
comms_console.Announce("This is a test of the communications console announcement.")
var/title = "Nanotrasen Update"
var/message = "This is an admin report."
var/subtitle = "NAS Trurl Update"
GLOB.major_announcement.Announce(
message,
new_title = title,
new_subtitle = subtitle,
new_sound = 'sound/misc/notice2.ogg'
)
GLOB.event_announcement.Announce("Bioscans indicate that lizards have been breeding in the kitchen. Clear them out, before this starts to affect productivity.", "Lifesign Alert")
var/datum/announcer/ai_announcer = new(config_type = /datum/announcement_configuration/ai)
ai_announcer.author = "AI-NAME-0345"
ai_announcer.Announce("AI only get one input box so here ya go")
set_security_level(SEC_LEVEL_RED)
set_security_level(SEC_LEVEL_GAMMA)
set_security_level(SEC_LEVEL_EPSILON)
set_security_level(SEC_LEVEL_RED)
set_security_level(SEC_LEVEL_BLUE)
set_security_level(SEC_LEVEL_GREEN)
var/reason = "We're getting the fuck out of here"
var/redAlert = TRUE
GLOB.major_announcement.Announce(
message = "The emergency shuttle has been called. [redAlert ? "Red Alert state confirmed: Dispatching priority shuttle. " : "" ]It will arrive in 10 minutes.[reason]",
new_title = "Priority Announcement",
new_sound = sound('sound/AI/eshuttle_call.ogg')
)