Merge pull request #6032 from Walter0o/low_pressure_fix

fixes #6005 and broken ancient human low/high pressure code.
This commit is contained in:
Ccomp5950
2014-08-19 05:54:30 -05:00
5 changed files with 39 additions and 33 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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