mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Big nerf and cleanup of 3D sound. should fix most of #5789
This commit is contained in:
@@ -9,7 +9,7 @@ var/list/hiss_sound = list('sound/voice/hiss1.ogg','sound/voice/hiss2.ogg','soun
|
|||||||
var/list/page_sound = list('sound/effects/pageturn1.ogg', 'sound/effects/pageturn2.ogg','sound/effects/pageturn3.ogg')
|
var/list/page_sound = list('sound/effects/pageturn1.ogg', 'sound/effects/pageturn2.ogg','sound/effects/pageturn3.ogg')
|
||||||
//var/list/gun_sound = list('sound/weapons/Gunshot.ogg', 'sound/weapons/Gunshot2.ogg','sound/weapons/Gunshot3.ogg','sound/weapons/Gunshot4.ogg')
|
//var/list/gun_sound = list('sound/weapons/Gunshot.ogg', 'sound/weapons/Gunshot2.ogg','sound/weapons/Gunshot3.ogg','sound/weapons/Gunshot4.ogg')
|
||||||
|
|
||||||
/proc/playsound(var/atom/source, soundin, vol as num, vary, extrarange as num, falloff)
|
/proc/playsound(var/atom/source, soundin, vol as num, vary, extrarange as num, falloff, var/is_global)
|
||||||
|
|
||||||
soundin = get_sfx(soundin) // same sound for everyone
|
soundin = get_sfx(soundin) // same sound for everyone
|
||||||
|
|
||||||
@@ -25,28 +25,27 @@ var/list/page_sound = list('sound/effects/pageturn1.ogg', 'sound/effects/pagetur
|
|||||||
var/mob/M = P
|
var/mob/M = P
|
||||||
if(!M || !M.client)
|
if(!M || !M.client)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var/distance = get_dist(M, turf_source)
|
var/distance = get_dist(M, turf_source)
|
||||||
if(distance <= (world.view + extrarange) * 3)
|
if(distance <= (world.view + extrarange) * 3)
|
||||||
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
|
//check that the air can transmit sound
|
||||||
var/datum/gas_mixture/environment = T.return_air()
|
var/datum/gas_mixture/environment = T.return_air()
|
||||||
if (!environment || environment.return_pressure() < SOUND_MINIMUM_PRESSURE)
|
if (!environment || environment.return_pressure() < SOUND_MINIMUM_PRESSURE)
|
||||||
if (distance > 1)
|
if (distance > 1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var/new_frequency = 32000 + (frequency - 32000)*0.125 //lower the frequency. very rudimentary
|
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
|
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)
|
M.playsound_local(turf_source, soundin, new_volume, vary, new_frequency, falloff, is_global)
|
||||||
else
|
else
|
||||||
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff)
|
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, is_global)
|
||||||
|
|
||||||
var/const/FALLOFF_SOUNDS = 2
|
var/const/FALLOFF_SOUNDS = 0.5
|
||||||
var/const/SURROUND_CAP = 255
|
|
||||||
|
|
||||||
/mob/proc/playsound_local(var/turf/turf_source, soundin, vol as num, vary, frequency, falloff)
|
/mob/proc/playsound_local(var/turf/turf_source, soundin, vol as num, vary, frequency, falloff, is_global)
|
||||||
if(!src.client || ear_deaf > 0) return
|
if(!src.client || ear_deaf > 0) return
|
||||||
soundin = get_sfx(soundin)
|
soundin = get_sfx(soundin)
|
||||||
|
|
||||||
@@ -54,8 +53,7 @@ var/const/SURROUND_CAP = 255
|
|||||||
S.wait = 0 //No queue
|
S.wait = 0 //No queue
|
||||||
S.channel = 0 //Any channel
|
S.channel = 0 //Any channel
|
||||||
S.volume = vol
|
S.volume = vol
|
||||||
S.environment = 2
|
S.environment = -1
|
||||||
|
|
||||||
if (vary)
|
if (vary)
|
||||||
if(frequency)
|
if(frequency)
|
||||||
S.frequency = frequency
|
S.frequency = frequency
|
||||||
@@ -65,20 +63,20 @@ var/const/SURROUND_CAP = 255
|
|||||||
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) * 0.75
|
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()
|
||||||
|
S.volume -= environment.return_pressure()/100 + 1
|
||||||
if (S.volume < 0)
|
if (S.volume < 0)
|
||||||
S.volume = 0
|
S.volume = 0
|
||||||
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 = round(max(-SURROUND_CAP, min(SURROUND_CAP, dx)), 1)
|
|
||||||
|
|
||||||
var/dz = turf_source.y - T.y // Hearing from infront/behind
|
var/dz = turf_source.y - T.y // Hearing from infront/behind
|
||||||
S.z = round(max(-SURROUND_CAP, min(SURROUND_CAP, dz)), 1)
|
S.z = dz
|
||||||
|
|
||||||
// The y value is for above your head, but there is no ceiling in 2d spessmens.
|
// The y value is for above your head, but there is no ceiling in 2d spessmens.
|
||||||
S.y = 1
|
S.y = 1
|
||||||
S.falloff = (falloff ? falloff : FALLOFF_SOUNDS)
|
S.falloff = (falloff ? falloff : FALLOFF_SOUNDS)
|
||||||
|
if(!is_global)
|
||||||
|
S.environment = 2
|
||||||
src << S
|
src << S
|
||||||
|
|
||||||
/client/proc/playtitlemusic()
|
/client/proc/playtitlemusic()
|
||||||
|
|||||||
Reference in New Issue
Block a user