Merge pull request #8172 from DrCelt/FinallyFixesThisAwfulCode

Changes calculate_affecting_pressure to actually be intelligible
This commit is contained in:
sood
2016-02-09 13:36:58 -08:00
5 changed files with 58 additions and 55 deletions

View File

@@ -49,20 +49,8 @@
var/vending_cat = null// subcategory for vending machines. var/vending_cat = null// subcategory for vending machines.
var/list/dynamic_overlay[0] //For items which need to slightly alter their on-mob appearance while being worn. var/list/dynamic_overlay[0] //For items which need to slightly alter their on-mob appearance while being worn.
var/global/list/thermal_protection_value_list = list()
/obj/item/proc/return_thermal_protection() /obj/item/proc/return_thermal_protection()
var/true_body_parts_covered = body_parts_covered return return_cover_protection(body_parts_covered) * (1 - src.heat_conductivity)
true_body_parts_covered &= ~(EARS|IGNORE_INV|BEARD) // these don't affect thermal conductivity so no need for them here
if(thermal_protection_value_list["[true_body_parts_covered]"])
return thermal_protection_value_list["[true_body_parts_covered]"] * (1 - src.heat_conductivity)
else
var/total_protection = 0
for(var/body_part in THERMAL_BODY_PARTS)
if (body_part & true_body_parts_covered)
total_protection += BODY_THERMAL_VALUE_LIST["[body_part]"]
thermal_protection_value_list["[true_body_parts_covered]"] = total_protection
return total_protection * (1 - src.heat_conductivity)
/obj/item/Destroy() /obj/item/Destroy()
if(istype(src.loc, /mob)) if(istype(src.loc, /mob))

View File

@@ -12,6 +12,7 @@
siemens_coefficient = 0.9 siemens_coefficient = 0.9
species_fit = list("Vox") species_fit = list("Vox")
body_parts_covered = FACE body_parts_covered = FACE
pressure_resistance = ONE_ATMOSPHERE
var/stage = 0 var/stage = 0

View File

@@ -3,23 +3,19 @@
/mob/living/carbon/human/calculate_affecting_pressure(var/pressure) /mob/living/carbon/human/calculate_affecting_pressure(var/pressure)
..() ..()
var/pressure_difference = abs( pressure - ONE_ATMOSPHERE ) var/pressure_difference = abs( pressure - ONE_ATMOSPHERE )
var/list/clothing_items = list(head, wear_mask, wear_suit, w_uniform, gloves, shoes)
//mainly used in horror form, but other things work as well //mainly used in horror form, but other things work as well
var/species_difference = 0 var/species_difference = 0
if(species) if(species)
species_difference = species.pressure_resistance species_difference = species.pressure_resistance
//look for what's protecting the head and body, and adjust tolerable pressure by those resistance var/body_parts_protected = 0
var/equip_difference = 0 for(var/obj/item/equipment in clothing_items)
var/obj/item/press_protect = get_body_part_coverage(FULL_HEAD) if(equipment && equipment.pressure_resistance >= pressure_difference)
if(press_protect) body_parts_protected |= equipment.body_parts_covered
equip_difference += press_protect.pressure_resistance * PRESSURE_HEAD_REDUCTION_COEFFICIENT pressure_difference = max(pressure_difference - species_difference,0)
press_protect = get_body_part_coverage(FULL_BODY) pressure_difference *= (1 - ((return_cover_protection(body_parts_protected))**5)) // if one part of your suit's not up to scratch, we can assume the rest of the suit isn't as effective.
if(press_protect)
equip_difference += press_protect.pressure_resistance * PRESSURE_SUIT_REDUCTION_COEFFICIENT
pressure_difference = max(pressure_difference - equip_difference - species_difference, 0) //brings us as close to one atmosphere as possible
if(pressure > ONE_ATMOSPHERE) if(pressure > ONE_ATMOSPHERE)
return ONE_ATMOSPHERE + pressure_difference return ONE_ATMOSPHERE + pressure_difference
else else
@@ -187,4 +183,19 @@
/mob/living/carbon/human/proc/has_reagent_in_blood(var/reagent_name) /mob/living/carbon/human/proc/has_reagent_in_blood(var/reagent_name)
if(!reagents) if(!reagents)
return 0 return 0
return reagents.has_reagent(reagent_name) return reagents.has_reagent(reagent_name)
var/list/cover_protection_value_list = list()
proc/return_cover_protection(var/body_parts_covered)
var/true_body_parts_covered = body_parts_covered
true_body_parts_covered &= ~(IGNORE_INV|BEARD) // these being covered doesn't particularly matter so no need for them here
if(cover_protection_value_list["[true_body_parts_covered]"])
return cover_protection_value_list["[true_body_parts_covered]"]
else
var/total_protection = 0
for(var/body_part in BODY_PARTS)
if (body_part & true_body_parts_covered)
total_protection += BODY_COVER_VALUE_LIST["[body_part]"]
cover_protection_value_list["[true_body_parts_covered]"] = total_protection
return total_protection

View File

@@ -67,31 +67,33 @@
if(thermal_protection_flags) if(thermal_protection_flags)
if(thermal_protection_flags & HEAD) if(thermal_protection_flags & HEAD)
thermal_protection += THERMAL_PROTECTION_HEAD thermal_protection += COVER_PROTECTION_HEAD
if(thermal_protection_flags & EYES) if(thermal_protection_flags & EYES)
thermal_protection += THERMAL_PROTECTION_EYES thermal_protection += COVER_PROTECTION_EYES
if(thermal_protection_flags & MOUTH) if(thermal_protection_flags & MOUTH)
thermal_protection += THERMAL_PROTECTION_MOUTH thermal_protection += COVER_PROTECTION_MOUTH
if(thermal_protection_flags & UPPER_TORSO) if(thermal_protection_flags & UPPER_TORSO)
thermal_protection += THERMAL_PROTECTION_UPPER_TORSO thermal_protection += COVER_PROTECTION_UPPER_TORSO
if(thermal_protection_flags & LOWER_TORSO) if(thermal_protection_flags & LOWER_TORSO)
thermal_protection += THERMAL_PROTECTION_LOWER_TORSO thermal_protection += COVER_PROTECTION_LOWER_TORSO
if(thermal_protection_flags & LEG_LEFT) if(thermal_protection_flags & LEG_LEFT)
thermal_protection += THERMAL_PROTECTION_LEG_LEFT thermal_protection += COVER_PROTECTION_LEG_LEFT
if(thermal_protection_flags & LEG_RIGHT) if(thermal_protection_flags & LEG_RIGHT)
thermal_protection += THERMAL_PROTECTION_LEG_RIGHT thermal_protection += COVER_PROTECTION_LEG_RIGHT
if(thermal_protection_flags & FOOT_LEFT) if(thermal_protection_flags & FOOT_LEFT)
thermal_protection += THERMAL_PROTECTION_FOOT_LEFT thermal_protection += COVER_PROTECTION_FOOT_LEFT
if(thermal_protection_flags & FOOT_RIGHT) if(thermal_protection_flags & FOOT_RIGHT)
thermal_protection += THERMAL_PROTECTION_FOOT_RIGHT thermal_protection += COVER_PROTECTION_FOOT_RIGHT
if(thermal_protection_flags & ARM_LEFT) if(thermal_protection_flags & ARM_LEFT)
thermal_protection += THERMAL_PROTECTION_ARM_LEFT thermal_protection += COVER_PROTECTION_ARM_LEFT
if(thermal_protection_flags & ARM_RIGHT) if(thermal_protection_flags & ARM_RIGHT)
thermal_protection += THERMAL_PROTECTION_ARM_RIGHT thermal_protection += COVER_PROTECTION_ARM_RIGHT
if(thermal_protection_flags & HAND_LEFT) if(thermal_protection_flags & HAND_LEFT)
thermal_protection += THERMAL_PROTECTION_HAND_LEFT thermal_protection += COVER_PROTECTION_HAND_LEFT
if(thermal_protection_flags & HAND_RIGHT) if(thermal_protection_flags & HAND_RIGHT)
thermal_protection += THERMAL_PROTECTION_HAND_RIGHT thermal_protection += COVER_PROTECTION_HAND_RIGHT
if(thermal_protection_flags & EARS)
thermal_protection += COVER_PROTECTION_EARS
return min(1, thermal_protection) return min(1, thermal_protection)

View File

@@ -358,27 +358,28 @@ var/MAX_EXPLOSION_RANGE = 14
#define HIDESUITSTORAGE LOWER_TORSO #define HIDESUITSTORAGE LOWER_TORSO
// bitflags for the percentual amount of protection a piece of clothing which covers the body part offers. // bitflags for the percentual amount of protection a piece of clothing which covers the body part offers.
// Used with human/proc/get_heat_protection() and human/proc/get_cold_protection() // Used with human/proc/get_heat_protection() and human/proc/get_cold_protection() as well as calculate_affecting_pressure() now
// The values here should add up to 1. // The values here should add up to 1.
// Hands and feet have 2.5%, arms and legs 7.5%, each of the torso parts has 15%, and each of the head parts has 10% // Hands and feet have 2.5%, arms and legs 7.5%, each of the torso parts has 15%, and each of the head parts has 7.5%
#define THERMAL_PROTECTION_HEAD 0.1 #define COVER_PROTECTION_HEAD 0.075
#define THERMAL_PROTECTION_EYES 0.1 #define COVER_PROTECTION_EYES 0.075
#define THERMAL_PROTECTION_MOUTH 0.1 #define COVER_PROTECTION_MOUTH 0.075
#define COVER_PROTECTION_EARS 0.075
#define THERMAL_PROTECTION_UPPER_TORSO 0.15 #define COVER_PROTECTION_UPPER_TORSO 0.15
#define THERMAL_PROTECTION_LOWER_TORSO 0.15 #define COVER_PROTECTION_LOWER_TORSO 0.15
#define THERMAL_PROTECTION_LEG_LEFT 0.075 #define COVER_PROTECTION_LEG_LEFT 0.075
#define THERMAL_PROTECTION_LEG_RIGHT 0.075 #define COVER_PROTECTION_LEG_RIGHT 0.075
#define THERMAL_PROTECTION_FOOT_LEFT 0.025 #define COVER_PROTECTION_FOOT_LEFT 0.025
#define THERMAL_PROTECTION_FOOT_RIGHT 0.025 #define COVER_PROTECTION_FOOT_RIGHT 0.025
#define THERMAL_PROTECTION_ARM_LEFT 0.075 #define COVER_PROTECTION_ARM_LEFT 0.075
#define THERMAL_PROTECTION_ARM_RIGHT 0.075 #define COVER_PROTECTION_ARM_RIGHT 0.075
#define THERMAL_PROTECTION_HAND_LEFT 0.025 #define COVER_PROTECTION_HAND_LEFT 0.025
#define THERMAL_PROTECTION_HAND_RIGHT 0.025 #define COVER_PROTECTION_HAND_RIGHT 0.025
var/global/list/THERMAL_BODY_PARTS = list(HEAD,EYES,MOUTH,UPPER_TORSO,LOWER_TORSO,LEG_RIGHT,LEG_LEFT,FOOT_LEFT,FOOT_RIGHT,ARM_LEFT,ARM_RIGHT,HAND_LEFT,HAND_RIGHT) var/global/list/BODY_PARTS = list(HEAD,EYES,EARS,MOUTH,UPPER_TORSO,LOWER_TORSO,LEG_RIGHT,LEG_LEFT,FOOT_LEFT,FOOT_RIGHT,ARM_LEFT,ARM_RIGHT,HAND_LEFT,HAND_RIGHT)
var/global/list/BODY_THERMAL_VALUE_LIST=list("[HEAD]" = THERMAL_PROTECTION_HEAD,"[EYES]" = THERMAL_PROTECTION_EYES,"[MOUTH]" = THERMAL_PROTECTION_MOUTH, "[UPPER_TORSO]" = THERMAL_PROTECTION_UPPER_TORSO,"[LOWER_TORSO]" = THERMAL_PROTECTION_LOWER_TORSO,"[LEG_LEFT]" = THERMAL_PROTECTION_LEG_LEFT,"[LEG_RIGHT]" = THERMAL_PROTECTION_LEG_RIGHT,"[FOOT_LEFT]" = THERMAL_PROTECTION_FOOT_LEFT,"[FOOT_RIGHT]" = THERMAL_PROTECTION_FOOT_RIGHT,"[ARM_LEFT]" = THERMAL_PROTECTION_ARM_LEFT,"[ARM_RIGHT]" = THERMAL_PROTECTION_ARM_RIGHT,"[HAND_LEFT]" = THERMAL_PROTECTION_HAND_LEFT,"[HAND_RIGHT]" = THERMAL_PROTECTION_HAND_RIGHT) var/global/list/BODY_COVER_VALUE_LIST=list("[HEAD]" = COVER_PROTECTION_HEAD,"[EYES]" = COVER_PROTECTION_EYES,"[EARS]" = COVER_PROTECTION_EARS, "[MOUTH]" = COVER_PROTECTION_MOUTH, "[UPPER_TORSO]" = COVER_PROTECTION_UPPER_TORSO,"[LOWER_TORSO]" = COVER_PROTECTION_LOWER_TORSO,"[LEG_LEFT]" = COVER_PROTECTION_LEG_LEFT,"[LEG_RIGHT]" = COVER_PROTECTION_LEG_RIGHT,"[FOOT_LEFT]" = COVER_PROTECTION_FOOT_LEFT,"[FOOT_RIGHT]" = COVER_PROTECTION_FOOT_RIGHT,"[ARM_LEFT]" = COVER_PROTECTION_ARM_LEFT,"[ARM_RIGHT]" = COVER_PROTECTION_ARM_RIGHT,"[HAND_LEFT]" = COVER_PROTECTION_HAND_LEFT,"[HAND_RIGHT]" = COVER_PROTECTION_HAND_RIGHT)
//bitflags for mutations //bitflags for mutations