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
+15 -10
View File
@@ -492,16 +492,21 @@
QDEL_LIST(sparkles)
/obj/machinery/jukebox/process()
if(active && world.time >= stop)
active = FALSE
dance_over()
if(stop && queuedplaylist.len)
activate_music()
else
playsound(src,'sound/machines/terminal_off.ogg',50,1)
update_icon()
playing = null
stop = 0
if(active)
if(world.time >= stop)
active = FALSE
dance_over()
if(stop && queuedplaylist.len)
activate_music()
else
playsound(src,'sound/machines/terminal_off.ogg',50,1)
update_icon()
playing = null
stop = 0
else if(volume > 140) // BOOM BOOM BOOM BOOM
for(var/mob/living/carbon/C in hearers(round(volume/35), src)) // I WANT YOU IN MY ROOM
if(istype(C)) // LETS SPEND THE NIGHT TOGETHER
C.adjustEarDamage(max((((volume/35) - sqrt(get_dist(C, src) * 4)) - C.get_ear_protection())*0.1, 0)) // FROM NOW UNTIL FOREVER
/obj/machinery/jukebox/disco/process()
+9 -4
View File
@@ -18,10 +18,9 @@
// to hear anything.
var/deaf = 0
// `ear_damage` measures long term damage to the ears, if too high,
// `damage` in this case measures long term damage to the ears, if too high,
// the person will not have either `deaf` or `ear_damage` decrease
// without external aid (earmuffs, drugs)
var/ear_damage = 0
//Resistance against loud noises
var/bang_protect = 0
@@ -44,16 +43,22 @@
/obj/item/organ/ears/proc/restoreEars()
deaf = 0
ear_damage = 0
damage = 0
prev_damage = 0
organ_flags &= ~ORGAN_FAILING
var/mob/living/carbon/C = owner
if(iscarbon(owner) && HAS_TRAIT(C, TRAIT_DEAF))
deaf = 1
var/mess = check_damage_thresholds()
if(mess && owner)
to_chat(owner, mess)
/obj/item/organ/ears/proc/adjustEarDamage(ddmg, ddeaf)
ear_damage = max(ear_damage + (ddmg*damage_multiplier), 0)
if(owner.status_flags & GODMODE)
return
setOrganDamage(max(damage + (ddmg*damage_multiplier), 0))
deaf = max(deaf + (ddeaf*damage_multiplier), 0)
/obj/item/organ/ears/proc/minimumDeafTicks(value)