Files
CabinetOnFire 5a68cb5ff3 Implements "Sound Tokens", a way to have spatial audio. And implements it on looping sounds. (And also some tweaks to fall-off) (#96018)
## About The Pull Request

This pull request implements sound tokens, based on the implementation
by Kapu at https://github.com/DaedalusDock/daedalusdock/pull/1379

I've taken that implementation and extended it to looping_sounds,
allowing us to have spatial audio that updates much more nicely when
players walk closer. This system also lets players that walk into range
after the sound has started playing to also hear the sound, before if
you missed the sound, you would never hear it. This is particularly
noticeable with long sounds (Which is lame!)

**VIDEOS**:
griddle:
https://streamable.com/v7ayqm

engineering / SM:
https://streamable.com/5lr1oj


The system essentially sends the sound to every client, and changes the
volume based on distance to the sound. There are some performance
concerns here, so we will need to testmerge this and see how impactful
it is. It is in a subsystem though, so there is some limit to the amount
of cpu it will use. Do keep this in mind when watching the videos; it
will probably not be AS responsive as in there.

I've also changed how intense our fall-off is, making sounds lose their
volume slower. Before taking one step away from a 50 volume sound would
make it 18 volume, this is way too big of a drop and it became
particularly jarring with the changes in this PR.

Some sounds might be too long range now, but I think we should just
reduce the max range of those sounds as we were basically playing them
at <5 volume after 10 tiles, at which point we should maybe just reduce
the range a bit since at those volumes theyre really not audible.

**OLD FALLOFF;** note the MASSIVE drop from 1 tile to 2 tiles
<img width="1416" height="897" alt="image"
src="https://github.com/user-attachments/assets/805b270e-6aa5-4e84-868e-39585966f0a4"
/>

**NEW FALLOFF:**
<img width="1418" height="905" alt="image"
src="https://github.com/user-attachments/assets/eabbd592-ae9c-4690-8945-fbd0b4f6614f"
/>

Also tweaked a few looping sounds (deep-fryer in particular got some
clean-up, as its mid-length was way too short for the sounds and it had
a double-definition)


## Why It's Good For The Game

This system allows us to have a richer audio experience, I really don't
like how choppy our looping sounds are, especially in some areas where
you hear them a lot (kitchen and engineering)



## Changelog

🆑 CabinetOnFire, Kapu
sound: Changed our falloff to be less intense, as it was punching volume
down way too fast.
refactor: Implements a system for spatial audio to improve our looping
sounds
/🆑

---------

Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
2026-06-05 16:24:25 -07:00

130 lines
4.4 KiB
Plaintext

///Adds the mob reference to the list and directory of all mobs. Called on Initialize().
/mob/proc/add_to_mob_list()
GLOB.mob_list |= src
///Removes the mob reference from the list and directory of all mobs. Called on Destroy().
/mob/proc/remove_from_mob_list()
GLOB.mob_list -= src
///Adds the mob reference to the list of all mobs alive. If mob is cliented, it adds it to the list of all living player-mobs.
/mob/proc/add_to_alive_mob_list()
if(QDELETED(src))
return
GLOB.alive_mob_list |= src
if(client)
add_to_current_living_players()
///Removes the mob reference from the list of all mobs alive. If mob is cliented, it removes it from the list of all living player-mobs.
/mob/proc/remove_from_alive_mob_list()
GLOB.alive_mob_list -= src
if(client)
remove_from_current_living_players()
///Adds a mob reference to the list of all suicided mobs
/mob/proc/add_to_mob_suicide_list()
GLOB.suicided_mob_list += src
///Removes a mob references from the list of all suicided mobs
/mob/proc/remove_from_mob_suicide_list()
GLOB.suicided_mob_list -= src
///Adds the mob reference to the list of all the dead mobs. If mob is cliented, it adds it to the list of all dead player-mobs.
/mob/proc/add_to_dead_mob_list()
if(QDELETED(src))
return
GLOB.dead_mob_list |= src
if(client)
add_to_current_dead_players()
///Remvoes the mob reference from list of all the dead mobs. If mob is cliented, it adds it to the list of all dead player-mobs.
/mob/proc/remove_from_dead_mob_list()
GLOB.dead_mob_list -= src
if(client)
remove_from_current_dead_players()
///Adds the cliented mob reference to the list of all player-mobs, besides to either the of dead or alive player-mob lists, as appropriate. Called on Login().
/mob/proc/add_to_player_list()
SHOULD_CALL_PARENT(TRUE)
GLOB.player_list |= src
if(stat == DEAD)
add_to_current_dead_players()
else
add_to_current_living_players()
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_PLAYER_LOGIN, src)
///Removes the mob reference from the list of all player-mobs, besides from either the of dead or alive player-mob lists, as appropriate. Called on Logout().
/mob/proc/remove_from_player_list()
SHOULD_CALL_PARENT(TRUE)
GLOB.player_list -= src
GLOB.keyloop_list -= src
if(stat == DEAD)
remove_from_current_dead_players()
else
remove_from_current_living_players()
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_PLAYER_LOGOUT, src)
///Adds the cliented mob reference to either the list of dead player-mobs or to the list of observers, depending on how they joined the game.
/mob/proc/add_to_current_dead_players()
GLOB.dead_player_list |= src
if(!SSlag_switch.measures[DISABLE_DEAD_KEYLOOP] || client.holder)
GLOB.keyloop_list |= src
else
GLOB.keyloop_list -= src
/mob/dead/observer/add_to_current_dead_players()
if(!SSlag_switch.measures[DISABLE_DEAD_KEYLOOP] || client?.holder) // observers can move
GLOB.keyloop_list |= src
if(started_as_observer)
GLOB.current_observers_list |= src
return
else
GLOB.dead_player_list |= src
/mob/dead/new_player/add_to_current_dead_players()
return
///Removes the mob reference from either the list of dead player-mobs or from the list of observers, depending on how they joined the game.
/mob/proc/remove_from_current_dead_players()
GLOB.dead_player_list -= src
/mob/dead/observer/remove_from_current_dead_players()
if(started_as_observer)
GLOB.current_observers_list -= src
return
return ..()
///Adds the cliented mob reference to the list of living player-mobs. If the mob is an antag, it adds it to the list of living antag player-mobs.
/mob/proc/add_to_current_living_players()
GLOB.alive_player_list |= src
GLOB.keyloop_list |= src
if(is_antag(NONE))
add_to_current_living_antags()
///Removes the mob reference from the list of living player-mobs. If the mob is an antag, it removes it from the list of living antag player-mobs.
/mob/proc/remove_from_current_living_players()
GLOB.alive_player_list -= src
if(is_antag(NONE))
remove_from_current_living_antags()
///Adds the cliented mob reference to the list of living antag player-mobs.
/mob/proc/add_to_current_living_antags()
if (length(mind.antag_datums) == 0)
return
for (var/datum/antagonist/antagonist in mind.antag_datums)
if (antagonist.antag_flags & ANTAG_SKIP_GLOBAL_LIST)
continue
GLOB.current_living_antags |= src
return
///Removes the mob reference from the list of living antag player-mobs.
/mob/proc/remove_from_current_living_antags()
GLOB.current_living_antags -= src