Skip to content

Commit

Permalink
Implement getMaxGearMod() to be used in core
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaver-DaRed committed Sep 28, 2023
1 parent c7302ce commit b2d9f56
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/globals/weaponskills.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ 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 = attacker:getMaxGearMod(xi.mod.SOULEATER_EFFECT) * 0.01)
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 = math.floor(attacker:getHP() * (0.1 + souleaterEffect + souleaterEffectII))
Expand Down
35 changes: 35 additions & 0 deletions src/map/entities/battleentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
auto* PChar = dynamic_cast<CCharEntity*>(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;
Expand Down
1 change: 1 addition & 0 deletions src/map/entities/battleentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/map/utils/battleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4471,7 +4471,7 @@ namespace battleutils
if (m_PChar->StatusEffectContainer->HasStatusEffect(EFFECT_SOULEATER))
{
// 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 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<float>(m_PChar->getMod(Mod::STALWART_SOUL)) / 100;
float bonusDamage = m_PChar->health.hp * (0.1f + souleaterBonus + souleaterBonusII);
Expand Down

0 comments on commit b2d9f56

Please sign in to comment.