From 4a62fb4557e465af09d544b331682cd78910ef9c Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 21 Aug 2020 23:36:26 +0200 Subject: [PATCH] [MIRROR] Fixes a thrown damage runtime (#465) * thrown damage runtime (#52913) * Fixes a thrown damage runtime Co-authored-by: Rohesie --- code/modules/mob/living/living_defense.dm | 41 ++++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 4748489e0c8..9dba85ca52f 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -68,34 +68,35 @@ else return 0 + /mob/living/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum) - if(istype(AM, /obj/item)) - var/obj/item/I = AM + if(isitem(AM)) + var/obj/item/thrown_item = AM var/zone = ran_zone(BODY_ZONE_CHEST, 65)//Hits a random part of the body, geared towards the chest - var/dtype = BRUTE - var/nosell_hit = SEND_SIGNAL(I, COMSIG_MOVABLE_IMPACT_ZONE, src, zone, throwingdatum) // TODO: find a better way to handle hitpush and skipcatch for humans + var/nosell_hit = SEND_SIGNAL(thrown_item, COMSIG_MOVABLE_IMPACT_ZONE, src, zone, throwingdatum) // TODO: find a better way to handle hitpush and skipcatch for humans if(nosell_hit) skipcatch = TRUE hitpush = FALSE - dtype = I.damtype - if(!blocked) - if(I.thrownby) - log_combat(I.thrownby, src, "threw and hit", I) - if(!nosell_hit) - visible_message("[src] is hit by [I]!", \ - "You're hit by [I]!") - if(!I.throwforce) - return - var/armor = run_armor_check(zone, "melee", "Your armor has protected your [parse_zone(zone)].", "Your armor has softened hit to your [parse_zone(zone)].",I.armour_penetration) - apply_damage(I.throwforce, dtype, zone, armor, sharpness=I.get_sharpness(), wound_bonus=(nosell_hit * CANT_WOUND)) + if(blocked) + return TRUE - else - return 1 - else - playsound(loc, 'sound/weapons/genhit.ogg', 50, TRUE, -1) //Item sounds are handled in the item itself - ..() + if(thrown_item.thrownby) + log_combat(thrown_item.thrownby, src, "threw and hit", thrown_item) + if(nosell_hit) + return ..() + visible_message("[src] is hit by [thrown_item]!", \ + "You're hit by [thrown_item]!") + if(!thrown_item.throwforce) + return + var/armor = run_armor_check(zone, "melee", "Your armor has protected your [parse_zone(zone)].", "Your armor has softened hit to your [parse_zone(zone)].", thrown_item.armour_penetration) + apply_damage(thrown_item.throwforce, thrown_item.damtype, zone, armor, sharpness = thrown_item.get_sharpness(), wound_bonus = (nosell_hit * CANT_WOUND)) + if(QDELETED(src)) //Damage can delete the mob. + return + return ..() + playsound(loc, 'sound/weapons/genhit.ogg', 50, TRUE, -1) //Item sounds are handled in the item itself + return ..() /mob/living/mech_melee_attack(obj/mecha/M)