Skip to content

Commit

Permalink
fix: preserve sign when scaling absorb aura amount (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogladev authored Jan 3, 2025
1 parent aa8c6b4 commit f842f90
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/mod_zone_difficulty_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,28 @@ class mod_zone_difficulty_unitscript : public UnitScript
uint32 phaseMask = target->GetPhaseMask();
int matchingPhase = sZoneDifficulty->GetLowestMatchingPhase(mapId, phaseMask);
int8 mode = sZoneDifficulty->NerfInfo[mapId][matchingPhase].Enabled;

// Ensure that negative values do not scale to 0
auto scaleAbsorb = [](int32 amount, float pct) -> int32
{
float scaled = amount * pct;
return (scaled < 0) ? static_cast<int32>(std::floor(scaled)) : static_cast<int32>(scaled);
};

if (matchingPhase != -1)
{
Map* map = target->GetMap();
if (sZoneDifficulty->HasNormalMode(mode))
absorb = eff->GetAmount() * sZoneDifficulty->NerfInfo[mapId][matchingPhase].AbsorbNerfPct;
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[mapId][matchingPhase].AbsorbNerfPct);

if (sZoneDifficulty->HasMythicmode(mode) && sZoneDifficulty->MythicmodeInstanceData[target->GetMap()->GetInstanceId()])
{
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
absorb = eff->GetAmount() * sZoneDifficulty->NerfInfo[mapId][matchingPhase].AbsorbNerfPctHard;
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[mapId][matchingPhase].AbsorbNerfPctHard);
}
}
else if (sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0 && nerfInDuel)
{
absorb = eff->GetAmount() * sZoneDifficulty->NerfInfo[DUEL_INDEX][0].AbsorbNerfPct;
}
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[DUEL_INDEX][0].AbsorbNerfPct);

//This check must be last and override duel and map adjustments
if (sZoneDifficulty->SpellNerfOverrides.find(spellInfo->Id) != sZoneDifficulty->SpellNerfOverrides.end())
Expand All @@ -88,12 +94,12 @@ class mod_zone_difficulty_unitscript : public UnitScript
{
// Check if the mode of instance and SpellNerfOverride match
if (sZoneDifficulty->OverrideModeMatches(target->GetMap()->GetInstanceId(), spellInfo->Id, mapId))
absorb = eff->GetAmount() * sZoneDifficulty->SpellNerfOverrides[spellInfo->Id][mapId].NerfPct;
absorb = scaleAbsorb(absorb, sZoneDifficulty->SpellNerfOverrides[spellInfo->Id][mapId].NerfPct);
}
else if (sZoneDifficulty->SpellNerfOverrides[spellInfo->Id].find(0) != sZoneDifficulty->SpellNerfOverrides[spellInfo->Id].end())
{
if (sZoneDifficulty->OverrideModeMatches(target->GetMap()->GetInstanceId(), spellInfo->Id, mapId))
absorb = eff->GetAmount() * sZoneDifficulty->SpellNerfOverrides[spellInfo->Id][0].NerfPct;
absorb = scaleAbsorb(absorb, sZoneDifficulty->SpellNerfOverrides[spellInfo->Id][0].NerfPct);
}
}

Expand Down

0 comments on commit f842f90

Please sign in to comment.