Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions code/__HELPERS/radiation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
65 changes: 42 additions & 23 deletions code/datums/radiation_wave.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down Expand Up @@ -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
Expand All @@ -360,6 +363,7 @@
return

operating = TRUE
rad_insulation = rad_insulation_closed // PENTEST ADDITION - RADIATION REFACTOR

do_animate("closing")
layer = closingLayer
Expand Down
2 changes: 2 additions & 0 deletions code/game/objects/structures/false_walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions code/game/objects/structures/mineral_doors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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":""]"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/machinery/door/airlock
rad_insulation = RAD_MEDIUM_INSULATION //Generally start closed.
rad_insulation_closed = RAD_MEDIUM_INSULATION
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/machinery/door/window
rad_insulation = RAD_LIGHT_INSULATION
rad_insulation_closed = RAD_LIGHT_INSULATION
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions modular_pentest/master_files/code/game/structures/window.dm
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/obj/machinery/door/poddoor/crusher/automatic/preopen
rad_insulation = RAD_NO_INSULATION
7 changes: 7 additions & 0 deletions modular_pentest/~pentest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Loading