From 23bdb9c387844a3b3d782ab5ca63f7113b72b1d0 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Sun, 5 Jan 2025 22:17:52 -0600 Subject: [PATCH] Radio crackle QoL (#3902) ## About The Pull Request Makes radio crackle a lot less spammy. Basically, first of all re-adds the toggle to disable it, second of all, simplifies the code into one place, and third of all, makes it so that messages (besides your own) only crackle when another message hasn't been sent in 5 seconds (subject to change). As a ~~side effect~~ totally intended feature, people using radios near you will instead play the much less intrusive radio message receive sound instead of the noisy walkie-talkie sound. ## Why It's Good For The Game Making it less repetitive and focusing it down to when it's actually needed is good for everyone. ## Changelog :cl: add: A pref to totally disable radio crackle sounds. tweak: Radio crackle will only play if it's been 5 seconds since the last radio message the mob has heard. tweak: The radio crackle will only play once a message has been successfully transmitted. /:cl: --- code/__DEFINES/flags.dm | 2 -- code/__DEFINES/preferences.dm | 7 ++++--- code/game/machinery/telecomms/broadcasting.dm | 4 ---- code/game/objects/items/devices/radio/radio.dm | 9 +-------- code/modules/client/preferences_savefile.dm | 17 ++++++++++++++++- code/modules/client/preferences_toggles.dm | 3 +-- code/modules/mob/living/living_defines.dm | 3 +++ code/modules/mob/living/living_say.dm | 13 ++++++++++++- 8 files changed, 37 insertions(+), 21 deletions(-) diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index b97972be8a4c..b367c514232e 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -46,8 +46,6 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define SHOW_BEHIND_LARGE_ICONS_1 (1<<12) /// Should we use the initial icon for display? Mostly used by overlay only objects #define HTML_USE_INITAL_ICON_1 (1<<20) -// Whether or not this atom is storing contents for a disassociated storage object -#define HAS_DISASSOCIATED_STORAGE_1 (1<<24) // Update flags for [/atom/proc/update_appearance] /// Update the atom's name diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index 4f225d304313..4c076b0550a4 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -21,10 +21,11 @@ #define DEADMIN_POSITION_SECURITY (1<<18) #define DEADMIN_POSITION_SILICON (1<<19) #define SOUND_ENDOFROUND (1<<20) -#define SPLIT_ADMIN_TABS (1<<22) -#define FAST_MC_REFRESH (1<<23) +#define SPLIT_ADMIN_TABS (1<<21) +#define FAST_MC_REFRESH (1<<22) +#define SOUND_RADIO (1<<23) -#define TOGGLES_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|SOUND_ENDOFROUND|MEMBER_PUBLIC|INTENT_STYLE|MIDROUND_ANTAG|SOUND_INSTRUMENTS|SOUND_SHIP_AMBIENCE|SOUND_PRAYERS|SOUND_ANNOUNCEMENTS) +#define TOGGLES_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|SOUND_ENDOFROUND|SOUND_RADIO|MEMBER_PUBLIC|INTENT_STYLE|MIDROUND_ANTAG|SOUND_INSTRUMENTS|SOUND_SHIP_AMBIENCE|SOUND_PRAYERS|SOUND_ANNOUNCEMENTS) //Chat toggles #define CHAT_OOC (1<<0) diff --git a/code/game/machinery/telecomms/broadcasting.dm b/code/game/machinery/telecomms/broadcasting.dm index 9c3af38b0b44..1927c3963ca6 100644 --- a/code/game/machinery/telecomms/broadcasting.dm +++ b/code/game/machinery/telecomms/broadcasting.dm @@ -167,12 +167,8 @@ if(R.independent && R.can_receive(frequency, map_zones)) radios += R - //WS edit begin - Radio chatter #434 // Next, we'll have each radio play a small sound effect except for the one that broadcasted it. for(var/obj/item/radio/radio in radios) - if(radio.last_chatter_time + 1 SECONDS < world.time && source != radio) - playsound(radio, "sound/effects/radio_chatter.ogg", 20, FALSE) - radio.last_chatter_time = world.time if(radio.log) var/name = data["name"] var/list/log_details = list() diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 822901de7e27..26b64330bba0 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -28,9 +28,6 @@ var/emped = 0 ///It can be used for hotkeys var/headset = FALSE - ///The time since we last played a radio chatter sound. - var/last_chatter_time - ///Whether the radio will transmit dialogue it hears nearby. var/broadcasting = FALSE ///Whether the radio is currently receiving. @@ -274,20 +271,16 @@ var/datum/signal/subspace/vocal/signal = new(src, freq, speaker, language, message, spans, message_mods) // Independent radios, on the CentCom frequency, reach all independent radios - if (independent && (freq == FREQ_CENTCOM || freq == FREQ_WIDEBAND)) //WS Edit - SolGov Rep + if (independent && (freq == FREQ_CENTCOM || freq == FREQ_WIDEBAND)) signal.data["compression"] = 0 signal.transmission_method = TRANSMISSION_SUPERSPACE signal.map_zones = list(0) // reaches all Z-levels signal.broadcast() - playsound(src, "sound/effects/walkietalkie.ogg", 20, FALSE) //WS Edit - Radio chatter return // All radios make an attempt to use the subspace system first signal.send_to_receivers() - //At this point the signal was transmitted so play a sound //WS Edit - Radio chatter - playsound(src, "sound/effects/walkietalkie.ogg", 20, FALSE) //WS Edit - Radio chatter - // If the radio is subspace-only, that's all it can do if (subspace_transmission) return diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 7d9aae456185..f5c4dff3e637 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -5,7 +5,7 @@ // You do not need to raise this if you are adding new values that have sane defaults. // Only raise this value when changing the meaning/format/name/layout of an existing value // where you would want the updater procs below to run -#define SAVEFILE_VERSION_MAX 41 +#define SAVEFILE_VERSION_MAX 42 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn @@ -76,9 +76,24 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if(current_version < 38) outline_enabled = TRUE outline_color = COLOR_BLUE_GRAY + if (current_version < 40) LAZYADD(key_bindings["Space"], "hold_throw_mode") + if(current_version < 42) + //The toggles defines were moved down one bit + if(toggles & FAST_MC_REFRESH) + toggles |= SPLIT_ADMIN_TABS + else + toggles &= ~SPLIT_ADMIN_TABS + + if(toggles & SOUND_RADIO) + toggles |= FAST_MC_REFRESH + else + toggles &= ~FAST_MC_REFRESH + + toggles |= SOUND_RADIO + /datum/preferences/proc/update_character(current_version, savefile/S) if(current_version < 39) var/species_id diff --git a/code/modules/client/preferences_toggles.dm b/code/modules/client/preferences_toggles.dm index b40e1702652e..13f56a90a63a 100644 --- a/code/modules/client/preferences_toggles.dm +++ b/code/modules/client/preferences_toggles.dm @@ -248,7 +248,7 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, toggle_announcement_sound)() /datum/verbs/menu/Settings/Sound/toggle_announcement_sound/Get_checked(client/C) return C.prefs.toggles & SOUND_ANNOUNCEMENTS -/* READD THIS WHEN YOU FIX RADIO CHATTER +//Readded, now that radio chatter is fixed. TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, toggle_radio_sound)() set name = "Hear/Silence Radio Chatter" set category = "Preferences" @@ -260,7 +260,6 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, toggle_radio_sound)() /datum/verbs/menu/Settings/Sound/toggle_radio_sound/Get_checked(client/C) return C.prefs.toggles & SOUND_RADIO -*/ /datum/verbs/menu/Settings/Sound/verb/stop_client_sounds() set name = "Stop Sounds" diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index 734ffac08595..223e5639548f 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -182,3 +182,6 @@ var/body_pixel_x_offset = 0 ///Default Y offset var/body_pixel_y_offset = 0 + + /// World time of the last time this mob heard a radio crackle, to reduce spamminess. + COOLDOWN_DECLARE(radio_crackle_cooldown) diff --git a/code/modules/mob/living/living_say.dm b/code/modules/mob/living/living_say.dm index abe8b52c6c1e..81647642fb25 100644 --- a/code/modules/mob/living/living_say.dm +++ b/code/modules/mob/living/living_say.dm @@ -245,7 +245,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list( deaf_type = 2 // Since you should be able to hear yourself without looking // Create map text prior to modifying message for goonchat - if (client?.prefs.chat_on_map && !(stat == UNCONSCIOUS || stat == HARD_CRIT) && (client.prefs.see_chat_non_mob || ismob(speaker)) && can_hear()) + if(client?.prefs.chat_on_map && !(stat == UNCONSCIOUS || stat == HARD_CRIT) && (client.prefs.see_chat_non_mob || ismob(speaker)) && can_hear()) if(message_mods[MODE_WHISPER] == MODE_WHISPER_CRIT) play_screen_text("message") if(message_mods[MODE_CUSTOM_SAY_ERASE_INPUT]) @@ -253,6 +253,17 @@ GLOBAL_LIST_INIT(department_radio_keys, list( else create_chat_message(speaker, message_language, raw_message, spans) + if(radio_freq && (client?.prefs.toggles & SOUND_RADIO)) + //All calls to hear that include radio_freq will be from radios, so we can assume that the speaker is a virtualspeaker + var/atom/movable/virtualspeaker/virt = speaker + //Play the walkie sound if this mob is speaking, and don't apply cooldown + if(virt.source == src) + playsound_local(get_turf(speaker), "sound/effects/walkietalkie.ogg", 20, FALSE) + else if(COOLDOWN_FINISHED(src, radio_crackle_cooldown)) + playsound_local(get_turf(speaker), "sound/effects/radio_chatter.ogg", 20, FALSE) + //Always start it so that it only crackles when there hasn't been a message in a while + COOLDOWN_START(src, radio_crackle_cooldown, 5 SECONDS) + // Recompose message for AI hrefs, language incomprehension. message = compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mods)