Skip to content

Commit

Permalink
[MIRROR] Legion narrations now broadcast over telecomms
Browse files Browse the repository at this point in the history
  • Loading branch information
SierraKomodo authored and SierraHelper committed Dec 15, 2024
1 parent 2355871 commit 03906a8
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 40 deletions.
27 changes: 27 additions & 0 deletions packs/legion/_globals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
1 change: 1 addition & 0 deletions packs/legion/_pack.dm
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 9 additions & 1 deletion packs/legion/legion_beacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand All @@ -65,6 +67,8 @@
if (!length(spawn_types))
spawn_types = typesof(/mob/living/simple_animal/hostile/legion)

broadcaster = new(src)

START_PROCESSING(SSobj, src)


Expand All @@ -75,6 +79,8 @@
legion.linked_beacon = null
linked_mobs.Cut()

QDEL_NULL(broadcaster)

return ..()


Expand All @@ -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()
Expand Down
61 changes: 61 additions & 0 deletions packs/legion/legion_broadcaster.dm
Original file line number Diff line number Diff line change
@@ -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"])
81 changes: 42 additions & 39 deletions packs/legion/legion_narrate.dm
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand All @@ -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].")

0 comments on commit 03906a8

Please sign in to comment.