From ec25623e96302dc30897cffacc3e6800c38f3ee9 Mon Sep 17 00:00:00 2001 From: sruon Date: Fri, 18 Apr 2025 19:18:50 -0600 Subject: [PATCH] Check for throwing weapons when calculating pDIF Co-Authored-By: lumokai <155067345+lumokai@users.noreply.github.com> --- src/map/utils/battleutils.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/map/utils/battleutils.cpp b/src/map/utils/battleutils.cpp index cdcf3d27362..d30a15364e5 100644 --- a/src/map/utils/battleutils.cpp +++ b/src/map/utils/battleutils.cpp @@ -1659,7 +1659,19 @@ namespace battleutils float pDIF = 1.0; auto* targ_weapon = dynamic_cast(PAttacker->m_Weapons[SLOT_RANGED]); - uint8 weaponType = targ_weapon ? targ_weapon->getSkillType() : static_cast(SKILL_MARKSMANSHIP); // TODO: does the no-weapon case actually hit? + if (!targ_weapon) + { + // No ranged weapon, check ammo slot for throwing + targ_weapon = dynamic_cast(PAttacker->m_Weapons[SLOT_AMMO]); + + if (!targ_weapon) + { + ShowError("battleutils::GetRangedDamageRatio(): No ranged weapon or ammo"); + return pDIF; + } + } + + uint8 weaponType = targ_weapon->getSkillType(); auto levelCorrectionFunc = lua["xi"]["combat"]["levelCorrection"]["isLevelCorrectedZone"]; auto rangedPDIFFunc = lua["xi"]["combat"]["physical"]["calculateRangedPDIF"];