From c8db120dcea650aba0f694fa0700304f4952052e Mon Sep 17 00:00:00 2001 From: Markolie Date: Mon, 22 Dec 2014 20:31:03 +0100 Subject: [PATCH] Transit tube pressure fix --- .../transit_tubes/transit_tube_pod.dm | 6 +-- code/modules/karma/karma.dm | 9 ++-- code/modules/mob/living/carbon/human/life.dm | 45 ++++++++++++++++--- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/code/game/objects/structures/transit_tubes/transit_tube_pod.dm b/code/game/objects/structures/transit_tubes/transit_tube_pod.dm index 1eb1910a7fc..293f823fc43 100644 --- a/code/game/objects/structures/transit_tubes/transit_tube_pod.dm +++ b/code/game/objects/structures/transit_tubes/transit_tube_pod.dm @@ -104,11 +104,7 @@ // datum, there might be problems if I don't... /obj/structure/transit_tube_pod/return_air() var/datum/gas_mixture/GM = new() - GM.oxygen = air_contents.oxygen - GM.carbon_dioxide = air_contents.carbon_dioxide - GM.nitrogen = air_contents.nitrogen - GM.toxins = air_contents.toxins - GM.temperature = air_contents.temperature + GM.copy_from(air_contents) return GM // For now, copying what I found in an unused FEA file (and almost identical in a diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index 594358ce151..0baecdb2905 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -61,18 +61,21 @@ var/list/karma_spenders = list() usr << "\red You can't award karma until the game has started." return - var/list/karma_list = list() + var/list/karma_list = list("Cancel") for(var/mob/M in player_list) if(M.client && M.mind) var/special_role = M.mind.special_role if (special_role == "Wizard" || special_role == "Ninja" || special_role == "Syndicate" || special_role == "Syndicate Commando" || special_role == "Vox Raider" || special_role == "Alien") // Don't include special roles, because players use it to meta continue karma_list += M - if(!karma_list.len) + if(!karma_list.len || karma_list.len == 1) usr << "\red There's no-one to spend your karma on." return - var/pickedmob = input("Who would you like to award Karma to?", "Award Karma", null) as mob in karma_list + var/pickedmob = input("Who would you like to award Karma to?", "Award Karma", "Cancel") as null|mob in karma_list + + if(isnull(pickedmob)) + return if(!istype(pickedmob, /mob)) usr << "\red That's not a mob." diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 4a5b0ad21bd..43a59c86d09 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -182,16 +182,51 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc return 1 - pressure_adjustment_coefficient //want 0 to be bad protection, 1 to be good protection +// 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() + + var/pressure_adjustment_coefficient = 1 // Assume no protection at first. + + 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 + + // 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) + 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. + + return pressure_adjustment_coefficient + /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