diff --git a/scripts/globals/weaponskills.lua b/scripts/globals/weaponskills.lua index 17bb1bdd8d0..6d39c2312e3 100644 --- a/scripts/globals/weaponskills.lua +++ b/scripts/globals/weaponskills.lua @@ -84,16 +84,16 @@ end -- https://www.bg-wiki.com/ffxi/Agwu%27s_Scythe Souleater Effect that goes beyond established cap, Stalwart Soul bonus being additive to trait local function souleaterBonus(attacker, wsParams) if attacker:hasStatusEffect(xi.effect.SOULEATER) then - local souleaterEffect = math.min(0.02, attacker:getMod(xi.mod.SOULEATER_EFFECT) * 0.01) - local souleaterEffectII = attacker:getMod(xi.mod.SOULEATER_EFFECT_II) * 0.01 -- No known cap to this bonus. Used on Agwu's scythe + local souleaterEffect = attacker:getMaxGearMod(xi.mod.SOULEATER_EFFECT) * 0.01 + local souleaterEffectII = attacker:getMod(xi.mod.SOULEATER_EFFECT_II) * 0.01 local stalwartSoulBonus = 1 - attacker:getMod(xi.mod.STALWART_SOUL) / 100 - local bonusDamage = attacker:getHP() * (0.1 + souleaterEffect + souleaterEffectII) + local bonusDamage = math.floor(attacker:getHP() * (0.1 + souleaterEffect + souleaterEffectII)) if bonusDamage >= 1 then attacker:delHP(utils.stoneskin(attacker, bonusDamage * stalwartSoulBonus)) if attacker:getMainJob() ~= xi.job.DRK then - return bonusDamage / 2 + return math.floor(bonusDamage / 2) end return bonusDamage diff --git a/src/map/entities/battleentity.cpp b/src/map/entities/battleentity.cpp index 3477233ffc0..6e37d195e2d 100644 --- a/src/map/entities/battleentity.cpp +++ b/src/map/entities/battleentity.cpp @@ -1188,6 +1188,41 @@ int16 CBattleEntity::getMod(Mod modID) return m_modStat[modID]; } +/************************************************************************ + * * + * Get the highest value of the specified modifier across all gear * + * * + ************************************************************************/ +int16 CBattleEntity::getMaxGearMod(Mod modID) +{ + TracyZoneScoped; + CCharEntity* PChar = dynamic_cast(this); + uint16 maxModValue = 0; + + if (!PChar) + { + ShowWarning("CBattleEntity::getMaxGearMod() - Entity is not a player."); + + return 0; + } + + for (uint8 i = 0; i < SLOT_BACK; ++i) + { + auto* PItem = PChar->getEquip((SLOTTYPE)i); + if (PItem && (PItem->isType(ITEM_EQUIPMENT) || PItem->isType(ITEM_WEAPON))) + { + uint16 modValue = PItem->getModifier(modID); + + if (modValue > maxModValue) + { + maxModValue = modValue; + } + } + } + + return maxModValue; +} + void CBattleEntity::addPetModifier(Mod type, PetModType petmod, int16 amount) { TracyZoneScoped; diff --git a/src/map/entities/battleentity.h b/src/map/entities/battleentity.h index aaed5b16ef0..f7a2c046203 100644 --- a/src/map/entities/battleentity.h +++ b/src/map/entities/battleentity.h @@ -600,6 +600,7 @@ class CBattleEntity : public CBaseEntity DAMAGE_TYPE damageType = DAMAGE_TYPE::NONE, bool isSkillchainDamage = false); int16 getMod(Mod modID); + int16 getMaxGearMod(Mod modID); bool CanRest(); // checks if able to heal bool Rest(float rate); // heal an amount of hp / mp diff --git a/src/map/lua/lua_baseentity.cpp b/src/map/lua/lua_baseentity.cpp index 725c4160e19..91916ec8456 100644 --- a/src/map/lua/lua_baseentity.cpp +++ b/src/map/lua/lua_baseentity.cpp @@ -12666,28 +12666,14 @@ bool CLuaBaseEntity::delLatent(uint16 condID, uint16 conditionValue, uint16 mID, int16 CLuaBaseEntity::getMaxGearMod(Mod modId) { - CCharEntity* PChar = dynamic_cast(m_PBaseEntity); - uint16 maxModValue = 0; - - if (!PChar) + if (m_PBaseEntity->objtype != TYPE_PC) { - ShowWarning("CLuaBaseEntity::getMaxGearMod() - m_PBaseEntity is not a player."); + ShowWarning("Invalid Entity (Non-PC: %s) calling function.", m_PBaseEntity->GetName()); + return 0; } - for (uint8 i = 0; i < SLOT_BACK; ++i) - { - auto* PItem = PChar->getEquip((SLOTTYPE)i); - if (PItem && (PItem->isType(ITEM_EQUIPMENT) || PItem->isType(ITEM_WEAPON))) - { - uint16 modValue = PItem->getModifier(modId); - if (modValue > maxModValue) - { - maxModValue = modValue; - } - } - } - return maxModValue; + return static_cast(m_PBaseEntity)->getMaxGearMod(static_cast(modId)); } /************************************************************************ diff --git a/src/map/utils/battleutils.cpp b/src/map/utils/battleutils.cpp index 496641b801a..35a5dbe9fb9 100644 --- a/src/map/utils/battleutils.cpp +++ b/src/map/utils/battleutils.cpp @@ -4470,9 +4470,9 @@ namespace battleutils { if (m_PChar->StatusEffectContainer->HasStatusEffect(EFFECT_SOULEATER)) { - // at most 2% bonus from gear - float souleaterBonus = std::min(0.2, m_PChar->getMod(Mod::SOULEATER_EFFECT) * 0.01); - float souleaterBonusII = m_PChar->getMod(Mod::SOULEATER_EFFECT_II) * 0.01; // No known cap to this bonus. Used on Agwu's scythe + // Souleater's HP consumed is 10% (base) + x% from gear (ONLY HIGHEST) + x% from gear augments. + float souleaterBonus = m_PChar->getMaxGearMod(Mod::SOULEATER_EFFECT) * 0.01; + float souleaterBonusII = m_PChar->getMod(Mod::SOULEATER_EFFECT_II) * 0.01; float stalwartSoulBonus = 1 - static_cast(m_PChar->getMod(Mod::STALWART_SOUL)) / 100; float bonusDamage = m_PChar->health.hp * (0.1f + souleaterBonus + souleaterBonusII);