diff --git a/code/controllers/subsystem/explosions.dm b/code/controllers/subsystem/explosions.dm index 600f8645de8..92d1be419d6 100644 --- a/code/controllers/subsystem/explosions.dm +++ b/code/controllers/subsystem/explosions.dm @@ -172,6 +172,16 @@ SUBSYSTEM_DEF(explosions) /proc/explosion(atom/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = TRUE, ignorecap = FALSE, flame_range = 0, silent = FALSE, smoke = FALSE) . = SSexplosions.explode(arglist(args)) +#define CREAK_DELAY 5 SECONDS //Time taken for the creak to play after explosion, if applicable. +#define DEVASTATION_PROB 30 //The probability modifier for devistation, maths! +#define HEAVY_IMPACT_PROB 5 //ditto +#define FAR_UPPER 60 //Upper limit for the far_volume, distance, clamped. +#define FAR_LOWER 40 //lower limit for the far_volume, distance, clamped. +#define PROB_SOUND 75 //The probability modifier for a sound to be an echo, or a far sound. (0-100) +#define SHAKE_CLAMP 2.5 //The limit for how much the camera can shake for out of view booms. +#define FREQ_UPPER 40 //The upper limit for the randomly selected frequency. +#define FREQ_LOWER 25 //The lower of the above. + /datum/controller/subsystem/explosions/proc/explode(atom/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog, ignorecap, flame_range, silent, smoke) epicenter = get_turf(epicenter) if(!epicenter) @@ -220,13 +230,21 @@ SUBSYSTEM_DEF(explosions) // 3/7/14 will calculate to 80 + 35 var/far_dist = 0 - far_dist += heavy_impact_range * 5 + far_dist += heavy_impact_range * 15 far_dist += devastation_range * 20 if(!silent) var/frequency = get_rand_frequency() var/sound/explosion_sound = sound(get_sfx("explosion")) var/sound/far_explosion_sound = sound('sound/effects/explosionfar.ogg') + var/sound/creaking_explosion_sound = sound(get_sfx("explosion_creaking")) + var/sound/hull_creaking_sound = sound(get_sfx("hull_creaking")) + var/sound/explosion_echo_sound = sound('sound/effects/explosion_distant.ogg') + var/on_station = SSmapping.level_trait(epicenter.z, ZTRAIT_STATION) + var/creaking_explosion = FALSE + + if(prob(devastation_range*DEVASTATION_PROB+heavy_impact_range*HEAVY_IMPACT_PROB) && on_station) // Huge explosions are near guaranteed to make the station creak and whine, smaller ones might. + creaking_explosion = TRUE // prob over 100 always returns true for(var/MN in GLOB.player_list) var/mob/M = MN @@ -244,11 +262,28 @@ SUBSYSTEM_DEF(explosions) shake_camera(M, 25, clamp(baseshakeamount, 0, 10)) // You hear a far explosion if you're outside the blast radius. Small bombs shouldn't be heard all over the station. 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 - M.playsound_local(epicenter, null, far_volume, 1, frequency, falloff = 5, S = far_explosion_sound) - if(baseshakeamount > 0) - shake_camera(M, 10, clamp(baseshakeamount*0.25, 0, 2.5)) + var/far_volume = clamp(far_dist/2, FAR_LOWER, FAR_UPPER) // Volume is based on explosion size and dist + if(creaking_explosion) + M.playsound_local(epicenter, null, far_volume, 1, frequency, S = creaking_explosion_sound, distance_multiplier = 0) + else if(prob(PROB_SOUND)) // Sound variety during meteor storm/tesloose/other bad event + M.playsound_local(epicenter, null, far_volume, 1, frequency, S = far_explosion_sound, distance_multiplier = 0) // Far sound + else + M.playsound_local(epicenter, null, far_volume, 1, frequency, S = explosion_echo_sound, distance_multiplier = 0) // Echo sound + + if(baseshakeamount > 0 || devastation_range) + if(!baseshakeamount) // Devastating explosions rock the station and ground + baseshakeamount = devastation_range*3 + shake_camera(M, 10, clamp(baseshakeamount*0.25, 0, SHAKE_CLAMP)) + else if(!isspaceturf(get_turf(M)) && heavy_impact_range) // Big enough explosions echo throughout the hull + var/echo_volume = 40 + if(devastation_range) + baseshakeamount = devastation_range + shake_camera(M, 10, clamp(baseshakeamount*0.25, 0, SHAKE_CLAMP)) + echo_volume = 60 + M.playsound_local(epicenter, null, echo_volume, 1, frequency, S = explosion_echo_sound, distance_multiplier = 0) + + if(creaking_explosion) // 5 seconds after the bang, the station begins to creak + addtimer(CALLBACK(M, /mob/proc/playsound_local, epicenter, null, rand(FREQ_LOWER, FREQ_UPPER), 1, frequency, null, null, FALSE, hull_creaking_sound, 0), CREAK_DELAY) if(heavy_impact_range > 1) var/datum/effect_system/explosion/E @@ -348,6 +383,15 @@ SUBSYSTEM_DEF(explosions) SEND_GLOBAL_SIGNAL(COMSIG_GLOB_EXPLOSION, epicenter, devastation_range, heavy_impact_range, light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range) +#undef CREAK_DELAY +#undef DEVASTATION_PROB +#undef HEAVY_IMPACT_PROB +#undef FAR_UPPER +#undef FAR_LOWER +#undef PROB_SOUND +#undef SHAKE_CLAMP +#undef FREQ_UPPER +#undef FREQ_LOWER /datum/controller/subsystem/explosions/proc/GatherSpiralTurfs(range, turf/epicenter) var/list/outlist = list() diff --git a/code/game/sound.dm b/code/game/sound.dm index 5b65bc87c43..1688c0d13cf 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -137,6 +137,10 @@ soundin = pick('sound/effects/glassbr1.ogg','sound/effects/glassbr2.ogg','sound/effects/glassbr3.ogg') if ("explosion") soundin = pick('sound/effects/explosion1.ogg','sound/effects/explosion2.ogg') + if ("explosion_creaking") + soundin = pick('sound/effects/explosioncreak1.ogg', 'sound/effects/explosioncreak2.ogg') + if ("hull_creaking") + soundin = pick('sound/effects/creak1.ogg', 'sound/effects/creak2.ogg', 'sound/effects/creak3.ogg') if ("sparks") soundin = pick('sound/effects/sparks1.ogg','sound/effects/sparks2.ogg','sound/effects/sparks3.ogg','sound/effects/sparks4.ogg') if ("rustle") diff --git a/sound/effects/creak1.ogg b/sound/effects/creak1.ogg new file mode 100644 index 00000000000..0cad4802ffa Binary files /dev/null and b/sound/effects/creak1.ogg differ diff --git a/sound/effects/creak2.ogg b/sound/effects/creak2.ogg new file mode 100644 index 00000000000..707bf39e338 Binary files /dev/null and b/sound/effects/creak2.ogg differ diff --git a/sound/effects/creak3.ogg b/sound/effects/creak3.ogg new file mode 100644 index 00000000000..88ff37a339e Binary files /dev/null and b/sound/effects/creak3.ogg differ diff --git a/sound/effects/explosioncreak1.ogg b/sound/effects/explosioncreak1.ogg new file mode 100644 index 00000000000..474f5febb5c Binary files /dev/null and b/sound/effects/explosioncreak1.ogg differ diff --git a/sound/effects/explosioncreak2.ogg b/sound/effects/explosioncreak2.ogg new file mode 100644 index 00000000000..75d323eb06f Binary files /dev/null and b/sound/effects/explosioncreak2.ogg differ