Files
Paradise/code/game/objects/explosion.dm
elly1989@rocketmail.com 3cbd05ddef Changed circledistance a bit, talk about ambiguous proc-names...it has nothing to do with circles! It's now called approx_dist and uses some magic constants to avoid those god-awful sqrts and powers which were called for N^2 turfs during explosions. It should approximate the distance between two points fairly accurately using a (surprisingly accurate) linear approximation of pythagoras theorem. C:
Changed RoundExplosions to a temporary define named USE_CIRCULAR_EXPLOSIONS which is a lot more intuitive and less confusing. Removing this define will compile square explosions code instead of circular ones. (So the cost of having a choice between circular/square is seen at compile-time not at run-time)

Fixed aliums being able to pick up storage objects such as bags/boxes/pillboxes and such.

Fixed unbuckling yourself from beds (via clicking the bed). You can also unbuckle yourself via resisting because beds are hard to click on when you're lying on them and they're covered in a sheet.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3854 316c924e-a436-60f5-8080-3fe189b3f50e
2012-06-18 07:37:50 +00:00

83 lines
2.7 KiB
Plaintext

#define USE_CIRCULAR_EXPLOSIONS 1
//TODO: Flash range does nothing currently
proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1)
if(!epicenter) return
spawn(0)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 1
if (!istype(epicenter, /turf))
epicenter = get_turf(epicenter.loc)
playsound(epicenter.loc, 'explosionfar.ogg', 100, 1, round(devastation_range*2,1) )
playsound(epicenter.loc, "explosion", 100, 1, round(devastation_range,1) )
if (adminlog)
message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ")
log_game("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ")
tension_master.explosion()
if(heavy_impact_range > 1)
var/datum/effect/system/explosion/E = new/datum/effect/system/explosion()
E.set_up(epicenter)
E.start()
var/list/expTurfs = list() // All turfs being affected by the explosion (not flash range)
#ifdef USE_CIRCULAR_EXPLOSIONS
expTurfs = circlerangeturfs(epicenter, max(devastation_range, heavy_impact_range, light_impact_range))
#else
expTurfs = range(epicenter, max(devastation_range, heavy_impact_range, light_impact_range))
#endif
// Hello future editors, please note that 1000 calls to spawn will not speed this up, but this exact amount has been tested
// Now, tonnes of calls to spawn will allow other stuff to happen, but I believe we may as well let explosions
// Get over with and blow up like an explosion would
var/list/dTurfs = list()
var/list/hTurfs = list()
var/list/lTurfs = list()
for(var/turf/T in expTurfs) // This doesn't slow it down at all, even 100,100,100 bombs
var/dist = approx_dist(epicenter, T)
if(dist < devastation_range)
dTurfs.Add(T)
else if(dist < heavy_impact_range)
hTurfs.Add(T)
else // The expTurfs list only has turfs that are in it's range, so no if here for light_impact
lTurfs.Add(T)
spawn()
for(var/turf/T in dTurfs)
if(prob(10))
T.ex_act(2)
else
T.ex_act(1)
for(var/atom/object in T.contents)
object.ex_act(1)
spawn()
for(var/turf/T in hTurfs)
T.ex_act(2)
for(var/atom/object in T.contents)
object.ex_act(2)
spawn()
for(var/turf/T in lTurfs)
T.ex_act(3)
for(var/atom/object in T.contents)
object.ex_act(3)
if(defer_powernet_rebuild != 2)
defer_powernet_rebuild = 0
return 1
#undef USE_CIRCULAR_EXPLOSIONS
proc/secondaryexplosion(turf/epicenter, range)
for(var/turf/tile in range(range, epicenter))
tile.ex_act(2)