mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-22 03:27:46 +01:00
Explosion subsystem (#17499)
* Initial port * pause air * decoupled input from processing * explosion condition tweak * closer to original recursive code * accurate explosions * better defer calls * glob fix * fix * DON'T DO THAT * initial deferral code * small explosions ignored * lower thresholds * better thresholds again * forbid powernet defer during init, explosions too * don't block your own network regen * use procs * better thresholds, always defer at least * admin notice * subsytem updated * Allow removal from networks * defer till rebuild * dir * Update breaker_box.dm * no init means no init * then flag it... --------- Co-authored-by: Selis <12716288+ItsSelis@users.noreply.github.com> Co-authored-by: C.L. <killer65311@gmail.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
co-authored by
Selis
C.L.
Kashargul
parent
5fa1055b7c
commit
eba43f278c
@@ -1,63 +1,11 @@
|
||||
/client/proc/kaboom()
|
||||
var/power = tgui_input_number(src, "power?", "power?")
|
||||
var/turf/T = get_turf(src.mob)
|
||||
explosion_rec(T, power)
|
||||
explosion(T, power)
|
||||
|
||||
/obj
|
||||
var/explosion_resistance
|
||||
|
||||
/proc/explosion_rec(turf/epicenter, power)
|
||||
var/list/explosion_turfs = list()
|
||||
var/explosion_in_progress = 0
|
||||
|
||||
var/loopbreak = 0
|
||||
while(explosion_in_progress)
|
||||
if(loopbreak >= 15) return
|
||||
spawn(10)
|
||||
loopbreak++
|
||||
|
||||
if(power <= 0) return
|
||||
epicenter = get_turf(epicenter)
|
||||
if(!epicenter) return
|
||||
|
||||
message_admins("Explosion with size ([power]) in area [epicenter.loc.name] ([epicenter.x],[epicenter.y],[epicenter.z])")
|
||||
log_game("Explosion with size ([power]) in area [epicenter.loc.name] ")
|
||||
|
||||
playsound(epicenter, 'sound/effects/explosionfar.ogg', 100, 1, round(power*2,1) )
|
||||
playsound(epicenter, "explosion", 100, 1, round(power,1) )
|
||||
|
||||
explosion_in_progress = 1
|
||||
explosion_turfs = list()
|
||||
|
||||
explosion_turfs[epicenter] = power
|
||||
|
||||
//This steap handles the gathering of turfs which will be ex_act() -ed in the next step. It also ensures each turf gets the maximum possible amount of power dealt to it.
|
||||
for(var/direction in GLOB.cardinal)
|
||||
var/turf/T = get_step(epicenter, direction)
|
||||
T.explosion_spread(power - epicenter.explosion_resistance, direction, explosion_turfs)
|
||||
|
||||
//This step applies the ex_act effects for the explosion, as planned in the previous step.
|
||||
for(var/turf/T in explosion_turfs)
|
||||
if(explosion_turfs[T] <= 0) continue
|
||||
if(!T) continue
|
||||
|
||||
//Wow severity looks confusing to calculate... Fret not, I didn't leave you with any additional instructions or help. (just kidding, see the line under the calculation)
|
||||
var/severity = 4 - round(max(min( 3, ((explosion_turfs[T] - T.explosion_resistance) / (max(3,(power/3)))) ) ,1), 1) //sanity effective power on tile divided by either 3 or one third the total explosion power
|
||||
// One third because there are three power levels and I
|
||||
// want each one to take up a third of the crater
|
||||
var/x = T.x
|
||||
var/y = T.y
|
||||
var/z = T.z
|
||||
T.ex_act(severity)
|
||||
if(!T)
|
||||
T = locate(x,y,z)
|
||||
for(var/atom_movable in T.contents)
|
||||
var/atom/movable/AM = atom_movable
|
||||
if(AM && AM.simulated)
|
||||
AM.ex_act(severity)
|
||||
|
||||
explosion_in_progress = 0
|
||||
|
||||
/turf
|
||||
var/explosion_resistance
|
||||
|
||||
@@ -87,31 +35,3 @@
|
||||
|
||||
/turf/simulated/wall
|
||||
explosion_resistance = 10
|
||||
|
||||
//Code-wise, a safe value for power is something up to ~25 or ~30.. This does quite a bit of damage to the station.
|
||||
//direction is the direction that the spread took to come to this tile. So it is pointing in the main blast direction - meaning where this tile should spread most of it's force.
|
||||
/turf/proc/explosion_spread(power, direction, var/list/explosion_turfs)
|
||||
if(power <= 0)
|
||||
return
|
||||
if(src in explosion_turfs)
|
||||
if(explosion_turfs[src] >= power)
|
||||
return //The turf already sustained and spread a power greated than what we are dealing with. No point spreading again.
|
||||
explosion_turfs[src] = power
|
||||
|
||||
var/spread_power = power - src.explosion_resistance //This is the amount of power that will be spread to the tile in the direction of the blast
|
||||
for(var/obj/O in src)
|
||||
if(O.explosion_resistance)
|
||||
spread_power -= O.explosion_resistance
|
||||
|
||||
var/turf/T = get_step(src, direction)
|
||||
if(T)
|
||||
T.explosion_spread(spread_power, direction, explosion_turfs)
|
||||
T = get_step(src, turn(direction,90))
|
||||
if(T)
|
||||
T.explosion_spread(spread_power, turn(direction,90), explosion_turfs)
|
||||
T = get_step(src, turn(direction,-90))
|
||||
if(T)
|
||||
T.explosion_spread(spread_power, turn(direction,-90), explosion_turfs)
|
||||
|
||||
/turf/unsimulated/explosion_spread(power)
|
||||
return //So it doesn't get to the parent proc, which simulates explosions
|
||||
|
||||
Reference in New Issue
Block a user