From e936ed1a5ce255ca64e65d77c0b78387daf05bc6 Mon Sep 17 00:00:00 2001 From: MrSent Date: Mon, 23 Mar 2026 18:10:24 +0000 Subject: [PATCH] [core] nullptr check for Rune Enhancement --- src/map/utils/battleutils.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/map/utils/battleutils.cpp b/src/map/utils/battleutils.cpp index 37dbcb1719b..84f022630e1 100644 --- a/src/map/utils/battleutils.cpp +++ b/src/map/utils/battleutils.cpp @@ -603,7 +603,16 @@ int32 CalculateEnspellDamage(CBattleEntity* PAttacker, CBattleEntity* PDefender, { // see https://www.ffxiah.com/forum/topic/56613/rune-enhancement-damage-formula-testing/ for data and comments double runeDPS = 0.0; - CItemWeapon* PWeapon = static_cast(static_cast(PAttacker)->getEquip(SLOT_MAIN)); + CItemWeapon* PWeapon = nullptr; + + // Prefer player equip if attacker is a player + if (auto* PChar = dynamic_cast(PAttacker)) + { + if (auto* equip = PChar->getEquip(SLOT_MAIN)) + { + PWeapon = dynamic_cast(equip); + } + } // If no player equip, try the entity's internal weapon slot (used by mobs/trusts) if (PWeapon == nullptr)