diff --git a/code/__DEFINES/reactions.dm b/code/__DEFINES/reactions.dm index f5559e795a7..dcb6e93a065 100644 --- a/code/__DEFINES/reactions.dm +++ b/code/__DEFINES/reactions.dm @@ -13,6 +13,9 @@ /// An exponent used to make large volume gas mixtures significantly less likely to release rads. Used to prevent tritfires in distro from irradiating literally the entire station with no warning. #define ATMOS_RADIATION_VOLUME_EXP 3 +/// Maximum range a radiation pulse is allowed to be from a gas reaction. +#define GAS_REACTION_MAXIMUM_RADIATION_PULSE_RANGE 20 + // Water Vapor: /// The temperature required for water vapor to condense. #define WATER_VAPOR_CONDENSATION_POINT (T20C + 10) @@ -85,13 +88,9 @@ /// The minimum released energy necessary for tritium to release radiation during combustion. (at a mix volume of [CELL_VOLUME]). #define TRITIUM_RADIATION_RELEASE_THRESHOLD (FIRE_TRITIUM_ENERGY_RELEASED * TRITIUM_OXYBURN_MULTIPLIER) /// A scaling factor for the range of radiation pulses produced by tritium fires. -#define TRITIUM_RADIATION_RANGE_DIVISOR 4 +#define TRITIUM_RADIATION_RANGE_DIVISOR 1.5 /// A scaling factor for the irradiation threshold of radiation pulses produced by tritium fires. #define TRITIUM_RADIATION_THRESHOLD_BASE 15 -/// A scaling factor for the irradiation chance from energy released. This is the energy release required for everything in range to have a 50% chance of getting irradiated. -#define TRITIUM_RADIATION_CHANCE_ENERGY_THRESHOLD_BASE 1.68e9 -/// The minimum radiation pulse range from tritium fires. -#define TRITIUM_MINIMUM_RADIATION_RANGE 6 // - Freon: /// The maximum temperature freon can combust at. diff --git a/code/__HELPERS/radiation.dm b/code/__HELPERS/radiation.dm index 477cbbd197d..345d2f89196 100644 --- a/code/__HELPERS/radiation.dm +++ b/code/__HELPERS/radiation.dm @@ -15,6 +15,10 @@ /// You can also pass in a minimum exposure time. If this is set, then this radiation pulse /// will not irradiate the source unless they have been around *any* radioactive source for that /// period of time. +/// The chance to get irradiated diminishes over range, and from objects that block radiation. +/// Assuming there is nothing in the way, the chance will determine what the chance is to get irradiated from half of max_range. +/// Example: If chance is equal to 30%, and max_range is equal to 8, +/// then the chance for a thing to get irradiated is 30% if they are 4 turfs away from the pulse source. /proc/radiation_pulse( atom/source, max_range, diff --git a/code/controllers/subsystem/radiation.dm b/code/controllers/subsystem/radiation.dm index afd570ff31e..1a60e09dccc 100644 --- a/code/controllers/subsystem/radiation.dm +++ b/code/controllers/subsystem/radiation.dm @@ -57,6 +57,23 @@ SUBSYSTEM_DEF(radiation) if (current_insulation <= pulse_information.threshold) continue + /// Perceived chance of target getting irradiated. + var/perceived_chance + /// Intensity variable which will describe the radiation pulse. + /// It is used by perceived intensity, which diminishes over range. The chance of the target getting irradiated is determined by perceived_intensity. + /// Intensity is calculated so that the chance of getting irradiated at half of the max range is the same as the chance parameter. + var/intensity + /// Diminishes over range. Used by perceived chance, which is the actual chance to get irradiated. + var/perceived_intensity + + if(pulse_information.chance < 100) // Prevents log(0) runtime if chance is 100% + intensity = -log(1 - pulse_information.chance / 100) * (1 + pulse_information.max_range / 2) ** 2 + perceived_intensity = intensity * INVERSE((1 + get_dist_euclidian(source, target)) ** 2) // Diminishes over range. + perceived_intensity *= (current_insulation - pulse_information.threshold) * INVERSE(1 - pulse_information.threshold) // Perceived intensity decreases as objects that absorb radiation block its trajectory. + perceived_chance = 100 * (1 - NUM_E ** -perceived_intensity) + else + perceived_chance = 100 + var/irradiation_result = SEND_SIGNAL(target, COMSIG_IN_THRESHOLD_OF_IRRADIATION, pulse_information) if (irradiation_result & CANCEL_IRRADIATION) continue @@ -65,7 +82,7 @@ SUBSYSTEM_DEF(radiation) target.AddComponent(/datum/component/radiation_countdown, pulse_information.minimum_exposure_time) continue - if (!prob(pulse_information.chance)) + if (!prob(perceived_chance)) continue if (irradiate_after_basic_checks(target)) diff --git a/code/modules/atmospherics/gasmixtures/reactions.dm b/code/modules/atmospherics/gasmixtures/reactions.dm index 811de00a216..eb690f56119 100644 --- a/code/modules/atmospherics/gasmixtures/reactions.dm +++ b/code/modules/atmospherics/gasmixtures/reactions.dm @@ -352,7 +352,7 @@ var/energy_released = FIRE_TRITIUM_ENERGY_RELEASED * burned_fuel * effect_scale if(location && burned_fuel > TRITIUM_RADIATION_MINIMUM_MOLES && energy_released > TRITIUM_RADIATION_RELEASE_THRESHOLD * (air.volume / CELL_VOLUME) ** ATMOS_RADIATION_VOLUME_EXP && prob(10)) - radiation_pulse(location, max_range = min(TRITIUM_MINIMUM_RADIATION_RANGE + sqrt(burned_fuel * effect_scale / TRITIUM_OXYBURN_MULTIPLIER) / TRITIUM_RADIATION_RANGE_DIVISOR, 20), threshold = TRITIUM_RADIATION_THRESHOLD_BASE * INVERSE(TRITIUM_RADIATION_THRESHOLD_BASE + (burned_fuel * effect_scale / TRITIUM_OXYBURN_MULTIPLIER)), chance = 100 * (1 - 0.5 ** (energy_released / TRITIUM_RADIATION_CHANCE_ENERGY_THRESHOLD_BASE))) + radiation_pulse(location, max_range = min(sqrt(burned_fuel * effect_scale / TRITIUM_OXYBURN_MULTIPLIER) / TRITIUM_RADIATION_RANGE_DIVISOR, GAS_REACTION_MAXIMUM_RADIATION_PULSE_RANGE), threshold = TRITIUM_RADIATION_THRESHOLD_BASE * INVERSE(TRITIUM_RADIATION_THRESHOLD_BASE + (burned_fuel * effect_scale / TRITIUM_OXYBURN_MULTIPLIER))) if(energy_released > 0) var/new_heat_capacity = air.heat_capacity() @@ -1090,7 +1090,7 @@ else if(isatom(holder)) location = holder if (location && energy_released > PN_BZASE_RAD_RELEASE_THRESHOLD * (air.volume / CELL_VOLUME) ** ATMOS_RADIATION_VOLUME_EXP) - radiation_pulse(location, max_range = min(sqrt(produced_amount) / PN_TRITIUM_RAD_RANGE_DIVISOR, 20), threshold = PN_TRITIUM_RAD_THRESHOLD_BASE * INVERSE(PN_TRITIUM_RAD_THRESHOLD_BASE + produced_amount), chance = 50) + radiation_pulse(location, max_range = min(sqrt(produced_amount) / PN_TRITIUM_RAD_RANGE_DIVISOR, GAS_REACTION_MAXIMUM_RADIATION_PULSE_RANGE), threshold = PN_TRITIUM_RAD_THRESHOLD_BASE * INVERSE(PN_TRITIUM_RAD_THRESHOLD_BASE + produced_amount)) if(energy_released) var/new_heat_capacity = air.heat_capacity() @@ -1142,7 +1142,7 @@ else if(isatom(holder)) location = holder if (location && energy_released > PN_TRITIUM_CONVERSION_RAD_RELEASE_THRESHOLD * (air.volume / CELL_VOLUME) ** ATMOS_RADIATION_VOLUME_EXP) - radiation_pulse(location, max_range = min(sqrt(consumed_amount) / PN_BZASE_RAD_RANGE_DIVISOR, 20), threshold = PN_BZASE_RAD_THRESHOLD_BASE * INVERSE(PN_BZASE_RAD_THRESHOLD_BASE + consumed_amount), chance = 50) + radiation_pulse(location, max_range = min(sqrt(consumed_amount) / PN_BZASE_RAD_RANGE_DIVISOR, GAS_REACTION_MAXIMUM_RADIATION_PULSE_RANGE), threshold = PN_BZASE_RAD_THRESHOLD_BASE * INVERSE(PN_BZASE_RAD_THRESHOLD_BASE + consumed_amount)) for(var/mob/living/carbon/L in location) L.hallucination += consumed_amount diff --git a/code/modules/mob/living/carbon/human/species_types/golems.dm b/code/modules/mob/living/carbon/human/species_types/golems.dm index 1563e36e5f7..dbf39d46237 100644 --- a/code/modules/mob/living/carbon/human/species_types/golems.dm +++ b/code/modules/mob/living/carbon/human/species_types/golems.dm @@ -552,7 +552,7 @@ var/cooldown = 150 var/last_teleport = 0 ///Set to true upon action activation to prevent spamming teleport callbacks while the first is still occurring. - var/is_charging = FALSE + var/is_charging = FALSE /datum/action/innate/unstable_teleport/IsAvailable() . = ..()