Radiation rework and subsystem

This commit is contained in:
Emmett Gaines
2017-10-13 10:22:00 -04:00
committed by CitadelStationBot
parent 692e226d24
commit 55e8f6526c
72 changed files with 841 additions and 262 deletions
+9
View File
@@ -0,0 +1,9 @@
/datum/component/rad_insulation // Yes, this really is just a component to add some vars
var/amount // Multiplier for radiation strength passing through
var/protects // Does this protect things in its contents from being affected?
var/contamination_proof // Can this object be contaminated?
/datum/component/rad_insulation/Initialize(_amount=RAD_MEDIUM_INSULATION, _protects=TRUE, _contamination_proof=TRUE)
amount = _amount
protects = _protects
contamination_proof = _contamination_proof
+73
View File
@@ -0,0 +1,73 @@
#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
var/hl3_release_date //the half-life measured in ticks
var/strength
var/can_contaminate
/datum/component/radioactive/Initialize(_strength=0, _half_life=RAD_HALF_LIFE, _can_contaminate=TRUE)
strength = _strength
hl3_release_date = _half_life
can_contaminate = _can_contaminate
if(istype(parent, /atom))
RegisterSignal(COMSIG_PARENT_EXAMINE, .proc/rad_examine)
if(istype(parent, /obj/item))
RegisterSignal(COMSIG_ITEM_ATTACK, .proc/rad_attack)
RegisterSignal(COMSIG_ITEM_ATTACK_OBJ, .proc/rad_attack)
else
CRASH("Something that wasn't an atom was given /datum/component/radioactive")
return
START_PROCESSING(SSradiation, src)
/datum/component/radioactive/Destroy()
STOP_PROCESSING(SSradiation, src)
return ..()
/datum/component/radioactive/process()
radiation_pulse(get_turf(parent),strength,1,FALSE,can_contaminate)
if(hl3_release_date && prob(50))
strength -= strength / hl3_release_date
if(strength <= RAD_BACKGROUND_RADIATION)
qdel(src)
/datum/component/radioactive/InheritComponent(datum/component/C, i_am_original)
if(!i_am_original)
return
if(!hl3_release_date) // Permanently radioactive things don't get to grow stronger
return
var/datum/component/radioactive/other = C
strength = max(strength, other.strength)
return
/datum/component/radioactive/proc/rad_examine(mob/user, atom/thing)
var/atom/master = parent
var/list/out = list()
if(get_dist(master, user) <= 1)
out += "The air around [master] feels warm"
switch(strength)
if(RAD_AMOUNT_LOW to RAD_AMOUNT_MEDIUM)
out += "[out ? " and it " : "[master] "]feels weird to look at."
if(RAD_AMOUNT_MEDIUM to RAD_AMOUNT_HIGH)
out += "[out ? " and it " : "[master] "]seems to be glowing a bit."
if(RAD_AMOUNT_HIGH to INFINITY) //At this level the object can contaminate other objects
out += "[out ? " and it " : "[master] "]hurts to look at."
else
out += "."
to_chat(user, out.Join())
/datum/component/radioactive/proc/rad_attack(atom/movable/target, mob/living/user)
radiation_pulse(get_turf(target), strength/20)
target.rad_act(strength/2)
#undef RAD_AMOUNT_LOW
#undef RAD_AMOUNT_MEDIUM
#undef RAD_AMOUNT_HIGH
#undef RAD_AMOUNT_EXTREME
+98
View File
@@ -0,0 +1,98 @@
/datum/radiation_wave
var/turf/master_turf //The center of the wave
var/steps=0 //How far we've moved
var/intensity //How strong it was originaly
var/range_modifier //Higher than 1 makes it drop off faster, 0.5 makes it drop off half etc
var/move_dir //The direction of movement
var/list/__dirs //The directions to the side of the wave, stored for easy looping
var/can_contaminate
/datum/radiation_wave/New(turf/place, dir, _intensity=0, _range_modifier=RAD_DISTANCE_COEFFICIENT, _can_contaminate=TRUE)
master_turf = place
move_dir = dir
__dirs = list()
__dirs+=turn(dir, 90)
__dirs+=turn(dir, -90)
intensity = _intensity
range_modifier = _range_modifier
can_contaminate = _can_contaminate
START_PROCESSING(SSradiation, src)
/datum/radiation_wave/Destroy()
STOP_PROCESSING(SSradiation, src)
return ..()
/datum/radiation_wave/process()
master_turf = get_step(master_turf, move_dir)
steps++
var/list/atoms = get_rad_atoms()
var/strength
if(steps>1)
strength = InverseSquareLaw(intensity, max(range_modifier*steps, 1), 1)
else
strength = intensity
if(strength<RAD_BACKGROUND_RADIATION)
qdel(src)
return
radiate(atoms, Floor(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)
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
var/datum/component/rad_insulation/insulation = thing.GetComponent(/datum/component/rad_insulation)
if(!insulation)
continue
intensity = intensity*(1-((1-insulation.amount)/width)) // The further out the rad wave goes the less it's affected by insulation
/datum/radiation_wave/proc/radiate(list/atoms, strength)
for(var/k in 1 to atoms.len)
var/atom/thing = atoms[k]
if(!thing)
continue
thing.rad_act(strength)
var/static/list/blacklisted = typecacheof(list(/turf))
if(!can_contaminate || blacklisted[thing.type])
continue
if(prob((strength-RAD_MINIMUM_CONTAMINATION) * RAD_CONTAMINATION_CHANCE_COEFFICIENT * min(1/(steps*range_modifier), 1))) // Only stronk rads get to have little baby rads
var/datum/component/rad_insulation/insulation = thing.GetComponent(/datum/component/rad_insulation)
if(insulation && insulation.contamination_proof)
continue
else
thing.AddComponent(/datum/component/radioactive, (strength-RAD_MINIMUM_CONTAMINATION) * RAD_CONTAMINATION_STR_COEFFICIENT * min(1/(steps*range_modifier), 1))
@@ -43,7 +43,7 @@
else
H.randmutg()
H.domutcheck()
L.rad_act(20,1)
L.rad_act(20)
/datum/weather/rad_storm/end()
if(..())