From 563a7012ff01163d3bc499f03b75c44f4c8b765c Mon Sep 17 00:00:00 2001 From: Aleos Date: Wed, 22 Jun 2022 09:33:07 -0400 Subject: [PATCH] Weapon Blocking can now trigger on ATK_MISS (#7042) * Fixes #6886. * Weapon Blocking is able to trigger on missed attacks. * Weapon Blocking can still be triggered even if the target has Kyrie, Safety Wall, or other damage nullification statuses. Thanks to @Atemo! --- src/map/battle.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 8916c001a7..cfbbf66036 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -1165,6 +1165,14 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe status_change_end(target, SC_GUARDIAN_S, INVALID_TIMER); } + // Weapon Blocking can be triggered while the above statuses are active. + if ((sce = sc->data[SC_WEAPONBLOCKING]) && flag & (BF_SHORT | BF_WEAPON) && rnd() % 100 < sce->val2) { + clif_skill_nodamage(target, src, GC_WEAPONBLOCKING, sce->val1, 1); + sc_start(src, target, SC_WEAPONBLOCK_ON, 100, src->id, skill_get_time2(GC_WEAPONBLOCKING, sce->val1)); + d->dmg_lv = ATK_BLOCK; + return false; + } + if (damage == 0) return false; @@ -1238,13 +1246,6 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe } } - if ((sce = sc->data[SC_WEAPONBLOCKING]) && flag&(BF_SHORT | BF_WEAPON) && rnd() % 100 < sce->val2) { - clif_skill_nodamage(target, src, GC_WEAPONBLOCKING, sce->val1, 1); - sc_start(src, target, SC_WEAPONBLOCK_ON, 100, src->id, skill_get_time2(GC_WEAPONBLOCKING, sce->val1)); - d->dmg_lv = ATK_BLOCK; - return false; - } - if ((sce = sc->data[SC_MILLENNIUMSHIELD]) && sce->val2 > 0 && damage > 0) { sce->val3 -= static_cast(cap_value(damage, INT_MIN, INT_MAX)); // absorb damage d->dmg_lv = ATK_BLOCK; @@ -8266,6 +8267,18 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl if (d.dmg_lv == ATK_DEF /*&& attack_type&(BF_MAGIC|BF_MISC)*/) // Isn't it that additional effects don't apply if miss? d.dmg_lv = ATK_MISS; d.dmotion = 0; + + status_change *tsc = status_get_sc(target); + + // Weapon Blocking has the ability to trigger on ATK_MISS as well. + if (tsc != nullptr && tsc->data[SC_WEAPONBLOCKING]) { + status_change_entry *tsce = tsc->data[SC_WEAPONBLOCKING]; + + if (attack_type == BF_WEAPON && rnd() % 100 < tsce->val2) { + clif_skill_nodamage(target, bl, GC_WEAPONBLOCKING, tsce->val1, 1); + sc_start(bl, target, SC_WEAPONBLOCK_ON, 100, bl->id, skill_get_time2(GC_WEAPONBLOCKING, tsce->val1)); + } + } } else // Some skills like Weaponry Research will cause damage even if attack is dodged d.dmg_lv = ATK_DEF;