Radiation Refactor (#15331)

* First Commit

* visible radiation and engine goggles

* correction

* t-ray fix

* further adjustments and fixups

* gieger addition and cleaning fixup

* yet more fixes

* styling fixes

* fixes

* human glowing fix

* do the merge conflict avoidance dance

* Update supermatter.dm

* supermatter rads

* mapping in

* radiation doors

* yeah yeah line endings

* clean up

* styling issues

* showers
This commit is contained in:
Fox McCloud
2021-01-24 22:03:13 +00:00
committed by GitHub
parent acaefa9591
commit de795c4e31
154 changed files with 1967 additions and 674 deletions
+104
View File
@@ -0,0 +1,104 @@
#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
///the half-life measured in ticks
var/hl3_release_date
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)
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()
if(!prob(50))
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 class='warning'>[fragments.Join()]</span>"
/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
#undef RAD_AMOUNT_LOW
#undef RAD_AMOUNT_MEDIUM
#undef RAD_AMOUNT_HIGH
#undef RAD_AMOUNT_EXTREME
+34
View File
@@ -0,0 +1,34 @@
/datum/element/rad_insulation
element_flags = ELEMENT_DETACH | ELEMENT_BESPOKE
id_arg_index = 2
var/amount // Multiplier for radiation strength passing through
/datum/element/rad_insulation/Attach(datum/target, _amount = RAD_MEDIUM_INSULATION, protects = TRUE, contamination_proof = TRUE)
. = ..()
if(!isatom(target))
return COMPONENT_INCOMPATIBLE
if(protects) // Does this protect things in its contents from being affected?
RegisterSignal(target, COMSIG_ATOM_RAD_PROBE, .proc/rad_probe_react)
if(contamination_proof) // Can this object be contaminated?
RegisterSignal(target, COMSIG_ATOM_RAD_CONTAMINATING, .proc/rad_contaminating)
if(_amount != 1) // If it's 1 it won't have any impact on radiation passing through anyway
RegisterSignal(target, COMSIG_ATOM_RAD_WAVE_PASSING, .proc/rad_pass)
amount = _amount
/datum/element/rad_insulation/proc/rad_probe_react(datum/source)
SIGNAL_HANDLER
return COMPONENT_BLOCK_RADIATION
/datum/element/rad_insulation/proc/rad_contaminating(datum/source, strength)
SIGNAL_HANDLER
return COMPONENT_BLOCK_CONTAMINATION
/datum/element/rad_insulation/proc/rad_pass(datum/source, datum/radiation_wave/wave, width)
SIGNAL_HANDLER
wave.intensity = wave.intensity * (1 - ((1 - amount) / width)) // The further out the rad wave goes the less it's affected by insulation (larger width)
return COMPONENT_RAD_WAVE_HANDLED
+37
View File
@@ -0,0 +1,37 @@
#define RAD_GEIGER_LOW 100 // Geiger counter sound thresholds
#define RAD_GEIGER_MEDIUM 500
#define RAD_GEIGER_HIGH 1000
/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/last_radiation
/datum/looping_sound/geiger/get_sound(starttime)
var/danger
switch(last_radiation)
if(RAD_BACKGROUND_RADIATION to RAD_GEIGER_LOW)
danger = 1
if(RAD_GEIGER_LOW to RAD_GEIGER_MEDIUM)
danger = 2
if(RAD_GEIGER_MEDIUM to RAD_GEIGER_HIGH)
danger = 3
if(RAD_GEIGER_HIGH to INFINITY)
danger = 4
else
return null
return ..(starttime, mid_sounds[danger])
/datum/looping_sound/geiger/stop()
. = ..()
last_radiation = 0
#undef RAD_GEIGER_LOW
#undef RAD_GEIGER_MEDIUM
#undef RAD_GEIGER_HIGH
+139
View File
@@ -0,0 +1,139 @@
/datum/radiation_wave
/// The thing that spawned this radiation wave
var/source
/// The center of the wave
var/turf/master_turf
/// How far we've moved
var/steps=0
/// How strong it was originaly
var/intensity
/// How much contaminated material it still has
var/remaining_contam
/// Higher than 1 makes it drop off faster, 0.5 makes it drop off half etc
var/range_modifier
/// The direction of movement
var/move_dir
/// The directions to the side of the wave, stored for easy looping
var/list/__dirs
/// Whether or not this radiation wave can create contaminated objects
var/can_contaminate
/datum/radiation_wave/New(atom/_source, dir, _intensity = 0, _range_modifier = RAD_DISTANCE_COEFFICIENT, _can_contaminate = TRUE)
source = "[_source] \[[_source.UID()]\]"
master_turf = get_turf(_source)
move_dir = dir
__dirs = list()
__dirs += turn(dir, 90)
__dirs += turn(dir, -90)
intensity = _intensity
remaining_contam = intensity
range_modifier = _range_modifier
can_contaminate = _can_contaminate
START_PROCESSING(SSradiation, src)
/datum/radiation_wave/Destroy()
. = QDEL_HINT_IWILLGC
STOP_PROCESSING(SSradiation, src)
..()
/datum/radiation_wave/process()
master_turf = get_step(master_turf, move_dir)
if(!master_turf)
qdel(src)
return
steps++
var/list/atoms = get_rad_atoms()
var/strength
if(steps > 1)
strength = INVERSE_SQUARE(intensity, max(range_modifier * steps, 1), 1)
else
strength = intensity
if(strength < RAD_BACKGROUND_RADIATION)
qdel(src)
return
radiate(atoms, strength)
check_obstructions(atoms) // reduce our overall strength if there are radiation insulators
/datum/radiation_wave/proc/get_rad_atoms()
var/list/atoms = list()
var/distance = steps
var/cmove_dir = move_dir
var/cmaster_turf = master_turf
if(cmove_dir == NORTH || cmove_dir == SOUTH)
distance-- //otherwise corners overlap
atoms += get_rad_contents(cmaster_turf)
var/turf/place
for(var/dir in __dirs) //There should be just 2 dirs in here, left and right of the direction of movement
place = cmaster_turf
for(var/i in 1 to distance)
place = get_step(place, dir)
if(!place)
break
atoms += get_rad_contents(place)
return atoms
/datum/radiation_wave/proc/check_obstructions(list/atoms)
var/width = steps
var/cmove_dir = move_dir
if(cmove_dir == NORTH || cmove_dir == SOUTH)
width--
width = 1 + (2 * width)
for(var/k in 1 to atoms.len)
var/atom/thing = atoms[k]
if(!thing)
continue
if(SEND_SIGNAL(thing, COMSIG_ATOM_RAD_WAVE_PASSING, src, width) & COMPONENT_RAD_WAVE_HANDLED)
continue
if(thing.rad_insulation != RAD_NO_INSULATION)
intensity *= (1 - ((1 - thing.rad_insulation) / width))
/datum/radiation_wave/proc/radiate(list/atoms, strength)
var/can_contam = strength >= RAD_MINIMUM_CONTAMINATION
var/contamination_strength = (strength-RAD_MINIMUM_CONTAMINATION) * RAD_CONTAMINATION_STR_COEFFICIENT
contamination_strength = max(contamination_strength, RAD_BACKGROUND_RADIATION)
// It'll never reach 100% chance but the further out it gets the more likely it'll contaminate
var/contamination_chance = 100 - (90 / (1 + steps * 0.1))
for(var/k in atoms)
var/atom/thing = k
if(QDELETED(thing))
continue
thing.rad_act(strength)
// This list should only be for types which don't get contaminated but you want to look in their contents
// If you don't want to look in their contents and you don't want to rad_act them:
// modify the ignored_things list in __HELPERS/radiation.dm instead
var/static/list/blacklisted = typecacheof(list(
/turf,
/obj/structure/cable,
/obj/machinery/atmospherics,
/obj/item/ammo_casing,
/obj/item/implant,
/obj/singularity,
))
if(!can_contaminate || !can_contam || blacklisted[thing.type])
continue
if(thing.flags_2 & RAD_NO_CONTAMINATE_2 || SEND_SIGNAL(thing, COMSIG_ATOM_RAD_CONTAMINATING, strength) & COMPONENT_BLOCK_CONTAMINATION)
continue
if(contamination_strength > remaining_contam)
contamination_strength = remaining_contam
if(!prob(contamination_chance))
continue
if(SEND_SIGNAL(thing, COMSIG_ATOM_RAD_CONTAMINATING, strength) & COMPONENT_BLOCK_CONTAMINATION)
continue
remaining_contam -= contamination_strength
if(remaining_contam < RAD_BACKGROUND_RADIATION)
can_contaminate = FALSE
thing.AddComponent(/datum/component/radioactive, contamination_strength, source)
+15 -1
View File
@@ -608,7 +608,9 @@ GLOBAL_LIST_INIT(all_supply_groups, list(SUPPLY_EMERGENCY,SUPPLY_SECURITY,SUPPLY
/obj/item/clothing/head/welding,
/obj/item/clothing/head/hardhat,
/obj/item/clothing/head/hardhat,
/obj/item/clothing/head/hardhat)
/obj/item/clothing/head/hardhat,
/obj/item/clothing/glasses/meson/engine,
/obj/item/clothing/glasses/meson/engine)
cost = 10
containername = "engineering gear crate"
@@ -705,6 +707,18 @@ GLOBAL_LIST_INIT(all_supply_groups, list(SUPPLY_EMERGENCY,SUPPLY_SECURITY,SUPPLY
cost = 25
containername = "particle accelerator crate"
/datum/supply_packs/engineering/radiation
name = "Radiation Protection Crate"
cost = 20
contains = list(/obj/item/clothing/head/radiation,
/obj/item/clothing/head/radiation,
/obj/item/clothing/suit/radiation,
/obj/item/clothing/suit/radiation,
/obj/item/geiger_counter,
/obj/item/geiger_counter)
containername = "radiation protection crate"
containertype = /obj/structure/closet/crate/radiation
/datum/supply_packs/engineering/engine/spacesuit
name = "Space Suit Crate"
contains = list(/obj/item/clothing/suit/space,
@@ -46,7 +46,7 @@
randmutg(H)
domutcheck(H, null, 1)
L.apply_effect(20, IRRADIATE, resist)
L.rad_act(20)
/datum/weather/rad_storm/end()
if(..())