Modernizing Radiation -- TL;DR: Radiation is now a status effect healed by tox healing, and contamination is removed (#62265)

Implements the Modernizing radiation design document ( https://hackmd.io/@tgstation/rJNIyeBHt ) and replaces the current radiation sources with the new system, as well as replacing/removing a bunch of old consumers of radiation that either had no reason to exist, or could be replaced by something else.

Diverges from the doc in that items radiation don't go up like explained. I was going to, but items get irradiated so easily that it just feels pretty lame. Items still get irradiated, but it's mostly just so that radiation sources look cooler (wow, lots of stuff around going green), and for things like the geiger counter.

Instead of the complicated radiation_wave system, radiation now just checks everything between the radiation source and the potential target, losing power along the way based on the radiation insulation of whats in between. If this reaches too low a point (specified by radiation_pulse consumers), then the radiation will not pass. Otherwise, will roll a chance to irradiate. Uranium structures allow a delay before irradiating, so stay away!
This commit is contained in:
Mothblocks
2021-11-01 04:20:39 -03:00
committed by GitHub
parent 9003982726
commit 0f3c4e51f7
342 changed files with 1869 additions and 2152 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
/// This component behaves similar to connect_loc, hooking into a signal on a tracked object's turf
/// It has the ability to react to that signal on behalf of a seperate listener however
/// This has great use, primarially for components, but it carries with it some overhead
/// This has great use, primarily for components, but it carries with it some overhead
/// So we do it seperately as it needs to hold state which is very likely to lead to bugs if it remains as an element.
/datum/component/connect_loc_behalf
dupe_mode = COMPONENT_DUPE_UNIQUE
+92
View File
@@ -0,0 +1,92 @@
/// Atoms with this component will play sounds depending on nearby radiation
/datum/component/geiger_sound
var/datum/looping_sound/geiger/sound
var/last_parent = null
/datum/component/geiger_sound/Initialize(...)
if (!isatom(parent))
return COMPONENT_INCOMPATIBLE
/datum/component/geiger_sound/Destroy(force, silent)
QDEL_NULL(sound)
if (!isnull(last_parent))
UnregisterSignal(last_parent, COMSIG_IN_RANGE_OF_IRRADIATION)
last_parent = null
return ..()
/datum/component/geiger_sound/RegisterWithParent()
sound = new(parent)
RegisterSignal(parent, COMSIG_IN_RANGE_OF_IRRADIATION, .proc/on_pre_potential_irradiation)
ADD_TRAIT(parent, TRAIT_BYPASS_EARLY_IRRADIATED_CHECK, REF(src))
if (isitem(parent))
var/atom/atom_parent = parent
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, .proc/on_moved)
register_to_loc(atom_parent.loc)
/datum/component/geiger_sound/UnregisterFromParent()
UnregisterSignal(parent, list(
COMSIG_MOVABLE_MOVED,
COMSIG_IN_RANGE_OF_IRRADIATION,
))
REMOVE_TRAIT(parent, TRAIT_BYPASS_EARLY_IRRADIATED_CHECK, REF(src))
/datum/component/geiger_sound/proc/on_pre_potential_irradiation(datum/source, datum/radiation_pulse_information/pulse_information, insulation_to_target)
SIGNAL_HANDLER
sound.last_insulation_to_target = insulation_to_target
sound.last_radiation_pulse = pulse_information
sound.start()
addtimer(CALLBACK(sound, /datum/looping_sound/proc/stop), TIME_WITHOUT_RADIATION_BEFORE_RESET, TIMER_UNIQUE | TIMER_OVERRIDE)
/datum/component/geiger_sound/proc/on_moved(atom/source)
SIGNAL_HANDLER
register_to_loc(source.loc)
/datum/component/geiger_sound/proc/register_to_loc(new_loc)
if (last_parent == new_loc)
return
if (!isnull(last_parent))
UnregisterSignal(last_parent, COMSIG_IN_RANGE_OF_IRRADIATION)
last_parent = new_loc
if (!isnull(new_loc))
RegisterSignal(new_loc, COMSIG_IN_RANGE_OF_IRRADIATION, .proc/on_pre_potential_irradiation)
/datum/looping_sound/geiger
mid_sounds = list(
list('sound/items/geiger/low1.ogg'=1, 'sound/items/geiger/low2.ogg'=1, 'sound/items/geiger/low3.ogg'=1, 'sound/items/geiger/low4.ogg'=1),
list('sound/items/geiger/med1.ogg'=1, 'sound/items/geiger/med2.ogg'=1, 'sound/items/geiger/med3.ogg'=1, 'sound/items/geiger/med4.ogg'=1),
list('sound/items/geiger/high1.ogg'=1, 'sound/items/geiger/high2.ogg'=1, 'sound/items/geiger/high3.ogg'=1, 'sound/items/geiger/high4.ogg'=1),
list('sound/items/geiger/ext1.ogg'=1, 'sound/items/geiger/ext2.ogg'=1, 'sound/items/geiger/ext3.ogg'=1, 'sound/items/geiger/ext4.ogg'=1)
)
mid_length = 2
volume = 25
var/datum/radiation_pulse_information/last_radiation_pulse
var/last_insulation_to_target
/datum/looping_sound/geiger/Destroy()
last_radiation_pulse = null
return ..()
/datum/looping_sound/geiger/get_sound(starttime)
if (isnull(last_radiation_pulse))
return null
return ..(starttime, mid_sounds[get_perceived_radiation_danger(last_radiation_pulse, last_insulation_to_target)])
/datum/looping_sound/geiger/stop()
. = ..()
last_radiation_pulse = null
+72
View File
@@ -0,0 +1,72 @@
#define GORILLA_MUTATION_CHANCE_PER_SECOND 0.25
#define GORILLA_MUTATION_MINIMUM_DAMAGE 2500
/// Genetic damage, given by DNA consoles, will start to deal toxin damage
/// past a certain threshold, and will go down consistently.
/// Adding multiple of this component will increase the total damage.
/// Can turn monkeys into gorillas.
/datum/component/genetic_damage
dupe_mode = COMPONENT_DUPE_UNIQUE
/// The total genetic damage on the mob
var/total_damage = 0
/// The amount of genetic damage a mob can sustain before taking damage
var/minimum_before_damage = 500
/// The amount of genetic damage to remove per second
var/remove_per_second = 1 / 3
/// The amount of toxin damage to deal per second, if over the minimum before taking damage
var/toxin_damage_per_second = 1 / 3
/datum/component/genetic_damage/Initialize(genetic_damage)
if (!isliving(parent))
return COMPONENT_INCOMPATIBLE
src.total_damage = genetic_damage
START_PROCESSING(SSprocessing, src)
/datum/component/genetic_damage/RegisterWithParent()
RegisterSignal(parent, COMSIG_LIVING_HEALTHSCAN, .proc/on_healthscan)
/datum/component/genetic_damage/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_LIVING_HEALTHSCAN)
/datum/component/genetic_damage/Destroy(force, silent)
STOP_PROCESSING(SSprocessing, src)
return ..()
/datum/component/genetic_damage/InheritComponent(datum/component/genetic_damage/old_component)
total_damage += old_component.total_damage
/datum/component/genetic_damage/process(delta_time)
if (ismonkey(parent) && total_damage >= GORILLA_MUTATION_MINIMUM_DAMAGE && DT_PROB(GORILLA_MUTATION_CHANCE_PER_SECOND, delta_time))
var/mob/living/carbon/carbon_parent = parent
carbon_parent.gorillize()
qdel(src)
return PROCESS_KILL
if (total_damage >= minimum_before_damage)
var/mob/living/living_mob = parent
living_mob.adjustToxLoss(toxin_damage_per_second * delta_time)
total_damage -= remove_per_second * delta_time
if (total_damage <= 0)
qdel(src)
return PROCESS_KILL
/datum/component/genetic_damage/proc/on_healthscan(datum/source, list/render_list, advanced)
SIGNAL_HANDLER
if (advanced)
render_list += "<span class='alert ml-1'>Genetic damage: [round(total_damage / minimum_before_damage * 100, 0.1)]%</span>\n"
else if (total_damage >= minimum_before_damage)
render_list += "<span class='alert ml-1'>Severe genetic damage detected.</span>\n"
else
render_list += "<span class='alert ml-1'>Minor genetic damage detected.</span>\n"
#undef GORILLA_MUTATION_CHANCE_PER_SECOND
#undef GORILLA_MUTATION_MINIMUM_DAMAGE
+201
View File
@@ -0,0 +1,201 @@
#define RADIATION_IMMEDIATE_TOX_DAMAGE 10
#define RADIATION_TOX_DAMAGE_PER_INTERVAL 2
#define RADIATION_TOX_INTERVAL (25 SECONDS)
#define RADIATION_BURN_SPLOTCH_DAMAGE 11
#define RADIATION_BURN_INTERVAL_MIN (30 SECONDS)
#define RADIATION_BURN_INTERVAL_MAX (60 SECONDS)
// Showers process on SSmachines
#define RADIATION_CLEAN_IMMUNITY_TIME (SSMACHINES_DT + (1 SECONDS))
/// This atom is irradiated, and will glow green.
/// Humans will take toxin damage until all their toxin damage is cleared.
/// Items will attempt to irradiate whoever is holding them, as well as whatever they are inside.
/datum/component/irradiated
dupe_mode = COMPONENT_DUPE_UNIQUE
var/beginning_of_irradiation
var/burn_splotch_timer_id
COOLDOWN_DECLARE(clean_cooldown)
COOLDOWN_DECLARE(last_tox_damage)
/datum/component/irradiated/Initialize()
if (!CAN_IRRADIATE(parent))
return COMPONENT_INCOMPATIBLE
// This isn't incompatible, it's just wrong
if (HAS_TRAIT(parent, TRAIT_RADIMMUNE))
qdel(src)
return
ADD_TRAIT(parent, TRAIT_IRRADIATED, REF(src))
create_glow()
beginning_of_irradiation = world.time
if (ishuman(parent))
var/mob/living/carbon/human/human_parent = parent
human_parent.apply_damage(RADIATION_IMMEDIATE_TOX_DAMAGE, TOX)
START_PROCESSING(SSobj, src)
COOLDOWN_START(src, last_tox_damage, RADIATION_TOX_INTERVAL)
start_burn_splotch_timer()
human_parent.throw_alert("irradiated", /atom/movable/screen/alert/irradiated)
/datum/component/irradiated/RegisterWithParent()
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, .proc/on_clean)
RegisterSignal(parent, COMSIG_GEIGER_COUNTER_SCAN, .proc/on_geiger_counter_scan)
/datum/component/irradiated/UnregisterFromParent()
UnregisterSignal(parent, list(
COMSIG_COMPONENT_CLEAN_ACT,
COMSIG_GEIGER_COUNTER_SCAN,
))
/datum/component/irradiated/Destroy(force, silent)
var/atom/movable/parent_movable = parent
if (istype(parent_movable))
parent_movable.remove_filter("rad_glow")
var/mob/living/carbon/human/human_parent = parent
if (istype(human_parent))
human_parent.clear_alert("irradiated")
REMOVE_TRAIT(parent, TRAIT_IRRADIATED, REF(src))
deltimer(burn_splotch_timer_id)
STOP_PROCESSING(SSobj, src)
return ..()
/datum/component/irradiated/process(delta_time)
if (!ishuman(parent))
return PROCESS_KILL
if (HAS_TRAIT(parent, TRAIT_RADIMMUNE))
qdel(src)
return PROCESS_KILL
var/mob/living/carbon/human/human_parent = parent
if (human_parent.getToxLoss() == 0)
qdel(src)
return PROCESS_KILL
if (should_halt_effects(parent))
return
if (human_parent.stat > DEAD)
human_parent.dna?.species?.handle_radiation(human_parent, world.time - beginning_of_irradiation, delta_time)
process_tox_damage(human_parent, delta_time)
/datum/component/irradiated/proc/should_halt_effects(mob/living/carbon/human/target)
if (IS_IN_STASIS(target))
return TRUE
if (HAS_TRAIT(target, TRAIT_HALT_RADIATION_EFFECTS))
return TRUE
if (!COOLDOWN_FINISHED(src, clean_cooldown))
return TRUE
return FALSE
/datum/component/irradiated/proc/process_tox_damage(mob/living/carbon/human/target, delta_time)
if (!COOLDOWN_FINISHED(src, last_tox_damage))
return
target.apply_damage(RADIATION_TOX_DAMAGE_PER_INTERVAL, TOX)
COOLDOWN_START(src, last_tox_damage, RADIATION_TOX_INTERVAL)
/datum/component/irradiated/proc/start_burn_splotch_timer()
addtimer(CALLBACK(src, .proc/give_burn_splotches), rand(RADIATION_BURN_INTERVAL_MIN, RADIATION_BURN_INTERVAL_MAX), TIMER_STOPPABLE)
/datum/component/irradiated/proc/give_burn_splotches()
// This shouldn't be possible, but just in case.
if (QDELETED(src))
return
start_burn_splotch_timer()
var/mob/living/carbon/human/human_parent = parent
if (should_halt_effects(parent))
return
var/obj/affected_limb = human_parent.get_bodypart(ran_zone())
human_parent.visible_message(
span_boldwarning("[human_parent]'s [affected_limb.name] bubbles unnaturally, then bursts into blisters!"),
span_boldwarning("Your [affected_limb.name] bubbles unnaturally, then bursts into blisters!"),
)
if (human_parent.is_blind())
to_chat(human_parent, span_boldwarning("Your [affected_limb.name] feels like it's bubbling, then burns like hell!"))
human_parent.apply_damage(RADIATION_BURN_SPLOTCH_DAMAGE, BURN, affected_limb)
playsound(
human_parent,
pick('sound/effects/wounds/sizzle1.ogg', 'sound/effects/wounds/sizzle2.ogg'),
50,
vary = TRUE,
)
/datum/component/irradiated/proc/create_glow()
var/atom/movable/parent_movable = parent
if (!istype(parent_movable))
return
parent_movable.add_filter("rad_glow", 2, list("type" = "outline", "color" = "#39ff1430", "size" = 2))
addtimer(CALLBACK(src, .proc/start_glow_loop, parent_movable), rand(0.1 SECONDS, 1.9 SECONDS)) // Things should look uneven
/datum/component/irradiated/proc/start_glow_loop(atom/movable/parent_movable)
var/filter = parent_movable.get_filter("rad_glow")
if (!filter)
return
animate(filter, alpha = 110, time = 1.5 SECONDS, loop = -1)
animate(alpha = 40, time = 2.5 SECONDS)
/datum/component/irradiated/proc/on_clean(datum/source, clean_types)
SIGNAL_HANDLER
if (!(clean_types & CLEAN_TYPE_RADIATION))
return
if (isitem(parent))
qdel(src)
return COMPONENT_CLEANED
COOLDOWN_START(src, clean_cooldown, RADIATION_CLEAN_IMMUNITY_TIME)
/datum/component/irradiated/proc/on_geiger_counter_scan(datum/source, mob/user, obj/item/geiger_counter/geiger_counter)
SIGNAL_HANDLER
if (isliving(source))
var/mob/living/living_source = source
to_chat(user, span_boldannounce("[icon2html(geiger_counter, user)] Subject is irradiated. Contamination traces back to roughly [DisplayTimeText(world.time - beginning_of_irradiation, 5)] ago. Current toxin levels: [living_source.getToxLoss()]."))
else
// In case the green wasn't obvious enough...
to_chat(user, span_boldannounce("[icon2html(geiger_counter, user)] Target is irradiated."))
return COMSIG_GEIGER_COUNTER_SCAN_SUCCESSFUL
/atom/movable/screen/alert/irradiated
name = "Irradiated"
desc = "You're irradiated! Heal your toxins quick, and stand under a shower to halt the incoming damage."
icon_state = "irradiated"
#undef RADIATION_BURN_SPLOTCH_DAMAGE
#undef RADIATION_BURN_INTERVAL_MIN
#undef RADIATION_BURN_INTERVAL_MAX
#undef RADIATION_CLEAN_IMMUNITY_TIME
#undef RADIATION_IMMEDIATE_TOX_DAMAGE
#undef RADIATION_TOX_INTERVAL
#undef RADIATION_TOX_DAMAGE_PER_INTERVAL
@@ -0,0 +1,55 @@
// Should be more than any minimum exposure time coming in
#define TIME_UNTIL_DELETION (10 SECONDS)
/// Begins the countdown before a target can be irradiated.
/// Added by the radiation subsystem when a pulse information has a minimum exposure time.
/// Will clear itself out after a while.
/datum/component/radiation_countdown
/// The time this component was added
var/time_added
/// The shortest minimum time before being irradiated.
/// If the source has an attempted irradiation again outside this timeframe, it will go through.
var/minimum_exposure_time
/datum/component/radiation_countdown/Initialize(minimum_exposure_time)
if (!CAN_IRRADIATE(parent))
return COMPONENT_INCOMPATIBLE
src.minimum_exposure_time = minimum_exposure_time
time_added = world.time
to_chat(parent, span_userdanger("The air around you feels warm...perhaps you should go somewhere else."))
start_deletion_timer()
/datum/component/radiation_countdown/proc/start_deletion_timer()
addtimer(CALLBACK(src, .proc/remove_self), TIME_UNTIL_DELETION, TIMER_UNIQUE | TIMER_OVERRIDE)
/datum/component/radiation_countdown/proc/remove_self()
if (!HAS_TRAIT(parent, TRAIT_IRRADIATED))
to_chat(parent, span_notice("The air here feels safer."))
qdel(src)
/datum/component/radiation_countdown/RegisterWithParent()
RegisterSignal(parent, COMSIG_IN_THRESHOLD_OF_IRRADIATION, .proc/on_pre_potential_irradiation_within_range)
/datum/component/radiation_countdown/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_IN_THRESHOLD_OF_IRRADIATION)
/datum/component/radiation_countdown/proc/on_pre_potential_irradiation_within_range(datum/source, datum/radiation_pulse_information/pulse_information)
SIGNAL_HANDLER
minimum_exposure_time = min(minimum_exposure_time, pulse_information.minimum_exposure_time)
start_deletion_timer()
// Played with fire, now you might be getting irradiated.
if (world.time - time_added >= minimum_exposure_time)
return SKIP_MINIMUM_EXPOSURE_TIME_CHECK
return CANCEL_IRRADIATION
#undef TIME_UNTIL_DELETION
-122
View File
@@ -1,122 +0,0 @@
#define RAD_AMOUNT_LOW 50
#define RAD_AMOUNT_MEDIUM 200
#define RAD_AMOUNT_HIGH 500
#define RAD_AMOUNT_EXTREME 1000
/datum/component/radioactive
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
var/source
var/hl3_release_date //the half-life measured in ticks
var/strength
var/can_contaminate
/datum/component/radioactive/Initialize(_strength=0, _source, _half_life=RAD_HALF_LIFE, _can_contaminate=TRUE)
strength = _strength
source = _source
hl3_release_date = _half_life
can_contaminate = _can_contaminate
if(istype(parent, /atom))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/rad_examine)
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, .proc/rad_clean)
if(istype(parent, /obj/item))
RegisterSignal(parent, COMSIG_ITEM_ATTACK, .proc/rad_attack)
RegisterSignal(parent, COMSIG_ITEM_ATTACK_OBJ, .proc/rad_attack)
else
return COMPONENT_INCOMPATIBLE
if(strength > RAD_MINIMUM_CONTAMINATION)
SSradiation.warn(src)
//Let's make er glow
//This relies on parent not being a turf or something. IF YOU CHANGE THAT, CHANGE THIS
var/atom/movable/master = parent
master.add_filter("rad_glow", 2, list("type" = "outline", "color" = "#39ff1430", "size" = 2))
addtimer(CALLBACK(src, .proc/glow_loop, master), rand(1,19))//Things should look uneven
START_PROCESSING(SSradiation, src)
/datum/component/radioactive/Destroy()
STOP_PROCESSING(SSradiation, src)
var/atom/movable/master = parent
master.remove_filter("rad_glow")
return ..()
/datum/component/radioactive/process(delta_time)
if(!DT_PROB(50, delta_time))
return
radiation_pulse(parent, strength, RAD_DISTANCE_COEFFICIENT*2, FALSE, can_contaminate)
if(!hl3_release_date)
return
strength -= strength / hl3_release_date
if(strength <= RAD_BACKGROUND_RADIATION)
qdel(src)
return PROCESS_KILL
/datum/component/radioactive/proc/glow_loop(atom/movable/master)
var/filter = master.get_filter("rad_glow")
if(filter)
animate(filter, alpha = 110, time = 15, loop = -1)
animate(alpha = 40, time = 25)
/datum/component/radioactive/InheritComponent(datum/component/C, i_am_original, _strength, _source, _half_life, _can_contaminate)
if(!i_am_original)
return
if(!hl3_release_date) // Permanently radioactive things don't get to grow stronger
return
if(C)
var/datum/component/radioactive/other = C
strength = max(strength, other.strength)
else
strength = max(strength, _strength)
/datum/component/radioactive/proc/rad_examine(datum/source, mob/user, list/out)
SIGNAL_HANDLER
var/atom/master = parent
var/list/fragments = list()
if(get_dist(master, user) <= 1)
fragments += "The air around [master] feels warm"
switch(strength)
if(0 to RAD_AMOUNT_LOW)
if(length(fragments))
fragments += "."
if(RAD_AMOUNT_LOW to RAD_AMOUNT_MEDIUM)
fragments += "[length(fragments) ? " and [master.p_they()] " : "[master] "]feel[master.p_s()] weird to look at."
if(RAD_AMOUNT_MEDIUM to RAD_AMOUNT_HIGH)
fragments += "[length(fragments) ? " and [master.p_they()] " : "[master] "]seem[master.p_s()] to be glowing a bit."
if(RAD_AMOUNT_HIGH to INFINITY) //At this level the object can contaminate other objects
fragments += "[length(fragments) ? " and [master.p_they()] " : "[master] "]hurt[master.p_s()] to look at."
if(length(fragments))
out += span_warning("[fragments.Join()]")
/datum/component/radioactive/proc/rad_attack(datum/source, atom/movable/target, mob/living/user)
SIGNAL_HANDLER
radiation_pulse(parent, strength/20)
target.rad_act(strength/2)
if(!hl3_release_date)
return
strength -= strength / hl3_release_date
/datum/component/radioactive/proc/rad_clean(datum/source, clean_types)
SIGNAL_HANDLER
if(QDELETED(src))
return COMPONENT_CLEANED
if(!(clean_types & CLEAN_TYPE_RADIATION))
return COMPONENT_CLEANED
if(!(clean_types & CLEAN_TYPE_WEAK))
qdel(src)
return COMPONENT_CLEANED
strength = max(0, (strength - (RAD_BACKGROUND_RADIATION * 2)))
if(strength <= RAD_BACKGROUND_RADIATION)
qdel(src)
return COMPONENT_CLEANED
#undef RAD_AMOUNT_LOW
#undef RAD_AMOUNT_MEDIUM
#undef RAD_AMOUNT_HIGH
#undef RAD_AMOUNT_EXTREME