Skip to content

Commit

Permalink
Adds squad TTS
Browse files Browse the repository at this point in the history
  • Loading branch information
breadhunt committed May 31, 2024
1 parent 0be9485 commit fd489d5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
22 changes: 21 additions & 1 deletion code/game/objects/items/radio/headset.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Defines for TTS modes.
#define HEADSET_TTS_NONE 0
#define HEADSET_TTS_SL_ONLY 1
#define HEADSET_TTS_ALL 2

// Used for translating channels to tokens on examination
GLOBAL_LIST_INIT(channel_tokens, list(
RADIO_CHANNEL_REQUISITIONS = RADIO_TOKEN_REQUISITIONS,
Expand Down Expand Up @@ -26,7 +31,8 @@ GLOBAL_LIST_INIT(channel_tokens, list(

equip_slot_flags = ITEM_SLOT_EARS
var/obj/item/encryptionkey/keyslot2 = null

/// Current squad TTS mode the headset is switched to; defaults to no radio TTS
var/squad_tts_mode = HEADSET_TTS_NONE

/obj/item/radio/headset/Initialize(mapload)
if(keyslot)
Expand Down Expand Up @@ -156,6 +162,20 @@ GLOBAL_LIST_INIT(channel_tokens, list(
channels[RADIO_CHANNEL_REQUISITIONS] = !channels[RADIO_CHANNEL_REQUISITIONS]
balloon_alert(user, "toggles supply comms [channels[RADIO_CHANNEL_REQUISITIONS] ? "on" : "off"].")

//Toggles TTS mode. If TTS is enabled, we will play TTS for any radio messages passed through the headset.
/obj/item/radio/headset/RightClick(mob/user)
. = ..()
switch(squad_tts_mode)
if(HEADSET_TTS_NONE)
user.balloon_alert(user, "You switch the TTS mode to \"SL Only\"")
squad_tts_mode = HEADSET_TTS_SL_ONLY
if(HEADSET_TTS_SL_ONLY)
user.balloon_alert(user, "You switch the TTS mode to \"All\"")
squad_tts_mode = HEADSET_TTS_ALL
if(HEADSET_TTS_ALL)
user.balloon_alert(user, "You switch the TTS mode to \"None\"")
squad_tts_mode = HEADSET_TTS_NONE

/obj/item/radio/headset/vendor_equip(mob/user)
..()
return user.equip_to_appropriate_slot(src)
Expand Down
14 changes: 14 additions & 0 deletions code/game/objects/machinery/telecomms/broadcasting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@
continue
hearer.Hear(rendered, virt, language, message, frequency, spans)


//Now we can handle radio TTS for squads

var/mob/living/carbon/human/speaker = virt.source
if(speaker?.assigned_squad && speaker.voice && !(speaker.client?.prefs.muted & MUTE_TTS) && !is_banned_from(speaker.ckey, "TTS"))
var/headset_target = HEADSET_TTS_ALL
if(speaker.assigned_squad.squad_leader == speaker)
headset_target = HEADSET_TTS_SL_ONLY //Lower the bar if the speaker is the active aSL

for(var/mob/living/carbon/human/potential_squadmate in receive)
var/obj/item/radio/headset/radio = potential_squadmate.wear_ear
if(speaker.assigned_squad != potential_squadmate.assigned_squad && radio.squad_tts_mode >= headset_target )
INVOKE_ASYNC(SStts, TYPE_PROC_REF(/datum/controller/subsystem/tts, queue_tts_message), potential_squadmate, html_decode(message), language, speaker.voice, potential_squadmate.voice_filter, local = TRUE, pitch = speaker.pitch, special_filters = TTS_FILTER_RADIO)

var/spans_part = ""
if(length(spans))
spans_part = "(spans:"
Expand Down

0 comments on commit fd489d5

Please sign in to comment.