From 3cd86a33c66bd76d9372d9aec359be1735af9e41 Mon Sep 17 00:00:00 2001 From: Dip Date: Mon, 28 Sep 2020 22:18:29 -0300 Subject: [PATCH] Radiation Update Port --- code/__DEFINES/radiation.dm | 6 ++-- code/__HELPERS/radiation.dm | 32 ++++++++++++------- code/datums/components/radioactive.dm | 19 ++++++----- code/game/machinery/suit_storage_unit.dm | 26 +++++++++++---- .../objects/items/devices/geiger_counter.dm | 2 ++ 5 files changed, 57 insertions(+), 28 deletions(-) diff --git a/code/__DEFINES/radiation.dm b/code/__DEFINES/radiation.dm index 3e973141..ad2daffb 100644 --- a/code/__DEFINES/radiation.dm +++ b/code/__DEFINES/radiation.dm @@ -41,9 +41,9 @@ Ask ninjanomnom if they're around // WARNING: The deines below could have disastrous consequences if tweaked incorrectly. See: The great SM purge of Oct.6.2017 // contamination_chance = (strength-RAD_MINIMUM_CONTAMINATION) * RAD_CONTAMINATION_CHANCE_COEFFICIENT * min(1/(steps*RAD_DISTANCE_COEFFICIENT), 1)) // contamination_strength = (strength-RAD_MINIMUM_CONTAMINATION) * RAD_CONTAMINATION_STR_COEFFICIENT -#define RAD_MINIMUM_CONTAMINATION 350 // How strong does a radiation wave have to be to contaminate objects +#define RAD_MINIMUM_CONTAMINATION 300 // How strong does a radiation wave have to be to contaminate objects #define RAD_CONTAMINATION_CHANCE_COEFFICIENT 0.005 // Higher means higher strength scaling contamination chance -#define RAD_CONTAMINATION_STR_COEFFICIENT 0.3 // Higher means higher strength scaling contamination strength +#define RAD_CONTAMINATION_STR_COEFFICIENT 0.99 // Higher means higher strength scaling contamination strength #define RAD_DISTANCE_COEFFICIENT 1 // Lower means further rad spread -#define RAD_HALF_LIFE 90 // The half-life of contaminated objects \ No newline at end of file +#define RAD_HALF_LIFE 90 // The half-life of contaminated objects diff --git a/code/__HELPERS/radiation.dm b/code/__HELPERS/radiation.dm index e082be7d..8c34ce35 100644 --- a/code/__HELPERS/radiation.dm +++ b/code/__HELPERS/radiation.dm @@ -12,9 +12,9 @@ )) var/list/processing_list = list(location) . = list() - while(processing_list.len) - var/atom/thing = processing_list[1] - processing_list -= thing + var/i = 0 + while(i < length(processing_list)) + var/atom/thing = processing_list[++i] if(ignored_things[thing.type]) continue . += thing @@ -25,8 +25,22 @@ /proc/radiation_pulse(atom/source, intensity, range_modifier, log=FALSE, can_contaminate=TRUE) if(!SSradiation.can_fire) return - for(var/dir in GLOB.cardinals) - new /datum/radiation_wave(source, dir, intensity, range_modifier, can_contaminate) + var/area/A = get_area(source) + var/atom/nested_loc = source.loc + var/spawn_waves = TRUE + while(nested_loc != A) + if(nested_loc.rad_flags & RAD_PROTECT_CONTENTS) + spawn_waves = FALSE + break + nested_loc = nested_loc.loc + if(spawn_waves) + for(var/dir in GLOB.cardinals) + new /datum/radiation_wave(source, dir, intensity, range_modifier, can_contaminate) + + var/static/last_huge_pulse = 0 + if(intensity > 3000 && world.time > last_huge_pulse + 200) + last_huge_pulse = world.time + log = TRUE var/list/things = get_rad_contents(source) //copypasta because I don't want to put special code in waves to handle their origin for(var/k in 1 to things.len) @@ -35,11 +49,7 @@ continue thing.rad_act(intensity) - var/static/last_huge_pulse = 0 - if(intensity > 3000 && world.time > last_huge_pulse + 200) - last_huge_pulse = world.time - log = TRUE if(log) - var/turf/_source_T = isturf(source) ? source : get_turf(source) - log_game("Radiation pulse with intensity: [intensity] and range modifier: [range_modifier] in [loc_name(_source_T)] ") + var/turf/_source_T = get_turf(source) + log_game("Radiation pulse with intensity: [intensity] and range modifier: [range_modifier] in [loc_name(_source_T)][spawn_waves ? "" : " (contained by [nested_loc.name])"]") return TRUE diff --git a/code/datums/components/radioactive.dm b/code/datums/components/radioactive.dm index 674ab2ef..8afa4353 100644 --- a/code/datums/components/radioactive.dm +++ b/code/datums/components/radioactive.dm @@ -18,14 +18,13 @@ hl3_release_date = _half_life can_contaminate = _can_contaminate - if(istype(parent, /atom)) + 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 CRASH("Something that wasn't an atom was given /datum/component/radioactive") - return if(strength > RAD_MINIMUM_CONTAMINATION) SSradiation.warn(src) @@ -55,13 +54,14 @@ if(strength <= RAD_BACKGROUND_RADIATION) 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, list/arguments) +/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 @@ -70,9 +70,9 @@ var/datum/component/radioactive/other = C strength = max(strength, other.strength) else - strength = max(strength, arguments[1]) + strength = max(strength, _strength) -/datum/component/radioactive/proc/rad_examine(datum/source, mob/user, atom/thing) +/datum/component/radioactive/proc/rad_examine(datum/source, mob/user, list/examine_list) var/atom/master = parent var/list/out = list() if(get_dist(master, user) <= 1) @@ -84,13 +84,16 @@ 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()) + if(!LAZYLEN(out)) + return + out += "." + examine_list += out.Join() /datum/component/radioactive/proc/rad_attack(datum/source, atom/movable/target, mob/living/user) radiation_pulse(parent, strength/20) target.rad_act(strength/2) + if(!hl3_release_date) + return strength -= strength / hl3_release_date #undef RAD_AMOUNT_LOW diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index 19e71bcf..85720764 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -247,9 +247,25 @@ visible_message("[src]'s door slides open, barraging you with the nauseating smell of charred flesh.") mob_occupant.radiation = 0 playsound(src, 'sound/machines/airlockclose.ogg', 25, 1) - for(var/obj/item/I in src) //Scorches away blood and forensic evidence, although the SSU itself is unaffected - SEND_SIGNAL(I, COMSIG_COMPONENT_CLEAN_ACT, CLEAN_STRONG) - var/datum/component/radioactive/contamination = I.GetComponent(/datum/component/radioactive) + var/list/things_to_clear = list() //Done this way since using GetAllContents on the SSU itself would include circuitry and such. + if(suit) + things_to_clear += suit + things_to_clear += suit.GetAllContents() + if(helmet) + things_to_clear += helmet + things_to_clear += helmet.GetAllContents() + if(mask) + things_to_clear += mask + things_to_clear += mask.GetAllContents() + if(storage) + things_to_clear += storage + things_to_clear += storage.GetAllContents() + if(occupant) + things_to_clear += occupant + things_to_clear += occupant.GetAllContents() + for(var/atom/movable/AM in things_to_clear) //Scorches away blood and forensic evidence, although the SSU itself is unaffected + SEND_SIGNAL(AM, COMSIG_COMPONENT_CLEAN_ACT, CLEAN_STRONG) + var/datum/component/radioactive/contamination = AM.GetComponent(/datum/component/radioactive) if(contamination) qdel(contamination) open_machine(FALSE) @@ -278,8 +294,6 @@ open_machine() dump_contents() return - user.changeNext_move(CLICK_CD_BREAKOUT) - user.last_special = world.time + CLICK_CD_BREAKOUT user.visible_message("You see [user] kicking against the doors of [src]!", \ "You start kicking against the doors... (this will take about [DisplayTimeText(breakout_time)].)", \ "You hear a thump from [src].") @@ -309,7 +323,7 @@ /obj/machinery/suit_storage_unit/attackby(obj/item/I, mob/user, params) if(state_open && is_operational()) if(istype(I, /obj/item/clothing/head/mob_holder)) - to_chat(user, "You can't quite fit that while you hold it!") + to_chat(user, "You can't quite fit that in while you hold it!") return if(istype(I, /obj/item/clothing/suit)) if(suit) diff --git a/code/game/objects/items/devices/geiger_counter.dm b/code/game/objects/items/devices/geiger_counter.dm index 7823e570..fe6fecbb 100644 --- a/code/game/objects/items/devices/geiger_counter.dm +++ b/code/game/objects/items/devices/geiger_counter.dm @@ -18,6 +18,7 @@ righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' w_class = WEIGHT_CLASS_SMALL slot_flags = ITEM_SLOT_BELT + rad_flags = RAD_NO_CONTAMINATE materials = list(MAT_METAL = 150, MAT_GLASS = 150) var/grace = RAD_GRACE_PERIOD @@ -38,6 +39,7 @@ /obj/item/geiger_counter/Destroy() STOP_PROCESSING(SSobj, src) + QDEL_NULL(soundloop) return ..() /obj/item/geiger_counter/process()