From 1477fe17abcdb8083dbf1289e0fb2f08a42141e0 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Fri, 22 Aug 2014 00:02:50 -0400 Subject: [PATCH] Fixes apply_effect() used without armour checks --- .../structures/stool_bed_chair_nest/chairs.dm | 20 ++++++++----- .../stool_bed_chair_nest/wheelchair.dm | 20 ++++++++----- .../mob/living/carbon/human/human_damage.dm | 4 +++ .../reagent_containers/food/drinks/bottle.dm | 30 ++----------------- 4 files changed, 33 insertions(+), 41 deletions(-) diff --git a/code/game/objects/structures/stool_bed_chair_nest/chairs.dm b/code/game/objects/structures/stool_bed_chair_nest/chairs.dm index 115806277cd..b8b2d9a40b3 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/chairs.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/chairs.dm @@ -138,17 +138,23 @@ if(propelled) var/mob/living/occupant = buckled_mob unbuckle() + + var/def_zone = ran_zone() + var/blocked = occupant.run_armor_check(def_zone, "melee") occupant.throw_at(A, 3, propelled) - occupant.apply_effect(6, STUN, 0) - occupant.apply_effect(6, WEAKEN, 0) - occupant.apply_effect(6, STUTTER, 0) + occupant.apply_effect(6, STUN, blocked) + occupant.apply_effect(6, WEAKEN, blocked) + occupant.apply_effect(6, STUTTER, blocked) + occupant.apply_damage(10, BRUTE, def_zone, blocked) playsound(src.loc, 'sound/weapons/punch1.ogg', 50, 1, -1) if(istype(A, /mob/living)) var/mob/living/victim = A - victim.apply_effect(6, STUN, 0) - victim.apply_effect(6, WEAKEN, 0) - victim.apply_effect(6, STUTTER, 0) - victim.take_organ_damage(10) + def_zone = ran_zone() + blocked = victim.run_armor_check(def_zone, "melee") + victim.apply_effect(6, STUN, blocked) + victim.apply_effect(6, WEAKEN, blocked) + victim.apply_effect(6, STUTTER, blocked) + victim.apply_damage(10, BRUTE, def_zone, blocked) occupant.visible_message("[occupant] crashed into \the [A]!") /obj/structure/stool/bed/chair/office/light diff --git a/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm b/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm index 705351acfc4..80a4540f754 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm @@ -142,16 +142,22 @@ else if (propelled) occupant.throw_at(A, 3, propelled) - occupant.apply_effect(6, STUN, 0) - occupant.apply_effect(6, WEAKEN, 0) - occupant.apply_effect(6, STUTTER, 0) + var/def_zone = ran_zone() + var/blocked = occupant.run_armor_check(def_zone, "melee") + occupant.throw_at(A, 3, propelled) + occupant.apply_effect(6, STUN, blocked) + occupant.apply_effect(6, WEAKEN, blocked) + occupant.apply_effect(6, STUTTER, blocked) + occupant.apply_damage(10, BRUTE, def_zone) playsound(src.loc, 'sound/weapons/punch1.ogg', 50, 1, -1) if(istype(A, /mob/living)) var/mob/living/victim = A - victim.apply_effect(6, STUN, 0) - victim.apply_effect(6, WEAKEN, 0) - victim.apply_effect(6, STUTTER, 0) - victim.take_organ_damage(10) + def_zone = ran_zone() + blocked = victim.run_armor_check(def_zone, "melee") + victim.apply_effect(6, STUN, blocked) + victim.apply_effect(6, WEAKEN, blocked) + victim.apply_effect(6, STUTTER, blocked) + victim.apply_damage(10, BRUTE, def_zone) if(pulling) occupant.visible_message("[pulling] has thrusted \the [name] into \the [A], throwing \the [occupant] out of it!") diff --git a/code/modules/mob/living/carbon/human/human_damage.dm b/code/modules/mob/living/carbon/human/human_damage.dm index bc6d2832e6a..01caff57e5a 100644 --- a/code/modules/mob/living/carbon/human/human_damage.dm +++ b/code/modules/mob/living/carbon/human/human_damage.dm @@ -165,6 +165,10 @@ hud_updateflag |= 1 << HEALTH_HUD updatehealth() + +/* +In most cases it makes more sense to use apply_damage() instead! And make sure to check armour if applicable. +*/ //Damages ONE external organ, organ gets randomly selected from damagable ones. //It automatically updates damage overlays if necesary //It automatically updates health status diff --git a/code/modules/reagents/reagent_containers/food/drinks/bottle.dm b/code/modules/reagents/reagent_containers/food/drinks/bottle.dm index 35b776af287..9e5dbbb4d4d 100644 --- a/code/modules/reagents/reagent_containers/food/drinks/bottle.dm +++ b/code/modules/reagents/reagent_containers/food/drinks/bottle.dm @@ -49,32 +49,8 @@ var/armor_duration = 0 //The more force the bottle has, the longer the duration. //Calculating duration and calculating damage. - if(ishuman(target)) - - var/mob/living/carbon/human/H = target - var/headarmor = 0 // Target's head armour - armor_block = H.run_armor_check(affecting, "melee") // For normal attack damage - - //If they have a hat/helmet and the user is targeting their head. - if(istype(H.head, /obj/item/clothing/head) && affecting == "head") - - // If their head has an armour value, assign headarmor to it, else give it 0. - if(H.head.armor["melee"]) - headarmor = H.head.armor["melee"] - else - headarmor = 0 - else - headarmor = 0 - - //Calculate the weakening duration for the target. - armor_duration = (duration - headarmor) + force - - else - //Only humans can have armour, right? - armor_block = target.run_armor_check(affecting, "melee") - if(affecting == "head") - armor_duration = duration + force - armor_duration /= 10 + armor_block = target.run_armor_check(affecting, "melee") + armor_duration = duration + force - target.getarmor(affecting, "melee") //Apply the damage! target.apply_damage(force, BRUTE, affecting, armor_block, sharp=0) @@ -88,7 +64,7 @@ else O.show_message(text("\red [target] hit himself with a bottle of [src.name] on the head!"), 1) //Weaken the target for the duration that we calculated and divide it by 5. if(armor_duration) - target.apply_effect(min(armor_duration, 10) , WEAKEN) // Never weaken more than a flash! + target.apply_effect(min(armor_duration, 10) , WEAKEN, armor_block) // Never weaken more than a flash! else //Default attack message and don't weaken the target.