Fixes apply_effect() used without armour checks

This commit is contained in:
mwerezak
2014-08-22 00:02:50 -04:00
parent 170baf15c7
commit 1477fe17ab
4 changed files with 33 additions and 41 deletions
@@ -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("<span class='danger'>[occupant] crashed into \the [A]!</span>")
/obj/structure/stool/bed/chair/office/light
@@ -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("<span class='danger'>[pulling] has thrusted \the [name] into \the [A], throwing \the [occupant] out of it!</span>")
@@ -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
@@ -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 <B>[target] hit himself with a bottle of [src.name] on the head!</B>"), 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.