Skip to content
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
28 changes: 28 additions & 0 deletions scripts/globals/automaton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,31 @@ xi.automaton.handleAttuner = function(actor, target)

return 0
end

---@param actor CBaseEntity
---@param damage integer
---@return integer
xi.automaton.handleEqualizer = function(actor, damage)
local equalizerModifier = actor:getMod(xi.mod.AUTO_EQUALIZER)
local maxHP = actor:getMaxHP()

-- No Equalizer Equipped, return unmodified damage.
if equalizerModifier == 0 then
return damage
end

-- No Damage to reduce, return unmodified damage.
if damage <= 0 then
return damage
end

-- Equalizer damage reduction becomes more effective the higher the damage is in relation to the automatons max HP.
local reductionRate = damage / maxHP * (equalizerModifier / 100)

reductionRate = math.floor(reductionRate * 100) / 100

-- Damage reduction is capped at 90%.
reductionRate = math.min(reductionRate, 0.90)

return math.floor(damage * (1 - reductionRate))
end
4 changes: 2 additions & 2 deletions scripts/globals/mobskills.lua
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ local function handleSinglePhysicalHit(mob, target, baseHitDamage, params)
hitDamage = math.floor(hitDamage * xi.combat.damage.physicalElementSDT(target, params.damageType))
hitDamage = math.floor(hitDamage * xi.combat.damage.calculateDamageAdjustment(target, true, false, false, false))

-- TODO: Automaton Equalizer Reduction
hitDamage = xi.automaton.handleEqualizer(target, hitDamage)

-- TODO: Need captures for different severe damage mechanics. Do they proc per hit or per skill
hitDamage = math.floor(target:handleSevereDamage(hitDamage, true))
Expand Down Expand Up @@ -506,7 +506,7 @@ local function handleSingleRangedHit(mob, target, baseHitDamage, params)
hitDamage = math.floor(hitDamage * xi.combat.damage.physicalElementSDT(target, params.damageType))
hitDamage = math.floor(hitDamage * xi.combat.damage.calculateDamageAdjustment(target, true, false, true, false))

-- TODO: Automaton Equalizer Reduction
hitDamage = xi.automaton.handleEqualizer(target, hitDamage)

-- TODO: Need captures for different severe damage mechanics. Do they proc per hit or per skill
hitDamage = math.floor(target:handleSevereDamage(hitDamage, true))
Expand Down
2 changes: 1 addition & 1 deletion scripts/globals/pets/automaton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ local function applyAutomatonFrameMods(mob)
end

for _, modData in ipairs(frameData.mods or {}) do
mob:setMod(modData[1], modData[2])
mob:addMod(modData[1], modData[2])
end
end

Expand Down
10 changes: 6 additions & 4 deletions src/map/utils/battleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4680,9 +4680,10 @@ int32 PhysicalDmgTaken(CBattleEntity* PDefender, int32 damage, DAMAGE_TYPE damag
resist += PDefender->getMod(Mod::DMGPHYS_II) / 10000.0f; // Add Burtgang reduction after 50% cap. Extends cap to -68%
damage = (int32)(damage * resist);

if (damage > 0 && PDefender->objtype == TYPE_PET && PDefender->getMod(Mod::AUTO_EQUALIZER) > 0)
if (damage > 0 && PDefender->getMod(Mod::AUTO_EQUALIZER) > 0)
{
damage -= (int32)(damage / float(PDefender->GetMaxHP()) * (PDefender->getMod(Mod::AUTO_EQUALIZER) / 100.0f));
const auto reductionRate = std::floor(damage / static_cast<float>(PDefender->GetMaxHP()) * PDefender->getMod(Mod::AUTO_EQUALIZER)) / 100.0f;
damage = static_cast<int32>(std::floor(damage * (1.0f - std::min(reductionRate, 0.90f))));
}

// Handle damage absorption.
Expand Down Expand Up @@ -4723,9 +4724,10 @@ int32 RangedDmgTaken(CBattleEntity* PDefender, int32 damage, DAMAGE_TYPE damageT
resist = std::max(resist, 0.5f);
damage = (int32)(damage * resist);

if (damage > 0 && PDefender->objtype == TYPE_PET && PDefender->getMod(Mod::AUTO_EQUALIZER) > 0)
if (damage > 0 && PDefender->getMod(Mod::AUTO_EQUALIZER) > 0)
{
damage -= (int32)(damage / float(PDefender->GetMaxHP()) * (PDefender->getMod(Mod::AUTO_EQUALIZER) / 10000.0f));
const auto reductionRate = std::floor(damage / static_cast<float>(PDefender->GetMaxHP()) * PDefender->getMod(Mod::AUTO_EQUALIZER)) / 100.0f;
damage = static_cast<int32>(std::floor(damage * (1.0f - std::min(reductionRate, 0.90f))));
}

// Handle damage absorption.
Expand Down
Loading