From 03906a8ded98b0d0624e8bc1f635765ffc408819 Mon Sep 17 00:00:00 2001 From: SierraKomodo <11140088+SierraKomodo@users.noreply.github.com> Date: Sun, 15 Dec 2024 00:55:05 +0000 Subject: [PATCH] [MIRROR] Legion narrations now broadcast over telecomms --- packs/legion/_globals.dm | 27 ++++++++++ packs/legion/_pack.dm | 1 + packs/legion/legion_beacon.dm | 10 +++- packs/legion/legion_broadcaster.dm | 61 ++++++++++++++++++++++ packs/legion/legion_narrate.dm | 81 ++++++++++++++++-------------- 5 files changed, 140 insertions(+), 40 deletions(-) create mode 100644 packs/legion/legion_broadcaster.dm diff --git a/packs/legion/_globals.dm b/packs/legion/_globals.dm index 4440c8c0af28d..f21cd7be4af0f 100644 --- a/packs/legion/_globals.dm +++ b/packs/legion/_globals.dm @@ -3,3 +3,30 @@ GLOBAL_VAR_CONST(legion_warp_sound, 'packs/legion/sounds/legion_arrive.ogg') GLOBAL_LIST_INIT(legion_voices_sounds, list(\ 'packs/legion/sounds/legion_voices1.ogg'\ )) + + +/// List of strings. Pool of generic messages to use for legion broadcast and narration events. +GLOBAL_LIST_INIT(legion_narrations, list(\ + "A cacaphony of voices suddenly floods you. You can't make anything out.",\ + "The voices. There's so many voices. They're all crying out in endless agony.",\ + "You hear a thousand voices all at once, each trying to scream over the rest. The sound drowns itself out.",\ + "A tidal force of voices shakes your very being, each one shifting in volume and pitch to such degree that it's nothing but an overbearing white noise.",\ + "A wave of voices coalesce and your ears ring as if struck by a hammer.",\ + "A flood of voices crash against eachother with their pleas, their cries and their dying breathes in never-ending throes of noise, sometimes they blend together into nothingness-- and then they come back, stronger and more desperate.",\ + "A turgid symphony assaults you. Fleshy primordial noises are all you can make out. This place is where one abandons their dreams."\ +)) + + +/// List of strings. Pool of generic individual voices that can be heard for legion broadcast and narration events. +GLOBAL_LIST_INIT(legion_last_words_generic, list(\ + "I don't want to die!",\ + "No, get away!",\ + "I give up. Just do it already.",\ + "I'm so scared...",\ + "Help me!",\ + "It's so hot!",\ +)) + + +/// List of strings. Pool of individual voices from harvested player characters from this round to be used for legion broadcast and narration events. Format should be `"Character Name" => "Last Message/Thought"` +GLOBAL_LIST_INIT(legion_last_words_player, list(list("Urist McTestFace", "I ded plz restart"))) diff --git a/packs/legion/_pack.dm b/packs/legion/_pack.dm index bfd0a1ed4e4ee..06cb4696a9944 100644 --- a/packs/legion/_pack.dm +++ b/packs/legion/_pack.dm @@ -1,5 +1,6 @@ #include "_globals.dm" #include "legion_beacon.dm" +#include "legion_broadcaster.dm" #include "legion_hivebot.dm" #include "legion_mob.dm" #include "legion_narrate.dm" diff --git a/packs/legion/legion_beacon.dm b/packs/legion/legion_beacon.dm index 66eb852b6a822..7d9b98c3790dd 100644 --- a/packs/legion/legion_beacon.dm +++ b/packs/legion/legion_beacon.dm @@ -54,6 +54,8 @@ /// The beacon is currently active. var/const/BEACON_STATE_ON = 1 + var/mob/legion_broadcaster/broadcaster + /obj/structure/legion/beacon/Initialize(mapload) . = ..() @@ -65,6 +67,8 @@ if (!length(spawn_types)) spawn_types = typesof(/mob/living/simple_animal/hostile/legion) + broadcaster = new(src) + START_PROCESSING(SSobj, src) @@ -75,6 +79,8 @@ legion.linked_beacon = null linked_mobs.Cut() + QDEL_NULL(broadcaster) + return ..() @@ -95,7 +101,9 @@ if (world.time >= last_broadcast_time + broadcast_rate && rand(1, 100) <= broadcast_chance) last_broadcast_time = world.time - show_legion_messages(get_z(src)) + var/list/message_data = pick_legion_message() + show_legion_messages(get_z(src), message_data["full"]) + broadcaster.legion_broadcast(message_data["origin"], message_data["contents"]) /obj/structure/legion/beacon/proc/set_active() diff --git a/packs/legion/legion_broadcaster.dm b/packs/legion/legion_broadcaster.dm new file mode 100644 index 0000000000000..898bade7f269e --- /dev/null +++ b/packs/legion/legion_broadcaster.dm @@ -0,0 +1,61 @@ +// Because telecoms code is dumb and hardcoded to require an origin mob and radio. This will just exist inside things that are broadcasting legion messages across a radio net. +/mob/legion_broadcaster + name = "legion" + + /// Broadcaster radio this mob uses. Created during init. + var/obj/item/device/radio/broadcaster + + /// List of frequencies this device will broadcast on. + var/list/frequencies = list() + + /// List of default frequencies the device will use if no tcomms servers are found. + var/static/list/default_frequencies = list( + PUB_FREQ, + HAIL_FREQ + ) + + +/mob/legion_broadcaster/Initialize() + . = ..() + broadcaster = new(src) + broadcaster.SetName("legion broadcaster") + broadcaster.power_usage = FALSE + broadcaster.listening = FALSE + broadcaster.on = TRUE + resync_frequencies() + + +/mob/legion_broadcaster/Destroy() + QDEL_NULL(broadcaster) + frequencies.Cut() + return ..() + + +/mob/legion_broadcaster/SetName(new_name) + name = new_name + real_name = new_name + + +/mob/legion_broadcaster/proc/resync_frequencies() + frequencies.Cut() + + for (var/obj/machinery/telecomms/server in telecomms_list) + if (!AreConnectedZLevels(get_z(src), get_z(server))) + continue + frequencies |= server.freq_listening + + if (!length(frequencies)) + frequencies = default_frequencies + + +/mob/legion_broadcaster/proc/legion_broadcast(origin, message) + SetName(origin) + for (var/frequency in frequencies) + broadcaster.set_frequency(frequency) + do_message(message) + SetName("") + + +/mob/legion_broadcaster/proc/do_message(message) + set waitfor = FALSE + broadcaster.talk_into(src, message, null, null, all_languages["Noise"]) diff --git a/packs/legion/legion_narrate.dm b/packs/legion/legion_narrate.dm index 1c247efd0759c..446f5f48702a6 100644 --- a/packs/legion/legion_narrate.dm +++ b/packs/legion/legion_narrate.dm @@ -1,27 +1,3 @@ -GLOBAL_LIST_INIT(legion_narrations, list(\ - "A cacaphony of voices suddenly invades your mind. You can't make anything out.",\ - "The voices. There's so many voices in your head. They're all crying out in endless agony.",\ - "You hear a thousand voices all at once, each trying to scream over the rest. The sound drowns itself out.",\ - "A tidal force of voices shakes your very being, each one shifting in volume and pitch to such degree that it's nothing but an overbearing white noise.",\ - "A wave of voices coalesce and your ears ring as if struck by a hammer.",\ - "A flood of voices crash against your head with their pleas, their cries and their dying breathes in never-ending throes of noise, sometimes they blend together into nothingness-- and then they come back, stronger and more desperate.",\ - "A turgid symphony assaults your mind. Fleshy primordial noises are all you can make out. This place is where one abandons their dreams."\ -)) - - -GLOBAL_LIST_INIT(legion_last_words_generic, list(\ - "I don't want to die!",\ - "No, get away!",\ - "I give up. Just do it already.",\ - "I'm so scared...",\ - "Help me!",\ - "It's so hot!",\ -)) - - -GLOBAL_LIST_EMPTY(legion_last_words_player) - - /** * Adds a player's last words to the legion's pool. `origin` can be a living mob, a mind datum, or a brain. */ @@ -51,14 +27,45 @@ GLOBAL_LIST_EMPTY(legion_last_words_player) if (!origin_name || !message) return - GLOB.legion_last_words_player[origin_name] = message + GLOB.legion_last_words_player += list(origin_name, message) log_debug("Added [origin_name]'s last words of '[message]' to the legion message pool.") +/** + * Randomly chooses a legion message to broadcast. + * + * Returns list containing `"full"`, `"origin"`, and `"contents"` keys. + */ +/proc/pick_legion_message() + var/message + var/message_origin = "" + var/message_contents + // Choose a message to display + if (rand(0, 100) <= 20) + if (!length(GLOB.legion_last_words_player) || rand(0, 1)) + message_contents = "A voice rises above the chorus, \"[pick(GLOB.legion_last_words_generic)]\"" + message = message_contents + else + var/list/chosen = pick(GLOB.legion_last_words_player) + message_origin = chosen[1] + message_contents = chosen[2] + message = "[message_origin]'s voice rises above the chorus, \"[message_contents]\"" + message_contents = "cries out above the chorus, \"[message_contents]\"" + else + message_contents = pick(GLOB.legion_narrations) + message = message_contents + + return list( + "full" = message, + "origin" = message_origin, + "contents" = message_contents + ) + + /** * Displays a randomly chosen legion message to synthetic mobs in z-levels connected to the given level(s) */ -/proc/show_legion_messages(list/z_levels = list()) +/proc/show_legion_messages(list/z_levels = list(), message) if (!islist(z_levels)) z_levels = list(z_levels) if (!length(z_levels)) @@ -70,18 +77,6 @@ GLOBAL_LIST_EMPTY(legion_last_words_player) continue connected_z_levels |= GetConnectedZlevels(z_level) - var/message - // Choose a message to display - if (rand(0, 100) <= 20) - if (!length(GLOB.legion_last_words_player) || rand(0, 1)) - message = "A voice rises above the chorus, \"[pick(GLOB.legion_last_words_generic)]\"" - else - var/message_origin = pick(GLOB.legion_last_words_player) - var/message_contents = GLOB.legion_last_words_player[message_origin] - message = "[message_origin]'s voice rises above the chorus, \"[message_contents]\"" - else - message = pick(GLOB.legion_narrations) - var/count = 0 var/sound_to_play = pick(GLOB.legion_voices_sounds) for (var/mob/player in GLOB.player_list) @@ -108,5 +103,13 @@ GLOBAL_LIST_EMPTY(legion_last_words_player) if (!z_level) return - show_legion_messages(z_level) + var/list/message_data = pick_legion_message() + + show_legion_messages(z_level, message_data["full"]) + + var/mob/legion_broadcaster/broadcaster = new(get_turf(usr)) + broadcaster.z = z_level + broadcaster.legion_broadcast(message_data["origin"], SPAN_LEGION(message_data["contents"])) + QDEL_NULL(broadcaster) + log_and_message_staff(" - Manual Legion Narrate to z-levels connected to [z_level].")