From c622878626524a0b1166987f0b48cd4e6e52d8bf Mon Sep 17 00:00:00 2001 From: ZomgPonies Date: Tue, 19 Nov 2013 23:01:03 -0500 Subject: [PATCH] Better explosion sounds --- code/game/objects/explosion.dm | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index da4f51eef0a..ebcf1008464 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -7,7 +7,7 @@ else return dy + (0.5*dx) -proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1) +proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, adminlog = 1) src = null //so we don't abort once src is deleted spawn(0) if(config.use_recursive_explosions) @@ -19,9 +19,25 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa epicenter = get_turf(epicenter) if(!epicenter) return + var/max_range = max(devastation_range, heavy_impact_range, light_impact_range) + + // Play sounds; since playsound uses range() for each use, we'll try doing it through the player list. + // Playsound_local will also have an extra bonus of panning the sound, depending on the source. So stereo users will hear the direction of the explosion + for(var/mob/M in player_list) + // Double check for client + if(M && M.client) + var/turf/M_turf = get_turf(M) + if(M_turf.z == epicenter.z) + var/dist = get_dist(M_turf, epicenter) + // If inside the blast radius + world.view - 2 + if(dist <= round(max_range + world.view - 2, 1)) + M.playsound_local(epicenter, "explosion", 100, 1) + // You hear a far explosion if you're outside the blast radius (*5) Small bombs shouldn't be heard all over the station. + else if(dist <= round(max_range * 10, 1)) + var/far_volume = Clamp(max_range * 10, 30, 60) // Volume is based on explosion size and dist + far_volume += (dist > max_range * 2 ? 0 : 40) // add 40 volume if the mob is pretty close to the explosion + M.playsound_local(epicenter, 'sound/effects/explosionfar.ogg', far_volume, 1) - playsound(epicenter, 'sound/effects/explosionfar.ogg', 100, 1, round(devastation_range*2,1) ) - playsound(epicenter, "explosion", 100, 1, round(devastation_range,1) ) var/close = range(world.view+round(devastation_range,1), epicenter) // to all distanced mobs play a different sound @@ -48,7 +64,7 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa var/y0 = epicenter.y var/z0 = epicenter.z - for(var/turf/T in range(epicenter, max(devastation_range, heavy_impact_range, light_impact_range))) + for(var/turf/T in range(epicenter, max_range)) var/dist = cheap_pythag(T.x - x0,T.y - y0) if(dist < devastation_range) dist = 1