From 0eff96adacd3cecce5837dad5e587fd2be4ddc80 Mon Sep 17 00:00:00 2001 From: CriticalXI Date: Wed, 22 Jan 2025 14:14:14 -0700 Subject: [PATCH] [core] Differentiate between player and mob for getWeaponDmg --- scripts/commands/getstats.lua | 4 ++-- src/map/lua/lua_baseentity.cpp | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/commands/getstats.lua b/scripts/commands/getstats.lua index 65493549260..ed029305b91 100644 --- a/scripts/commands/getstats.lua +++ b/scripts/commands/getstats.lua @@ -71,6 +71,8 @@ commandObj.onTrigger = function(player, option) player:printToPlayer(string.format('Food Accuracy%% bonus: %i ', target:getMod(xi.mod.FOOD_ACCP)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Accuracy Base: %i ', target:getMod(xi.mod.ACC)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Total Accuracy: %i ', target:getStat(xi.mod.ACC)), xi.msg.channel.SYSTEM_3) + player:printToPlayer(string.format('Attack Base: %i ', target:getMod(xi.mod.ATT)), xi.msg.channel.SYSTEM_3) + player:printToPlayer(string.format('Total Attack: %i ', target:getStat(xi.mod.ATT)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Main Weap Dmg: %i ', target:getWeaponDmg()), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('RAccuracy Base: %i ', target:getMod(xi.mod.RACC)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Total RAccuracy: %i ', target:getStat(xi.mod.RACC)), xi.msg.channel.SYSTEM_3) @@ -85,8 +87,6 @@ commandObj.onTrigger = function(player, option) player:printToPlayer(string.format('EVA Base: %i ', target:getMod(xi.mod.EVA)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('EVA Total: %i ', target:getStat(xi.mod.EVA)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Magic EVA Base: %i ', target:getMod(xi.mod.MEVA)), xi.msg.channel.SYSTEM_3) - player:printToPlayer(string.format('Attack Base: %i ', target:getMod(xi.mod.ATT)), xi.msg.channel.SYSTEM_3) - player:printToPlayer(string.format('Total Attack: %i ', target:getStat(xi.mod.ATT)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Defense Base: %i ', target:getMod(xi.mod.DEF)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Total Defense: %i ', target:getStat(xi.mod.DEF)), xi.msg.channel.SYSTEM_3) player:printToPlayer(string.format('Magic Defense bonus: %i ', target:getMod(xi.mod.MDEF)), xi.msg.channel.SYSTEM_3) diff --git a/src/map/lua/lua_baseentity.cpp b/src/map/lua/lua_baseentity.cpp index 72cd058fcd7..9c2be1338e2 100644 --- a/src/map/lua/lua_baseentity.cpp +++ b/src/map/lua/lua_baseentity.cpp @@ -14507,7 +14507,21 @@ uint16 CLuaBaseEntity::getWeaponDmg() return 0; } - return static_cast(m_PBaseEntity)->GetMainWeaponDmg(); + uint16 weaponDamage = 0; + + // TODO: Determine if trusts and player fellows use mob or player damage formula + if (m_PBaseEntity->objtype == TYPE_MOB || + m_PBaseEntity->objtype == TYPE_PET) + { + auto* PMob = static_cast(m_PBaseEntity); + weaponDamage = mobutils::GetWeaponDamage(PMob, SLOT_MAIN); + } + else + { + weaponDamage = static_cast(m_PBaseEntity)->GetMainWeaponDmg(); + } + + return weaponDamage; } /************************************************************************