Skip to content

Commit 34a883e

Browse files
committed
refactor: clean up more brackets
1 parent f0330c4 commit 34a883e

File tree

1 file changed

+20
-107
lines changed

1 file changed

+20
-107
lines changed

src/mod_zone_difficulty_scripts.cpp

+20-107
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ class mod_zone_difficulty_unitscript : public UnitScript
5757
continue;
5858

5959
if (sZoneDifficulty->IsDebugInfoEnabled && target)
60-
{
6160
if (Player* player = target->ToPlayer()) // Pointless check? Perhaps.
62-
if (player->GetSession())
63-
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Base Value: {}", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, eff->GetAmount());
64-
}
61+
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Base Value: {}", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, eff->GetAmount());
6562

6663
int32 absorb = eff->GetAmount();
6764
uint32 phaseMask = target->GetPhaseMask();
@@ -71,16 +68,12 @@ class mod_zone_difficulty_unitscript : public UnitScript
7168
{
7269
Map* map = target->GetMap();
7370
if (sZoneDifficulty->HasNormalMode(mode))
74-
{
7571
absorb = eff->GetAmount() * sZoneDifficulty->NerfInfo[mapId][matchingPhase].AbsorbNerfPct;
76-
}
72+
7773
if (sZoneDifficulty->HasMythicmode(mode) && sZoneDifficulty->MythicmodeInstanceData[target->GetMap()->GetInstanceId()])
7874
{
79-
if (map->IsRaid() ||
80-
(map->IsHeroic() && map->IsDungeon()))
81-
{
75+
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
8276
absorb = eff->GetAmount() * sZoneDifficulty->NerfInfo[mapId][matchingPhase].AbsorbNerfPctHard;
83-
}
8477
}
8578
}
8679
else if (sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0 && nerfInDuel)
@@ -95,16 +88,12 @@ class mod_zone_difficulty_unitscript : public UnitScript
9588
{
9689
// Check if the mode of instance and SpellNerfOverride match
9790
if (sZoneDifficulty->OverrideModeMatches(target->GetMap()->GetInstanceId(), spellInfo->Id, mapId))
98-
{
9991
absorb = eff->GetAmount() * sZoneDifficulty->SpellNerfOverrides[spellInfo->Id][mapId].NerfPct;
100-
}
10192
}
10293
else if (sZoneDifficulty->SpellNerfOverrides[spellInfo->Id].find(0) != sZoneDifficulty->SpellNerfOverrides[spellInfo->Id].end())
10394
{
10495
if (sZoneDifficulty->OverrideModeMatches(target->GetMap()->GetInstanceId(), spellInfo->Id, mapId))
105-
{
10696
absorb = eff->GetAmount() * sZoneDifficulty->SpellNerfOverrides[spellInfo->Id][0].NerfPct;
107-
}
10897
}
10998
}
11099

@@ -184,17 +173,11 @@ class mod_zone_difficulty_unitscript : public UnitScript
184173
{
185174
Map* map = target->GetMap();
186175
if (sZoneDifficulty->HasNormalMode(mode))
187-
{
188176
heal = heal * sZoneDifficulty->NerfInfo[mapId][matchingPhase].HealingNerfPct;
189-
}
177+
190178
if (sZoneDifficulty->HasMythicmode(mode) && sZoneDifficulty->MythicmodeInstanceData[map->GetInstanceId()])
191-
{
192-
if (map->IsRaid() ||
193-
(map->IsHeroic() && map->IsDungeon()))
194-
{
179+
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
195180
heal = heal * sZoneDifficulty->NerfInfo[mapId][matchingPhase].HealingNerfPctHard;
196-
}
197-
}
198181
}
199182
else if (sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0 && nerfInDuel)
200183
{
@@ -210,9 +193,7 @@ class mod_zone_difficulty_unitscript : public UnitScript
210193
return;
211194

212195
if (!sZoneDifficulty->MythicmodeInNormalDungeons && !target->GetMap()->IsRaidOrHeroicDungeon())
213-
{
214196
return;
215-
}
216197

217198
bool isDot = false;
218199

@@ -221,9 +202,7 @@ class mod_zone_difficulty_unitscript : public UnitScript
221202
for (auto const& eff : spellInfo->GetEffects())
222203
{
223204
if (eff.ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || eff.ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE_PERCENT)
224-
{
225205
isDot = true;
226-
}
227206
}
228207
}
229208

@@ -232,10 +211,8 @@ class mod_zone_difficulty_unitscript : public UnitScript
232211

233212
// Disclaimer: also affects disables boss adds buff.
234213
if (sConfigMgr->GetOption<bool>("ModZoneDifficulty.SpellBuff.OnlyBosses", false))
235-
{
236214
if (attacker->ToCreature() && !attacker->ToCreature()->IsDungeonBoss())
237215
return;
238-
}
239216

240217
if (sZoneDifficulty->IsValidNerfTarget(target))
241218
{
@@ -244,63 +221,45 @@ class mod_zone_difficulty_unitscript : public UnitScript
244221
int32 matchingPhase = sZoneDifficulty->GetLowestMatchingPhase(mapId, phaseMask);
245222

246223
if (sZoneDifficulty->IsDebugInfoEnabled && attacker)
247-
{
248224
if (Player* player = attacker->ToPlayer())
249225
ChatHandler(player->GetSession()).PSendSysMessage("A dot tick will be altered. Pre Nerf Value: {}", damage);
250-
}
251226

252227
if (sZoneDifficulty->ShouldNerfMap(mapId) && matchingPhase != -1)
253228
{
254229
int8 mode = sZoneDifficulty->NerfInfo[mapId][matchingPhase].Enabled;
255230
Map* map = target->GetMap();
231+
256232
if (sZoneDifficulty->HasNormalMode(mode))
257-
{
258233
damage = damage * sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPct;
259-
}
234+
260235
if (sZoneDifficulty->HasMythicmode(mode) && sZoneDifficulty->MythicmodeInstanceData[map->GetInstanceId()])
261-
{
262-
if (map->IsRaid() ||
263-
(map->IsHeroic() && map->IsDungeon()))
264-
{
236+
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
265237
damage = damage * sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPctHard;
266-
}
267-
}
268238
}
269239
else if (sZoneDifficulty->ShouldNerfInDuels(target))
270240
{
271241
if (sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0)
272-
{
273242
damage = damage * sZoneDifficulty->NerfInfo[DUEL_INDEX][0].SpellDamageBuffPct;
274-
}
275243
}
276244

277245
if (sZoneDifficulty->IsDebugInfoEnabled && attacker)
278-
{
279246
if (Player* player = attacker->ToPlayer())
280247
ChatHandler(player->GetSession()).PSendSysMessage("A dot tick was altered. Post Nerf Value: {}", damage);
281-
}
282248
}
283249
}
284250

285251
void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage, SpellInfo const* spellInfo) override
286252
{
287253
if (!sZoneDifficulty->IsEnabled)
288-
{
289254
return;
290-
}
255+
291256
if (!sZoneDifficulty->MythicmodeInNormalDungeons && !target->GetMap()->IsRaidOrHeroicDungeon())
292-
{
293257
return;
294-
}
295258

296259
// Disclaimer: also affects disables boss adds buff.
297260
if (sConfigMgr->GetOption<bool>("ModZoneDifficulty.SpellBuff.OnlyBosses", false))
298-
{
299261
if (attacker->ToCreature() && !attacker->ToCreature()->IsDungeonBoss())
300-
{
301262
return;
302-
}
303-
}
304263

305264
if (sZoneDifficulty->IsValidNerfTarget(target))
306265
{
@@ -334,11 +293,8 @@ class mod_zone_difficulty_unitscript : public UnitScript
334293
{
335294
if (Player* player = target->ToPlayer()) // Pointless check? Perhaps.
336295
{
337-
if (player->GetSession())
338-
{
339-
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Before Nerf Value: {} ({} Normal Mode)", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, damage, sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPct);
340-
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Before Nerf Value: {} ({} Mythic Mode)", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, damage, sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPctHard);
341-
}
296+
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Before Nerf Value: {} ({} Normal Mode)", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, damage, sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPct);
297+
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Before Nerf Value: {} ({} Mythic Mode)", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, damage, sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPctHard);
342298
}
343299
}
344300
}
@@ -347,59 +303,38 @@ class mod_zone_difficulty_unitscript : public UnitScript
347303
{
348304
int8 mode = sZoneDifficulty->NerfInfo[mapId][matchingPhase].Enabled;
349305
Map* map = target->GetMap();
306+
350307
if (sZoneDifficulty->HasNormalMode(mode))
351-
{
352308
damage = damage * sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPct;
353-
}
309+
354310
if (sZoneDifficulty->HasMythicmode(mode) && sZoneDifficulty->MythicmodeInstanceData[map->GetInstanceId()])
355-
{
356-
if (map->IsRaid() ||
357-
(map->IsHeroic() && map->IsDungeon()))
358-
{
311+
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
359312
damage = damage * sZoneDifficulty->NerfInfo[mapId][matchingPhase].SpellDamageBuffPctHard;
360-
}
361-
}
362313
}
363314
else if (sZoneDifficulty->ShouldNerfInDuels(target))
364315
{
365316
if (sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0)
366-
{
367317
damage = damage * sZoneDifficulty->NerfInfo[DUEL_INDEX][0].SpellDamageBuffPct;
368-
}
369318
}
370319

371320
if (sZoneDifficulty->IsDebugInfoEnabled && target)
372-
{
373321
if (Player* player = target->ToPlayer()) // Pointless check? Perhaps.
374-
{
375-
if (player->GetSession())
376-
{
377-
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Post Nerf Value: {}", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, damage);
378-
}
379-
}
380-
}
322+
ChatHandler(player->GetSession()).PSendSysMessage("Spell: {} ({}) Post Nerf Value: {}", spellInfo->SpellName[player->GetSession()->GetSessionDbcLocale()], spellInfo->Id, damage);
381323
}
382324
}
383325

384326
void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage) override
385327
{
386328
if (!sZoneDifficulty->IsEnabled)
387-
{
388329
return;
389-
}
330+
390331
if (!sZoneDifficulty->MythicmodeInNormalDungeons && !target->GetMap()->IsRaidOrHeroicDungeon())
391-
{
392332
return;
393-
}
394333

395334
// Disclaimer: also affects disables boss adds buff.
396335
if (sConfigMgr->GetOption<bool>("ModZoneDifficulty.MeleeBuff.OnlyBosses", false))
397-
{
398336
if (attacker->ToCreature() && !attacker->ToCreature()->IsDungeonBoss())
399-
{
400337
return;
401-
}
402-
}
403338

404339
if (sZoneDifficulty->IsValidNerfTarget(target))
405340
{
@@ -410,25 +345,18 @@ class mod_zone_difficulty_unitscript : public UnitScript
410345
{
411346
int8 mode = sZoneDifficulty->NerfInfo[mapId][matchingPhase].Enabled;
412347
Map* map = target->GetMap();
348+
413349
if (sZoneDifficulty->HasNormalMode(mode))
414-
{
415350
damage = damage * sZoneDifficulty->NerfInfo[mapId][matchingPhase].MeleeDamageBuffPct;
416-
}
351+
417352
if (sZoneDifficulty->HasMythicmode(mode) && sZoneDifficulty->MythicmodeInstanceData[target->GetMap()->GetInstanceId()])
418-
{
419-
if (map->IsRaid() ||
420-
(map->IsHeroic() && map->IsDungeon()))
421-
{
353+
if (map->IsRaid() || (map->IsHeroic() && map->IsDungeon()))
422354
damage = damage * sZoneDifficulty->NerfInfo[mapId][matchingPhase].MeleeDamageBuffPctHard;
423-
}
424-
}
425355
}
426356
else if (sZoneDifficulty->ShouldNerfInDuels(target))
427357
{
428358
if (sZoneDifficulty->NerfInfo[DUEL_INDEX][0].Enabled > 0)
429-
{
430359
damage = damage * sZoneDifficulty->NerfInfo[DUEL_INDEX][0].MeleeDamageBuffPct;
431-
}
432360
}
433361
}
434362
}
@@ -438,36 +366,21 @@ class mod_zone_difficulty_unitscript : public UnitScript
438366
*/
439367
void OnUnitEnterCombat(Unit* unit, Unit* /*victim*/) override
440368
{
441-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: OnUnitEnterCombat for unit {}", unit->GetEntry());
442369
if (sZoneDifficulty->MythicmodeInstanceData.find(unit->GetInstanceId()) == sZoneDifficulty->MythicmodeInstanceData.end())
443-
{
444-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Instance is not in mythic mode.");
445370
return;
446-
}
371+
447372
if (!sZoneDifficulty->MythicmodeInstanceData[unit->GetInstanceId()])
448-
{
449-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: InstanceId not found in mythic mode list.");
450373
return;
451-
}
452374

453375
if (Creature* creature = unit->ToCreature())
454-
{
455376
if (creature->IsTrigger())
456-
{
457-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Creature is a trigger.");
458377
return;
459-
}
460-
}
461378

462379
uint32 entry = unit->GetEntry();
463380
if (sZoneDifficulty->MythicmodeAI.find(entry) == sZoneDifficulty->MythicmodeAI.end())
464-
{
465-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: No HarmodeAI found for creature with entry {}", entry);
466381
return;
467-
}
468382

469383
unit->m_Events.CancelEventGroup(EVENT_GROUP);
470-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: OnUnitEnterCombat checks passed for unit {}", unit->GetEntry());
471384

472385
uint32 i = 0;
473386
for (ZoneDifficultyHAI& data : sZoneDifficulty->MythicmodeAI[entry])

0 commit comments

Comments
 (0)