Skip to content

Commit 56e2628

Browse files
authored
Fix indentation
1 parent 54472d5 commit 56e2628

File tree

1 file changed

+69
-68
lines changed

1 file changed

+69
-68
lines changed

src/mod_zone_difficulty_scripts.cpp

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -32,90 +32,91 @@ class mod_zone_difficulty_unitscript : public UnitScript
3232
UNITHOOK_ON_UNIT_ENTER_COMBAT
3333
}) { }
3434

35-
void OnAuraApply(Unit* target, Aura* aura) override
36-
{
37-
if (!sZoneDifficulty->IsEnabled)
38-
return;
35+
void OnAuraApply(Unit* target, Aura* aura) override
36+
{
37+
if (!sZoneDifficulty->IsEnabled)
38+
return;
39+
40+
if (!sZoneDifficulty->MythicmodeInNormalDungeons && !target->GetMap()->IsRaidOrHeroicDungeon())
41+
return;
3942

40-
if (!sZoneDifficulty->MythicmodeInNormalDungeons && !target->GetMap()->IsRaidOrHeroicDungeon())
41-
return;
43+
if (!sZoneDifficulty->IsValidNerfTarget(target))
44+
return;
4245

43-
if (!sZoneDifficulty->IsValidNerfTarget(target))
44-
return;
46+
if (!sZoneDifficulty->ShouldNerfMap(targett->GetMapId()) && !sZoneDifficulty->ShouldNerfInDuels(target))
47+
return;
4548

46-
SpellInfo const* spellInfo = aura->GetSpellInfo();
47-
if (!spellInfo || spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
48-
return;
49+
SpellInfo const* spellInfo = aura->GetSpellInfo();
50+
if (!spellInfo || spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
51+
return;
4952

50-
if (!spellInfo->HasAura(SPELL_AURA_SCHOOL_ABSORB))
51-
return;
53+
if (!spellInfo->HasAura(SPELL_AURA_SCHOOL_ABSORB))
54+
return;
5255

53-
auto& absorbEffects = target->GetAuraEffectsByType(SPELL_AURA_SCHOOL_ABSORB);
54-
for (AuraEffect* eff : absorbEffects)
55-
{
56-
if (eff->GetAuraType() != SPELL_AURA_SCHOOL_ABSORB || eff->GetSpellInfo()->Id != spellInfo->Id)
57-
continue;
58-
59-
int32 absorb = eff->GetAmount();
60-
uint32 mapId = target->GetMapId();
61-
uint32 instanceId = target->GetMap()->GetInstanceId();
62-
uint32 phaseMask = target->GetPhaseMask();
63-
int phase = sZoneDifficulty->GetLowestMatchingPhase(mapId, phaseMask);
64-
bool isMythic = sZoneDifficulty->MythicmodeInstanceData[instanceId];
65-
bool nerfInDuel = sZoneDifficulty->ShouldNerfInDuels(target);
66-
67-
// Lambda: scalable reduction
68-
auto scaleAbsorb = [](int32 amount, float pct) -> int32 {
69-
float scaled = amount * pct;
70-
return (scaled < 0) ? static_cast<int32>(std::floor(scaled)) : static_cast<int32>(scaled);
71-
};
72-
73-
// Apply duel-based nerf if no valid map phase
74-
if (phase == -1 && nerfInDuel && sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0)
75-
{
76-
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[DUEL_INDEX][0].AbsorbNerfPct);
77-
}
78-
else if (phase != -1)
56+
auto& absorbEffects = target->GetAuraEffectsByType(SPELL_AURA_SCHOOL_ABSORB);
57+
for (AuraEffect* eff : absorbEffects)
7958
{
80-
int8 mode = sZoneDifficulty->NerfInfo[mapId][phase].Enabled;
81-
82-
if (!isMythic && sZoneDifficulty->HasNormalMode(mode))
83-
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[mapId][phase].AbsorbNerfPct);
59+
if (eff->GetAuraType() != SPELL_AURA_SCHOOL_ABSORB || eff->GetSpellInfo()->Id != spellInfo->Id)
60+
continue;
8461

85-
if (isMythic && sZoneDifficulty->HasMythicmode(mode))
62+
int32 absorb = eff->GetAmount();
63+
uint32 mapId = target->GetMapId();
64+
uint32 instanceId = target->GetMap()->GetInstanceId();
65+
uint32 phaseMask = target->GetPhaseMask();
66+
int phase = sZoneDifficulty->GetLowestMatchingPhase(mapId, phaseMask);
67+
bool isMythic = sZoneDifficulty->MythicmodeInstanceData[instanceId];
68+
bool nerfInDuel = sZoneDifficulty->ShouldNerfInDuels(target);
69+
70+
auto scaleAbsorb = [](int32 amount, float pct) -> int32 {
71+
float scaled = amount * pct;
72+
return (scaled < 0) ? static_cast<int32>(std::floor(scaled)) : static_cast<int32>(scaled);
73+
};
74+
75+
// Apply duel-based nerf if no valid map phase
76+
if (phase == -1 && nerfInDuel && sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0)
8677
{
87-
Map* map = target->GetMap();
88-
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
89-
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[mapId][phase].AbsorbNerfPctHard);
78+
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[DUEL_INDEX][0].AbsorbNerfPct);
9079
}
91-
}
80+
else if (phase != -1)
81+
{
82+
int8 mode = sZoneDifficulty->NerfInfo[mapId][phase].Enabled;
9283

93-
// Overrides always apply last
94-
auto const& overrideIt = sZoneDifficulty->SpellNerfOverrides.find(spellInfo->Id);
95-
if (overrideIt != sZoneDifficulty->SpellNerfOverrides.end())
96-
{
97-
auto const& overrideMap = overrideIt->second;
98-
if (sZoneDifficulty->OverrideModeMatches(instanceId, spellInfo->Id, mapId))
84+
if (!isMythic && sZoneDifficulty->HasNormalMode(mode))
85+
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[mapId][phase].AbsorbNerfPct);
86+
87+
if (isMythic && sZoneDifficulty->HasMythicmode(mode))
88+
{
89+
Map* map = target->GetMap();
90+
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
91+
absorb = scaleAbsorb(absorb, sZoneDifficulty->NerfInfo[mapId][phase].AbsorbNerfPctHard);
92+
}
93+
}
94+
95+
auto const& overrideIt = sZoneDifficulty->SpellNerfOverrides.find(spellInfo->Id);
96+
if (overrideIt != sZoneDifficulty->SpellNerfOverrides.end())
9997
{
100-
if (overrideMap.count(mapId))
101-
absorb = scaleAbsorb(absorb, overrideMap.at(mapId).NerfPct);
102-
else if (overrideMap.count(0))
103-
absorb = scaleAbsorb(absorb, overrideMap.at(0).NerfPct);
98+
auto const& overrideMap = overrideIt->second;
99+
if (sZoneDifficulty->OverrideModeMatches(instanceId, spellInfo->Id, mapId))
100+
{
101+
if (overrideMap.count(mapId))
102+
absorb = scaleAbsorb(absorb, overrideMap.at(mapId).NerfPct);
103+
else if (overrideMap.count(0))
104+
absorb = scaleAbsorb(absorb, overrideMap.at(0).NerfPct);
105+
}
104106
}
105-
}
106107

107-
eff->SetAmount(absorb);
108+
eff->SetAmount(absorb);
108109

109-
if (sZoneDifficulty->IsDebugInfoEnabled)
110-
{
111-
if (Player* player = target->ToPlayer())
110+
if (sZoneDifficulty->IsDebugInfoEnabled)
112111
{
113-
ChatHandler(player->GetSession()).PSendSysMessage(
114-
"Spell: {} ({}) Nerfed Value: {}",
115-
spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()],
116-
spellInfo->Id, absorb);
112+
if (Player* player = target->ToPlayer())
113+
{
114+
ChatHandler(player->GetSession()).PSendSysMessage(
115+
"Spell: {} ({}) Nerfed Value: {}",
116+
spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()],
117+
spellInfo->Id, absorb);
118+
}
117119
}
118-
}
119120
}
120121
}
121122

0 commit comments

Comments
 (0)