From 0b61e8e64650ef0996d5dafe95efef512b20e918 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 15 Jul 2014 15:30:10 -0400 Subject: [PATCH] Limits hearing sounds in a vacuum Conflicts: code/modules/mob/living/say.dm --- code/game/sound.dm | 17 +++++++++++++++-- code/modules/mob/living/say.dm | 3 +-- code/setup.dm | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/code/game/sound.dm b/code/game/sound.dm index 1ba836b1945..c700e84592a 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -14,10 +14,23 @@ var/mob/M = P if(!M || !M.client) continue - if(get_dist(M, turf_source) <= (world.view + extrarange) * 3) + + var/distance = get_dist(M, turf_source) + if(distance <= (world.view + extrarange) * 3) var/turf/T = get_turf(M) + if(T && T.z == turf_source.z) - M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff) + //check that the air can transmit sound + 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.75 //lower the frequency a bit. very rudimentary + var/new_volume = vol*0.5 //muffle the sound, like we're hearing through contact + M.playsound_local(turf_source, soundin, new_volume, vary, new_frequency, falloff) + else + M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff) var/const/FALLOFF_SOUNDS = 2 var/const/SURROUND_CAP = 255 diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 02fc30278a8..ffb1602fc80 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -1,4 +1,3 @@ -#define SAY_MINIMUM_PRESSURE 10 var/list/department_radio_keys = list( ":r" = "right ear", "#r" = "right ear", ".r" = "right ear", "!r" = "fake right ear", ":l" = "left ear", "#l" = "left ear", ".l" = "left ear", "!l" = "fake left ear", @@ -329,7 +328,7 @@ var/list/department_radio_keys = list( var/datum/gas_mixture/environment = loc.return_air() if(environment) var/pressure = environment.return_pressure() - if (pressure < SAY_MINIMUM_PRESSURE) //in space no one can hear you scream + if(pressure < SOUND_MINIMUM_PRESSURE) italics = 1 message_range = 1 diff --git a/code/setup.dm b/code/setup.dm index 9c9eace6cf6..02cd256c44f 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -27,6 +27,8 @@ #define HUMAN_NEEDED_OXYGEN MOLES_CELLSTANDARD*BREATH_PERCENTAGE*0.16 //Amount of air needed before pass out/suffocation commences +#define SOUND_MINIMUM_PRESSURE 10 + // Pressure limits. #define HAZARD_HIGH_PRESSURE 550 //This determins at what pressure the ultra-high pressure red icon is displayed. (This one is set as a constant) #define WARNING_HIGH_PRESSURE 325 //This determins when the orange pressure icon is displayed (it is 0.7 * HAZARD_HIGH_PRESSURE)