Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Souleater effect modifier stacking #4557

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scripts/globals/weaponskills.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
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)
Xaver-DaRed marked this conversation as resolved.
Show resolved Hide resolved
{
TracyZoneScoped;
CCharEntity* 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
22 changes: 4 additions & 18 deletions src/map/lua/lua_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12666,28 +12666,14 @@ bool CLuaBaseEntity::delLatent(uint16 condID, uint16 conditionValue, uint16 mID,

int16 CLuaBaseEntity::getMaxGearMod(Mod modId)
{
CCharEntity* PChar = dynamic_cast<CCharEntity*>(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<CCharEntity*>(m_PBaseEntity)->getMaxGearMod(static_cast<Mod>(modId));
}

/************************************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/map/utils/battleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(m_PChar->getMod(Mod::STALWART_SOUL)) / 100;
float bonusDamage = m_PChar->health.hp * (0.1f + souleaterBonus + souleaterBonusII);

Expand Down