diff --git a/code/game/objects/items/devices/suit_cooling.dm b/code/game/objects/items/devices/suit_cooling.dm index 19d146b82c..6355fd26fd 100644 --- a/code/game/objects/items/devices/suit_cooling.dm +++ b/code/game/objects/items/devices/suit_cooling.dm @@ -42,7 +42,7 @@ var/mob/living/carbon/human/H = loc - var/efficiency = H.get_pressure_protection() //you need to have a good seal for effective cooling + var/efficiency = 1 - H.get_pressure_weakness() //you need to have a good seal for effective cooling var/env_temp = get_environment_temperature() //wont save you from a fire var/temp_adj = min(H.bodytemperature - max(thermostat, env_temp), max_cooling) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 4af096131f..c756dc918e 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -33,6 +33,8 @@ /mob/living/carbon/human/Life() + + set invisibility = 0 set background = 1 @@ -128,38 +130,52 @@ for(var/obj/item/weapon/grab/G in src) G.process() +// Calculate how vulnerable the human is to under- and overpressure. +// Returns 0 (equals 0 %) if sealed in an undamaged suit, 1 if unprotected (equals 100%). +// Suitdamage can modifiy this in 10% steps. +/mob/living/carbon/human/proc/get_pressure_weakness() -//Much like get_heat_protection(), this returns a 0 - 1 value, which corresponds to the percentage of protection based on what you're wearing and what you're exposed to. -/mob/living/carbon/human/proc/get_pressure_protection() - var/pressure_adjustment_coefficient = 1 //Determins how much the clothing you are wearing protects you in percent. + var/pressure_adjustment_coefficient = 1 // Assume no protection at first. - if(head && (head.flags & STOPSPRESSUREDMAGE)) - pressure_adjustment_coefficient -= PRESSURE_HEAD_REDUCTION_COEFFICIENT + if(wear_suit && (wear_suit.flags & STOPSPRESSUREDMAGE) && head && (head.flags & STOPSPRESSUREDMAGE)) // Complete set of pressure-proof suit worn, assume fully sealed. + pressure_adjustment_coefficient = 0 - if(wear_suit && (wear_suit.flags & STOPSPRESSUREDMAGE)) - pressure_adjustment_coefficient -= PRESSURE_SUIT_REDUCTION_COEFFICIENT - - //Handles breaches in your space suit. 10 suit damage equals a 100% loss of pressure reduction. + // Handles breaches in your space suit. 10 suit damage equals a 100% loss of pressure protection. if(istype(wear_suit,/obj/item/clothing/suit/space)) var/obj/item/clothing/suit/space/S = wear_suit if(S.can_breach && S.damage) - var/pressure_loss = S.damage * 0.1 - pressure_adjustment_coefficient += pressure_loss + pressure_adjustment_coefficient += S.damage * 0.1 - pressure_adjustment_coefficient = min(1,max(pressure_adjustment_coefficient,0)) //So it isn't less than 0 or larger than 1. + pressure_adjustment_coefficient = min(1,max(pressure_adjustment_coefficient,0)) // So it isn't less than 0 or larger than 1. - return 1 - pressure_adjustment_coefficient //want 0 to be bad protection, 1 to be good protection + return pressure_adjustment_coefficient +// Calculate how much of the enviroment pressure-difference affects the human. /mob/living/carbon/human/calculate_affecting_pressure(var/pressure) - ..() - var/pressure_difference = abs( pressure - ONE_ATMOSPHERE ) + var/pressure_difference - pressure_difference = pressure_difference * (1 - get_pressure_protection()) + // First get the absolute pressure difference. + if(pressure < ONE_ATMOSPHERE) // We are in an underpressure. + pressure_difference = ONE_ATMOSPHERE - pressure + + else //We are in an overpressure or standard atmosphere. + pressure_difference = pressure - ONE_ATMOSPHERE + + if(pressure_difference < 5) // If the difference is small, don't bother calculating the fraction. + pressure_difference = 0 - if(pressure > ONE_ATMOSPHERE) - return ONE_ATMOSPHERE + pressure_difference else + // Otherwise calculate how much of that absolute pressure difference affects us, can be 0 to 1 (equals 0% to 100%). + // This is our relative difference. + pressure_difference *= get_pressure_weakness() + + // The difference is always positive to avoid extra calculations. + // Apply the relative difference on a standard atmosphere to get the final result. + // The return value will be the adjusted_pressure of the human that is the basis of pressure warnings and damage. + if(pressure < ONE_ATMOSPHERE) return ONE_ATMOSPHERE - pressure_difference + else + return ONE_ATMOSPHERE + pressure_difference /mob/living/carbon/human proc/handle_disabilities() diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index 19cfe31686..ead7444671 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -80,11 +80,6 @@ emote(pick("scratch","jump","roll","tail")) updatehealth() - -/mob/living/carbon/monkey/calculate_affecting_pressure(var/pressure) - ..() - return pressure - /mob/living/carbon/monkey proc/handle_disabilities() @@ -401,9 +396,7 @@ //Moved these vars here for use in the fuck-it-skip-processing check. var/pressure = environment.return_pressure() - var/adjusted_pressure = calculate_affecting_pressure(pressure) //Returns how much pressure actually affects the mob. - - if(adjusted_pressure < WARNING_HIGH_PRESSURE && adjusted_pressure > WARNING_LOW_PRESSURE && abs(environment.temperature - 293.15) < 20 && abs(bodytemperature - 310.14) < 0.5 && environment.phoron < MOLES_PHORON_VISIBLE) + if(pressure < WARNING_HIGH_PRESSURE && pressure > WARNING_LOW_PRESSURE && abs(environment.temperature - 293.15) < 20 && abs(bodytemperature - 310.14) < 0.5 && environment.phoron < MOLES_PHORON_VISIBLE) //Hopefully should fix the walk-inside-still-pressure-warning issue. if(pressure_alert) @@ -425,9 +418,9 @@ bodytemperature += 0.1*(environment.temperature - bodytemperature)*environment_heat_capacity/(environment_heat_capacity + 270000) //Account for massive pressure differences - switch(adjusted_pressure) + switch(pressure) if(HAZARD_HIGH_PRESSURE to INFINITY) - adjustBruteLoss( min( ( (adjusted_pressure / HAZARD_HIGH_PRESSURE) -1 )*PRESSURE_DAMAGE_COEFFICIENT , MAX_HIGH_PRESSURE_DAMAGE) ) + adjustBruteLoss( min( ( (pressure / HAZARD_HIGH_PRESSURE) -1 )*PRESSURE_DAMAGE_COEFFICIENT , MAX_HIGH_PRESSURE_DAMAGE) ) pressure_alert = 2 if(WARNING_HIGH_PRESSURE to HAZARD_HIGH_PRESSURE) pressure_alert = 1 diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index e3de241980..e0733ce7b4 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -18,7 +18,7 @@ //This proc is used for mobs which are affected by pressure to calculate the amount of pressure that actually //affects them once clothing is factored in. ~Errorage /mob/living/proc/calculate_affecting_pressure(var/pressure) - return 0 + return //sort of a legacy burn method for /electrocute, /shock, and the e_chair diff --git a/code/setup.dm b/code/setup.dm index 13974e022e..f26f05780e 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -66,9 +66,6 @@ #define MAX_HIGH_PRESSURE_DAMAGE 4 //This used to be 20... I got this much random rage for some retarded decision by polymorph?! Polymorph now lies in a pool of blood with a katana jammed in his spleen. ~Errorage --PS: The katana did less than 20 damage to him :( #define LOW_PRESSURE_DAMAGE 2 //The amounb of damage someone takes when in a low pressure area (The pressure threshold is so low that it doesn't make sense to do any calculations, so it just applies this flat value). -#define PRESSURE_SUIT_REDUCTION_COEFFICIENT 0.8 //This is how much (percentual) a suit with the flag STOPSPRESSUREDMAGE reduces pressure. -#define PRESSURE_HEAD_REDUCTION_COEFFICIENT 0.4 //This is how much (percentual) a helmet/hat with the flag STOPSPRESSUREDMAGE reduces pressure. - // Doors! #define DOOR_CRUSH_DAMAGE 10