makes jukeboxes deal hearing loss when too loud, makes being deaf temporarily mute jukebox

This commit is contained in:
deathride58
2022-05-21 19:23:10 -04:00
parent a920bd4038
commit 5d648fcf6a
3 changed files with 34 additions and 19 deletions
+10 -5
View File
@@ -118,23 +118,28 @@ SUBSYSTEM_DEF(jukeboxes)
var/list/hearerscache = hearers(7, jukebox)
var/targetfalloff = jukeinfo[JUKE_FALLOFF]
var/mixes = ((targetfalloff*250)-750)
var/inrange
//Workaround for a BYOND bug. (SOUND_MUTE | SOUND_UPDATE) no longer works. at all. it doesn't mute the sound, and it doesn't allow the sound to update. We have no idea when this broke.
//"What happens if you just set the volume to 0?" this never worked. When a sound's sent with a volume of 0, dreamseeker simply does nothing.
//So instead, we're gonna mute the dry and wet channels while still keeping the sound exactly the same. TECHNICALLY this works. Buuuut technically the sound's still audible.
for(var/mob/M in GLOB.player_list)
if(!M.client)
continue
if(!(M.client.prefs.toggles & SOUND_INSTRUMENTS) || !M.can_hear())
if(!(M.client.prefs.toggles & SOUND_INSTRUMENTS))
M.stop_sound_channel(jukeinfo[JUKE_CHANNEL])
continue
var/inrange = FALSE
if(targetfalloff && (M.z in audible_zlevels))
song_played.status = SOUND_UPDATE
inrange = FALSE
if(targetfalloff && M.can_hear() && (M.z in audible_zlevels))
if(get_area(M) == currentarea)
inrange = TRUE
else if(M in hearerscache)
inrange = TRUE
song_played.status = SOUND_UPDATE
else
song_played.status = SOUND_MUTE | SOUND_UPDATE //Setting volume = 0 doesn't let the sound properties update at all, which is lame.
song_played.status = SOUND_MUTE | SOUND_UPDATE
song_played.falloff = (inrange ? targetfalloff : targetfalloff * targetfalloff) //The wet channel uses a sqrt falloff by default. Exponentially increasing the falloff when muffled makes
M.playsound_local(currentturf, null, (targetfalloff ? min((targetfalloff * 50), 100) : 1), channel = jukeinfo[JUKE_CHANNEL], S = song_played, envwet = ((inrange) ? mixes : max(mixes, 0)), envdry = (inrange ? max(mixes, 0) : -10000))
CHECK_TICK