From 278a3369c5bf8b308b8e264989cdf1af78006e1c Mon Sep 17 00:00:00 2001 From: phil235 Date: Thu, 6 Aug 2015 16:53:11 +0200 Subject: [PATCH 1/2] Fixes reactionary explosion not acting correctly. Fixes indestructible turfs not blocking explosions. Replacing cheap_pythag by cheap_hypothenuse --- code/game/objects/explosion.dm | 13 ++++--------- code/game/turfs/turf.dm | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index cf714ed52eb..5502ef807ee 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -1,11 +1,5 @@ //TODO: Flash range does nothing currently -//A very crude linear approximatiaon of pythagoras theorem. -/proc/cheap_pythag(dx, dy) - dx = abs(dx); dy = abs(dy); - if(dx>=dy) return dx + (0.5*dy) //The longest side add half the shortest side approximates the hypotenuse - else return dy + (0.5*dx) - /proc/trange(Dist=0,turf/Center=null)//alternative to range (ONLY processes turfs and thus less intensive) if(Center==null) return @@ -89,7 +83,7 @@ for(var/turf/T in trange(max_range, epicenter)) - var/dist = cheap_pythag(T.x - x0,T.y - y0) + var/dist = cheap_hypotenuse(T.x, T.y, x0, y0) if(config.reactionary_explosions) var/turf/Trajectory = T @@ -123,7 +117,8 @@ if(flame_dist && prob(40) && !istype(T, /turf/space) && !T.density) PoolOrNew(/obj/effect/hotspot, T) //Mostly for ambience! if(dist > 0) - T.ex_act(dist) + spawn(0) + T.ex_act(dist) //--- THROW ITEMS AROUND --- @@ -196,7 +191,7 @@ var/list/wipe_colours = list() for(var/turf/T in trange(max_range, epicenter)) wipe_colours += T - var/dist = cheap_pythag(T.x - x0, T.y - y0) + var/dist = cheap_hypotenuse(T.x, T.y, x0, y0) if(newmode == "Yes") var/turf/TT = T diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 2bcfe8d976f..a9ab0f0b0b1 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -280,6 +280,7 @@ density = 1 blocks_air = 1 opacity = 1 + explosion_block = 50 /turf/indestructible/splashscreen name = "Space Station 13" From 0951213f85092b4cb8e6a53e1845492344465848 Mon Sep 17 00:00:00 2001 From: phil235 Date: Mon, 17 Aug 2015 02:11:27 +0200 Subject: [PATCH 2/2] Use Krausus' fix for Paradise station to replace my laggy spawn(0) fix. --- code/game/objects/explosion.dm | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index 5502ef807ee..682fc5293fe 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -35,6 +35,7 @@ if(!epicenter) return var/max_range = max(devastation_range, heavy_impact_range, light_impact_range, flame_range) + var/list/cached_exp_block = list() if(adminlog) message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range], [flame_range]) in area [epicenter.loc.name] ([epicenter.x],[epicenter.y],[epicenter.z])") @@ -81,7 +82,23 @@ var/y0 = epicenter.y var/z0 = epicenter.z - for(var/turf/T in trange(max_range, epicenter)) + var/list/affected_turfs = trange(max_range, epicenter) + + if(config.reactionary_explosions) + for(var/turf/T in affected_turfs) // we cache the explosion block rating of every turf in the explosion area + cached_exp_block[T] = 0 + if(T.density && T.explosion_block) + cached_exp_block[T] += T.explosion_block + + for(var/obj/machinery/door/D in T) + if(D.density && D.explosion_block) + cached_exp_block[T] += D.explosion_block + + for(var/obj/structure/window/W in T) + if(W.reinf && W.fulltile) + cached_exp_block[T] += W.explosion_block + + for(var/turf/T in affected_turfs) var/dist = cheap_hypotenuse(T.x, T.y, x0, y0) @@ -89,16 +106,7 @@ var/turf/Trajectory = T while(Trajectory != epicenter) Trajectory = get_step_towards(Trajectory, epicenter) - if(Trajectory.density && Trajectory.explosion_block) - dist += Trajectory.explosion_block - - for(var/obj/machinery/door/D in Trajectory) - if(D.density && D.explosion_block) - dist += D.explosion_block - - for(var/obj/structure/window/W in Trajectory) - if(W.reinf && W.fulltile) - dist += W.explosion_block + dist += cached_exp_block[Trajectory] var/flame_dist = 0 var/throw_dist = dist @@ -117,8 +125,7 @@ if(flame_dist && prob(40) && !istype(T, /turf/space) && !T.density) PoolOrNew(/obj/effect/hotspot, T) //Mostly for ambience! if(dist > 0) - spawn(0) - T.ex_act(dist) + T.ex_act(dist) //--- THROW ITEMS AROUND ---