mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-25 09:41:29 +00:00
runtime error: Cannot execute null.ex act(). proc name: explosion (/proc/explosion) source file: explosion.dm,52 usr: 0 src: null call stack: explosion(space (133,173,1) (/turf/space), 4, 5, 6, 7, 0) git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4632 316c924e-a436-60f5-8080-3fe189b3f50e
77 lines
3.1 KiB
Plaintext
77 lines
3.1 KiB
Plaintext
//TODO: Flash range does nothing currently
|
|
|
|
//A very crude linear approximatiaon of pythagoras theorem.
|
|
/proc/cheap_pythag(var/dx, var/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/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1)
|
|
src = null //so we don't abort once src is deleted
|
|
spawn(0)
|
|
var/start = world.timeofday
|
|
epicenter = get_turf(epicenter)
|
|
if(!epicenter) return
|
|
|
|
if(adminlog)
|
|
message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ([epicenter.x],[epicenter.y],[epicenter.z])")
|
|
log_game("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ")
|
|
|
|
playsound(epicenter, 'sound/effects/explosionfar.ogg', 100, 1, round(devastation_range*2,1) )
|
|
playsound(epicenter, "explosion", 100, 1, round(devastation_range,1) )
|
|
|
|
|
|
var/lighting_controller_was_processing = lighting_controller.processing //Pause the lighting updates for a bit
|
|
lighting_controller.processing = 0
|
|
var/powernet_rebuild_was_deferred_already = defer_powernet_rebuild
|
|
if(defer_powernet_rebuild != 2)
|
|
defer_powernet_rebuild = 1
|
|
|
|
if(heavy_impact_range > 1)
|
|
var/datum/effect/system/explosion/E = new/datum/effect/system/explosion()
|
|
E.set_up(epicenter)
|
|
E.start()
|
|
|
|
var/x0 = epicenter.x
|
|
var/y0 = epicenter.y
|
|
var/z0 = epicenter.z
|
|
|
|
for(var/turf/T in range(epicenter, max(devastation_range, heavy_impact_range, light_impact_range)))
|
|
var/dist = cheap_pythag(T.x - x0,T.y - y0)
|
|
|
|
if(dist < devastation_range) dist = 1
|
|
else if(dist < heavy_impact_range) dist = 2
|
|
else if(dist < light_impact_range) dist = 3
|
|
else continue
|
|
|
|
T.ex_act(dist)
|
|
if(T)
|
|
for(var/atom_movable in T.contents) //bypass type checking since only atom/movable can be contained by turfs anyway
|
|
var/atom/movable/AM = atom_movable
|
|
if(AM) AM.ex_act(dist)
|
|
|
|
var/took = (world.timeofday-start)/10
|
|
//You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare
|
|
if(Debug2) world.log << "## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [took] seconds."
|
|
|
|
//Machines which report explosions.
|
|
for(var/i,i<=doppler_arrays.len,i++)
|
|
var/obj/machinery/doppler_array/Array = doppler_arrays[i]
|
|
if(Array)
|
|
Array.sense_explosion(x0,y0,z0,devastation_range,heavy_impact_range,light_impact_range,took)
|
|
|
|
sleep(8)
|
|
|
|
if(!lighting_controller.processing) lighting_controller.processing = lighting_controller_was_processing
|
|
if(!powernet_rebuild_was_deferred_already)
|
|
if(defer_powernet_rebuild != 2)
|
|
defer_powernet_rebuild = 0
|
|
|
|
return 1
|
|
|
|
|
|
|
|
proc/secondaryexplosion(turf/epicenter, range)
|
|
for(var/turf/tile in range(range, epicenter))
|
|
tile.ex_act(2) |