Files
Paradise/code/datums/radiation_wave.dm
Migratingcocofruit ebf7fdbfd2 Radiation Rework (#28320)
* initial changes

* Rad wave is working. now to implement the rest

* Makes the waves square

* Makes wave square

* multiplies the strength in all instances of radiation_pulse by 4 because each pulse makes one wave instead of 4 now

* Undef thing and apply suggestion

* Make radiation_pulse() not radiate the radiation source and implements contamination

* Adds contamination to uranium walls and meteors

* Fixes stuff

* Handle some contamination on attack still need to take care of meteors

* Fixed the meteor stuff

* Introduce emission types

* moves contaminate_touch to an atom proc and renames it to contaminate_atom

* deduplicates some contamination code

* Move inherent radioactivity to a component and signals from the atom vars and behaviour

* fix some things with the new component

* Update inherent_radioactivity.dm

* implement contaminating things that hit things that are inherently radioactive

* window things

* adds emission type to the rad_act call

* Changes radiation insulation values on a bunch of stuff

* fixes radioactive component radiating the wrong type

* more adjustments

* refactros rad_act

* adjustments to collector power production

* Adds plastitaniumglass windows and makes further adjustments

* Adds sprites to the shards and plastitanium directional window

* Update misc_cleanables.dm

* removes alpha rad insulation from floor turfs

* Fixes a bug with the starting tile of radiation waves

* More adjustments

* Adjusting singularity rad production

* reduces window half life a bit to make power smoother and buffs full window rad conversion

* Strengthens gamma and beta radiation effect on mobs.

* Makes radsuit block radiation completely

* Fixes Geiger Counters

* Fixes contamination not irradiating the contaminated thing

* Fixes inherent radioactivity not processing. Also makes it stop processing when a nuke core is contained

* Fixes ghost contamination

* Adds info to the collector

* Handles alpha radiation better on humans and changes some instances of rad_act to base_rad_act

* oops

* adjustments and fixes to alpha rad handling on mobs

* Make collector info more compact

* Core no longer radiates and contaminates from within the nuke until the plates are removed

* Contamination no longer counts as being inside a mob(it is supposed to be surface level)

* Adds inherent radioactivity to a bunch of uranium things. makes it all process.

* Nerf full windows

* Adjustments to collector and fulltile window radiation absorption

* Reduces passive contamination, especially while on the floor

* Adds different rad types to the geiger counter and fixes a runtime

* Makes full tile windows strong again and disallows building them on top of collectors

* adds emissive blockers to the rad blacklist and gives windows and collectors priority when irradiating for increased consistency

* Gives each contamination type it's own color.

* Gives each contamination type it's own color.  And makes the rad hud display them separately

* Changes how much the radiation wave affects the source tile, adds decay for performance reasons and adjusts collector parameters as well as SM and singulo rad production

* improves performance at very high rad amounts

* Fixes supermatter sliver box not containing radiation

* Restores supermatter sliver to old behaviour(not inherently radioactive)

* Slight nerf to fulltile windows and removes an unnecessary multiplication from rad wave processing

* Removes redundant line from window rad act

* Fixes radiation waves ignoring walls

* fixes it better

* more adjustments to collector stats

* Adjustment to collector gamma absorption

* increases grille beta blocking

* Review changes
2025-03-02 20:34:45 +00:00

103 lines
4.0 KiB
Plaintext

#define WRAP_INDEX(index, length)((index - 1) % length + 1)
/datum/radiation_wave
/// The thing that spawned this radiation wave
var/source
/// The top left corner of the wave, from which we begin iteration on a step
var/turf/master_turf
/// How far we've moved
var/steps = 0
/// The strength at the origin. Multiplied by the weight of a tile to determine the strength of radiation there.
var/intensity
/// The direction of movement
var/move_dir
/// The directions to the side of the wave, stored for easy looping
var/list/__dirs
/// Weights of the current tiles in the step going clockwise from the top left corner. Starts as one tile with a weight of 1
var/list/weights = list(1)
/// Sum of all weights
var/weight_sum = 1
/// The type of particle emitted
var/emission_type = ALPHA_RAD
/datum/radiation_wave/New(atom/_source, _intensity = 0, _emission_type = ALPHA_RAD)
source = _source
master_turf = get_turf(_source)
intensity = _intensity
emission_type = _emission_type
START_PROCESSING(SSradiation, src)
/datum/radiation_wave/Destroy()
. = QDEL_HINT_IWILLGC
STOP_PROCESSING(SSradiation, src)
..()
/// Deals with wave propagation. Radiation waves always expand in a 90 degree cone
/datum/radiation_wave/process()
// If the wave is too weak to do anything
if(weight_sum * intensity < RAD_BACKGROUND_RADIATION)
qdel(src)
return
/// We start iteration from the top left corner of the current wave step
master_turf = get_step(master_turf, NORTHWEST)
if(!master_turf)
qdel(src)
return
steps++
var/list/new_weights = list()
var/turf/current_turf = master_turf
weight_sum = 0
var/weight_left
var/weight_center
var/weight_right
var/index
var/offset
var/walk_dir = EAST
var/ratio = steps > 1 ? (steps - 1) / steps : (1 / 8)
var/weight_length = length(weights)
// Iterate around the periphery of a square for each step
for(var/i in 0 to (8 * steps - 1))
// our index along the edge we are on, each corner starts a new edge.
index = (i % (2 * steps)) + 1
// Get weights for rear, right rear and left rear tiles if they were part of the previous step, where rear means towards the center and left and right are along the edge we are on
weight_left = index > 2 ? weights[WRAP_INDEX((index + offset - 2), weight_length)] : 0
weight_center = index > 1 ? weights[WRAP_INDEX((index + offset - 1), weight_length)] : 0
weight_right = index < (2 * steps) ? weights[WRAP_INDEX((index + offset), weight_length)] : 0
// The weight of the current tile the average of the weights of the tiles we checked for earlier
// And is reduced by irradiating things and getting blocked
if(weight_left + weight_center + weight_right)
new_weights += radiate(source, current_turf, (ratio) * (weight_left + weight_center + weight_right) / ((1 + (index > 1 && index < (2 * steps + 1) && steps > 1) + (index > 2 && index < (2 * steps)))), emission_type)
else
new_weights += 0
weight_sum += new_weights[i + 1]
// Advance to next turf
current_turf = get_step(current_turf, walk_dir)
// If we reached a corner turn to the right
if(index == (2 * steps))
walk_dir = turn(walk_dir, -90)
offset += 2 * (steps - 1)
weights = new_weights
// With the spread each step being linear waves can spread very far. This limits the distance for performace reasons
if(steps > RAD_DECAY_POINT)
intensity *= RAD_DECAY_RATE
/// Calls rad act on each relevant atom in the turf and returns the resulting weight for that tile after reduction by insulation
/datum/radiation_wave/proc/radiate(atom/source, turf/current_turf, weight, emission_type)
var/list/turf_atoms = list()
if(length(current_turf.contents))
turf_atoms = get_rad_contents(current_turf, emission_type)
else
turf_atoms = list(current_turf)
for(var/k in turf_atoms)
var/atom/thing = k
if(QDELETED(thing))
continue
weight = weight * thing.base_rad_act(source ,weight * intensity, emission_type)
// return the resulting weight if the radiation on the tile would end up greater than background
return (((weight * intensity) > RAD_BACKGROUND_RADIATION) ? weight : 0)
#undef WRAP_INDEX