Internet web sounds will automatically stop lobby music. End of round music will not play if there is ongoing web sounds. (#90330)

## About The Pull Request
As the title says. Also moves lobby music to use variable instead of the
timer subsystem since it needs to track on client time rather than
server time and variable cooldowns are more relevant for this usecase.

## Why It's Good For The Game
Removes the need for admins to stop all playing sounds. Also, people
with admin sounds turned off will still be able to hear the lobby music
so their experience is improved.

Makes the web sound cooldown timings more consistent, hopefully.

## Changelog
🆑
admin: Play Internet Sound will now automatically stop lobby music and
prevent lobby music from playing at roundend whilst active.
/🆑
This commit is contained in:
Watermelon914
2025-03-30 20:45:14 +00:00
committed by GitHub
parent a834a92ed6
commit b9500efdf8
3 changed files with 31 additions and 8 deletions
+20 -3
View File
@@ -59,9 +59,6 @@
// mob cooldowns
#define COOLDOWN_YAWN_PROPAGATION "yawn_propagation_cooldown"
// admin verb cooldowns
#define COOLDOWN_INTERNET_SOUND "internet_sound"
//Shared cooldowns for actions
#define MOB_SHARED_COOLDOWN_1 (1<<0)
#define MOB_SHARED_COOLDOWN_2 (1<<1)
@@ -124,3 +121,23 @@
return; \
} \
cd_source.cd_index += (cd_increment); \
/*
* Same as the above cooldown system, but uses REALTIMEOFDAY
* Primarily only used for times that need to be tracked with the client, such as sound or animations
*/
#define CLIENT_COOLDOWN_DECLARE(cd_index) var/##cd_index = 0
#define CLIENT_STATIC_COOLDOWN_DECLARE(cd_index) var/static/##cd_index = 0
#define CLIENT_COOLDOWN_START(cd_source, cd_index, cd_time) (cd_source.cd_index = REALTIMEOFDAY + (cd_time))
//Returns true if the cooldown has run its course, false otherwise
#define CLIENT_COOLDOWN_FINISHED(cd_source, cd_index) (cd_source.cd_index <= REALTIMEOFDAY)
#define CLIENT_COOLDOWN_RESET(cd_source, cd_index) cd_source.cd_index = 0
#define CLIENT_COOLDOWN_STARTED(cd_source, cd_index) (cd_source.cd_index != 0)
#define CLIENT_COOLDOWN_TIMELEFT(cd_source, cd_index) (max(0, cd_source.cd_index - REALTIMEOFDAY))
+2 -1
View File
@@ -224,7 +224,8 @@ GLOBAL_LIST_INIT(achievements_unlocked, list())
for(var/client/C in GLOB.clients)
if(!C?.credits)
C?.RollCredits()
C?.playtitlemusic(volume_multiplier = 0.5)
if(COOLDOWN_FINISHED(GLOB, web_sound_cooldown))
C?.playtitlemusic(volume_multiplier = 0.5)
if(speed_round && was_forced != ADMIN_FORCE_END_ROUND)
C?.give_award(/datum/award/achievement/misc/speed_round, C?.mob)
HandleRandomHardcoreScore(C)
+9 -4
View File
@@ -60,6 +60,8 @@ ADMIN_VERB(play_direct_mob_sound, R_SOUND, "Play Direct Mob Sound", "Play a soun
SEND_SOUND(target, sound)
BLACKBOX_LOG_ADMIN_VERB("Play Direct Mob Sound")
GLOBAL_VAR_INIT(web_sound_cooldown, 0)
///Takes an input from either proc/play_web_sound or the request manager and runs it through yt-dlp and prompts the user before playing it to the server.
/proc/web_sound(mob/user, input, credit)
if(!check_rights(R_SOUND))
@@ -150,12 +152,15 @@ ADMIN_VERB(play_direct_mob_sound, R_SOUND, "Play Direct Mob Sound", "Play a soun
var/mob/M = m
var/client/C = M.client
if(C.prefs.read_preference(/datum/preference/numeric/volume/sound_midi))
// Stops playing lobby music and admin loaded music automatically.
SEND_SOUND(C, sound(null, channel = CHANNEL_LOBBYMUSIC))
SEND_SOUND(C, sound(null, channel = CHANNEL_ADMIN))
if(!stop_web_sounds)
C.tgui_panel?.play_music(web_sound_url, music_extra_data)
else
C.tgui_panel?.stop_music()
S_TIMER_COOLDOWN_START(SStimer, COOLDOWN_INTERNET_SOUND, duration)
CLIENT_COOLDOWN_START(GLOB, web_sound_cooldown, duration)
BLACKBOX_LOG_ADMIN_VERB("Play Internet Sound")
@@ -163,8 +168,8 @@ ADMIN_VERB_CUSTOM_EXIST_CHECK(play_web_sound)
return !!CONFIG_GET(string/invoke_youtubedl)
ADMIN_VERB(play_web_sound, R_SOUND, "Play Internet Sound", "Play a given internet sound to all players.", ADMIN_CATEGORY_FUN)
if(S_TIMER_COOLDOWN_TIMELEFT(SStimer, COOLDOWN_INTERNET_SOUND))
if(tgui_alert(user, "Someone else is already playing an Internet sound! It has [DisplayTimeText(S_TIMER_COOLDOWN_TIMELEFT(SStimer, COOLDOWN_INTERNET_SOUND), 1)] remaining. \
if(!CLIENT_COOLDOWN_FINISHED(GLOB, web_sound_cooldown))
if(tgui_alert(user, "Someone else is already playing an Internet sound! It has [DisplayTimeText(CLIENT_COOLDOWN_TIMELEFT(GLOB, web_sound_cooldown), 1)] remaining. \
Would you like to override?", "Musicalis Interruptus", list("No","Yes")) != "Yes")
return
@@ -199,7 +204,7 @@ ADMIN_VERB(stop_sounds, R_NONE, "Stop All Playing Sounds", "Stops all playing so
var/client/player_client = player.client
player_client?.tgui_panel?.stop_music()
S_TIMER_COOLDOWN_RESET(SStimer, COOLDOWN_INTERNET_SOUND)
CLIENT_COOLDOWN_RESET(GLOB, web_sound_cooldown)
BLACKBOX_LOG_ADMIN_VERB("Stop All Playing Sounds")
//world/proc/shelleo