From 87395fd6c2ddfc85cd2f00d0ca53952d75999f33 Mon Sep 17 00:00:00 2001 From: Chinsky Date: Sun, 21 Feb 2016 15:24:36 +0300 Subject: [PATCH 1/4] Shortens some wordy procs that used a lot of duplicate code with power of OOP --- code/modules/mob/living/carbon/human/life.dm | 139 ++++++------------- 1 file changed, 40 insertions(+), 99 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 47cca0e5cf..8247a6636a 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -711,85 +711,25 @@ //This proc returns a number made up of the flags for body parts which you are protected on. (such as HEAD, UPPER_TORSO, LOWER_TORSO, etc. See setup.dm for the full list) /mob/living/carbon/human/proc/get_heat_protection_flags(temperature) //Temperature is the temperature you're being exposed to. - var/thermal_protection_flags = 0 + . = 0 //Handle normal clothing - if(head) - if(head.max_heat_protection_temperature && head.max_heat_protection_temperature >= temperature) - thermal_protection_flags |= head.heat_protection - if(wear_suit) - if(wear_suit.max_heat_protection_temperature && wear_suit.max_heat_protection_temperature >= temperature) - thermal_protection_flags |= wear_suit.heat_protection - if(w_uniform) - if(w_uniform.max_heat_protection_temperature && w_uniform.max_heat_protection_temperature >= temperature) - thermal_protection_flags |= w_uniform.heat_protection - if(shoes) - if(shoes.max_heat_protection_temperature && shoes.max_heat_protection_temperature >= temperature) - thermal_protection_flags |= shoes.heat_protection - if(gloves) - if(gloves.max_heat_protection_temperature && gloves.max_heat_protection_temperature >= temperature) - thermal_protection_flags |= gloves.heat_protection - if(wear_mask) - if(wear_mask.max_heat_protection_temperature && wear_mask.max_heat_protection_temperature >= temperature) - thermal_protection_flags |= wear_mask.heat_protection - - return thermal_protection_flags - -/mob/living/carbon/human/get_heat_protection(temperature) //Temperature is the temperature you're being exposed to. - var/thermal_protection_flags = get_heat_protection_flags(temperature) - - var/thermal_protection = 0.0 - if(thermal_protection_flags) - if(thermal_protection_flags & HEAD) - thermal_protection += THERMAL_PROTECTION_HEAD - if(thermal_protection_flags & UPPER_TORSO) - thermal_protection += THERMAL_PROTECTION_UPPER_TORSO - if(thermal_protection_flags & LOWER_TORSO) - thermal_protection += THERMAL_PROTECTION_LOWER_TORSO - if(thermal_protection_flags & LEG_LEFT) - thermal_protection += THERMAL_PROTECTION_LEG_LEFT - if(thermal_protection_flags & LEG_RIGHT) - thermal_protection += THERMAL_PROTECTION_LEG_RIGHT - if(thermal_protection_flags & FOOT_LEFT) - thermal_protection += THERMAL_PROTECTION_FOOT_LEFT - if(thermal_protection_flags & FOOT_RIGHT) - thermal_protection += THERMAL_PROTECTION_FOOT_RIGHT - if(thermal_protection_flags & ARM_LEFT) - thermal_protection += THERMAL_PROTECTION_ARM_LEFT - if(thermal_protection_flags & ARM_RIGHT) - thermal_protection += THERMAL_PROTECTION_ARM_RIGHT - if(thermal_protection_flags & HAND_LEFT) - thermal_protection += THERMAL_PROTECTION_HAND_LEFT - if(thermal_protection_flags & HAND_RIGHT) - thermal_protection += THERMAL_PROTECTION_HAND_RIGHT - - - return min(1,thermal_protection) + for(var/obj/item/clothing/C in list(head,wear_suit,w_uniform,shoes,gloves,wear_mask)) + if(C) + if(C.max_heat_protection_temperature && C.max_heat_protection_temperature >= temperature) + . |= C.heat_protection //See proc/get_heat_protection_flags(temperature) for the description of this proc. /mob/living/carbon/human/proc/get_cold_protection_flags(temperature) - var/thermal_protection_flags = 0 + . = 0 //Handle normal clothing + for(var/obj/item/clothing/C in list(head,wear_suit,w_uniform,shoes,gloves,wear_mask)) + if(C) + if(C.min_cold_protection_temperature && C.min_cold_protection_temperature <= temperature) + . |= C.cold_protection - if(head) - if(head.min_cold_protection_temperature && head.min_cold_protection_temperature <= temperature) - thermal_protection_flags |= head.cold_protection - if(wear_suit) - if(wear_suit.min_cold_protection_temperature && wear_suit.min_cold_protection_temperature <= temperature) - thermal_protection_flags |= wear_suit.cold_protection - if(w_uniform) - if(w_uniform.min_cold_protection_temperature && w_uniform.min_cold_protection_temperature <= temperature) - thermal_protection_flags |= w_uniform.cold_protection - if(shoes) - if(shoes.min_cold_protection_temperature && shoes.min_cold_protection_temperature <= temperature) - thermal_protection_flags |= shoes.cold_protection - if(gloves) - if(gloves.min_cold_protection_temperature && gloves.min_cold_protection_temperature <= temperature) - thermal_protection_flags |= gloves.cold_protection - if(wear_mask) - if(wear_mask.min_cold_protection_temperature && wear_mask.min_cold_protection_temperature <= temperature) - thermal_protection_flags |= wear_mask.cold_protection - - return thermal_protection_flags +/mob/living/carbon/human/get_heat_protection(temperature) //Temperature is the temperature you're being exposed to. + var/thermal_protection_flags = get_heat_protection_flags(temperature) + return get_thermal_protection(thermal_protection_flags) /mob/living/carbon/human/get_cold_protection(temperature) if(COLD_RESISTANCE in mutations) @@ -797,33 +737,34 @@ temperature = max(temperature, 2.7) //There is an occasional bug where the temperature is miscalculated in ares with a small amount of gas on them, so this is necessary to ensure that that bug does not affect this calculation. Space's temperature is 2.7K and most suits that are intended to protect against any cold, protect down to 2.0K. var/thermal_protection_flags = get_cold_protection_flags(temperature) + return get_thermal_protection(thermal_protection_flags) - var/thermal_protection = 0.0 - if(thermal_protection_flags) - if(thermal_protection_flags & HEAD) - thermal_protection += THERMAL_PROTECTION_HEAD - if(thermal_protection_flags & UPPER_TORSO) - thermal_protection += THERMAL_PROTECTION_UPPER_TORSO - if(thermal_protection_flags & LOWER_TORSO) - thermal_protection += THERMAL_PROTECTION_LOWER_TORSO - if(thermal_protection_flags & LEG_LEFT) - thermal_protection += THERMAL_PROTECTION_LEG_LEFT - if(thermal_protection_flags & LEG_RIGHT) - thermal_protection += THERMAL_PROTECTION_LEG_RIGHT - if(thermal_protection_flags & FOOT_LEFT) - thermal_protection += THERMAL_PROTECTION_FOOT_LEFT - if(thermal_protection_flags & FOOT_RIGHT) - thermal_protection += THERMAL_PROTECTION_FOOT_RIGHT - if(thermal_protection_flags & ARM_LEFT) - thermal_protection += THERMAL_PROTECTION_ARM_LEFT - if(thermal_protection_flags & ARM_RIGHT) - thermal_protection += THERMAL_PROTECTION_ARM_RIGHT - if(thermal_protection_flags & HAND_LEFT) - thermal_protection += THERMAL_PROTECTION_HAND_LEFT - if(thermal_protection_flags & HAND_RIGHT) - thermal_protection += THERMAL_PROTECTION_HAND_RIGHT - - return min(1,thermal_protection) +/mob/living/carbon/human/proc/get_thermal_protection(var/flags) + .=0 + if(flags) + if(flags & HEAD) + . += THERMAL_PROTECTION_HEAD + if(flags & UPPER_TORSO) + . += THERMAL_PROTECTION_UPPER_TORSO + if(flags & LOWER_TORSO) + . += THERMAL_PROTECTION_LOWER_TORSO + if(flags & LEG_LEFT) + . += THERMAL_PROTECTION_LEG_LEFT + if(flags & LEG_RIGHT) + . += THERMAL_PROTECTION_LEG_RIGHT + if(flags & FOOT_LEFT) + . += THERMAL_PROTECTION_FOOT_LEFT + if(flags & FOOT_RIGHT) + . += THERMAL_PROTECTION_FOOT_RIGHT + if(flags & ARM_LEFT) + . += THERMAL_PROTECTION_ARM_LEFT + if(flags & ARM_RIGHT) + . += THERMAL_PROTECTION_ARM_RIGHT + if(flags & HAND_LEFT) + . += THERMAL_PROTECTION_HAND_LEFT + if(flags & HAND_RIGHT) + . += THERMAL_PROTECTION_HAND_RIGHT + return min(1,.) /mob/living/carbon/human/handle_chemicals_in_body() From 96fd04374ae5aaf7523d78ee125a3b6fca5b4f8d Mon Sep 17 00:00:00 2001 From: Chinsky Date: Sun, 21 Feb 2016 15:30:12 +0300 Subject: [PATCH 2/4] Makes unused code use jitterness proc. Fixes life assuming that if we don't have eyes, we never had em. --- code/modules/mob/living/carbon/human/life.dm | 28 +++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 8247a6636a..bc667be0bf 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -149,6 +149,26 @@ return ONE_ATMOSPHERE + pressure_difference /mob/living/carbon/human/handle_disabilities() + ..() + //Vision + var/obj/item/organ/vision + if(species.vision_organ) + vision = internal_organs_by_name[species.vision_organ] + + if(!species.vision_organ) // Presumably if a species has no vision organs, they see via some other means. + eye_blind = 0 + blinded = 0 + eye_blurry = 0 + else if(!vision || (vision && vision.is_broken())) // Vision organs cut out or broken? Permablind. + eye_blind = 1 + blinded = 1 + eye_blurry = 1 + else + //blindness + if(!(sdisabilities & BLIND)) + if(equipment_tint_total >= TINT_BLIND) // Covered eyes, heal faster + eye_blurry = max(eye_blurry-2, 0) + if (disabilities & EPILEPSY) if ((prob(1) && paralysis < 1)) src << "\red You have a seizure!" @@ -174,13 +194,7 @@ emote("twitch") if(2 to 3) say("[prob(50) ? ";" : ""][pick("SHIT", "PISS", "FUCK", "CUNT", "COCKSUCKER", "MOTHERFUCKER", "TITS")]") - var/old_x = pixel_x - var/old_y = pixel_y - pixel_x += rand(-2,2) - pixel_y += rand(-1,1) - sleep(2) - pixel_x = old_x - pixel_y = old_y + make_jittery(100) return if (disabilities & NERVOUS) speech_problem_flag = 1 From 98750f20bab46dff264451c6318d37996e1364c7 Mon Sep 17 00:00:00 2001 From: Chinsky Date: Sun, 21 Feb 2016 15:36:13 +0300 Subject: [PATCH 3/4] Removed some duplicated code for clearer readability. Fixed cold air giving high temperature traces. --- code/modules/mob/living/carbon/human/life.dm | 39 ++++++++++---------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index bc667be0bf..ec05789acf 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -615,31 +615,32 @@ //Body temperature is too hot. fire_alert = max(fire_alert, 1) if(status_flags & GODMODE) return 1 //godmode - - if(bodytemperature < species.heat_level_2) - take_overall_damage(burn=HEAT_DAMAGE_LEVEL_1, used_weapon = "High Body Temperature") - fire_alert = max(fire_alert, 2) - else if(bodytemperature < species.heat_level_3) - take_overall_damage(burn=HEAT_DAMAGE_LEVEL_2, used_weapon = "High Body Temperature") - fire_alert = max(fire_alert, 2) - else - take_overall_damage(burn=HEAT_DAMAGE_LEVEL_3, used_weapon = "High Body Temperature") - fire_alert = max(fire_alert, 2) + var/burn_dam = 0 + switch(bodytemperature) + if(species.heat_level_1 to species.heat_level_2) + burn_dam = HEAT_DAMAGE_LEVEL_1 + if(species.heat_level_2 to species.heat_level_3) + burn_dam = HEAT_DAMAGE_LEVEL_2 + if(species.heat_level_3 to INFINITY) + burn_dam = HEAT_DAMAGE_LEVEL_3 + take_overall_damage(burn=burn_dam, used_weapon = "High Body Temperature") + fire_alert = max(fire_alert, 2) else if(bodytemperature <= species.cold_level_1) fire_alert = max(fire_alert, 1) if(status_flags & GODMODE) return 1 //godmode if(!istype(loc, /obj/machinery/atmospherics/unary/cryo_cell)) - if(bodytemperature > species.cold_level_2) - take_overall_damage(burn=COLD_DAMAGE_LEVEL_1, used_weapon = "High Body Temperature") - fire_alert = max(fire_alert, 1) - else if(bodytemperature > species.cold_level_3) - take_overall_damage(burn=COLD_DAMAGE_LEVEL_2, used_weapon = "High Body Temperature") - fire_alert = max(fire_alert, 1) - else - take_overall_damage(burn=COLD_DAMAGE_LEVEL_3, used_weapon = "High Body Temperature") - fire_alert = max(fire_alert, 1) + var/burn_dam = 0 + switch(bodytemperature) + if(-INFINITY to species.cold_level_3) + burn_dam = COLD_DAMAGE_LEVEL_1 + if(species.cold_level_3 to species.cold_level_2) + burn_dam = COLD_DAMAGE_LEVEL_2 + if(species.cold_level_2 to species.cold_level_1) + burn_dam = COLD_DAMAGE_LEVEL_3 + take_overall_damage(burn=burn_dam, used_weapon = "Low Body Temperature") + fire_alert = max(fire_alert, 1) // Account for massive pressure differences. Done by Polymorph // Made it possible to actually have something that can protect against high pressure... Done by Errorage. Polymorph now has an axe sticking from his head for his previous hardcoded nonsense! From ca2e45cc3e0287e39916c0bfc6cc067eeaa232cb Mon Sep 17 00:00:00 2001 From: Datraen Date: Sat, 26 Mar 2016 16:35:31 -0400 Subject: [PATCH 4/4] Resolves conflicts with Baystation12/Baystation12#12276 --- code/modules/mob/living/carbon/human/life.dm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index ec05789acf..189c1ef7bb 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -163,11 +163,6 @@ eye_blind = 1 blinded = 1 eye_blurry = 1 - else - //blindness - if(!(sdisabilities & BLIND)) - if(equipment_tint_total >= TINT_BLIND) // Covered eyes, heal faster - eye_blurry = max(eye_blurry-2, 0) if (disabilities & EPILEPSY) if ((prob(1) && paralysis < 1))