From a5d9661b1cea24103fb2c6e12ec3ccaf872fa133 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Thu, 2 Jan 2025 17:20:34 -0300 Subject: [PATCH 1/2] Adds support for deleting multiple spells in the aura nerf system. This PR introduces a helper function to manage the IDs of spells that should be excluded from the aura nerf system. This improves the modularity of the code and makes it easier to add or remove new spells in the future. --- src/mod_zone_difficulty_scripts.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mod_zone_difficulty_scripts.cpp b/src/mod_zone_difficulty_scripts.cpp index 7fabc142..42f0908c 100644 --- a/src/mod_zone_difficulty_scripts.cpp +++ b/src/mod_zone_difficulty_scripts.cpp @@ -25,6 +25,12 @@ class mod_zone_difficulty_unitscript : public UnitScript public: mod_zone_difficulty_unitscript() : UnitScript("mod_zone_difficulty_unitscript") { } + bool IsExcludedSpell(uint32 spellId) + { + static const std::unordered_set excludedSpells = { 31852, 31851, 31850 }; + return excludedSpells.find(spellId) != excludedSpells.end(); + } + void OnAuraApply(Unit* target, Aura* aura) override { if (!sZoneDifficulty->IsEnabled) @@ -38,7 +44,7 @@ class mod_zone_difficulty_unitscript : public UnitScript uint32 mapId = target->GetMapId(); bool nerfInDuel = sZoneDifficulty->ShouldNerfInDuels(target); - //Check if the map of the target is subject of a nerf at all OR if the target is subject of a nerf in a duel + // Check if the map of the target is subject to a nerf at all OR if the target is subject to a nerf in a duel if (sZoneDifficulty->ShouldNerfMap(mapId) || nerfInDuel) { if (SpellInfo const* spellInfo = aura->GetSpellInfo()) @@ -47,6 +53,10 @@ class mod_zone_difficulty_unitscript : public UnitScript if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)) return; + // Use the function to skip excluded spells + if (IsExcludedSpell(spellInfo->Id)) + return; + if (spellInfo->HasAura(SPELL_AURA_SCHOOL_ABSORB)) { std::list AuraEffectList = target->GetAuraEffectsByType(SPELL_AURA_SCHOOL_ABSORB); @@ -81,7 +91,7 @@ class mod_zone_difficulty_unitscript : public UnitScript absorb = eff->GetAmount() * sZoneDifficulty->NerfInfo[DUEL_INDEX][0].AbsorbNerfPct; } - //This check must be last and override duel and map adjustments + // This check must be last and override duel and map adjustments if (sZoneDifficulty->SpellNerfOverrides.find(spellInfo->Id) != sZoneDifficulty->SpellNerfOverrides.end()) { if (sZoneDifficulty->SpellNerfOverrides[spellInfo->Id].find(mapId) != sZoneDifficulty->SpellNerfOverrides[spellInfo->Id].end()) From 553784b639724c767987dbd837d955a044a198a6 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Fri, 3 Jan 2025 18:10:56 -0300 Subject: [PATCH 2/2] Add Spell Exclusion Logic to OnAuraApply with Optimized Direct Check for Specific Spell IDs 1. std::unordered_set: A static set to store the IDs of excluded spells. This maintains modularity and makes it easier to add new IDs. 2. Direct check on the set: The exclusion check (excludedSpells.count(spellInfo->Id)) is now done inline, eliminating the need to call a separate function. --- src/mod_zone_difficulty_scripts.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/mod_zone_difficulty_scripts.cpp b/src/mod_zone_difficulty_scripts.cpp index 42f0908c..6c9bd9a0 100644 --- a/src/mod_zone_difficulty_scripts.cpp +++ b/src/mod_zone_difficulty_scripts.cpp @@ -25,12 +25,6 @@ class mod_zone_difficulty_unitscript : public UnitScript public: mod_zone_difficulty_unitscript() : UnitScript("mod_zone_difficulty_unitscript") { } - bool IsExcludedSpell(uint32 spellId) - { - static const std::unordered_set excludedSpells = { 31852, 31851, 31850 }; - return excludedSpells.find(spellId) != excludedSpells.end(); - } - void OnAuraApply(Unit* target, Aura* aura) override { if (!sZoneDifficulty->IsEnabled) @@ -50,11 +44,8 @@ class mod_zone_difficulty_unitscript : public UnitScript if (SpellInfo const* spellInfo = aura->GetSpellInfo()) { // Skip spells not affected by vulnerability (potions) - if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)) - return; - - // Use the function to skip excluded spells - if (IsExcludedSpell(spellInfo->Id)) + static const std::unordered_set excludedSpells = { 31852, 31851, 31850 }; + if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) || excludedSpells.count(spellInfo->Id)) return; if (spellInfo->HasAura(SPELL_AURA_SCHOOL_ABSORB))