diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm index 69b91d0dc3..e8242af113 100644 --- a/code/__defines/misc.dm +++ b/code/__defines/misc.dm @@ -353,7 +353,9 @@ var/global/list/##LIST_NAME = list();\ #define RAD_LEVEL_HIGH 25 #define RAD_LEVEL_VERY_HIGH 75 -#define RADIATION_THRESHOLD_CUTOFF 0.1 // Radiation will not affect a tile when below this value. +// Calculation modes for effective radiation +#define RAD_RESIST_CALC_DIV 0 // Each turf absorbs some fraction of the working radiation level +#define RAD_RESIST_CALC_SUB 1 // Each turf absorbs a fixed amount of radiation //https://secure.byond.com/docs/ref/info.html#/atom/var/mouse_opacity #define MOUSE_OPACITY_TRANSPARENT 0 diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 700b59fe59..c3c6e4eca6 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -235,8 +235,10 @@ var/list/gamemode_cache = list() var/show_human_death_message = 1 + var/radiation_resistance_calc_mode = RAD_RESIST_CALC_SUB // 0:1 subtraction:division for computing effective radiation on a turf var/radiation_decay_rate = 1 //How much radiation is reduced by each tick var/radiation_resistance_multiplier = 8.5 //VOREstation edit + var/radiation_material_resistance_divisor = 1 var/radiation_lower_limit = 0.35 //If the radiation level for a turf would be below this, ignore it. var/random_submap_orientation = FALSE // If true, submaps loaded automatically can be rotated. @@ -783,6 +785,21 @@ var/list/gamemode_cache = list() if("radiation_lower_limit") radiation_lower_limit = text2num(value) + if("radiation_resistance_calc_divide") + radiation_resistance_calc_mode = RAD_RESIST_CALC_DIV + + if("radiation_resistance_calc_subtract") + radiation_resistance_calc_mode = RAD_RESIST_CALC_SUB + + if("radiation_resistance_multiplier") + radiation_resistance_multiplier = text2num(value) + + if("radiation_material_resistance_divisor") + radiation_material_resistance_divisor = text2num(value) + + if("radiation_decay_rate") + radiation_decay_rate = text2num(value) + if ("panic_bunker") config.panic_bunker = 1 @@ -795,6 +812,8 @@ var/list/gamemode_cache = list() if("autostart_solars") config.autostart_solars = TRUE + + else log_misc("Unknown setting in configuration: '[name]'") diff --git a/code/controllers/subsystems/radiation.dm b/code/controllers/subsystems/radiation.dm index babc2c7d5d..50c72ddd60 100644 --- a/code/controllers/subsystems/radiation.dm +++ b/code/controllers/subsystems/radiation.dm @@ -67,8 +67,10 @@ SUBSYSTEM_DEF(radiation) var/datum/radiation_source/source = value if(source.rad_power < .) continue // Already being affected by a stronger source + if(source.source_turf.z != T.z) continue // Radiation is not multi-z + if(source.respect_maint) var/area/A = T.loc if(A.flags & RAD_SHIELDED) @@ -77,9 +79,10 @@ SUBSYSTEM_DEF(radiation) var/dist = get_dist(source.source_turf, T) if(dist > source.range) continue // Too far to possibly affect + if(source.flat) - . = max(., source.rad_power) - continue // No need to ray trace for flat field + . += source.rad_power + continue // No need to ray trace for flat field // Okay, now ray trace to find resistence! var/turf/origin = source.source_turf @@ -88,13 +91,23 @@ SUBSYSTEM_DEF(radiation) origin = get_step_towards(origin, T) //Raytracing if(!resistance_cache[origin]) //Only get the resistance if we don't already know it. origin.calc_rad_resistance() + if(origin.cached_rad_resistance) - working = round((working / (origin.cached_rad_resistance * config.radiation_resistance_multiplier)), 0.1) - if((working <= .) || (working <= RADIATION_THRESHOLD_CUTOFF)) - break // Already affected by a stronger source (or its zero...) - . = max((working / (dist ** 2)), .) //Butchered version of the inverse square law. Works for this purpose - if(. <= RADIATION_THRESHOLD_CUTOFF) - . = 0 + if(config.radiation_resistance_calc_mode == RAD_RESIST_CALC_DIV) + working = round((working / (origin.cached_rad_resistance * config.radiation_resistance_multiplier)), 0.01) + else if(config.radiation_resistance_calc_mode == RAD_RESIST_CALC_SUB) + working = round((working - (origin.cached_rad_resistance * config.radiation_resistance_multiplier)), 0.01) + + if(working <= config.radiation_lower_limit) // Too far from this source + working = 0 // May as well be 0 + break + + // Accumulate radiation from all sources in range, not just the biggest. + // Shouldn't really ever have practical uses, but standing in a room literally made from uranium is more dangerous than standing next to a single uranium vase + . += working / (dist ** 2) + + if(. <= config.radiation_lower_limit) + . = 0 // Add a radiation source instance to the repository. It will override any existing source on the same turf. /datum/controller/subsystem/radiation/proc/add_source(var/datum/radiation_source/S) diff --git a/code/modules/radiation/radiation.dm b/code/modules/radiation/radiation.dm index d913ad7cab..dc14c630f6 100644 --- a/code/modules/radiation/radiation.dm +++ b/code/modules/radiation/radiation.dm @@ -24,6 +24,7 @@ rad_power = new_power if(!flat) range = min(round(sqrt(rad_power / config.radiation_lower_limit)), 31) // R = rad_power / dist**2 - Solve for dist + return /turf var/cached_rad_resistance = 0 @@ -37,13 +38,15 @@ else if(O.density) //So open doors don't get counted var/material/M = O.get_material() if(!M) continue - cached_rad_resistance += M.weight + M.radiation_resistance + cached_rad_resistance += (M.weight + M.radiation_resistance) / config.radiation_material_resistance_divisor // Looks like storing the contents length is meant to be a basic check if the cache is stale due to items enter/exiting. Better than nothing so I'm leaving it as is. ~Leshana SSradiation.resistance_cache[src] = (length(contents) + 1) + return /turf/simulated/wall/calc_rad_resistance() SSradiation.resistance_cache[src] = (length(contents) + 1) - cached_rad_resistance = (density ? material.weight + material.radiation_resistance : 0) + cached_rad_resistance = (density ? material.weight / config.radiation_material_resistance_divisor : 0) + return /obj var/rad_resistance = 0 // Allow overriding rad resistance @@ -56,4 +59,5 @@ if(severity && !isbelly(loc)) //eaten mobs are made immune to radiation //VOREStation Edit src.apply_effect(severity, IRRADIATE, src.getarmor(null, "rad")) for(var/atom/I in src) - I.rad_act(severity) \ No newline at end of file + I.rad_act(severity) + return \ No newline at end of file diff --git a/config/example/config.txt b/config/example/config.txt index 06e02d14fc..434bd2233d 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -447,3 +447,21 @@ ENGINE_MAP Supermatter Engine,Edison's Bane ## Uncomment to allow specific solar control computers to set themselves up. ## This requires solar controller computers in the map to be set up to use it, with the auto_start variable. # AUTOSTART_SOLARS + +## Rate of radiation decay (how much it's reduced by) per life tick +RADIATION_DECAY_RATE 1 + +## Lower limit on radiation for actually irradiating things on a turf +RADIATION_LOWER_LIMIT 0.01 + +## Multiplier for radiation resistances when tracing a ray from source to destination to compute radiation on a turf +RADIATION_RESISTANCE_MULTIPLIER 2.1 + +## Divisor for material weights when computing radiation resistance of a material object (walls) +RADIATION_MATERIAL_RESISTANCE_DIVISOR 16 + + +## Mode of computing radiation resistance into effective radiation on a turf +## One and only one of the following options must be uncommented +RADIATION_RESISTANCE_CALC_DIVIDE +# RADIATION_RESISTANCE_CALC_SUBTRACT \ No newline at end of file diff --git a/html/changelogs/atermonera - rad_buff.yml b/html/changelogs/atermonera - rad_buff.yml new file mode 100644 index 0000000000..9b8c3b8afa --- /dev/null +++ b/html/changelogs/atermonera - rad_buff.yml @@ -0,0 +1,4 @@ +author: Atermonera +delete-after: True +changes: + - bugfix: "Radiation has been made more potent and is no longer defeated by a thin sheet of lead."