From 99fe1c9d0481ba67a269fca9096ccdd1aaef4d62 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Wed, 19 Nov 2014 17:03:12 +0000 Subject: [PATCH] Sounds in space/places with low pressure are quieter. You cannot hear people in low pressure environments unless you are next to them (or are them) --- code/__DEFINES/misc.dm | 8 +++++++- code/game/sound.dm | 27 ++++++++++++++++++++++++--- code/modules/mob/living/say.dm | 12 ++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 2991fe66569..f31959107f2 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -50,4 +50,10 @@ #define STAGE_TWO 3 #define STAGE_THREE 5 #define STAGE_FOUR 7 -#define STAGE_FIVE 9 \ No newline at end of file +#define STAGE_FIVE 9 + + +//SOUND: +#define SOUND_MINIMUM_PRESSURE 10 +#define FALLOFF_SOUNDS 1 +#define SURROUND_CAP 7 \ No newline at end of file diff --git a/code/game/sound.dm b/code/game/sound.dm index fa54a5dcd8a..b1a7042b8b3 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -19,8 +19,6 @@ if(T && T.z == turf_source.z) M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, surround) -var/const/FALLOFF_SOUNDS = 1 -var/const/SURROUND_CAP = 7 /mob/proc/playsound_local(var/turf/turf_source, soundin, vol as num, vary, frequency, falloff, surround = 1) if(!src.client || ear_deaf > 0) return @@ -38,8 +36,31 @@ var/const/SURROUND_CAP = 7 S.frequency = get_rand_frequency() if(isturf(turf_source)) - // 3D sounds, the technology is here! var/turf/T = get_turf(src) + + //Atmosphere affects sound + var/pressure_factor = 1 + 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 //space + pressure_factor = 0 + + var/distance = get_dist(T, turf_source) + if(distance <= 1) + pressure_factor = max(pressure_factor, 0.15) //touching the source of the sound + + S.volume *= pressure_factor + //End Atmosphere affecting sound + + if(S.volume <= 0) + return //No sound + + // 3D sounds, the technology is here! if (surround) var/dx = turf_source.x - T.x // Hearing from the right/left S.x = round(max(-SURROUND_CAP, min(SURROUND_CAP, dx)), 1) diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index c6ed851bece..3389c37a690 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -121,6 +121,18 @@ var/list/department_radio_keys = list( if(radio_return & REDUCE_RANGE) message_range = 1 + if(message_range != 1) + //No screams in space, unless you're next to someone. + var/turf/T = get_turf(src) + var/datum/gas_mixture/environment = T.return_air() + var/pressure = (environment)? environment.return_pressure() : 0 + if(pressure < SOUND_MINIMUM_PRESSURE) + message_range = 1 + + if(pressure < ONE_ATMOSPHERE*0.4) //Thin air, let's italicise the message + if(!findtextEx(message,"")) + message = "[message]" + send_speech(message, message_range, src, bubble_type) log_say("[name]/[key] : [message]")