From 3b752dd796a4bf0be741258d3f6c2d0a8ffaedc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Borz=C3=AC?= Date: Thu, 22 Jul 2021 01:12:28 +0200 Subject: [PATCH] refactor(Scripts/Spells): code cleanup (part 9) (#6946) --- .../game/AI/ScriptedAI/ScriptedCreature.cpp | 1 - src/server/scripts/Spells/spell_druid.cpp | 4 ++-- src/server/scripts/Spells/spell_generic.cpp | 15 +++++++++++---- src/server/scripts/Spells/spell_hunter.cpp | 6 +++++- src/server/scripts/Spells/spell_paladin.cpp | 14 ++++++++++---- src/server/scripts/Spells/spell_priest.cpp | 12 ++++++++---- src/server/scripts/Spells/spell_rogue.cpp | 1 - 7 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 36f69e47f..6f560e864 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -9,7 +9,6 @@ #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "Item.h" #include "ObjectMgr.h" #include "ScriptedCreature.h" #include "Spell.h" diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 88ae90d78..3171aaf13 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -886,8 +886,8 @@ public: if (AuraEffect const* idol = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_FERAL_SHADOWS, EFFECT_0)) amount += cp * idol->GetAmount(); // Idol of Worship. Can't be handled as SpellMod due its dependency from CPs - else if (AuraEffect const* idol = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_WORSHIP, EFFECT_0)) - amount += cp * idol->GetAmount(); + else if (AuraEffect const* idol2 = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_WORSHIP, EFFECT_0)) + amount += cp * idol2->GetAmount(); amount += int32(CalculatePct(caster->GetTotalAttackPowerValue(BASE_ATTACK), cp)); } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 0c894628b..7391d3c57 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -19,10 +19,8 @@ #include "CellImpl.h" #include "Chat.h" #include "GridNotifiers.h" -#include "GridNotifiersImpl.h" #include "Group.h" #include "InstanceScript.h" -#include "LFGMgr.h" #include "Pet.h" #include "ReputationMgr.h" #include "ScriptMgr.h" @@ -32,6 +30,11 @@ #include "Vehicle.h" #include +// TODO: this import is not necessary for compilation and marked as unused by the IDE +// however, for some reasons removing it would cause a damn linking issue +// there is probably some underlying problem with imports which should properly addressed +#include "GridNotifiersImpl.h" + // Ours class spell_gen_model_visible : public SpellScriptLoader { @@ -4713,15 +4716,19 @@ public: { Aura const* aura = GetHitAura(); if (!(aura && aura->GetStackAmount() == 3)) + { return; + } target->CastSpell(target, SPELL_FOAM_SWORD_DEFEAT, true); target->RemoveAurasDueToSpell(SPELL_BONKED); - if (Aura const* aura = target->GetAura(SPELL_ON_GUARD)) + if (Aura const* onGuardAura = target->GetAura(SPELL_ON_GUARD)) { - if (Item* item = target->GetItemByGuid(aura->GetCastItemGUID())) + if (Item* item = target->GetItemByGuid(onGuardAura->GetCastItemGUID())) + { target->DestroyItemCount(item->GetEntry(), 1, true); + } } } } diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 2f44fad97..a6c5f4956 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -13,12 +13,16 @@ #include "Cell.h" #include "CellImpl.h" #include "GridNotifiers.h" -#include "GridNotifiersImpl.h" #include "Pet.h" #include "ScriptMgr.h" #include "SpellAuraEffects.h" #include "SpellScript.h" +// TODO: this import is not necessary for compilation and marked as unused by the IDE +// however, for some reasons removing it would cause a damn linking issue +// there is probably some underlying problem with imports which should properly addressed +#include "GridNotifiersImpl.h" + enum HunterSpells { // Ours diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 1f3424e75..35bd2bfcd 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -227,10 +227,14 @@ public: // Xinef: removed divine guardian because it will affect triggered spell with increased amount // Arena - Dampening if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_ARENA_DAMPENING, EFFECT_0)) + { AddPct(amount, dampening->GetAmount()); + } // Battleground - Dampening - else if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_BATTLEGROUND_DAMPENING, EFFECT_0)) - AddPct(amount, dampening->GetAmount()); + else if (AuraEffect const* dampening2 = caster->GetAuraEffect(SPELL_GENERIC_BATTLEGROUND_DAMPENING, EFFECT_0)) + { + AddPct(amount, dampening2->GetAmount()); + } } } @@ -1259,8 +1263,10 @@ public: holy += eventInfo.GetProcTarget()->SpellBaseDamageBonusTaken(SPELL_SCHOOL_MASK_HOLY); // Xinef: Libram of Divine Purpose - if (AuraEffect* aurEff = GetTarget()->GetDummyAuraEffect(SPELLFAMILY_PALADIN, 2025, EFFECT_0)) - holy += aurEff->GetAmount(); + if (AuraEffect* aurEffPaladin = GetTarget()->GetDummyAuraEffect(SPELLFAMILY_PALADIN, 2025, EFFECT_0)) + { + holy += aurEffPaladin->GetAmount(); + } int32 bp = std::max(0, int32((ap * 0.022f + 0.044f * holy) * GetTarget()->GetAttackTime(BASE_ATTACK) / 1000)); GetTarget()->CastCustomSpell(SPELL_PALADIN_SEAL_OF_RIGHTEOUSNESS, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, nullptr, aurEff); diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index e3dafa1e4..86c7d01cd 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -713,11 +713,15 @@ public: AddPct(amount, healModifier); // Arena - Dampening - if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_ARENA_DAMPENING, EFFECT_0)) - AddPct(amount, dampening->GetAmount()); + if (AuraEffect const* arenaDampening = caster->GetAuraEffect(SPELL_GENERIC_ARENA_DAMPENING, EFFECT_0)) + { + AddPct(amount, arenaDampening->GetAmount()); + } // Battleground - Dampening - else if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_BATTLEGROUND_DAMPENING, EFFECT_0)) - AddPct(amount, dampening->GetAmount()); + else if (AuraEffect const* bgDampening = caster->GetAuraEffect(SPELL_GENERIC_BATTLEGROUND_DAMPENING, EFFECT_0)) + { + AddPct(amount, bgDampening->GetAmount()); + } return amount; } diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 22ffdd022..30884ca01 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -12,7 +12,6 @@ #include "CellImpl.h" #include "GridNotifiers.h" -#include "GridNotifiersImpl.h" #include "ScriptMgr.h" #include "SpellAuraEffects.h" #include "SpellScript.h"