diff --git a/code/__HELPERS/radiation.dm b/code/__HELPERS/radiation.dm index d77add64e50..dfc578c1861 100644 --- a/code/__HELPERS/radiation.dm +++ b/code/__HELPERS/radiation.dm @@ -22,6 +22,33 @@ continue processing_list += thing.contents +// PENTEST ADDITION - RADIATION REFACTOR START - same as base but also returns a list of insulation values. +/proc/get_rad_insulation_contents(atom/location, datum/radiation_wave/src_wave, width = 1) + var/static/list/ignored_things = typecacheof(list( + /mob/dead, + /mob/camera, + /obj/effect, + /obj/docking_port, + /atom/movable/lighting_object, + /obj/projectile, + )) + var/list/processing_list = list(location) + var/best_insulation = RAD_NO_INSULATION + var/return_list = list() + while(processing_list.len) + var/atom/thing = processing_list[1] + processing_list -= thing + if(ignored_things[thing.type]) + continue + return_list += thing + if (!(SEND_SIGNAL(thing, COMSIG_ATOM_RAD_WAVE_PASSING, src_wave, width) & COMPONENT_RAD_WAVE_HANDLED)) + best_insulation = min(thing.rad_insulation, best_insulation) + if((thing.flags_1 & RAD_PROTECT_CONTENTS_1) || (SEND_SIGNAL(thing, COMSIG_ATOM_RAD_PROBE) & COMPONENT_BLOCK_RADIATION)) + continue + processing_list += thing.contents + return list(return_list, best_insulation) +// PENTEST ADDITION - RADIATION REFACTOR END + /proc/radiation_pulse(atom/source, intensity, range_modifier, log=FALSE, can_contaminate=TRUE) // fusion will never ever be balanced. god bless it intensity = min(intensity, INFINITY) diff --git a/code/datums/radiation_wave.dm b/code/datums/radiation_wave.dm index 10e3b28e722..0921e6b361b 100644 --- a/code/datums/radiation_wave.dm +++ b/code/datums/radiation_wave.dm @@ -65,50 +65,69 @@ qdel(src) return - var/list/atoms = get_rad_atoms() + // PENTEST ADDITION - RADIATION REFACTOR - START + var/width = steps + var/cmove_dir = move_dir + if(cmove_dir == NORTH || cmove_dir == SOUTH) + width-- + width = 1+(2*width) + + var/list/atoms_and_insulation = get_rad_atoms(width) + var/list/atoms = atoms_and_insulation[1] if(radiate(atoms, FLOOR(min(strength,remaining_contam), 1))) //oof ow ouch remaining_contam = max(0,remaining_contam-((min(strength,remaining_contam)-RAD_MINIMUM_CONTAMINATION) * RAD_CONTAMINATION_STR_COEFFICIENT)) - check_obstructions(atoms) // reduce our overall strength if there are radiation insulators -/datum/radiation_wave/proc/get_rad_atoms() + var/insulation_tally = atoms_and_insulation[2] + if(insulation_tally) + var/insulation_total = atoms_and_insulation[3] + var/average_insulation = insulation_total / insulation_tally + // Determines how much the width dilutes the obstacle's effect. + // Using the square root of width (width ** 0.5) prevents the obstacles from becoming irrelevant at long distances. + var/spread_factor = max(1, width ** 0.5) + + // The exponent calculates the effective "thickness" of the wall relative to the wave size. + var/obstacle_density = insulation_tally / spread_factor + + // Apply the reduction. + intensity *= (average_insulation ** obstacle_density) + +/datum/radiation_wave/proc/get_rad_atoms(width = 1) var/list/atoms = list() var/distance = steps var/cmove_dir = move_dir var/cmaster_turf = master_turf + var/insulation_total = 0 + var/insulation_tally = 0 if(cmove_dir == NORTH || cmove_dir == SOUTH) distance-- //otherwise corners overlap - atoms += get_rad_contents(cmaster_turf) + var/list/master_turf_contents = get_rad_insulation_contents(cmaster_turf, src, width) + atoms += master_turf_contents[1] + var/best_insulation = master_turf_contents[2] + if(best_insulation != RAD_NO_INSULATION) + insulation_total += best_insulation + insulation_tally++ var/turf/place + var/list/place_turf_contents 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(!is_valid_rad_turf(place)) break // the break here is important. if a rad wave was travelling parallel to a virtual z edge, and the loop didn't break, it could "clip through" - 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)) + place_turf_contents = get_rad_insulation_contents(place, src, width) + atoms += place_turf_contents[1] + best_insulation = place_turf_contents[2] + if(best_insulation != RAD_NO_INSULATION) + insulation_total += place_turf_contents[2] + insulation_tally++ + + return list(atoms, insulation_tally, insulation_total) +// PENTEST RADIATION REFACTOR - END /datum/radiation_wave/proc/radiate(list/atoms, strength) var/can_contam = strength >= RAD_MINIMUM_CONTAMINATION diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index 10b3f44aabe..e9c7615b188 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -1285,6 +1285,7 @@ layer = OPEN_DOOR_LAYER update_icon(ALL, AIRLOCK_OPEN, TRUE) operating = FALSE + rad_insulation = RAD_NO_INSULATION // PENTEST ADDITION - RADIATION REFACTOR if(delayed_close_requested) delayed_close_requested = FALSE addtimer(CALLBACK(src, PROC_REF(close)), 1) @@ -1340,6 +1341,7 @@ update_icon(ALL, AIRLOCK_CLOSED, 1) operating = FALSE delayed_close_requested = FALSE + rad_insulation = rad_insulation_closed // PENTEST ADDITION - RADIATION REFACTOR if(safe) CheckForMobs() return TRUE diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index b0074a2b493..a1441549e52 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -44,7 +44,9 @@ var/unres_sides = 0 //Unrestricted sides. A bitflag for which direction (if any) can open the door with no access var/safety_mode = FALSE ///Whether or not the airlock can be opened with bare hands while unpowered var/can_crush = TRUE /// Whether or not the door can crush mobs. - + // PENTEST ADDITION - RADIATION REFACTOR START + var/rad_insulation_closed = RAD_NO_INSULATION /// How much rad_insulation it has when closed, so that it can be modified for closed/open state. + // PENTEST ADDITION - RADIATION REFACTOR END /obj/machinery/door/examine(mob/user) . = ..() @@ -343,6 +345,7 @@ operating = FALSE air_update_turf(1) update_freelook_sight() + rad_insulation = RAD_NO_INSULATION // PENTEST ADDITION - RADIATION REFACTOR if(autoclose) addtimer(CALLBACK(src, PROC_REF(close)), autoclose) return 1 @@ -360,6 +363,7 @@ return operating = TRUE + rad_insulation = rad_insulation_closed // PENTEST ADDITION - RADIATION REFACTOR do_animate("closing") layer = closingLayer diff --git a/code/game/objects/structures/false_walls.dm b/code/game/objects/structures/false_walls.dm index 87932e81553..eb7b08fd73d 100644 --- a/code/game/objects/structures/false_walls.dm +++ b/code/game/objects/structures/false_walls.dm @@ -19,6 +19,7 @@ CanAtmosPass = ATMOS_PASS_DENSITY flags_1 = RAD_PROTECT_CONTENTS_1 | RAD_NO_CONTAMINATE_1 rad_insulation = RAD_MEDIUM_INSULATION + var/rad_insulation_closed = RAD_MEDIUM_INSULATION // PENTEST ADDITION - RADIATION REFACTOR var/mineral = /obj/item/stack/sheet/metal var/mineral_amount = 2 var/walltype = /turf/closed/wall @@ -57,6 +58,7 @@ set_opacity(density) opening = FALSE update_appearance() + rad_insulation = density? rad_insulation_closed : RAD_NO_INSULATION // PENTEST ADDITION - RADIATION REFACTOR air_update_turf(TRUE) /obj/structure/falsewall/update_icon()//Calling icon_update will refresh the smoothwalls if it's closed, otherwise it will make sure the icon is correct if it's open diff --git a/code/game/objects/structures/mineral_doors.dm b/code/game/objects/structures/mineral_doors.dm index 2f14c90292b..71e570375a7 100644 --- a/code/game/objects/structures/mineral_doors.dm +++ b/code/game/objects/structures/mineral_doors.dm @@ -15,7 +15,7 @@ CanAtmosPass = ATMOS_PASS_DENSITY flags_1 = RAD_PROTECT_CONTENTS_1 | RAD_NO_CONTAMINATE_1 rad_insulation = RAD_MEDIUM_INSULATION - + var/rad_insulation_closed = RAD_MEDIUM_INSULATION // PENTEST ADDITION - RADIATION REFACTOR var/door_opened = FALSE //if it's open or not. var/isSwitchingStates = FALSE //don't try to change stats if we're already opening @@ -98,7 +98,7 @@ air_update_turf(TRUE) update_appearance() isSwitchingStates = FALSE - + rad_insulation = RAD_NO_INSULATION // PENTEST ADDITION - RADIATION REFACTOR if(close_delay != -1) addtimer(CALLBACK(src, PROC_REF(Close)), close_delay) @@ -120,6 +120,7 @@ air_update_turf(TRUE) update_appearance() isSwitchingStates = FALSE + rad_insulation = rad_insulation_closed // PENTEST ADDITION - RADIATION REFACTOR /obj/structure/mineral_door/update_icon_state() icon_state = "[initial(icon_state)][door_opened ? "open":""]" diff --git a/modular_pentest/master_files/code/game/machinery/doors/airlock.dm b/modular_pentest/master_files/code/game/machinery/doors/airlock.dm new file mode 100644 index 00000000000..d351f92d8db --- /dev/null +++ b/modular_pentest/master_files/code/game/machinery/doors/airlock.dm @@ -0,0 +1,3 @@ +/obj/machinery/door/airlock + rad_insulation = RAD_MEDIUM_INSULATION //Generally start closed. + rad_insulation_closed = RAD_MEDIUM_INSULATION diff --git a/modular_pentest/master_files/code/game/machinery/doors/firedoor.dm b/modular_pentest/master_files/code/game/machinery/doors/firedoor.dm new file mode 100644 index 00000000000..c3fa1f10fe2 --- /dev/null +++ b/modular_pentest/master_files/code/game/machinery/doors/firedoor.dm @@ -0,0 +1,15 @@ +/obj/machinery/door/firedoor + rad_insulation = RAD_NO_INSULATION //Generally start open. + rad_insulation_closed = RAD_MEDIUM_INSULATION //Same as airlocks. + +/obj/machinery/door/firedoor/closed + rad_insulation = RAD_MEDIUM_INSULATION + +/obj/machinery/door/firedoor/border_only/closed + rad_insulation = RAD_MEDIUM_INSULATION + +/obj/machinery/door/firedoor/heavy/closed + rad_insulation = RAD_MEDIUM_INSULATION + +/obj/machinery/door/firedoor/window + rad_insulation_closed = RAD_LIGHT_INSULATION //Not as good as firedoors. diff --git a/modular_pentest/master_files/code/game/machinery/doors/poddoor.dm b/modular_pentest/master_files/code/game/machinery/doors/poddoor.dm new file mode 100644 index 00000000000..e10b17cdbf3 --- /dev/null +++ b/modular_pentest/master_files/code/game/machinery/doors/poddoor.dm @@ -0,0 +1,6 @@ +/obj/machinery/door/poddoor + rad_insulation = RAD_HEAVY_INSULATION + rad_insulation_closed = RAD_HEAVY_INSULATION + +/obj/machinery/door/poddoor/preopen + rad_insulation = RAD_NO_INSULATION diff --git a/modular_pentest/master_files/code/game/machinery/doors/shutters.dm b/modular_pentest/master_files/code/game/machinery/doors/shutters.dm new file mode 100644 index 00000000000..8722bfba21a --- /dev/null +++ b/modular_pentest/master_files/code/game/machinery/doors/shutters.dm @@ -0,0 +1,9 @@ +/obj/machinery/door/poddoor/shutters/preopen + rad_insulation = RAD_NO_INSULATION + +/obj/machinery/door/poddoor/shutters/indestructible/preopen + rad_insulation = RAD_NO_INSULATION + +/obj/machinery/door/poddoor/gates + rad_insulation = RAD_NO_INSULATION //Offer no insulation. + rad_insulation_closed = RAD_NO_INSULATION diff --git a/modular_pentest/master_files/code/game/machinery/doors/windowdoor.dm b/modular_pentest/master_files/code/game/machinery/doors/windowdoor.dm new file mode 100644 index 00000000000..f20bde9c200 --- /dev/null +++ b/modular_pentest/master_files/code/game/machinery/doors/windowdoor.dm @@ -0,0 +1,3 @@ +/obj/machinery/door/window + rad_insulation = RAD_LIGHT_INSULATION + rad_insulation_closed = RAD_LIGHT_INSULATION diff --git a/modular_pentest/master_files/code/game/objects/items/puzzle_pieces.dm b/modular_pentest/master_files/code/game/objects/items/puzzle_pieces.dm index c43c5476ca6..7cb222c4262 100644 --- a/modular_pentest/master_files/code/game/objects/items/puzzle_pieces.dm +++ b/modular_pentest/master_files/code/game/objects/items/puzzle_pieces.dm @@ -33,6 +33,9 @@ desc = "A key belonging to a once peaceful scholar, brought to death and ruin through means of violence by savage outsider." puzzle_id = "priestkey" +/obj/machinery/door/keycard/gates + rad_insulation = RAD_NO_INSULATION //Offer no insulation. Redefining to make clear in case parent changes. + rad_insulation_closed = RAD_NO_INSULATION /obj/machinery/door/keycard/gates/drakelair puzzle_id = "drakelairkey" diff --git a/modular_pentest/master_files/code/game/structures/window.dm b/modular_pentest/master_files/code/game/structures/window.dm new file mode 100644 index 00000000000..0d0b604df70 --- /dev/null +++ b/modular_pentest/master_files/code/game/structures/window.dm @@ -0,0 +1,8 @@ +/obj/structure/window/reinforced + rad_insulation = RAD_MEDIUM_INSULATION + +/obj/structure/window/plasma + rad_insulation = RAD_LIGHT_INSULATION + +/obj/structure/window/plasma/reinforced/plastitanium + rad_insulation = RAD_MEDIUM_INSULATION diff --git a/modular_pentest/master_files/code/modules/ruins/rockplanet_ruin_code.dm b/modular_pentest/master_files/code/modules/ruins/rockplanet_ruin_code.dm new file mode 100644 index 00000000000..3722d4c4a3a --- /dev/null +++ b/modular_pentest/master_files/code/modules/ruins/rockplanet_ruin_code.dm @@ -0,0 +1,2 @@ +/obj/machinery/door/poddoor/crusher/automatic/preopen + rad_insulation = RAD_NO_INSULATION diff --git a/modular_pentest/~pentest.dme b/modular_pentest/~pentest.dme index 0f01ffcb89f..93fb091b2d5 100644 --- a/modular_pentest/~pentest.dme +++ b/modular_pentest/~pentest.dme @@ -32,7 +32,13 @@ #include "master_files\code\game\atoms.dm" #include "master_files\code\game\pentest_proc.dm" #include "master_files\code\game\items\tools\weldingtool.dm" +#include "master_files\code\game\structures\window.dm" #include "master_files\code\game\machinery\computer\crew.dm" +#include "master_files\code\game\machinery\doors\airlock.dm" +#include "master_files\code\game\machinery\doors\firedoor.dm" +#include "master_files\code\game\machinery\doors\poddoor.dm" +#include "master_files\code\game\machinery\doors\shutters.dm" +#include "master_files\code\game\machinery\doors\windowdoor.dm" #include "master_files\code\game\mecha\mech_fabricator.dm" #include "master_files\code\game\mecha\equipment\tools\mech_fabricator.dm" #include "master_files\code\game\objects\AI_modules.dm" @@ -204,6 +210,7 @@ #include "master_files\code\modules\reagents\chemistry\recipes\others.dm" #include "master_files\code\modules\reagents\chemistry\recipes\toxins.dm" #include "master_files\code\modules\reagents\reagent_containers\bottle.dm" +#include "master_files\code\modules\ruins\rockplanet_ruin_code.dm" #include "master_files\code\modules\ships\controlled_ship_datum.dm" #include "master_files\code\modules\spells\spell_types\aimed.dm" #include "master_files\code\modules\spells\spell_types\wizard.dm"