diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm
index 4896aed168..80e60404b2 100644
--- a/code/__defines/misc.dm
+++ b/code/__defines/misc.dm
@@ -347,10 +347,12 @@ var/global/list/##LIST_NAME = list();\
#define RCD_MAX_CAPACITY 30 * RCD_SHEETS_PER_MATTER_UNIT
// Radiation 'levels'. Used for the geiger counter, for visuals and sound. They are in different files so this goes here.
-#define RAD_LEVEL_LOW 0.01 // Around the level at which radiation starts to become harmful
-#define RAD_LEVEL_MODERATE 10
+#define RAD_LEVEL_LOW 0.5 // Around the level at which radiation starts to become harmful
+#define RAD_LEVEL_MODERATE 5
#define RAD_LEVEL_HIGH 25
-#define RAD_LEVEL_VERY_HIGH 50
+#define RAD_LEVEL_VERY_HIGH 75
+
+#define RADIATION_THRESHOLD_CUTOFF 0.1 // Radiation will not affect a tile when below this value.
//https://secure.byond.com/docs/ref/info.html#/atom/var/mouse_opacity
#define MOUSE_OPACITY_TRANSPARENT 0
diff --git a/code/controllers/Processes/radiation.dm b/code/controllers/Processes/radiation.dm
deleted file mode 100644
index 71d9c60233..0000000000
--- a/code/controllers/Processes/radiation.dm
+++ /dev/null
@@ -1,56 +0,0 @@
-/datum/controller/process/radiation
- var/repository/radiation/linked = null
-
-/datum/controller/process/radiation/setup()
- name = "radiation controller"
- schedule_interval = 20 // every 2 seconds
- linked = radiation_repository
-
-/datum/controller/process/radiation/doWork()
- sources_decay()
- cache_expires()
- irradiate_targets()
-
-// Step 1 - Sources Decay
-/datum/controller/process/radiation/proc/sources_decay()
- var/list/sources = linked.sources
- for(var/thing in sources)
- var/datum/radiation_source/S = thing
- if(QDELETED(S))
- sources.Remove(S)
- continue
- if(S.decay)
- S.update_rad_power(S.rad_power - config.radiation_decay_rate)
- if(S.rad_power <= config.radiation_lower_limit)
- sources.Remove(S)
- SCHECK // This scheck probably just wastes resources, but better safe than sorry in this case.
-
-// Step 2 - Cache Expires
-/datum/controller/process/radiation/proc/cache_expires()
- var/list/resistance_cache = linked.resistance_cache
- for(var/thing in resistance_cache)
- var/turf/T = thing
- if(QDELETED(T))
- resistance_cache.Remove(T)
- continue
- if((length(T.contents) + 1) != resistance_cache[T])
- resistance_cache.Remove(T) // If its stale REMOVE it! It will get added if its needed.
- SCHECK
-
-// Step 3 - Registered irradiatable things are checked for radiation
-/datum/controller/process/radiation/proc/irradiate_targets()
- var/list/registered_listeners = living_mob_list // For now just use this. Nothing else is interested anyway.
- if(length(linked.sources) > 0)
- for(var/thing in registered_listeners)
- var/atom/A = thing
- if(QDELETED(A))
- continue
- var/turf/T = get_turf(thing)
- var/rads = linked.get_rads_at_turf(T)
- if(rads)
- A.rad_act(rads)
- SCHECK
-
-/datum/controller/process/radiation/statProcess()
- ..()
- stat(null, "[linked.sources.len] sources, [linked.resistance_cache.len] cached turfs")
diff --git a/code/controllers/subsystems/radiation.dm b/code/controllers/subsystems/radiation.dm
new file mode 100644
index 0000000000..9a882e7f68
--- /dev/null
+++ b/code/controllers/subsystems/radiation.dm
@@ -0,0 +1,135 @@
+SUBSYSTEM_DEF(radiation)
+ name = "Radiation"
+ wait = 2 SECONDS
+ flags = SS_NO_INIT
+
+ var/list/sources = list() // all radiation source datums
+ var/list/sources_assoc = list() // Sources indexed by turf for de-duplication.
+ var/list/resistance_cache = list() // Cache of turf's radiation resistance.
+
+ var/tmp/list/current_sources = list()
+ var/tmp/list/current_res_cache = list()
+ var/tmp/list/listeners = list()
+
+/datum/controller/subsystem/radiation/fire(resumed = FALSE)
+ if (!resumed)
+ current_sources = sources.Copy()
+ current_res_cache = resistance_cache.Copy()
+ listeners = living_mob_list.Copy()
+
+ while(current_sources.len)
+ var/datum/radiation_source/S = current_sources[current_sources.len]
+ current_sources.len--
+
+ if(QDELETED(S))
+ sources -= S
+ else if(S.decay)
+ S.update_rad_power(S.rad_power - config.radiation_decay_rate)
+ if (MC_TICK_CHECK)
+ return
+
+ while(current_res_cache.len)
+ var/turf/T = current_res_cache[current_res_cache.len]
+ current_res_cache.len--
+
+ if(QDELETED(T))
+ resistance_cache -= T
+ else if((length(T.contents) + 1) != resistance_cache[T])
+ resistance_cache -= T // If its stale REMOVE it! It will get added if its needed.
+ if (MC_TICK_CHECK)
+ return
+
+ if(!sources.len)
+ listeners.Cut()
+
+ while(listeners.len)
+ var/atom/A = listeners[listeners.len]
+ listeners.len--
+
+ if(!QDELETED(A))
+ var/turf/T = get_turf(A)
+ var/rads = get_rads_at_turf(T)
+ if(rads)
+ A.rad_act(rads)
+ if (MC_TICK_CHECK)
+ return
+
+/datum/controller/subsystem/radiation/stat_entry()
+ ..("S:[sources.len], RC:[resistance_cache.len]")
+
+// Ray trace from all active radiation sources to T and return the strongest effect.
+/datum/controller/subsystem/radiation/proc/get_rads_at_turf(var/turf/T)
+ . = 0
+ if(!istype(T))
+ return
+
+ for(var/value in sources)
+ var/datum/radiation_source/source = value
+ if(source.rad_power < .)
+ continue // Already being affected by a stronger source
+ if(source.source_turf.z != T.z)
+ continue // Radiation is not multi-z
+ if(source.respect_maint)
+ var/area/A = T.loc
+ if(A.flags & RAD_SHIELDED)
+ continue // In shielded area
+
+ var/dist = get_dist(source.source_turf, T)
+ if(dist > source.range)
+ continue // Too far to possibly affect
+ if(source.flat)
+ . = max(., source.rad_power)
+ continue // No need to ray trace for flat field
+
+ // Okay, now ray trace to find resistence!
+ var/turf/origin = source.source_turf
+ var/working = source.rad_power
+ while(origin != T)
+ origin = get_step_towards(origin, T) //Raytracing
+ if(!resistance_cache[origin]) //Only get the resistance if we don't already know it.
+ origin.calc_rad_resistance()
+ if(origin.cached_rad_resistance)
+ working = round((working / (origin.cached_rad_resistance * config.radiation_resistance_multiplier)), 0.1)
+ if((working <= .) || (working <= RADIATION_THRESHOLD_CUTOFF))
+ break // Already affected by a stronger source (or its zero...)
+ . = max((working / (dist ** 2)), .) //Butchered version of the inverse square law. Works for this purpose
+ if(. <= RADIATION_THRESHOLD_CUTOFF)
+ . = 0
+
+// Add a radiation source instance to the repository. It will override any existing source on the same turf.
+/datum/controller/subsystem/radiation/proc/add_source(var/datum/radiation_source/S)
+ if(!isturf(S.source_turf))
+ return
+ var/datum/radiation_source/existing = sources_assoc[S.source_turf]
+ if(existing)
+ qdel(existing)
+ sources += S
+ sources_assoc[S.source_turf] = S
+
+// Creates a temporary radiation source that will decay
+/datum/controller/subsystem/radiation/proc/radiate(source, power) //Sends out a radiation pulse, taking walls into account
+ if(!(source && power)) //Sanity checking
+ return
+ var/datum/radiation_source/S = new()
+ S.source_turf = get_turf(source)
+ S.update_rad_power(power)
+ add_source(S)
+
+// Sets the radiation in a range to a constant value.
+/datum/controller/subsystem/radiation/proc/flat_radiate(source, power, range, var/respect_maint = FALSE)
+ if(!(source && power && range))
+ return
+ var/datum/radiation_source/S = new()
+ S.flat = TRUE
+ S.range = range
+ S.respect_maint = respect_maint
+ S.source_turf = get_turf(source)
+ S.update_rad_power(power)
+ add_source(S)
+
+// Irradiates a full Z-level. Hacky way of doing it, but not too expensive.
+/datum/controller/subsystem/radiation/proc/z_radiate(var/atom/source, power, var/respect_maint = FALSE)
+ if(!(power && source))
+ return
+ var/turf/epicentre = locate(round(world.maxx / 2), round(world.maxy / 2), source.z)
+ flat_radiate(epicentre, power, world.maxx, respect_maint)
\ No newline at end of file
diff --git a/code/datums/repositories/radiation.dm b/code/datums/repositories/radiation.dm
deleted file mode 100644
index 88510e0525..0000000000
--- a/code/datums/repositories/radiation.dm
+++ /dev/null
@@ -1,138 +0,0 @@
-var/global/repository/radiation/radiation_repository = new()
-
-/repository/radiation
- var/list/sources = list() // all radiation source datums
- var/list/sources_assoc = list() // Sources indexed by turf for de-duplication.
- var/list/resistance_cache = list() // Cache of turf's radiation resistance.
-
-// Describes a point source of radiation. Created either in response to a pulse of radiation, or over an irradiated atom.
-// Sources will decay over time, unless something is renewing their power!
-/datum/radiation_source
- var/turf/source_turf // Location of the radiation source.
- var/rad_power // Strength of the radiation being emitted.
- var/decay = TRUE // True for automatic decay. False if owner promises to handle it (i.e. supermatter)
- var/respect_maint = FALSE // True for not affecting RAD_SHIELDED areas.
- var/flat = FALSE // True for power falloff with distance.
- var/range // Cached maximum range, used for quick checks against mobs.
-
-/datum/radiation_source/Destroy()
- radiation_repository.sources -= src
- if(radiation_repository.sources_assoc[src.source_turf] == src)
- radiation_repository.sources_assoc -= src.source_turf
- src.source_turf = null
- . = ..()
-
-/datum/radiation_source/proc/update_rad_power(var/new_power = null)
- if(new_power == null || new_power == rad_power)
- return // No change
- else if(new_power <= 0)
- qdel(src) // Decayed to nothing
- else
- rad_power = new_power
- if(!flat)
- range = min(round(sqrt(rad_power / config.radiation_lower_limit)), 31) // R = rad_power / dist**2 - Solve for dist
-
-// Ray trace from all active radiation sources to T and return the strongest effect.
-/repository/radiation/proc/get_rads_at_turf(var/turf/T)
- if(!istype(T)) return 0
-
- . = 0
- for(var/value in sources)
- var/datum/radiation_source/source = value
- if(source.rad_power < .)
- continue // Already being affected by a stronger source
- if(source.source_turf.z != T.z)
- continue // Radiation is not multi-z
- var/dist = get_dist(source.source_turf, T)
- if(dist > source.range)
- continue // Too far to possibly affect
- if(source.respect_maint)
- var/atom/A = T.loc
- if(A.flags & RAD_SHIELDED)
- continue // In shielded area
- if(source.flat)
- . = max(., source.rad_power)
- continue // No need to ray trace for flat field
-
- // Okay, now ray trace to find resistence!
- var/turf/origin = source.source_turf
- var/working = source.rad_power
- while(origin != T)
- origin = get_step_towards(origin, T) //Raytracing
- if(!(origin in resistance_cache)) //Only get the resistance if we don't already know it.
- origin.calc_rad_resistance()
- working = max((working - (origin.cached_rad_resistance * config.radiation_resistance_multiplier)), 0)
- if(working <= .)
- break // Already affected by a stronger source (or its zero...)
- . = max((working * (1 / (dist ** 2))), .) //Butchered version of the inverse square law. Works for this purpose
-
-// Add a radiation source instance to the repository. It will override any existing source on the same turf.
-/repository/radiation/proc/add_source(var/datum/radiation_source/S)
- if(!isturf(S.source_turf))
- return
- var/datum/radiation_source/existing = sources_assoc[S.source_turf]
- if(existing)
- qdel(existing)
- sources += S
- sources_assoc[S.source_turf] = S
-
-// Creates a temporary radiation source that will decay
-/repository/radiation/proc/radiate(source, power) //Sends out a radiation pulse, taking walls into account
- if(!(source && power)) //Sanity checking
- return
- var/datum/radiation_source/S = new()
- S.source_turf = get_turf(source)
- S.update_rad_power(power)
- add_source(S)
-
-// Sets the radiation in a range to a constant value.
-/repository/radiation/proc/flat_radiate(source, power, range, var/respect_maint = FALSE)
- if(!(source && power && range))
- return
- var/datum/radiation_source/S = new()
- S.flat = TRUE
- S.range = range
- S.respect_maint = respect_maint
- S.source_turf = get_turf(source)
- S.update_rad_power(power)
- add_source(S)
-
-// Irradiates a full Z-level. Hacky way of doing it, but not too expensive.
-/repository/radiation/proc/z_radiate(var/atom/source, power, var/respect_maint = FALSE)
- if(!(power && source))
- return
- var/turf/epicentre = locate(round(world.maxx / 2), round(world.maxy / 2), source.z)
- flat_radiate(epicentre, power, world.maxx, respect_maint)
-
-/turf
- var/cached_rad_resistance = 0
-
-/turf/proc/calc_rad_resistance()
- cached_rad_resistance = 0
- for(var/obj/O in src.contents)
- if(O.rad_resistance) //Override
- cached_rad_resistance += O.rad_resistance
-
- else if(O.density) //So open doors don't get counted
- var/material/M = O.get_material()
- if(!M) continue
- cached_rad_resistance += M.weight + M.radiation_resistance
- // Looks like storing the contents length is meant to be a basic check if the cache is stale due to items enter/exiting. Better than nothing so I'm leaving it as is. ~Leshana
- radiation_repository.resistance_cache[src] = (length(contents) + 1)
-
-/turf/simulated/wall/calc_rad_resistance()
- radiation_repository.resistance_cache[src] = (length(contents) + 1)
- cached_rad_resistance = (density ? material.weight + material.radiation_resistance : 0)
-
-/obj
- var/rad_resistance = 0 // Allow overriding rad resistance
-
-// If people expand the system, this may be useful. Here as a placeholder until then
-/atom/proc/rad_act(var/severity)
- return 1
-
-/mob/living/rad_act(var/severity)
- if(severity)
- src.apply_effect(severity, IRRADIATE, src.getarmor(null, "rad"))
- for(var/atom/I in src)
- I.rad_act(severity)
diff --git a/code/game/gamemodes/meteor/meteors.dm b/code/game/gamemodes/meteor/meteors.dm
index 3be0ecdd8d..dd430a8989 100644
--- a/code/game/gamemodes/meteor/meteors.dm
+++ b/code/game/gamemodes/meteor/meteors.dm
@@ -272,7 +272,7 @@
if(explode)
explosion(src.loc, devastation_range = 0, heavy_impact_range = 0, light_impact_range = 4, flash_range = 6, adminlog = 0)
new /obj/effect/decal/cleanable/greenglow(get_turf(src))
- radiation_repository.radiate(src, 50)
+ SSradiation.radiate(src, 50)
// This meteor fries toasters.
/obj/effect/meteor/emp
diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm
index bd9229e2a1..a1f26485b9 100644
--- a/code/game/machinery/doors/airlock.dm
+++ b/code/game/machinery/doors/airlock.dm
@@ -359,7 +359,7 @@
/obj/machinery/door/airlock/uranium/process()
if(world.time > last_event+20)
if(prob(50))
- radiation_repository.radiate(src, rad_power)
+ SSradiation.radiate(src, rad_power)
last_event = world.time
..()
diff --git a/code/game/machinery/doors/blast_door.dm b/code/game/machinery/doors/blast_door.dm
index ea881323c8..bf201989fe 100644
--- a/code/game/machinery/doors/blast_door.dm
+++ b/code/game/machinery/doors/blast_door.dm
@@ -56,7 +56,7 @@
icon_state = icon_state_closed
else
icon_state = icon_state_open
- radiation_repository.resistance_cache.Remove(get_turf(src))
+ SSradiation.resistance_cache.Remove(get_turf(src))
return
// Has to be in here, comment at the top is older than the emag_act code on doors proper
diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm
index 2a2a6b3eaf..70949341ba 100644
--- a/code/game/machinery/doors/door.dm
+++ b/code/game/machinery/doors/door.dm
@@ -378,7 +378,7 @@
icon_state = "door1"
else
icon_state = "door0"
- radiation_repository.resistance_cache.Remove(get_turf(src))
+ SSradiation.resistance_cache.Remove(get_turf(src))
return
diff --git a/code/game/mecha/combat/phazon.dm b/code/game/mecha/combat/phazon.dm
index b54368a75e..3ada4824f7 100644
--- a/code/game/mecha/combat/phazon.dm
+++ b/code/game/mecha/combat/phazon.dm
@@ -133,7 +133,7 @@
..()
if(phasing)
phasing = FALSE
- radiation_repository.radiate(get_turf(src), 30)
+ SSradiation.radiate(get_turf(src), 30)
log_append_to_last("WARNING: BLUESPACE DRIVE INSTABILITY DETECTED. DISABLING DRIVE.",1)
visible_message("The [src.name] appears to flicker, before its silhouette stabilizes!")
return
diff --git a/code/game/mecha/equipment/tools/tools.dm b/code/game/mecha/equipment/tools/tools.dm
index f821945144..73f7356ade 100644
--- a/code/game/mecha/equipment/tools/tools.dm
+++ b/code/game/mecha/equipment/tools/tools.dm
@@ -1201,7 +1201,7 @@
/datum/global_iterator/mecha_generator/nuclear/process(var/obj/item/mecha_parts/mecha_equipment/generator/nuclear/EG)
if(..())
- radiation_repository.radiate(EG, (EG.rad_per_cycle * 3))
+ SSradiation.radiate(EG, (EG.rad_per_cycle * 3))
return 1
diff --git a/code/game/objects/effects/map_effects/radiation_emitter.dm b/code/game/objects/effects/map_effects/radiation_emitter.dm
index 367c27445d..74b3c39589 100644
--- a/code/game/objects/effects/map_effects/radiation_emitter.dm
+++ b/code/game/objects/effects/map_effects/radiation_emitter.dm
@@ -13,7 +13,7 @@
return ..()
/obj/effect/map_effect/radiation_emitter/process()
- radiation_repository.radiate(src, radiation_power)
+ SSradiation.radiate(src, radiation_power)
/obj/effect/map_effect/radiation_emitter/strong
radiation_power = 100
\ No newline at end of file
diff --git a/code/game/objects/items/devices/defib.dm b/code/game/objects/items/devices/defib.dm
index 26fb1b69aa..b66c4a3776 100644
--- a/code/game/objects/items/devices/defib.dm
+++ b/code/game/objects/items/devices/defib.dm
@@ -610,12 +610,12 @@
return 1
/obj/item/weapon/shockpaddles/standalone/checked_use(var/charge_amt)
- radiation_repository.radiate(src, charge_amt/12) //just a little bit of radiation. It's the price you pay for being powered by magic I guess
+ SSradiation.radiate(src, charge_amt/12) //just a little bit of radiation. It's the price you pay for being powered by magic I guess
return 1
/obj/item/weapon/shockpaddles/standalone/process()
if(fail_counter > 0)
- radiation_repository.radiate(src, fail_counter--)
+ SSradiation.radiate(src, fail_counter--)
else
STOP_PROCESSING(SSobj, src)
diff --git a/code/game/objects/items/devices/geiger.dm b/code/game/objects/items/devices/geiger.dm
index 76697ddba3..92ff449855 100644
--- a/code/game/objects/items/devices/geiger.dm
+++ b/code/game/objects/items/devices/geiger.dm
@@ -28,7 +28,7 @@
/obj/item/device/geiger/proc/get_radiation()
if(!scanning)
return
- radiation_count = radiation_repository.get_rads_at_turf(get_turf(src))
+ radiation_count = SSradiation.get_rads_at_turf(get_turf(src))
update_icon()
update_sound()
diff --git a/code/game/objects/items/poi_items.dm b/code/game/objects/items/poi_items.dm
index 6fd6d7debd..c12a3a655a 100644
--- a/code/game/objects/items/poi_items.dm
+++ b/code/game/objects/items/poi_items.dm
@@ -13,7 +13,7 @@
return ..()
/obj/item/poi/pascalb/process()
- radiation_repository.radiate(src, 5)
+ SSradiation.radiate(src, 5)
/obj/item/poi/pascalb/Destroy()
STOP_PROCESSING(SSobj, src)
@@ -41,7 +41,7 @@
return ..()
/obj/item/poi/brokenoldreactor/process()
- radiation_repository.radiate(src, 25)
+ SSradiation.radiate(src, 25)
/obj/item/poi/brokenoldreactor/Destroy()
STOP_PROCESSING(SSobj, src)
diff --git a/code/game/objects/items/weapons/tools/crowbar.dm b/code/game/objects/items/weapons/tools/crowbar.dm
index 73b62f0741..fab0a6fb98 100644
--- a/code/game/objects/items/weapons/tools/crowbar.dm
+++ b/code/game/objects/items/weapons/tools/crowbar.dm
@@ -64,7 +64,7 @@
/obj/item/weapon/tool/crowbar/hybrid/is_crowbar()
if(prob(10))
var/turf/T = get_turf(src)
- radiation_repository.radiate(get_turf(src), 5)
+ SSradiation.radiate(get_turf(src), 5)
T.visible_message("\The [src] shudders!")
return FALSE
return TRUE
diff --git a/code/game/objects/items/weapons/tools/screwdriver.dm b/code/game/objects/items/weapons/tools/screwdriver.dm
index a9bdd6cee8..1969987ff9 100644
--- a/code/game/objects/items/weapons/tools/screwdriver.dm
+++ b/code/game/objects/items/weapons/tools/screwdriver.dm
@@ -108,7 +108,7 @@
/obj/item/weapon/tool/screwdriver/hybrid/is_screwdriver()
if(prob(10))
var/turf/T = get_turf(src)
- radiation_repository.radiate(get_turf(src), 5)
+ SSradiation.radiate(get_turf(src), 5)
T.visible_message("\The [src] shudders!")
return FALSE
return TRUE
diff --git a/code/game/objects/items/weapons/tools/wirecutters.dm b/code/game/objects/items/weapons/tools/wirecutters.dm
index 181c786c4c..4d61609db4 100644
--- a/code/game/objects/items/weapons/tools/wirecutters.dm
+++ b/code/game/objects/items/weapons/tools/wirecutters.dm
@@ -88,7 +88,7 @@
/obj/item/weapon/tool/wirecutters/hybrid/is_wirecutter()
if(prob(10))
var/turf/T = get_turf(src)
- radiation_repository.radiate(get_turf(src), 5)
+ SSradiation.radiate(get_turf(src), 5)
T.visible_message("\The [src] shudders!")
return FALSE
return TRUE
diff --git a/code/game/objects/items/weapons/tools/wrench.dm b/code/game/objects/items/weapons/tools/wrench.dm
index 652e32cf75..3f02a2f8b3 100644
--- a/code/game/objects/items/weapons/tools/wrench.dm
+++ b/code/game/objects/items/weapons/tools/wrench.dm
@@ -44,7 +44,7 @@
/obj/item/weapon/tool/wrench/hybrid/is_wrench()
if(prob(10))
var/turf/T = get_turf(src)
- radiation_repository.radiate(get_turf(src), 5)
+ SSradiation.radiate(get_turf(src), 5)
T.visible_message("\The [src] shudders!")
return FALSE
return TRUE
diff --git a/code/game/objects/structures/girders.dm b/code/game/objects/structures/girders.dm
index 072dd43de6..2648723385 100644
--- a/code/game/objects/structures/girders.dm
+++ b/code/game/objects/structures/girders.dm
@@ -38,7 +38,7 @@
if(!total_radiation)
return
- radiation_repository.radiate(src, total_radiation)
+ SSradiation.radiate(src, total_radiation)
return total_radiation
diff --git a/code/game/objects/structures/simple_doors.dm b/code/game/objects/structures/simple_doors.dm
index e9ba05ecc9..ff8dbe141e 100644
--- a/code/game/objects/structures/simple_doors.dm
+++ b/code/game/objects/structures/simple_doors.dm
@@ -196,7 +196,7 @@
/obj/structure/simple_door/process()
if(!material.radioactivity)
return
- radiation_repository.radiate(src, round(material.radioactivity/3))
+ SSradiation.radiate(src, round(material.radioactivity/3))
/obj/structure/simple_door/iron/New(var/newloc,var/material_name)
..(newloc, "iron")
diff --git a/code/game/turfs/simulated/wall_attacks.dm b/code/game/turfs/simulated/wall_attacks.dm
index bd6adfe32f..8599def4a5 100644
--- a/code/game/turfs/simulated/wall_attacks.dm
+++ b/code/game/turfs/simulated/wall_attacks.dm
@@ -7,7 +7,7 @@
if(can_open == WALL_OPENING)
return
- radiation_repository.resistance_cache.Remove(src)
+ SSradiation.resistance_cache.Remove(src)
if(density)
can_open = WALL_OPENING
diff --git a/code/game/turfs/simulated/wall_icon.dm b/code/game/turfs/simulated/wall_icon.dm
index b8a0980de4..f277ea79f5 100644
--- a/code/game/turfs/simulated/wall_icon.dm
+++ b/code/game/turfs/simulated/wall_icon.dm
@@ -26,7 +26,7 @@
else if(material.opacity < 0.5 && opacity)
set_light(0)
- radiation_repository.resistance_cache.Remove(src)
+ SSradiation.resistance_cache.Remove(src)
update_connections(1)
update_icon()
diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm
index 1847767083..bf5f711b20 100644
--- a/code/game/turfs/simulated/walls.dm
+++ b/code/game/turfs/simulated/walls.dm
@@ -274,7 +274,7 @@
if(!total_radiation)
return
- radiation_repository.radiate(src, total_radiation)
+ SSradiation.radiate(src, total_radiation)
return total_radiation
/turf/simulated/wall/proc/burn(temperature)
diff --git a/code/modules/blob2/overmind/types.dm b/code/modules/blob2/overmind/types.dm
index 6049ccfc72..49b968cfcc 100644
--- a/code/modules/blob2/overmind/types.dm
+++ b/code/modules/blob2/overmind/types.dm
@@ -593,7 +593,7 @@
attack_verb = "splashes"
/datum/blob_type/radioactive_ooze/on_pulse(var/obj/structure/blob/B)
- radiation_repository.radiate(B, 200)
+ SSradiation.radiate(B, 200)
/datum/blob_type/volatile_alluvium
name = "volatile alluvium"
diff --git a/code/modules/events/radiation_storm.dm b/code/modules/events/radiation_storm.dm
index e778814e11..85bc8cff23 100644
--- a/code/modules/events/radiation_storm.dm
+++ b/code/modules/events/radiation_storm.dm
@@ -31,7 +31,7 @@
/datum/event/radiation_storm/proc/radiate()
var/radiation_level = rand(15, 35)
for(var/z in using_map.station_levels)
- radiation_repository.z_radiate(locate(1, 1, z), radiation_level, 1)
+ SSradiation.z_radiate(locate(1, 1, z), radiation_level, 1)
for(var/mob/living/carbon/C in living_mob_list)
var/area/A = get_area(C)
diff --git a/code/modules/gamemaster/actions/radiation_storm.dm b/code/modules/gamemaster/actions/radiation_storm.dm
index 243af5dbee..678ad16ab6 100644
--- a/code/modules/gamemaster/actions/radiation_storm.dm
+++ b/code/modules/gamemaster/actions/radiation_storm.dm
@@ -41,7 +41,7 @@
/datum/gm_action/radiation_storm/proc/radiate()
var/radiation_level = rand(15, 35)
for(var/z in using_map.station_levels)
- radiation_repository.z_radiate(locate(1, 1, z), radiation_level, 1)
+ SSradiation.z_radiate(locate(1, 1, z), radiation_level, 1)
for(var/mob/living/carbon/C in living_mob_list)
var/area/A = get_area(C)
diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm
index 4ca50889ea..64eee7ddbe 100644
--- a/code/modules/materials/material_sheets.dm
+++ b/code/modules/materials/material_sheets.dm
@@ -278,7 +278,7 @@
. = ..()
update_mass()
- radiation_repository.radiate(src, 5 + amount)
+ SSradiation.radiate(src, 5 + amount)
var/mob/living/M = user
if(!istype(M))
return
@@ -305,11 +305,11 @@
/obj/item/stack/material/supermatter/ex_act(severity) // An incredibly hard to manufacture material, SM chunks are unstable by their 'stabilized' nature.
if(prob((4 / severity) * 20))
- radiation_repository.radiate(get_turf(src), amount * 4)
+ SSradiation.radiate(get_turf(src), amount * 4)
explosion(get_turf(src),round(amount / 12) , round(amount / 6), round(amount / 3), round(amount / 25))
qdel(src)
return
- radiation_repository.radiate(get_turf(src), amount * 2)
+ SSradiation.radiate(get_turf(src), amount * 2)
..()
/obj/item/stack/material/wood
diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm
index f011181479..7c9cd245cf 100644
--- a/code/modules/mining/mine_turfs.dm
+++ b/code/modules/mining/mine_turfs.dm
@@ -574,7 +574,7 @@ turf/simulated/mineral/floor/light_corner
M.flash_eyes()
if(prob(50))
M.Stun(5)
- radiation_repository.flat_radiate(src, 25, 100)
+ SSradiation.flat_radiate(src, 25, 100)
if(prob(25))
excavate_find(prob(5), finds[1])
else if(rand(1,500) == 1)
diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm
index 6fb7778c9e..69d6ed2592 100644
--- a/code/modules/mob/dead/observer/observer.dm
+++ b/code/modules/mob/dead/observer/observer.dm
@@ -461,7 +461,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
var/turf/t = get_turf(src)
if(t)
- var/rads = radiation_repository.get_rads_at_turf(t)
+ var/rads = SSradiation.get_rads_at_turf(t)
to_chat(src, "Radiation level: [rads ? rads : "0"] Bq.")
diff --git a/code/modules/mob/living/simple_animal/slime/subtypes.dm b/code/modules/mob/living/simple_animal/slime/subtypes.dm
index 18b43dc33c..75f33cdcef 100644
--- a/code/modules/mob/living/simple_animal/slime/subtypes.dm
+++ b/code/modules/mob/living/simple_animal/slime/subtypes.dm
@@ -500,7 +500,7 @@
..()
/mob/living/simple_animal/slime/green/proc/irradiate()
- radiation_repository.radiate(src, rads)
+ SSradiation.radiate(src, rads)
/mob/living/simple_animal/slime/pink
diff --git a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm
index fe148b544b..b0988c28dd 100644
--- a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm
+++ b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm
@@ -527,7 +527,7 @@
..()
/mob/living/simple_mob/slime/xenobio/green/proc/irradiate()
- radiation_repository.radiate(src, rads)
+ SSradiation.radiate(src, rads)
diff --git a/code/modules/planet/sif.dm b/code/modules/planet/sif.dm
index e913da00cb..c8d42a6fce 100644
--- a/code/modules/planet/sif.dm
+++ b/code/modules/planet/sif.dm
@@ -555,4 +555,4 @@ var/datum/planet/sif/planet_sif = null
if(!istype(T))
return
if(T.outdoors)
- radiation_repository.radiate(T, rand(fallout_rad_low, fallout_rad_high))
\ No newline at end of file
+ SSradiation.radiate(T, rand(fallout_rad_low, fallout_rad_high))
\ No newline at end of file
diff --git a/code/modules/power/fusion/core/core_field.dm b/code/modules/power/fusion/core/core_field.dm
index f0eca3add6..5444c46b03 100644
--- a/code/modules/power/fusion/core/core_field.dm
+++ b/code/modules/power/fusion/core/core_field.dm
@@ -313,7 +313,7 @@
radiation += plasma_temperature/2
plasma_temperature = 0
- radiation_repository.radiate(src, radiation)
+ SSradiation.radiate(src, radiation)
Radiate()
/obj/effect/fusion_em_field/proc/Radiate()
@@ -522,7 +522,7 @@
//Reaction radiation is fairly buggy and there's at least three procs dealing with radiation here, this is to ensure constant radiation output.
/obj/effect/fusion_em_field/proc/radiation_scale()
- radiation_repository.radiate(src, 2 + plasma_temperature / PLASMA_TEMP_RADIATION_DIVISIOR)
+ SSradiation.radiate(src, 2 + plasma_temperature / PLASMA_TEMP_RADIATION_DIVISIOR)
//Somehow fixing the radiation issue managed to break this, but moving it to it's own proc seemed to have fixed it. I don't know.
/obj/effect/fusion_em_field/proc/temp_dump()
diff --git a/code/modules/power/fusion/fuel_assembly/fuel_assembly.dm b/code/modules/power/fusion/fuel_assembly/fuel_assembly.dm
index 4149274351..73543ead92 100644
--- a/code/modules/power/fusion/fuel_assembly/fuel_assembly.dm
+++ b/code/modules/power/fusion/fuel_assembly/fuel_assembly.dm
@@ -46,7 +46,7 @@
return PROCESS_KILL
if(istype(loc, /turf))
- radiation_repository.radiate(src, max(1,CEILING(radioactivity/30, 1)))
+ SSradiation.radiate(src, max(1,CEILING(radioactivity/30, 1)))
/obj/item/weapon/fuel_assembly/Destroy()
STOP_PROCESSING(SSobj, src)
diff --git a/code/modules/power/fusion/fusion_reactions.dm b/code/modules/power/fusion/fusion_reactions.dm
index 623f70bd6b..88117f8164 100644
--- a/code/modules/power/fusion/fusion_reactions.dm
+++ b/code/modules/power/fusion/fusion_reactions.dm
@@ -120,7 +120,7 @@ proc/get_fusion_reaction(var/p_react, var/s_react, var/m_energy)
var/radiation_level = 200
// Copied from the SM for proof of concept. //Not any more --Cirra //Use the whole z proc --Leshana
- radiation_repository.z_radiate(locate(1, 1, holder.z), radiation_level, 1)
+ SSradiation.z_radiate(locate(1, 1, holder.z), radiation_level, 1)
for(var/mob/living/mob in living_mob_list)
var/turf/T = get_turf(mob)
diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm
index 5e4c2e6207..2443f3ea27 100644
--- a/code/modules/power/port_gen.dm
+++ b/code/modules/power/port_gen.dm
@@ -399,13 +399,13 @@
/obj/machinery/power/port_gen/pacman/super/UseFuel()
//produces a tiny amount of radiation when in use
if (prob(2*power_output))
- radiation_repository.radiate(src, 4)
+ SSradiation.radiate(src, 4)
..()
/obj/machinery/power/port_gen/pacman/super/explode()
//a nice burst of radiation
var/rads = 50 + (sheets + sheet_left)*1.5
- radiation_repository.radiate(src, (max(20, rads)))
+ SSradiation.radiate(src, (max(20, rads)))
explosion(src.loc, 3, 3, 5, 3)
qdel(src)
diff --git a/code/modules/power/singularity/collector.dm b/code/modules/power/singularity/collector.dm
index af143b64a4..5e791e4c94 100644
--- a/code/modules/power/singularity/collector.dm
+++ b/code/modules/power/singularity/collector.dm
@@ -32,7 +32,7 @@ var/global/list/rad_collectors = list()
if(P && active)
- var/rads = radiation_repository.get_rads_at_turf(get_turf(src))
+ var/rads = SSradiation.get_rads_at_turf(get_turf(src))
if(rads)
receive_pulse(rads * 5) //Maths is hard
diff --git a/code/modules/power/singularity/particle_accelerator/particle_smasher.dm b/code/modules/power/singularity/particle_accelerator/particle_smasher.dm
index b3a1556395..921b000078 100644
--- a/code/modules/power/singularity/particle_accelerator/particle_smasher.dm
+++ b/code/modules/power/singularity/particle_accelerator/particle_smasher.dm
@@ -142,13 +142,13 @@
/obj/machinery/particle_smasher/process()
if(!src.anchored) // Rapidly loses focus.
if(energy)
- radiation_repository.radiate(src, round(((src.energy-150)/50)*5,1))
+ SSradiation.radiate(src, round(((src.energy-150)/50)*5,1))
energy = max(0, energy - 30)
update_icon()
return
if(energy)
- radiation_repository.radiate(src, round(((src.energy-150)/50)*5,1))
+ SSradiation.radiate(src, round(((src.energy-150)/50)*5,1))
energy = CLAMP(energy - 5, 0, max_energy)
return
@@ -178,7 +178,7 @@
if(successful_craft)
visible_message("\The [src] fizzles.")
if(prob(33)) // Why are you blasting it after it's already done!
- radiation_repository.radiate(src, 10 + round(src.energy / 60, 1))
+ SSradiation.radiate(src, 10 + round(src.energy / 60, 1))
energy = max(0, energy - 30)
update_icon()
return
diff --git a/code/modules/power/singularity/singularity.dm b/code/modules/power/singularity/singularity.dm
index 7b2742deca..a2ab0b8bd2 100644
--- a/code/modules/power/singularity/singularity.dm
+++ b/code/modules/power/singularity/singularity.dm
@@ -403,7 +403,7 @@ GLOBAL_LIST_BOILERPLATE(all_singularities, /obj/singularity)
if (src.energy>200)
toxdamage = round(((src.energy-150)/50)*4,1)
radiation = round(((src.energy-150)/50)*5,1)
- radiation_repository.radiate(src, radiation) //Always radiate at max, so a decent dose of radiation is applied
+ SSradiation.radiate(src, radiation) //Always radiate at max, so a decent dose of radiation is applied
for(var/mob/living/M in view(toxrange, src.loc))
if(M.status_flags & GODMODE)
continue
@@ -446,7 +446,7 @@ GLOBAL_LIST_BOILERPLATE(all_singularities, /obj/singularity)
M << "You hear an uneartly ringing, then what sounds like a shrilling kettle as you are washed with a wave of heat."
M << "You don't even have a moment to react as you are reduced to ashes by the intense radiation."
M.dust()
- radiation_repository.radiate(src, rand(energy))
+ SSradiation.radiate(src, rand(energy))
return
/obj/singularity/proc/pulse()
diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm
index ec6a03fc0e..0f50b48655 100644
--- a/code/modules/power/supermatter/supermatter.dm
+++ b/code/modules/power/supermatter/supermatter.dm
@@ -141,7 +141,7 @@
if(!TS)
return
for(var/z in GetConnectedZlevels(TS.z))
- radiation_repository.z_radiate(locate(1, 1, z), DETONATION_RADS, 1)
+ SSradiation.z_radiate(locate(1, 1, z), DETONATION_RADS, 1)
for(var/mob/living/mob in living_mob_list)
var/turf/T = get_turf(mob)
if(T && (loc.z == T.z))
@@ -312,7 +312,7 @@
if(eye_shield < 1)
l.hallucination = max(0, min(200, l.hallucination + power * config_hallucination_power * sqrt( 1 / max(1,get_dist(l, src)) ) ) )
- radiation_repository.radiate(src, max(power * 1.5, 50) ) //Better close those shutters!
+ SSradiation.radiate(src, max(power * 1.5, 50) ) //Better close those shutters!
power -= (power/DECAY_FACTOR)**3 //energy losses due to radiation
@@ -425,7 +425,7 @@
else
l.show_message("You hear an uneartly ringing and notice your skin is covered in fresh radiation burns.", 2)
var/rads = 500
- radiation_repository.radiate(src, rads)
+ SSradiation.radiate(src, rads)
/proc/supermatter_pull(var/atom/target, var/pull_range = 255, var/pull_power = STAGE_FIVE)
for(var/atom/A in range(pull_range, target))
@@ -468,7 +468,7 @@
return ..()
/obj/item/broken_sm/process()
- radiation_repository.radiate(src, 50)
+ SSradiation.radiate(src, 50)
/obj/item/broken_sm/Destroy()
STOP_PROCESSING(SSobj, src)
diff --git a/code/modules/projectiles/projectile/arc.dm b/code/modules/projectiles/projectile/arc.dm
index 0c4c9f4caa..1f19dc0242 100644
--- a/code/modules/projectiles/projectile/arc.dm
+++ b/code/modules/projectiles/projectile/arc.dm
@@ -167,4 +167,4 @@
var/rad_power = 50
/obj/item/projectile/arc/radioactive/on_impact(turf/T)
- radiation_repository.radiate(T, rad_power)
+ SSradiation.radiate(T, rad_power)
diff --git a/code/modules/radiation/radiation.dm b/code/modules/radiation/radiation.dm
new file mode 100644
index 0000000000..34bf77b46e
--- /dev/null
+++ b/code/modules/radiation/radiation.dm
@@ -0,0 +1,59 @@
+// Describes a point source of radiation. Created either in response to a pulse of radiation, or over an irradiated atom.
+// Sources will decay over time, unless something is renewing their power!
+/datum/radiation_source
+ var/turf/source_turf // Location of the radiation source.
+ var/rad_power // Strength of the radiation being emitted.
+ var/decay = TRUE // True for automatic decay. False if owner promises to handle it (i.e. supermatter)
+ var/respect_maint = FALSE // True for not affecting RAD_SHIELDED areas.
+ var/flat = FALSE // True for power falloff with distance.
+ var/range // Cached maximum range, used for quick checks against mobs.
+
+/datum/radiation_source/Destroy()
+ SSradiation.sources -= src
+ if(SSradiation.sources_assoc[src.source_turf] == src)
+ SSradiation.sources_assoc -= src.source_turf
+ src.source_turf = null
+ . = ..()
+
+/datum/radiation_source/proc/update_rad_power(var/new_power = null)
+ if(new_power == null || new_power == rad_power)
+ return // No change
+ else if(new_power <= config.radiation_lower_limit)
+ qdel(src) // Decayed to nothing
+ else
+ rad_power = new_power
+ if(!flat)
+ range = min(round(sqrt(rad_power / config.radiation_lower_limit)), 31) // R = rad_power / dist**2 - Solve for dist
+
+/turf
+ var/cached_rad_resistance = 0
+
+/turf/proc/calc_rad_resistance()
+ cached_rad_resistance = 0
+ for(var/obj/O in src.contents)
+ if(O.rad_resistance) //Override
+ cached_rad_resistance += O.rad_resistance
+
+ else if(O.density) //So open doors don't get counted
+ var/material/M = O.get_material()
+ if(!M) continue
+ cached_rad_resistance += M.weight + M.radiation_resistance
+ // Looks like storing the contents length is meant to be a basic check if the cache is stale due to items enter/exiting. Better than nothing so I'm leaving it as is. ~Leshana
+ SSradiation.resistance_cache[src] = (length(contents) + 1)
+
+/turf/simulated/wall/calc_rad_resistance()
+ SSradiation.resistance_cache[src] = (length(contents) + 1)
+ cached_rad_resistance = (density ? material.weight + material.radiation_resistance : 0)
+
+/obj
+ var/rad_resistance = 0 // Allow overriding rad resistance
+
+// If people expand the system, this may be useful. Here as a placeholder until then
+/atom/proc/rad_act(var/severity)
+ return 1
+
+/mob/living/rad_act(var/severity)
+ if(severity)
+ src.apply_effect(severity, IRRADIATE, src.getarmor(null, "rad"))
+ for(var/atom/I in src)
+ I.rad_act(severity)
\ No newline at end of file
diff --git a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm
index 38a65a78d8..43635aba5b 100644
--- a/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm
+++ b/code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Toxins.dm
@@ -965,7 +965,7 @@ datum/reagent/talum_quem/affect_blood(var/mob/living/carbon/M, var/alien, var/re
metabolism = REM * 4
/datum/reagent/irradiated_nanites/affect_blood(var/mob/living/carbon/M, var/alien, var/removed)
- radiation_repository.radiate(get_turf(M), 20) // Irradiate people around you.
+ SSradiation.radiate(get_turf(M), 20) // Irradiate people around you.
M.radiation = max(M.radiation + 5 * removed, 0) // Irradiate you. Because it's inside you.
/datum/reagent/neurophage_nanites
diff --git a/code/modules/xenoarcheaology/effects/radiate.dm b/code/modules/xenoarcheaology/effects/radiate.dm
index 6c8d37838a..e0cd109390 100644
--- a/code/modules/xenoarcheaology/effects/radiate.dm
+++ b/code/modules/xenoarcheaology/effects/radiate.dm
@@ -15,10 +15,10 @@
/datum/artifact_effect/radiate/DoEffectAura()
if(holder)
- radiation_repository.flat_radiate(holder, radiation_amount, src.effectrange)
+ SSradiation.flat_radiate(holder, radiation_amount, src.effectrange)
return 1
/datum/artifact_effect/radiate/DoEffectPulse()
if(holder)
- radiation_repository.radiate(holder, ((radiation_amount * 25) * (sqrt(src.effectrange)))) //Need to get feedback on this
+ SSradiation.radiate(holder, ((radiation_amount * 25) * (sqrt(src.effectrange)))) //Need to get feedback on this
return 1
diff --git a/code/modules/xenoarcheaology/tools/geosample_scanner.dm b/code/modules/xenoarcheaology/tools/geosample_scanner.dm
index b97a34e48f..7f266f454e 100644
--- a/code/modules/xenoarcheaology/tools/geosample_scanner.dm
+++ b/code/modules/xenoarcheaology/tools/geosample_scanner.dm
@@ -198,7 +198,7 @@
radiation = rand() * 15 + 85
if(!rad_shield)
//irradiate nearby mobs
- radiation_repository.radiate(src, radiation / 25)
+ SSradiation.radiate(src, radiation / 25)
else
t_left_radspike = pick(10,15,25)
diff --git a/polaris.dme b/polaris.dme
index 957bdb85c8..c0abfb7133 100644
--- a/polaris.dme
+++ b/polaris.dme
@@ -187,7 +187,6 @@
#include "code\controllers\Processes\emergencyShuttle.dm"
#include "code\controllers\Processes\game_master.dm"
#include "code\controllers\Processes\mob.dm"
-#include "code\controllers\Processes\radiation.dm"
#include "code\controllers\Processes\supply.dm"
#include "code\controllers\Processes\ticker.dm"
#include "code\controllers\ProcessScheduler\core\process.dm"
@@ -209,6 +208,7 @@
#include "code\controllers\subsystems\orbits.dm"
#include "code\controllers\subsystems\overlays.dm"
#include "code\controllers\subsystems\planets.dm"
+#include "code\controllers\subsystems\radiation.dm"
#include "code\controllers\subsystems\shuttles.dm"
#include "code\controllers\subsystems\sun.dm"
#include "code\controllers\subsystems\time_track.dm"
@@ -314,7 +314,6 @@
#include "code\datums\repositories\cameras.dm"
#include "code\datums\repositories\crew.dm"
#include "code\datums\repositories\decls.dm"
-#include "code\datums\repositories\radiation.dm"
#include "code\datums\repositories\repository.dm"
#include "code\datums\repositories\unique.dm"
#include "code\datums\supplypacks\atmospherics.dm"
@@ -2438,6 +2437,7 @@
#include "code\modules\projectiles\targeting\targeting_mob.dm"
#include "code\modules\projectiles\targeting\targeting_overlay.dm"
#include "code\modules\projectiles\targeting\targeting_triggers.dm"
+#include "code\modules\radiation\radiation.dm"
#include "code\modules\random_map\_random_map_setup.dm"
#include "code\modules\random_map\random_map.dm"
#include "code\modules\random_map\random_map_verbs.dm"