Skip to content

Commit

Permalink
[MIRROR] Fixes deaf mobs hearing ship/area ambience (#28461)
Browse files Browse the repository at this point in the history
* Fixes deaf mobs hearing ship/area ambience (#84207)

Fixes #65618

🆑 ShizCalev
fix: Deafened mobs will no longer hear the station's ambient sounds.
fix: Fixed ambient sounds resetting their loop when entering different
bodies (ie admin ghosting, being moved to other mobs, ect.)
/🆑

* Fixes deaf mobs hearing ship/area ambience

---------

Co-authored-by: Afevis <[email protected]>
  • Loading branch information
2 people authored and StrangeWeirdKitten committed Jul 1, 2024
1 parent f8d9b76 commit 92f2365
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
3 changes: 3 additions & 0 deletions code/controllers/subsystem/ambience.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ SUBSYSTEM_DEF(ambience)
client_old_areas -= client_iterator
continue

if(!client_mob.can_hear()) //WHAT? I CAN'T HEAR YOU
continue

//Check to see if the client-mob is in a valid area
var/area/current_area = get_area(client_mob)
if(!current_area) //Something's gone horribly wrong
Expand Down
17 changes: 15 additions & 2 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -552,13 +552,26 @@ GLOBAL_LIST_EMPTY(teleportlocs)

///Tries to play looping ambience to the mobs.
/mob/proc/refresh_looping_ambience()
if(!client) //if a tree falls in the woods...
return
var/area/my_area = get_area(src)
var/sound_to_use = my_area.ambient_buzz

if(!(client?.prefs.read_preference(/datum/preference/toggle/sound_ship_ambience)) || !my_area.ambient_buzz)
if(!sound_to_use || !(client.prefs.read_preference(/datum/preference/toggle/sound_ship_ambience)))
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
client.current_ambient_sound = null
return

SEND_SOUND(src, sound(my_area.ambient_buzz, repeat = 1, wait = 0, volume = my_area.ambient_buzz_vol, channel = CHANNEL_BUZZ))
if(!can_hear())
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
client.current_ambient_sound = null
return

if(sound_to_use == client.current_ambient_sound)
return //don't reset current loops.

client.current_ambient_sound = sound_to_use
SEND_SOUND(src, sound(sound_to_use, repeat = 1, wait = 0, volume = my_area.ambient_buzz_vol, channel = CHANNEL_BUZZ))

/**
* Called when an atom exits an area
Expand Down
3 changes: 3 additions & 0 deletions code/modules/client/client_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,6 @@

/// Loot panel for the client
var/datum/lootpanel/loot_panel

///Which ambient sound this client is currently being provided.
var/current_ambient_sound
14 changes: 14 additions & 0 deletions code/modules/mob/living/init_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), PROC_REF(on_restrained_trait_gain))
RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_RESTRAINED), PROC_REF(on_restrained_trait_loss))

RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_DEAF), PROC_REF(on_hearing_loss))
RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_DEAF), PROC_REF(on_hearing_regain))

RegisterSignals(src, list(
SIGNAL_ADDTRAIT(TRAIT_CRITICAL_CONDITION),
SIGNAL_REMOVETRAIT(TRAIT_CRITICAL_CONDITION),
Expand Down Expand Up @@ -272,3 +275,14 @@
/mob/living/proc/undense_changed(datum/source)
SIGNAL_HANDLER
update_density()

///Called when [TRAIT_DEAF] is added to the mob.
/mob/living/proc/on_hearing_loss()
SIGNAL_HANDLER
refresh_looping_ambience()
stop_sound_channel(CHANNEL_AMBIENCE)

///Called when [TRAIT_DEAF] is added to the mob.
/mob/living/proc/on_hearing_regain()
SIGNAL_HANDLER
refresh_looping_ambience()
4 changes: 4 additions & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,10 @@ GLOBAL_LIST_EMPTY(fire_appearances)
REMOVE_TRAIT(src, TRAIT_CRITICAL_CONDITION, STAT_TRAIT)
remove_from_alive_mob_list()
add_to_dead_mob_list()
if(!can_hear())
stop_sound_channel(CHANNEL_AMBIENCE)
refresh_looping_ambience()



///Reports the event of the change in value of the buckled variable.
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
update_client_colour()
update_mouse_pointer()
refresh_looping_ambience()
if(!can_hear())
stop_sound_channel(CHANNEL_AMBIENCE)

if(client)
if(client.view_size)
Expand Down

0 comments on commit 92f2365

Please sign in to comment.