Skip to content

Commit

Permalink
Взрывы
Browse files Browse the repository at this point in the history
  • Loading branch information
Lexanx committed Aug 12, 2024
1 parent 0bfe8f2 commit 3720744
Show file tree
Hide file tree
Showing 9 changed files with 482 additions and 246 deletions.
1 change: 1 addition & 0 deletions code/__defines/subsystem-priority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define SS_PRIORITY_PROCESSING 95 // Generic datum processor. Replaces objects processor.
#define SS_PRIORITY_PLANTS 90 // Plant processing, slow ticks.
#define SS_PRIORITY_VINES 50 // Spreading vine effects.
#define SS_PRIORITY_EXPLOSIVES 40 // Explosion processing.
#define SS_PRIORITY_PSYCHICS 45 // Psychic complexus processing.
#define SS_PRIORITY_NANO 40 // Updates to nanoui uis.
#define SS_PRIORITY_TURF 30 // Radioactive walls/blob.
Expand Down
10 changes: 10 additions & 0 deletions code/__defines/turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@
#define SMOOTH_BLACKLIST 3 //Smooth with all but a blacklist of subtypes

#define RANGE_TURFS(CENTER, RADIUS) block(locate(max(CENTER.x-(RADIUS), 1), max(CENTER.y-(RADIUS),1), CENTER.z), locate(min(CENTER.x+(RADIUS), world.maxx), min(CENTER.y+(RADIUS), world.maxy), CENTER.z))


#define RANGED_TURFS(RADIUS, CENTER) \
RECT_TURFS(RADIUS, RADIUS, CENTER)

#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \
block( \
locate(max((CENTER).x-(H_RADIUS),1), max((CENTER).y-(V_RADIUS),1), (CENTER).z), \
locate(min((CENTER).x+(H_RADIUS),world.maxx), min((CENTER).y+(V_RADIUS),world.maxy), (CENTER).z) \
)
2 changes: 1 addition & 1 deletion code/_global_vars/misc.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GLOBAL_LIST_EMPTY(all_observable_events)

// True if net rebuild will be called manually after an event.
GLOBAL_VAR_INIT(defer_powernet_rebuild, FALSE)
//GLOBAL_VAR_INIT(defer_powernet_rebuild, FALSE) //[SIERRA-REMOVE]

// Those networks can only be accessed by pre-existing terminals. AIs and new terminals can't use them.
GLOBAL_LIST_INIT(restricted_camera_networks, list(\
Expand Down
17 changes: 17 additions & 0 deletions code/controllers/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@

// [SIERRA-ADD]
var/static/shutdown_on_reboot = FALSE
var/static/use_spreading_explosions = TRUE //Defines whether the server uses iterative or circular explosions.

var/static/iterative_explosives_z_threshold = 15
var/static/iterative_explosives_z_multiplier = 0.25
var/static/iterative_explosives_z_subtraction = 4
// [/SIERRA-ADD]


Expand Down Expand Up @@ -898,6 +903,18 @@
// [SIERRA-ADD]
if ("shutdown_on_reboot")
shutdown_on_reboot = TRUE

if ("explosion_z_threshold")
iterative_explosives_z_threshold = text2num(value)

if ("explosion_z_mult")
iterative_explosives_z_multiplier = text2num(value)

if ("explosion_z_sub")
iterative_explosives_z_subtraction = text2num(value)

if ("use_spreading_explosions")
use_spreading_explosions = TRUE
// [/SIERRA-ADD]
// [SIERRA-ADD] - EX666_ECOSYSTEM
if ("overflow_server_url")
Expand Down
8 changes: 8 additions & 0 deletions code/controllers/controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@
return TRUE
statNext = time + 1 SECONDS
return FALSE

//[SIERRA-ADD]
// Called when SSexplosives begins processing explosions.
/datum/controller/proc/ExplosionStart()

// Called when SSexplosives finishes processing all queued explosions.
/datum/controller/proc/ExplosionEnd()
//[/SIERRA-ADD]
155 changes: 49 additions & 106 deletions code/game/objects/explosion.dm
Original file line number Diff line number Diff line change
@@ -1,108 +1,51 @@
#define EXPLOSION_RATIO_DEVASTATION 1
#define EXPLOSION_RATIO_HEAVY 2
#define EXPLOSION_RATIO_LIGHT 4
// explosion logic is in code/controllers/Processes/explosives.dm now


/proc/explosion(turf/epicenter, range, max_power = EX_ACT_DEVASTATING, adminlog = 1, z_transfer = UP|DOWN, shaped, turf_breaker)
set waitfor = FALSE

var/multi_z_scalar = 0.35
/proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, adminlog = 1, z_transfer = UP|DOWN, shaped, turf_breaker, spreading = config.use_spreading_explosions)
UNLINT(src = null) //so we don't abort once src is deleted
epicenter = get_turf(epicenter)
if(!epicenter) return

/// Range, in tiles, of `EX_ACT_DEVASTATING` damage.
var/devastation_range = 0
/// Range, in tiles, of `EX_ACT_HEAVY` damage.
var/heavy_impact_range = 0
/// Range, in tiles, of `EX_ACT_LIGHT` damage.
var/light_impact_range = 0
/// Ratio multiplier based on `max_power` and `range` used to determine the above three range values.
var/explosion_ratio = 0

switch (max_power)
if (EX_ACT_DEVASTATING)
explosion_ratio = range / (EXPLOSION_RATIO_DEVASTATION + EXPLOSION_RATIO_HEAVY + EXPLOSION_RATIO_LIGHT)
devastation_range = round(explosion_ratio * EXPLOSION_RATIO_DEVASTATION)
heavy_impact_range = round(explosion_ratio * EXPLOSION_RATIO_HEAVY)
light_impact_range = round(explosion_ratio * EXPLOSION_RATIO_LIGHT)
if (EX_ACT_HEAVY)
explosion_ratio = range / (EXPLOSION_RATIO_HEAVY + EXPLOSION_RATIO_LIGHT)
heavy_impact_range = round(explosion_ratio * EXPLOSION_RATIO_HEAVY)
light_impact_range = round(explosion_ratio * EXPLOSION_RATIO_LIGHT)
if (EX_ACT_LIGHT)
explosion_ratio = range
light_impact_range = range

// Handles recursive propagation of explosions.
if(z_transfer)
var/adj_dev = max(0, (multi_z_scalar * devastation_range) - (shaped ? 2 : 0) )
var/adj_heavy = max(0, (multi_z_scalar * heavy_impact_range) - (shaped ? 2 : 0) )
var/adj_light = max(0, (multi_z_scalar * light_impact_range) - (shaped ? 2 : 0) )
var/adj_range = adj_dev + adj_heavy + adj_light

var/adj_max_power
if (adj_dev)
adj_max_power = EX_ACT_DEVASTATING
else if (adj_heavy)
adj_max_power = EX_ACT_HEAVY
else
adj_max_power = EX_ACT_LIGHT

if(adj_dev > 0 || adj_heavy > 0)
if(HasAbove(epicenter.z) && z_transfer & UP)
explosion(GetAbove(epicenter), adj_range, adj_max_power, 0, UP, shaped)
if(HasBelow(epicenter.z) && z_transfer & DOWN)
explosion(GetBelow(epicenter), adj_range, adj_max_power, 0, DOWN, shaped)

var/max_range = max(devastation_range, heavy_impact_range, light_impact_range)

// Play sounds; we want sounds to be different depending on distance so we will manually do it ourselves.
// Stereo users will also hear the direction of the explosion!
// Calculate far explosion sound range. Only allow the sound effect for heavy/devastating explosions.
// 3/7/14 will calculate to 80 + 35
var/far_dist = 0
far_dist += heavy_impact_range * 5
far_dist += devastation_range * 20
var/frequency = get_rand_frequency()
for(var/mob/M in GLOB.player_list)
if(M.z == epicenter.z)
var/turf/M_turf = get_turf(M)
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, get_sfx("explosion"), 100, 1, frequency, falloff = 5) // get_sfx() is so that everyone gets the same sound
else if(dist <= far_dist)
var/far_volume = clamp(far_dist, 30, 50) // Volume is based on explosion size and dist
far_volume += (dist <= far_dist * 0.5 ? 50 : 0) // add 50 volume if the mob is pretty close to the explosion
M.playsound_local(epicenter, 'sound/effects/explosionfar.ogg', far_volume, 1, frequency, falloff = 5)

if(adminlog)
log_and_message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ([epicenter.x],[epicenter.y],[epicenter.z]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[epicenter.x];Y=[epicenter.y];Z=[epicenter.z]'>JMP</a>)")
var/approximate_intensity = (devastation_range * 3) + (heavy_impact_range * 2) + light_impact_range
// Large enough explosion. For performance reasons, powernets will be rebuilt manually
if(!GLOB.defer_powernet_rebuild && (approximate_intensity > 25))
GLOB.defer_powernet_rebuild = 1

if(heavy_impact_range > 1)
var/datum/effect/explosion/E = new
E.set_up(epicenter)
E.start()

var/power = devastation_range * 2 + heavy_impact_range + light_impact_range //The ranges add up, ie light 14 includes both heavy 7 and devestation 3. So this calculation means devestation counts for 4, heavy for 2 and light for 1 power, giving us a cap of 27 power.
explosion_rec(epicenter, power, shaped)

sleep(8)

return 1



/proc/secondaryexplosion(turf/epicenter, range)
for(var/turf/tile in range(range, epicenter))
tile.ex_act(EX_ACT_HEAVY)


#undef EXPLOSION_RATIO_DEVASTATION
#undef EXPLOSION_RATIO_HEAVY
#undef EXPLOSION_RATIO_LIGHT
var/datum/explosiondata/data = new
data.epicenter = epicenter
data.devastation_range = devastation_range
data.heavy_impact_range = heavy_impact_range
data.light_impact_range = light_impact_range
data.flash_range = flash_range
data.adminlog = adminlog
data.z_transfer = z_transfer
data.spreading = spreading
data.rec_pow = max(0,devastation_range) * 2 + max(0,heavy_impact_range) + max(0,light_impact_range)

// queue work
SSexplosives.queue(data)

//Machines which report explosions.
for(var/thing in doppler_arrays)
var/obj/machinery/doppler_array/Array = thing
Array.sense_explosion(epicenter.x,epicenter.y,epicenter.z,devastation_range,heavy_impact_range,light_impact_range)

// == Recursive Explosions stuff ==

/client/proc/kaboom()
var/power = input(src, "power?", "power?") as num
var/turf/T = get_turf(src.mob)
var/datum/explosiondata/d = new
d.spreading = TRUE
d.epicenter = T
d.rec_pow = power
SSexplosives.queue(d)

/atom
var/explosion_resistance

/turf/space
explosion_resistance = 3

/turf/simulated/open
explosion_resistance = 3

/turf/simulated/floor
explosion_resistance = 1

/turf/simulated/mineral
explosion_resistance = 2

/turf/simulated/wall
explosion_resistance = 10
Loading

0 comments on commit 3720744

Please sign in to comment.