mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Sound fixes
This commit is contained in:
@@ -31,17 +31,7 @@ var/list/page_sound = list('sound/effects/pageturn1.ogg', 'sound/effects/pagetur
|
|||||||
var/turf/T = get_turf(M)
|
var/turf/T = get_turf(M)
|
||||||
|
|
||||||
if(T && T.z == turf_source.z)
|
if(T && T.z == turf_source.z)
|
||||||
//check that the air can transmit sound
|
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, is_global)
|
||||||
var/datum/gas_mixture/environment = T.return_air()
|
|
||||||
if (!environment || environment.return_pressure() < SOUND_MINIMUM_PRESSURE)
|
|
||||||
if (distance > 1)
|
|
||||||
continue
|
|
||||||
|
|
||||||
var/new_frequency = 32000 + (frequency - 32000)*0.125 //lower the frequency. very rudimentary
|
|
||||||
var/new_volume = vol*0.15 //muffle the sound, like we're hearing through contact
|
|
||||||
M.playsound_local(turf_source, soundin, new_volume, vary, new_frequency, falloff, is_global)
|
|
||||||
else
|
|
||||||
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, is_global)
|
|
||||||
|
|
||||||
var/const/FALLOFF_SOUNDS = 0.5
|
var/const/FALLOFF_SOUNDS = 0.5
|
||||||
|
|
||||||
@@ -63,12 +53,34 @@ var/const/FALLOFF_SOUNDS = 0.5
|
|||||||
if(isturf(turf_source))
|
if(isturf(turf_source))
|
||||||
// 3D sounds, the technology is here!
|
// 3D sounds, the technology is here!
|
||||||
var/turf/T = get_turf(src)
|
var/turf/T = get_turf(src)
|
||||||
S.volume -= get_dist(T, turf_source) * 2 //multiplicative falloff to add on top of natural audio falloff.
|
|
||||||
var/datum/gas_mixture/environment = T.return_air()
|
//sound volume falloff with distance
|
||||||
if(get_dist(T, turf_source) > 2)
|
var/distance = get_dist(T, turf_source)
|
||||||
S.volume -= environment.return_pressure()/100 + 1
|
|
||||||
if (S.volume < 0)
|
S.volume -= max(distance - world.view, 0) * 2 //multiplicative falloff to add on top of natural audio falloff.
|
||||||
S.volume = 0
|
|
||||||
|
//sound volume falloff with pressure
|
||||||
|
var/pressure_factor = 1.0
|
||||||
|
|
||||||
|
var/datum/gas_mixture/hearer_env = T.return_air()
|
||||||
|
var/datum/gas_mixture/source_env = turf_source.return_air()
|
||||||
|
|
||||||
|
if (hearer_env && source_env)
|
||||||
|
var/pressure = min(hearer_env.return_pressure(), source_env.return_pressure())
|
||||||
|
|
||||||
|
if (pressure < ONE_ATMOSPHERE)
|
||||||
|
pressure_factor = max((pressure - SOUND_MINIMUM_PRESSURE)/(ONE_ATMOSPHERE - SOUND_MINIMUM_PRESSURE), 0)
|
||||||
|
else //in space
|
||||||
|
pressure_factor = 0
|
||||||
|
|
||||||
|
if (distance <= 1)
|
||||||
|
pressure_factor = max(pressure_factor, 0.15) //hearing through contact
|
||||||
|
|
||||||
|
S.volume *= pressure_factor
|
||||||
|
|
||||||
|
if (S.volume <= 0)
|
||||||
|
return //no volume means no sound
|
||||||
|
|
||||||
var/dx = turf_source.x - T.x // Hearing from the right/left
|
var/dx = turf_source.x - T.x // Hearing from the right/left
|
||||||
S.x = dx
|
S.x = dx
|
||||||
var/dz = turf_source.y - T.y // Hearing from infront/behind
|
var/dz = turf_source.y - T.y // Hearing from infront/behind
|
||||||
|
|||||||
Reference in New Issue
Block a user