From 4b892e320a30cbac227b8139ef00cc109c00933c Mon Sep 17 00:00:00 2001 From: oranges Date: Tue, 20 Sep 2016 03:52:10 +0000 Subject: [PATCH] Prevents trying to check armour against missing limbs --- code/modules/mob/living/carbon/carbon_defense.dm | 8 ++++++++ code/modules/mob/living/carbon/human/human_defense.dm | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 4de7733bd26..96afa3055f4 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -9,6 +9,14 @@ if(head && (head.flags & HEADBANGPROTECT)) return 1 +//Overridden so we can handle when it hits a limb that doesn't exist +mob/living/carbon/bullet_act(obj/item/projectile/P, def_zone) + var/obj/item/bodypart/affecting = get_bodypart(def_zone) + if(!affecting) //that zone is dismembered + . = bullet_act(P, "chest")//act on chest instead + else + . = ..()//Proceed with standard handling + /mob/living/carbon/check_projectile_dismemberment(obj/item/projectile/P, def_zone) var/obj/item/bodypart/affecting = get_bodypart(def_zone) if(affecting && affecting.dismemberable && affecting.get_damage() >= (affecting.max_damage - P.dismemberment)) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 535f7f39ffb..a3a7413932b 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -3,11 +3,12 @@ var/organnum = 0 if(def_zone) + //Can pass in a bodypart or zone, so lets shortcut that handling if(islimb(def_zone)) return checkarmor(def_zone, type) - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(def_zone)) + //Note the check_zone call, this changes UI target values to bodypart zones + var/obj/item/bodypart/affecting = get_bodypart(check_zone(def_zone)) return checkarmor(affecting, type) - //If a specific bodypart is targetted, check how that bodypart is protected and return the value. //If you don't specify a bodypart, it checks ALL your bodyparts for protection, and averages out the values for(var/X in bodyparts)