Merge pull request #5842 from Rykka-Stormheart/shep-dev-ear-ringing

Adds Deafened Feedback, enhances looping sounds further
This commit is contained in:
Razgriz
2023-03-04 16:37:29 -07:00
committed by GitHub
33 changed files with 127 additions and 16 deletions

View File

@@ -17,6 +17,7 @@
opacity_check (bool) If true, things behind walls/opaque things won't hear the sounds.
pref_check (type) If set to a /datum/client_preference type, will check if the hearer has that preference active before playing it to them.
volume_chan (type) If set to a specific volume channel via the incoming argument, we tell the playsound proc to modulate volume based on that channel
exclusive (bool) If true, only one of this sound is allowed to play.
*/
/datum/looping_sound
var/list/atom/output_atoms
@@ -34,16 +35,19 @@
var/opacity_check
var/pref_check
var/volume_chan
var/exclusive
var/timerid
var/started
/datum/looping_sound/New(list/_output_atoms=list(), start_immediately=FALSE, _direct=FALSE)
/datum/looping_sound/New(list/_output_atoms=list(), start_immediately=FALSE, disable_direct=FALSE) // CHOMPEdit: Fixes shitty default _direct forcing all direct sounds to false. Now it is an explicit override
if(!mid_sounds)
WARNING("A looping sound datum was created without sounds to play.")
return
output_atoms = _output_atoms
direct = _direct
if(disable_direct) // CHOMPEdit: Fixes shitty default _direct forcing all direct sounds to false. Now it is an explicit override
direct = FALSE // CHOMPEdit: Fixes shitty default _direct forcing all direct sounds to false. Now it is an explicit override
if(start_immediately)
start()
@@ -53,21 +57,30 @@
output_atoms = null
return ..()
/datum/looping_sound/proc/start(atom/add_thing)
/datum/looping_sound/proc/start(atom/add_thing, skip_start_sound = FALSE) // CHOMPStation Edit: Skip start sounds optionally
if(add_thing)
output_atoms |= add_thing
if(timerid)
return
if(skip_start_sound && (!exclusive && !started)) // CHOMPStation Edit: Skip start sounds optionally
sound_loop() // CHOMPStation Edit: Skip start sounds optionally
started = TRUE // CHOMPStation Edit: Skip start sounds optionally
return // CHOMPStation Edit: Skip start sounds optionally
if(exclusive && started) // Prevents a sound from starting multiple times
return // Don't start this loop.
on_start()
started = TRUE
/datum/looping_sound/proc/stop(atom/remove_thing)
/datum/looping_sound/proc/stop(atom/remove_thing, skip_stop_sound = FALSE)
if(remove_thing)
output_atoms -= remove_thing
if(!timerid)
return
on_stop()
if(!skip_stop_sound) // CHOMPEdit: Allows skipping the stop sound, should you need to.
on_stop() // CHOMPEdit: Allows skipping the stop sound, should you need to.
deltimer(timerid)
timerid = null
started = FALSE
/datum/looping_sound/proc/sound_loop(starttime)
if(max_loops && world.time >= starttime + mid_length * max_loops)
@@ -89,7 +102,7 @@
if(direct)
if(ismob(thing))
var/mob/M = thing
if(!M.is_preference_enabled(pref_check))
if(pref_check && !M.is_preference_enabled(pref_check)) // CHOMPEdit: Fixed this broken check, sent upstream
continue
SEND_SOUND(thing, S)
else
@@ -112,4 +125,4 @@
/datum/looping_sound/proc/on_stop()
if(end_sound)
play(end_sound)
play(end_sound)

View File

@@ -0,0 +1,23 @@
/*
* The purpose of this file is to house mob injury loops - such as being on fire.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/datum/looping_sound/mob
// volume_chan = VOLUME_CHANNEL_INJ_DEATH // Commented out until pain/etc PR is in
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/datum/looping_sound/mob/deafened
start_sound = 'modular_chomp/sound/effects/ear_ring/ear_deaf_in.ogg'
start_length = 4 SECONDS // 2 seconds shorter than the actual file ending, bc we want it to overlap
mid_sounds = list('modular_chomp/sound/effects/ear_ring/ear_deaf_loop.ogg'=1)
mid_length = 3 SECONDS
end_sound = 'modular_chomp/sound/effects/ear_ring/ear_deaf_out.ogg'
volume = 40
direct = TRUE // We send this sound directly to the mob, bc they only hear it when they're deaf.
exclusive = TRUE // This should only occur once, because we can only be deafened once.
// volume_chan = VOLUME_CHANNEL_INJ_DEATH // Commented out until pain/etc PR is in
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -119,6 +119,8 @@
/datum/dna/gene/disability/deaf/activate(var/mob/M, var/connected, var/flags)
..(M,connected,flags)
M.ear_deaf = 1
var/mob/living/mL = M // CHOMPStation Add: Ear Ringing/Deafness
mL.deaf_loop.start(skip_start_sound = TRUE) // CHOMPStation Add: Ear Ringing/Deafness
/datum/dna/gene/disability/nearsighted
name="Nearsightedness"

View File

@@ -912,6 +912,7 @@ var/list/sacrificed = list()
if(N)
continue
C.ear_deaf += 50
C.deaf_loop.start(skip_start_sound = TRUE) // CHOMPStation Add: Ear Ringing/Deafness
C.show_message("<span class='warning'>The world around you suddenly becomes quiet.</span>", 3)
affected += C
if(prob(1))
@@ -932,6 +933,7 @@ var/list/sacrificed = list()
if(N)
continue
C.ear_deaf += 30
C.deaf_loop.start(skip_start_sound = TRUE) // CHOMPStation Add: Ear Ringing/Deafness
//talismans is weaker.
C.show_message("<span class='warning'>The world around you suddenly becomes quiet.</span>", 3)
affected += C

View File

@@ -86,6 +86,7 @@
M.SetSleeping(0)
M.stuttering += 20
M.ear_deaf += 30
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.Weaken(3)
if(prob(30))
M.Stun(10)

View File

@@ -230,6 +230,7 @@
M.SetSleeping(0)
M.stuttering += 20
M.ear_deaf += 30
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.Weaken(3)
if(prob(30))
M.Stun(10)

View File

@@ -28,10 +28,11 @@
playsound(M, 'sound/effects/bang.ogg', 70, 1, 30)
M.SetSleeping(0)
M.ear_deaf += 30
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.ear_damage += rand(5, 20)
M.Weaken(3)
M.Stun(5)
chassis.use_power(energy_drain)
log_message("Used a sound emission device.")
do_after_cooldown()
return
return

View File

@@ -38,6 +38,8 @@
// If inside the blast radius + world.view - 2
if(dist <= round(max_range + world.view - 2, 1))
M.playsound_local(epicenter, get_sfx("explosion"), 100, 1, frequency, falloff = 5) // get_sfx() is so that everyone gets the same sound
var/mob/living/mL = M // CHOMPStation Add: Ear Ringing/Deafness
mL.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
else if(dist <= far_dist)
var/far_volume = CLAMP(far_dist, 30, 50) // Volume is based on explosion size and dist
far_volume += (dist <= far_dist * 0.5 ? 50 : 0) // add 50 volume if the mob is pretty close to the explosion

View File

@@ -143,6 +143,7 @@
M.SetSleeping(0)
M.stuttering += 20
M.ear_deaf += 30
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.Weaken(3)
if(prob(30))
M.Stun(10)

View File

@@ -38,6 +38,7 @@
else
H.Confuse(8)
H.Weaken(1)
H.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if ((prob(14) || (H == src.loc && prob(70))))
H.ear_damage += rand(1, 10)
else
@@ -54,6 +55,7 @@
H.Confuse(6)
H.ear_damage += rand(0, 3)
H.ear_deaf = max(H.ear_deaf,10)
H.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if(H.client)
if(prob(50))
@@ -65,15 +67,18 @@
H.Confuse(4)
H.ear_damage += rand(0, 1)
H.ear_deaf = max(H.ear_deaf,5)
H.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if(H.ear_damage >= 15)
to_chat(H, "<span class='danger'>Your ears start to ring badly!</span>")
H.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if(prob(H.ear_damage - 5))
to_chat(H, "<span class='danger'>You can't hear anything!</span>")
H.sdisabilities |= DEAF
else if(H.ear_damage >= 5)
to_chat(H, "<span class='danger'>Your ears start to ring!</span>")
H.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if(istype(L, /mob/living/silicon/robot))
var/mob/living/silicon/robot/R = L
if(L.client)
@@ -82,4 +87,4 @@
else
L.client.spinright()
to_chat(R, "<span class='critical'>Gyroscopic failure.</span>")
return
return

View File

@@ -64,17 +64,20 @@
else
M.ear_damage += rand(0, 5)
M.ear_deaf = max(M.ear_deaf,15)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
else if(get_dist(M, T) <= round(max_range * 0.5 * bang_effectiveness))
if(!ear_safety)
M.Confuse(8)
M.ear_damage += rand(0, 3)
M.ear_deaf = max(M.ear_deaf,10)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
else if(!ear_safety && get_dist(M, T) <= (max_range * 0.7 * bang_effectiveness))
M.Confuse(4)
M.ear_damage += rand(0, 1)
M.ear_deaf = max(M.ear_deaf,5)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
//This really should be in mob not every check
if(ishuman(M))
@@ -162,4 +165,4 @@
var/dettime = rand(15,60)
spawn(dettime)
detonate()
detonate()

View File

@@ -93,6 +93,7 @@
if(iscarbon(L))
var/mob/living/carbon/C = L
C.ear_deaf += 10
C.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
to_chat(L, span("danger", "Lightning struck nearby, and the thunderclap is deafening!"))
#undef LIGHTNING_ZAP_RANGE

View File

@@ -19,6 +19,7 @@
ear_damage += 30
ear_deaf += 120
deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if(3.0)
b_loss += 30
@@ -26,6 +27,7 @@
Paralyse(1)
ear_damage += 15
ear_deaf += 60
deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
adjustBruteLoss(b_loss)
adjustFireLoss(f_loss)

View File

@@ -41,12 +41,14 @@
if(stat == DEAD)
blinded = 1
silent = 0
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
else
updatehealth()
if(health <= 0)
death()
blinded = 1
silent = 0
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
return 1
if(paralysis && paralysis > 0)

View File

@@ -92,6 +92,7 @@
if(stat == DEAD) //DEAD. BROWN BREAD. SWIMMING WITH THE SPESS CARP
blinded = 1
silent = 0
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
else //ALIVE. LIGHTS ARE ON
if( !container && (health < config.health_threshold_dead || ((world.time - timeofhostdeath) > config.revival_brain_life)) )
death()
@@ -112,6 +113,7 @@
SetBlinded(1)
blinded = 1
ear_deaf = 1
deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
silent = 1
if(!alert)//Sounds an alarm, but only once per 'level'
emote("alarm")
@@ -124,6 +126,7 @@
blinded = 0
SetBlinded(0)
ear_deaf = 0
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness
silent = 0
emp_damage -= 1
if(11 to 19)//Moderate level of EMP damage, resulting in nearsightedness and ear damage
@@ -219,4 +222,4 @@
if(client && !client.adminobs)
reset_view(null)
return 1
return 1

View File

@@ -131,6 +131,7 @@
if(species.emp_sensitivity & EMP_DEAFEN)
src.ear_damage += rand(0,deafen_dur) //this will heal pretty quickly, but spamming them at someone could cause serious damage
src.ear_deaf = max(src.ear_deaf,deafen_dur)
src.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if(species.emp_sensitivity & EMP_CONFUSE)
if(confuse_dur >= 1)
to_chat(src, "<span class='danger'>Oh god, everything's spinning!</span>")

View File

@@ -143,6 +143,7 @@
if (!get_ear_protection() >= 2)
ear_damage += 30
ear_deaf += 120
deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if (prob(70) && !shielded)
Paralyse(10)
@@ -153,6 +154,7 @@
if (!get_ear_protection() >= 2)
ear_damage += 15
ear_deaf += 60
deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if (prob(50) && !shielded)
Paralyse(10)

View File

@@ -1257,6 +1257,7 @@
if(stat == DEAD) //DEAD. BROWN BREAD. SWIMMING WITH THE SPESS CARP
blinded = 1
silent = 0
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
else //ALIVE. LIGHTS ARE ON
updatehealth() //TODO
@@ -1264,6 +1265,7 @@
death()
blinded = 1
silent = 0
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
return 1
//UNCONSCIOUS. NO-ONE IS HOME
@@ -1379,6 +1381,7 @@
//Ears
if(sdisabilities & DEAF) //disabled-deaf, doesn't get better on its own
ear_deaf = max(ear_deaf, 1)
deaf_loop.start(skip_start_sound = TRUE) // CHOMPStation Add: Ear Ringing/Deafness
else if(ear_deaf) //deafness, heals slowly over time
ear_deaf = max(ear_deaf-1, 0)
else if(get_ear_protection() >= 2) //resting your ears with earmuffs heals ear damage faster
@@ -1387,6 +1390,11 @@
else if(ear_damage < 25) //ear damage heals slowly under this threshold. otherwise you'll need earmuffs
ear_damage = max(ear_damage-0.05, 0)
// CHOMPAdd: Handle Ear ringing, standalone safety check.
if(ear_deaf <= 0)
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness
// CHOMPAdd End
//Resting
if(resting)
dizziness = max(0, dizziness - 15)

View File

@@ -834,6 +834,10 @@
/mob/living/adjustEarDamage(var/damage, var/deaf)
ear_damage = max(0, ear_damage + damage)
ear_deaf = max(0, ear_deaf + deaf)
if(ear_deaf > 0)
deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
else if(ear_deaf <= 0)
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
//pass a negative argument to skip one of the variable
/mob/living/setEarDamage(var/damage, var/deaf)
@@ -841,6 +845,7 @@
ear_damage = damage
if(deaf >= 0)
ear_deaf = deaf
deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
/mob/living/proc/vomit(var/skip_wait, var/blood_vomit)
if(!check_has_mouth())

View File

@@ -113,11 +113,15 @@
src.AdjustBlinded(-1)
src.blinded = 1
if (src.ear_deaf > 0) src.ear_deaf--
if (src.ear_deaf > 0)
src.ear_deaf--
if (src.ear_damage < 25)
src.ear_damage -= 0.05
src.ear_damage = max(src.ear_damage, 0)
if(src.ear_deaf <= 0) // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness - Not sure if we need this, but, safety.
src.density = !( src.lying )
if (src.sdisabilities & BLIND)

View File

@@ -320,8 +320,10 @@
//If they're deaf
if(ext_deaf)
ear_deaf = 5
deaf_loop.start(skip_start_sound = TRUE) // CHOMPStation Add: Ear Ringing/Deafness
else
ear_deaf = 0
deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness
/mob/living/carbon/brain/caught_soul/hear_say()
if(ext_deaf || !client)

View File

@@ -331,7 +331,7 @@
/obj/item/weapon/gun/magnetic/fuelrod/proc/blitzed(var/turf/T, var/mob/living/carbon/M, var/max_range, var/banglet) // Added a new proc called 'bang' that takes a location and a person to be banged.
to_chat(M, "<span class='danger'>BANG</span>") // Called during the loop that bangs people in lockers/containers and when banging
playsound(src, 'sound/effects/bang.ogg', 50, 1, 30) // people in normal view. Could theroetically be called during other explosions.
//Checking for protections
var/eye_safety = 0
@@ -365,17 +365,20 @@
else
M.ear_damage += rand(0, 5)
M.ear_deaf = max(M.ear_deaf,15)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
else if(get_dist(M, T) <= round(max_range * 0.5 * bang_effectiveness))
if(!ear_safety)
M.Confuse(8)
M.ear_damage += rand(0, 3)
M.ear_deaf = max(M.ear_deaf,10)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
else if(!ear_safety && get_dist(M, T) <= (max_range * 0.7 * bang_effectiveness))
M.Confuse(4)
M.ear_damage += rand(0, 1)
M.ear_deaf = max(M.ear_deaf,5)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
//This really should be in mob not every check
if(ishuman(M))

View File

@@ -256,11 +256,13 @@
M.Weaken(2)
M.ear_damage += rand(1, 10)
M.ear_deaf = max(M.ear_deaf,15)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
if (M.ear_damage >= 15)
to_chat(M, "<span class='danger'>Your ears start to ring badly!</span>")
if (prob(M.ear_damage - 5))
to_chat(M, "<span class='danger'>You can't hear anything!</span>")
M.sdisabilities |= DEAF
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
else
if (M.ear_damage >= 5)
to_chat(M, "<span class='danger'>Your ears start to ring!</span>")

View File

@@ -691,6 +691,7 @@
M.eye_blurry = max(M.eye_blurry, 30)
if(prob(20))
M.ear_deaf = max(M.ear_deaf, 4)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.Confuse(2)
else
M.Weaken(2)
@@ -735,6 +736,7 @@
if(alien == IS_SLIME)
if(prob(30))
M.ear_deaf = max(M.ear_deaf, 4)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.eye_blurry = max(M.eye_blurry, 60)
M.Weaken(30)
M.Confuse(40)

View File

@@ -110,6 +110,7 @@
/datum/disease2/effect/deaf/activate(var/mob/living/carbon/mob,var/multiplier)
mob.ear_deaf += 20
mob.deaf_loop.start(skip_start_sound = TRUE) // CHOMPStation Add: Ear Ringing/Deafness
/datum/disease2/effect/monkey
name = "Genome Regression"
@@ -288,6 +289,7 @@
/datum/disease2/effect/minordeaf/activate(var/mob/living/carbon/mob,var/multiplier)
mob.ear_deaf = 5
mob.deaf_loop.start(skip_start_sound = TRUE) // CHOMPStation Add: Ear Ringing/Deafness
/datum/disease2/effect/giggle
name = "Uncontrolled Laughter"

View File

@@ -177,6 +177,7 @@
M.sleeping = 0
M.stuttering += 20
M.ear_deaf += 30
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.Weaken(3)
if(prob(30))
M.Stun(10)
@@ -365,4 +366,4 @@
icon_state = "x2"
lootcount = 1 //how many items will be spawned
lootdoubles = 0 //if the same item can be spawned twice
loot = "" //a list of possible items to spawn- a string of paths
loot = "" //a list of possible items to spawn- a string of paths

View File

@@ -357,6 +357,7 @@
H.SetBlinded(0)
H.eye_blurry = 0
H.ear_deaf = 0
H.deaf_loop.stop() // CHOMPStation Add: Ear Ringing/Deafness
H.ear_damage = 0
H.heal_overall_damage(H.getActualBruteLoss(), H.getActualFireLoss(), 1)
for(var/I in H.organs_by_name)
@@ -573,4 +574,4 @@
if("l_hand")
usr.unEquip(src)
usr.put_in_l_hand(src)
src.add_fingerprint(usr)
src.add_fingerprint(usr)

View File

@@ -1,3 +1,17 @@
/mob/living
// var/ear_deaf_loop = FALSE // Are we already playing our deafened loop? Checked for safety so we don't deafen our players. (Not sure if we need this bc looping sounds datums have protection for starts being called repeatedly, commented out)
var/datum/looping_sound/mob/deafened/deaf_loop
/mob/living/Initialize()
. = ..()
deaf_loop = new(list(src), FALSE)
/mob/living/Destroy()
. = ..()
QDEL_NULL(deaf_loop)
/mob/living/proc/vs_animate(var/belly_to_animate)
return
@@ -14,4 +28,4 @@ Maybe later, gotta figure out a way to click yourself when in a locker etc.
/mob/living/New(var/newloc)
..()
verbs |= /mob/living/proc/click_self
*/
*/

View File

@@ -223,6 +223,7 @@
M.eye_blurry = max(M.eye_blurry, 30)
if(prob(20))
M.ear_deaf = max(M.ear_deaf, 4)
M.deaf_loop.start() // CHOMPStation Add: Ear Ringing/Deafness
M.Confuse(2)
else
M.Weaken(2)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -411,6 +411,7 @@
#include "code\datums\looping_sounds\environment_sounds.dm"
#include "code\datums\looping_sounds\item_sounds.dm"
#include "code\datums\looping_sounds\machinery_sounds.dm"
#include "code\datums\looping_sounds\mob_sounds.dm"
#include "code\datums\looping_sounds\sequence.dm"
#include "code\datums\looping_sounds\weather_sounds.dm"
#include "code\datums\managed_browsers\_managed_browser.dm"