From 8a4e1119ac21e2d1112d1717337597fe073e495f Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 4 Sep 2021 15:13:15 +0200 Subject: Core/Spells: Unify spell effect access api in both branches --- src/server/scripts/Spells/spell_dk.cpp | 21 ++++---- src/server/scripts/Spells/spell_druid.cpp | 11 ++-- src/server/scripts/Spells/spell_generic.cpp | 79 +++++++++++++++++------------ src/server/scripts/Spells/spell_holiday.cpp | 13 +++-- src/server/scripts/Spells/spell_hunter.cpp | 3 +- src/server/scripts/Spells/spell_item.cpp | 40 +++++---------- src/server/scripts/Spells/spell_mage.cpp | 32 +++++++----- src/server/scripts/Spells/spell_monk.cpp | 13 ++--- src/server/scripts/Spells/spell_pet.cpp | 8 +-- src/server/scripts/Spells/spell_priest.cpp | 48 ++++++++---------- src/server/scripts/Spells/spell_quest.cpp | 16 ++++-- src/server/scripts/Spells/spell_warlock.cpp | 30 +++++------ src/server/scripts/Spells/spell_warrior.cpp | 13 ++--- 13 files changed, 167 insertions(+), 160 deletions(-) (limited to 'src/server/scripts/Spells') diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index fb46a1ee3e3..3f61ed7058c 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -120,14 +120,14 @@ public: absorbedAmount = 0; } - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_DK_RUNIC_POWER_ENERGIZE, SPELL_DK_VOLATILE_SHIELDING }); + return ValidateSpellInfo({ SPELL_DK_RUNIC_POWER_ENERGIZE, SPELL_DK_VOLATILE_SHIELDING }) && spellInfo->GetEffects().size() > EFFECT_1; } bool Load() override { - absorbPct = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue(GetCaster()); + absorbPct = GetEffectInfo(EFFECT_1).CalcValue(GetCaster()); maxHealth = GetCaster()->GetMaxHealth(); absorbedAmount = 0; return true; @@ -465,8 +465,7 @@ class spell_dk_death_strike : public SpellScript SPELL_DK_FROST, SPELL_DK_DEATH_STRIKE_OFFHAND }) - && spellInfo->GetEffect(EFFECT_1) - && spellInfo->GetEffect(EFFECT_2); + && spellInfo->GetEffects().size() > EFFECT_2; } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -475,12 +474,10 @@ class spell_dk_death_strike : public SpellScript if (AuraEffect* enabler = caster->GetAuraEffect(SPELL_DK_DEATH_STRIKE_ENABLER, EFFECT_0, GetCaster()->GetGUID())) { - SpellInfo const* spellInfo = GetSpellInfo(); - // Heals you for 25% of all damage taken in the last 5 sec, - int32 heal = CalculatePct(enabler->CalculateAmount(GetCaster()), spellInfo->GetEffect(EFFECT_1)->CalcValue(GetCaster())); + int32 heal = CalculatePct(enabler->CalculateAmount(GetCaster()), GetEffectInfo(EFFECT_1).CalcValue(GetCaster())); // minimum 7.0% of maximum health. - int32 pctOfMaxHealth = CalculatePct(spellInfo->GetEffect(EFFECT_2)->CalcValue(GetCaster()), caster->GetMaxHealth()); + int32 pctOfMaxHealth = CalculatePct(GetEffectInfo(EFFECT_2).CalcValue(GetCaster()), caster->GetMaxHealth()); heal = std::max(heal, pctOfMaxHealth); caster->CastSpell(caster, SPELL_DK_DEATH_STRIKE_HEAL, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_BASE_POINT0, heal)); @@ -574,14 +571,14 @@ class spell_dk_ghoul_explode : public SpellScript { PrepareSpellScript(spell_dk_ghoul_explode); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_DK_CORPSE_EXPLOSION_TRIGGERED }); + return ValidateSpellInfo({ SPELL_DK_CORPSE_EXPLOSION_TRIGGERED }) && spellInfo->GetEffects().size() > EFFECT_2; } void HandleDamage(SpellEffIndex /*effIndex*/) { - SetHitDamage(GetCaster()->CountPctFromMaxHealth(GetEffectInfo(EFFECT_2)->CalcValue(GetCaster()))); + SetHitDamage(GetCaster()->CountPctFromMaxHealth(GetEffectInfo(EFFECT_2).CalcValue(GetCaster()))); } void Suicide(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 9fadf1612f3..06b197b4c7b 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -472,7 +472,7 @@ class spell_dru_ferocious_bite : public SpellScript bool Validate(SpellInfo const* /*spellInfo*/) override { return ValidateSpellInfo({ SPELL_DRUID_INCARNATION_KING_OF_THE_JUNGLE }) - && sSpellMgr->AssertSpellInfo(SPELL_DRUID_INCARNATION_KING_OF_THE_JUNGLE, DIFFICULTY_NONE)->GetEffect(EFFECT_1); + && sSpellMgr->AssertSpellInfo(SPELL_DRUID_INCARNATION_KING_OF_THE_JUNGLE, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_1; } void HandleHitTargetBurn(SpellEffIndex /*effIndex*/) @@ -709,7 +709,7 @@ public: spellMod->op = SpellModOp::PeriodicHealingAndDamage; spellMod->type = SPELLMOD_FLAT; spellMod->spellId = GetId(); - spellMod->mask = aurEff->GetSpellEffectInfo()->SpellClassMask; + spellMod->mask = aurEff->GetSpellEffectInfo().SpellClassMask; } spellMod->value = aurEff->GetAmount() / 7; } @@ -1959,8 +1959,7 @@ public: bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect2 = spellInfo->GetEffect(EFFECT_2); - if (!effect2 || effect2->IsEffect() || effect2->CalcValue() <= 0) + if (spellInfo->GetEffects().size() <= EFFECT_2 || spellInfo->GetEffect(EFFECT_2).IsEffect() || spellInfo->GetEffect(EFFECT_2).CalcValue() <= 0) return false; return true; } @@ -1969,7 +1968,7 @@ public: { targets.remove_if(RaidCheck(GetCaster())); - uint32 const maxTargets = uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue(GetCaster())); + uint32 const maxTargets = uint32(GetEffectInfo(EFFECT_2).CalcValue(GetCaster())); if (targets.size() > maxTargets) { @@ -2010,7 +2009,7 @@ public: return; // calculate from base damage, not from aurEff->GetAmount() (already modified) - float damage = caster->CalculateSpellDamage(GetUnitOwner(), GetSpellInfo(), aurEff->GetEffIndex()); + float damage = caster->CalculateSpellDamage(GetUnitOwner(), aurEff->GetSpellEffectInfo()); // Wild Growth = first tick gains a 6% bonus, reduced by 2% each tick float reduction = 2.f; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 7875e4522aa..9971cc20d4c 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -52,7 +52,7 @@ class spell_gen_absorb0_hitlimit1 : public AuraScript bool Load() override { // Max absorb stored in 1 dummy effect - limit = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue(); + limit = GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(); return true; } @@ -229,7 +229,7 @@ class spell_gen_arena_drink : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - if (!spellInfo->GetEffect(EFFECT_0)->IsAura() || spellInfo->GetEffect(EFFECT_0)->ApplyAuraName != SPELL_AURA_MOD_POWER_REGEN) + if (spellInfo->GetEffects().empty() || !spellInfo->GetEffect(EFFECT_0).IsAura(SPELL_AURA_MOD_POWER_REGEN)) { TC_LOG_ERROR("spells", "Aura %d structure has been changed - first aura is no longer SPELL_AURA_MOD_POWER_REGEN", GetId()); return false; @@ -328,7 +328,7 @@ class spell_gen_aura_of_fear : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell }); } void PeriodicTick(AuraEffect const* aurEff) @@ -337,7 +337,7 @@ class spell_gen_aura_of_fear : public AuraScript if (!roll_chance_i(GetSpellInfo()->ProcChance)) return; - GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, true); + GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, true); } void Register() override @@ -676,18 +676,18 @@ class spell_gen_burning_depths_necrolyte_image : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_2)->CalcValue()) }); + return spellInfo->GetEffects().size() > EFFECT_2 && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_2).CalcValue()) }); } void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { if (Unit* caster = GetCaster()) - caster->CastSpell(GetTarget(), uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue())); + caster->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_2).CalcValue())); } void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue()), GetCasterGUID()); + GetTarget()->RemoveAurasDueToSpell(uint32(GetEffectInfo(EFFECT_2).CalcValue()), GetCasterGUID()); } void Register() override @@ -1344,7 +1344,7 @@ class spell_gen_despawn_self : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { - if (GetEffectInfo()->IsEffect(SPELL_EFFECT_DUMMY) || GetEffectInfo()->IsEffect(SPELL_EFFECT_SCRIPT_EFFECT)) + if (GetEffectInfo().IsEffect(SPELL_EFFECT_DUMMY) || GetEffectInfo().IsEffect(SPELL_EFFECT_SCRIPT_EFFECT)) GetCaster()->ToCreature()->DespawnOrUnsummon(); } @@ -1594,18 +1594,20 @@ class spell_gen_gift_of_naaru : public AuraScript { PrepareAuraScript(spell_gen_gift_of_naaru); + bool Validate(SpellInfo const* spellInfo) override + { + return spellInfo->GetEffects().size() > EFFECT_1; + } + void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !aurEff->GetTotalTicks()) return; - if (SpellEffectInfo const* eff1 = GetSpellInfo()->GetEffect(EFFECT_1)) - { - float healPct = eff1->CalcValue() / 100.0f; - float heal = healPct * GetCaster()->GetMaxHealth(); - int32 healTick = std::floor(heal / aurEff->GetTotalTicks()); - amount += healTick; - } + float healPct = GetEffectInfo(EFFECT_1).CalcValue() / 100.0f; + float heal = healPct * GetCaster()->GetMaxHealth(); + int32 healTick = std::floor(heal / aurEff->GetTotalTicks()); + amount += healTick; } void Register() override @@ -1906,7 +1908,7 @@ class spell_gen_mounted_charge : public SpellScript if (spell->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT)) OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT); - if (spell->GetEffect(EFFECT_0)->Effect == SPELL_EFFECT_CHARGE) + if (spell->GetEffect(EFFECT_0).IsEffect(SPELL_EFFECT_CHARGE)) OnEffectHitTarget += SpellEffectFn(spell_gen_mounted_charge::HandleChargeEffect, EFFECT_0, SPELL_EFFECT_CHARGE); } }; @@ -1946,7 +1948,7 @@ class spell_gen_negative_energy_periodic : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell }); } void PeriodicTick(AuraEffect const* aurEff) @@ -1955,7 +1957,7 @@ class spell_gen_negative_energy_periodic : public AuraScript CastSpellExtraArgs args(aurEff); args.AddSpellMod(SPELLVALUE_MAX_TARGETS, aurEff->GetTickNumber() / 10 + 1); - GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, args); + GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, args); } void Register() override @@ -2147,16 +2149,21 @@ class spell_gen_oracle_wolvar_reputation : public SpellScript { PrepareSpellScript(spell_gen_oracle_wolvar_reputation); + bool Validate(SpellInfo const* spellInfo) override + { + return spellInfo->GetEffects().size() > EFFECT_1; + } + bool Load() override { return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - void HandleDummy(SpellEffIndex effIndex) + void HandleDummy(SpellEffIndex /*effIndex*/) { Player* player = GetCaster()->ToPlayer(); - uint32 factionId = GetEffectInfo(effIndex)->CalcValue(); - int32 repChange = GetEffectInfo(EFFECT_1)->CalcValue(); + uint32 factionId = GetEffectInfo().CalcValue(); + int32 repChange = GetEffectInfo(EFFECT_1).CalcValue(); FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId); if (!factionEntry) @@ -2260,7 +2267,7 @@ class spell_gen_proc_below_pct_damaged : public SpellScriptLoader if (!damageInfo || !damageInfo->GetDamage()) return false; - int32 pct = GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue(); + int32 pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(); if (eventInfo.GetActionTarget()->HealthBelowPctDamaged(pct, damageInfo->GetDamage())) return true; @@ -2513,11 +2520,16 @@ class spell_gen_remove_on_health_pct : public AuraScript { PrepareAuraScript(spell_gen_remove_on_health_pct); + bool Validate(SpellInfo const* spellInfo) override + { + return spellInfo->GetEffects().size() > EFFECT_1; + } + void PeriodicTick(AuraEffect const* /*aurEff*/) { // they apply damage so no need to check for ticks here - if (GetTarget()->HealthAbovePct(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue())) + if (GetTarget()->HealthAbovePct(GetEffectInfo(EFFECT_1).CalcValue())) { Remove(AURA_REMOVE_BY_ENEMY_SPELL); PreventDefaultAction(); @@ -2542,7 +2554,7 @@ class spell_gen_remove_on_full_health : public AuraScript void PeriodicTick(AuraEffect const* aurEff) { // if it has only periodic effect, allow 1 tick - bool onlyEffect = (GetSpellInfo()->GetEffects().size() == 1); + bool onlyEffect = GetSpellInfo()->GetEffects().size() == 1; if (onlyEffect && aurEff->GetTickNumber() <= 1) return; @@ -3379,8 +3391,9 @@ class spell_gen_eject_passenger : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0); - if (!effect || effect->CalcValue() < 1) + if (spellInfo->GetEffects().empty()) + return false; + if (spellInfo->GetEffect(EFFECT_0).CalcValue() < 1) return false; return true; } @@ -3572,9 +3585,9 @@ class spell_gen_mixology_bonus : public AuraScript { PrepareAuraScript(spell_gen_mixology_bonus); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_MIXOLOGY }); + return ValidateSpellInfo({ SPELL_MIXOLOGY }) && !spellInfo->GetEffects().empty(); } bool Load() override @@ -3590,7 +3603,7 @@ class spell_gen_mixology_bonus : public AuraScript void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) { - if (GetCaster()->HasAura(SPELL_MIXOLOGY) && GetCaster()->HasSpell(GetSpellInfo()->GetEffect(EFFECT_0)->TriggerSpell)) + if (GetCaster()->HasAura(SPELL_MIXOLOGY) && GetCaster()->HasSpell(GetEffectInfo(EFFECT_0).TriggerSpell)) { switch (GetId()) { @@ -3973,14 +3986,14 @@ class spell_gen_face_rage : public AuraScript { PrepareAuraScript(spell_gen_face_rage); - bool Validate(SpellInfo const* /*spell*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_FACE_RAGE }); + return ValidateSpellInfo({ SPELL_FACE_RAGE }) && spellInfo->GetEffects().size() > EFFECT_2; } void OnRemove(AuraEffect const* /*effect*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(EFFECT_2)->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(GetEffectInfo(EFFECT_2).TriggerSpell); } void Register() override @@ -4001,7 +4014,7 @@ class spell_gen_impatient_mind : public AuraScript void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell); } void Register() override diff --git a/src/server/scripts/Spells/spell_holiday.cpp b/src/server/scripts/Spells/spell_holiday.cpp index 3d947c59db5..c046ce12c14 100644 --- a/src/server/scripts/Spells/spell_holiday.cpp +++ b/src/server/scripts/Spells/spell_holiday.cpp @@ -28,6 +28,7 @@ #include "Player.h" #include "ScriptedCreature.h" #include "SpellAuraEffects.h" +#include "SpellMgr.h" #include "SpellScript.h" #include "Vehicle.h" #include "World.h" @@ -539,6 +540,13 @@ class spell_pilgrims_bounty_feast_on : public SpellScriptLoader { PrepareSpellScript(spell_pilgrims_bounty_feast_on_SpellScript); + bool Validate(SpellInfo const* spellInfo) override + { + return !spellInfo->GetEffects().empty() + && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }) + && !sSpellMgr->AssertSpellInfo(spellInfo->GetEffect(EFFECT_0).CalcValue(), DIFFICULTY_NONE)->GetEffects().empty(); + } + void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); @@ -576,8 +584,7 @@ class spell_pilgrims_bounty_feast_on : public SpellScriptLoader if (Aura* aura = caster->GetAura(GetEffectValue())) { if (aura->GetStackAmount() == 1) - if (SpellEffectInfo const* effect = aura->GetSpellInfo()->GetEffect(EFFECT_0)) - caster->RemoveAurasDueToSpell(effect->CalcValue()); + caster->RemoveAurasDueToSpell(aura->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue()); aura->ModStackAmount(-1); } } @@ -1328,7 +1335,7 @@ class spell_brewfest_relay_race_intro_force_player_to_throw : public SpellScript PreventHitDefaultEffect(effIndex); // All this spells trigger a spell that requires reagents; if the // triggered spell is cast as "triggered", reagents are not consumed - GetHitUnit()->CastSpell(nullptr, GetEffectInfo()->TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); + GetHitUnit()->CastSpell(nullptr, GetEffectInfo().TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); } void Register() override diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index c36f78d76dd..1e2c6b382b9 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -211,7 +211,8 @@ class spell_hun_masters_call : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - return spellInfo->GetEffect(EFFECT_0) && ValidateSpellInfo({ SPELL_HUNTER_MASTERS_CALL_TRIGGERED, uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() + && ValidateSpellInfo({ SPELL_HUNTER_MASTERS_CALL_TRIGGERED, uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } bool Load() override diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index b9f15cf20df..33f61663b07 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -1121,12 +1121,12 @@ class spell_item_crystal_spire_of_karabor : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return spellInfo->GetEffect(EFFECT_0) != nullptr; + return !spellInfo->GetEffects().empty(); } bool CheckProc(ProcEventInfo& eventInfo) { - int32 pct = GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue(); + int32 pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(); if (HealInfo* healInfo = eventInfo.GetHealInfo()) if (Unit* healTarget = healInfo->GetTarget()) if (healTarget->GetHealth() - healInfo->GetEffectiveHeal() <= healTarget->CountPctFromMaxHealth(pct)) @@ -3765,7 +3765,7 @@ class spell_item_artifical_stamina : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return spellInfo->GetEffect(EFFECT_1) != nullptr; + return spellInfo->GetEffects().size() > EFFECT_1; } bool Load() override @@ -3776,7 +3776,7 @@ class spell_item_artifical_stamina : public AuraScript void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { if (Item* artifact = GetOwner()->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID())) - amount = GetSpellInfo()->GetEffect(EFFECT_1)->BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100; + amount = GetEffectInfo(EFFECT_1).BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100; } void Register() override @@ -3791,7 +3791,7 @@ class spell_item_artifical_damage : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return spellInfo->GetEffect(EFFECT_1) != nullptr; + return spellInfo->GetEffects().size() > EFFECT_1; } bool Load() override @@ -3802,7 +3802,7 @@ class spell_item_artifical_damage : public AuraScript void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) { if (Item* artifact = GetOwner()->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID())) - amount = GetSpellInfo()->GetEffect(EFFECT_1)->BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100; + amount = GetSpellInfo()->GetEffect(EFFECT_1).BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100; } void Register() override @@ -3817,11 +3817,6 @@ enum AuraProcRemoveSpells SPELL_JOM_GABBAR = 29602, SPELL_BATTLE_TRANCE = 45040, SPELL_WORLD_QUELLER_FOCUS = 90900, - SPELL_AZURE_WATER_STRIDER = 118089, - SPELL_CRIMSON_WATER_STRIDER = 127271, - SPELL_ORANGE_WATER_STRIDER = 127272, - SPELL_JADE_WATER_STRIDER = 127274, - SPELL_GOLDEN_WATER_STRIDER = 127278, SPELL_BRUTAL_KINSHIP_1 = 144671, SPELL_BRUTAL_KINSHIP_2 = 145738 }; @@ -3838,7 +3833,7 @@ class spell_item_talisman_of_ascendance : public AuraScript void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell); } void Register() override @@ -3859,7 +3854,7 @@ class spell_item_jom_gabbar : public AuraScript void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell); } void Register() override @@ -3880,7 +3875,7 @@ class spell_item_battle_trance : public AuraScript void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell); } void Register() override @@ -3901,7 +3896,7 @@ class spell_item_world_queller_focus : public AuraScript void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell); } void Register() override @@ -3919,21 +3914,14 @@ class spell_item_water_strider : public AuraScript { PrepareAuraScript(spell_item_water_strider); - bool Validate(SpellInfo const* /*spell*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo( - { - SPELL_AZURE_WATER_STRIDER, - SPELL_CRIMSON_WATER_STRIDER, - SPELL_ORANGE_WATER_STRIDER, - SPELL_JADE_WATER_STRIDER, - SPELL_GOLDEN_WATER_STRIDER - }); + return spellInfo->GetEffects().size() > EFFECT_1; } void OnRemove(AuraEffect const* /*effect*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(EFFECT_1)->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(EFFECT_1).TriggerSpell); } void Register() override @@ -3955,7 +3943,7 @@ class spell_item_brutal_kinship : public AuraScript void OnRemove(AuraEffect const* effect, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo()->TriggerSpell); + GetTarget()->RemoveAurasDueToSpell(effect->GetSpellEffectInfo().TriggerSpell); } void Register() override diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index 60203a08c5b..b0dfaa38a73 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -172,7 +172,7 @@ class spell_mage_arcane_barrage : public SpellScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellInfo({ SPELL_MAGE_ARCANE_BARRAGE_R3, SPELL_MAGE_ARCANE_BARRAGE_ENERGIZE }) - && spellInfo->GetEffect(EFFECT_1); + && spellInfo->GetEffects().size() > EFFECT_1; } void ConsumeArcaneCharges() @@ -188,7 +188,7 @@ class spell_mage_arcane_barrage : public SpellScript void HandleEffectHitTarget(SpellEffIndex /*effIndex*/) { if (GetHitUnit()->GetGUID() != _primaryTarget) - SetHitDamage(CalculatePct(GetHitDamage(), GetEffectInfo(EFFECT_1)->CalcValue(GetCaster()))); + SetHitDamage(CalculatePct(GetHitDamage(), GetEffectInfo(EFFECT_1).CalcValue(GetCaster()))); } void MarkPrimaryTarget(SpellEffIndex /*effIndex*/) @@ -237,8 +237,10 @@ class spell_mage_arcane_explosion : public SpellScript if (!ValidateSpellInfo({ SPELL_MAGE_ARCANE_MAGE, SPELL_MAGE_REVERBERATE })) return false; - SpellEffectInfo const* damageEffect = spellInfo->GetEffect(EFFECT_1); - return damageEffect && damageEffect->IsEffect(SPELL_EFFECT_SCHOOL_DAMAGE); + if (spellInfo->GetEffects().size() <= EFFECT_1) + return false; + + return spellInfo->GetEffect(EFFECT_1).IsEffect(SPELL_EFFECT_SCHOOL_DAMAGE); } void CheckRequiredAuraForBaselineEnergize(SpellEffIndex effIndex) @@ -350,11 +352,11 @@ class spell_mage_cauterize_AuraScript : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return spellInfo->GetEffect(EFFECT_2) && ValidateSpellInfo + return spellInfo->GetEffects().size() > EFFECT_2 && ValidateSpellInfo ({ SPELL_MAGE_CAUTERIZE_DOT, SPELL_MAGE_CAUTERIZED, - spellInfo->GetEffect(EFFECT_2)->TriggerSpell + spellInfo->GetEffect(EFFECT_2).TriggerSpell }); } @@ -372,7 +374,7 @@ class spell_mage_cauterize_AuraScript : public AuraScript } GetTarget()->SetHealth(GetTarget()->CountPctFromMaxHealth(effect1->GetAmount())); - GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->GetEffect(EFFECT_2)->TriggerSpell, TRIGGERED_FULL_MASK); + GetTarget()->CastSpell(GetTarget(), GetEffectInfo(EFFECT_2).TriggerSpell, TRIGGERED_FULL_MASK); GetTarget()->CastSpell(GetTarget(), SPELL_MAGE_CAUTERIZE_DOT, TRIGGERED_FULL_MASK); GetTarget()->CastSpell(GetTarget(), SPELL_MAGE_CAUTERIZED, TRIGGERED_FULL_MASK); } @@ -583,9 +585,9 @@ class spell_mage_ice_lance : public SpellScript { // Thermal Void if (Aura const* thermalVoid = caster->GetAura(SPELL_MAGE_THERMAL_VOID)) - if (SpellEffectInfo const* thermalVoidEffect = thermalVoid->GetSpellInfo()->GetEffect(EFFECT_0)) + if (!thermalVoid->GetSpellInfo()->GetEffects().empty()) if (Aura* icyVeins = caster->GetAura(SPELL_MAGE_ICY_VEINS)) - icyVeins->SetDuration(icyVeins->GetDuration() + thermalVoidEffect->CalcValue(caster) * IN_MILLISECONDS); + icyVeins->SetDuration(icyVeins->GetDuration() + thermalVoid->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(caster) * IN_MILLISECONDS); // Chain Reaction if (caster->HasAura(SPELL_MAGE_CHAIN_REACTION_DUMMY)) @@ -620,7 +622,7 @@ class spell_mage_ice_lance_damage : public SpellScript { int32 originalDamage = GetHitDamage(); float targetIndex = float(spellValue->EffectBasePoints[EFFECT_1]); - float multiplier = std::pow(GetEffectInfo()->CalcDamageMultiplier(GetCaster(), GetSpell()), targetIndex); + float multiplier = std::pow(GetEffectInfo().CalcDamageMultiplier(GetCaster(), GetSpell()), targetIndex); SetHitDamage(int32(originalDamage * multiplier)); } } @@ -834,7 +836,8 @@ class spell_mage_ring_of_frost : public AuraScript bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE }); + return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE }) + && !sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffects().empty(); } void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) @@ -846,7 +849,7 @@ class spell_mage_ring_of_frost : public AuraScript void Apply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { std::list minions; - GetTarget()->GetAllMinionsByEntry(minions, sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0)->MiscValue); + GetTarget()->GetAllMinionsByEntry(minions, sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0).MiscValue); // Get the last summoned RoF, save it and despawn older ones for (TempSummon* summon : minions) @@ -890,13 +893,14 @@ class spell_mage_ring_of_frost_freeze : public SpellScript bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE }); + return ValidateSpellInfo({ SPELL_MAGE_RING_OF_FROST_SUMMON, SPELL_MAGE_RING_OF_FROST_FREEZE }) + && !sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffects().empty(); } void FilterTargets(std::list& targets) { WorldLocation const* dest = GetExplTargetDest(); - float outRadius = sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0)->CalcRadius(); + float outRadius = sSpellMgr->AssertSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON, GetCastDifficulty())->GetEffect(EFFECT_0).CalcRadius(); float inRadius = 6.5f; targets.remove_if([dest, outRadius, inRadius](WorldObject* target) diff --git a/src/server/scripts/Spells/spell_monk.cpp b/src/server/scripts/Spells/spell_monk.cpp index 721ca1f829e..07072cbff43 100644 --- a/src/server/scripts/Spells/spell_monk.cpp +++ b/src/server/scripts/Spells/spell_monk.cpp @@ -326,14 +326,15 @@ class spell_monk_stagger_debuff_aura : public AuraScript { PrepareAuraScript(spell_monk_stagger_debuff_aura); - bool Load() override + bool Validate(SpellInfo const* /*spellInfo*/) override { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_MONK_STAGGER_DAMAGE_AURA, GetCastDifficulty()); - SpellEffectInfo const* effInfo = !spellInfo ? nullptr : spellInfo->GetEffect(EFFECT_0); - if (!effInfo) - return false; + return ValidateSpellInfo({ SPELL_MONK_STAGGER_DAMAGE_AURA }) + && !sSpellMgr->GetSpellInfo(SPELL_MONK_STAGGER_DAMAGE_AURA, DIFFICULTY_NONE)->GetEffects().empty(); + } - _period = float(effInfo->ApplyAuraPeriod); + bool Load() override + { + _period = float(sSpellMgr->AssertSpellInfo(SPELL_MONK_STAGGER_DAMAGE_AURA, GetCastDifficulty())->GetEffect(EFFECT_0).ApplyAuraPeriod); return true; } diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index e8743fa35fc..fa9acf4087f 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -898,7 +898,7 @@ public: if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, GetCastDifficulty()); // Then get the SpellProto and add the dummy effect value - AddPct(mod, spellInfo->GetEffect(EFFECT_0)->CalcValue()); + AddPct(mod, spellInfo->GetEffect(EFFECT_0).CalcValue()); } int32 const ownerBonus = owner->GetStat(STAT_STAMINA) * mod; @@ -940,7 +940,7 @@ public: if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, GetCastDifficulty()); // Then get the SpellProto and add the dummy effect value - mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1)->CalcValue()); + mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1).CalcValue()); } bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f * mod; @@ -970,7 +970,7 @@ public: if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, GetCastDifficulty()); // Then get the SpellProto and add the dummy effect value - mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1)->CalcValue()); + mod += CalculatePct(1.0f, spellInfo->GetEffect(EFFECT_1).CalcValue()); } bonusDamage = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.1287f * mod; @@ -1410,7 +1410,7 @@ public: amount = -90; // Night of the dead else if (Aura* aur = owner->GetAuraOfRankedSpell(SPELL_NIGHT_OF_THE_DEAD)) - amount = aur->GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue(); + amount = aur->GetSpellInfo()->GetEffect(EFFECT_2).CalcValue(); } } } diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 9efb49d5935..42546ba3cfe 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -174,9 +174,9 @@ public: { PrepareAuraScript(spell_pri_atonement_AuraScript); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT_HEAL }); + return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT_HEAL }) && spellInfo->GetEffects().size() > EFFECT_1; } bool CheckProc(ProcEventInfo& eventInfo) @@ -193,7 +193,7 @@ public: { if (Unit* target = ObjectAccessor::GetUnit(*GetTarget(), targetGuid)) { - if (target->GetExactDist(GetTarget()) < GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()) + if (target->GetExactDist(GetTarget()) < GetEffectInfo(EFFECT_1).CalcValue()) GetTarget()->CastSpell(target, SPELL_PRIEST_ATONEMENT_HEAL, args); return false; @@ -325,14 +325,14 @@ class spell_pri_guardian_spirit : public SpellScriptLoader uint32 healPct = 0; - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL }); + return ValidateSpellInfo({ SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL }) && spellInfo->GetEffects().size() > EFFECT_1; } bool Load() override { - healPct = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue(); + healPct = GetEffectInfo(EFFECT_1).CalcValue(); return true; } @@ -387,11 +387,10 @@ class spell_pri_holy_words : public AuraScript SPELL_PRIEST_HOLY_WORD_CHASTISE, SPELL_PRIEST_HOLY_WORD_SANCTIFY, SPELL_PRIEST_HOLY_WORD_SERENITY - }) - && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SERENITY, DIFFICULTY_NONE)->GetEffect(EFFECT_1) - && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SANCTIFY, DIFFICULTY_NONE)->GetEffect(EFFECT_2) - && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SANCTIFY, DIFFICULTY_NONE)->GetEffect(EFFECT_3) - && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_CHASTISE, DIFFICULTY_NONE)->GetEffect(EFFECT_1); + }) + && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SERENITY, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_1 + && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SANCTIFY, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_3 + && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_CHASTISE, DIFFICULTY_NONE)->GetEffects().size() > EFFECT_1; } void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& eventInfo) @@ -428,7 +427,7 @@ class spell_pri_holy_words : public AuraScript } SpellInfo const* targetSpellInfo = sSpellMgr->AssertSpellInfo(targetSpellId, GetCastDifficulty()); - int32 cdReduction = targetSpellInfo->GetEffect(cdReductionEffIndex)->CalcValue(GetTarget()); + int32 cdReduction = targetSpellInfo->GetEffect(cdReductionEffIndex).CalcValue(GetTarget()); GetTarget()->GetSpellHistory()->ModifyCooldown(targetSpellInfo, Seconds(-cdReduction)); } @@ -632,18 +631,15 @@ class spell_pri_power_word_radiance : public SpellScript { PrepareSpellScript(spell_pri_power_word_radiance); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT, SPELL_PRIEST_ATONEMENT_TRIGGERED, SPELL_PRIEST_TRINITY }); + return ValidateSpellInfo({ SPELL_PRIEST_ATONEMENT, SPELL_PRIEST_ATONEMENT_TRIGGERED, SPELL_PRIEST_TRINITY }) + && spellInfo->GetEffects().size() > EFFECT_3; } void OnTargetSelect(std::list& targets) { - SpellEffectInfo const* eff2 = GetEffectInfo(EFFECT_2); - if (!eff2) - return; - - uint32 maxTargets = eff2->CalcValue(GetCaster()) + 1; // adding 1 for explicit target unit + uint32 maxTargets = GetEffectInfo(EFFECT_2).CalcValue(GetCaster()) + 1; // adding 1 for explicit target unit if (targets.size() > maxTargets) { Unit* explTarget = GetExplTargetUnit(); @@ -669,11 +665,7 @@ class spell_pri_power_word_radiance : public SpellScript if (caster->HasAura(SPELL_PRIEST_TRINITY)) return; - SpellEffectInfo const* effect3 = GetEffectInfo(EFFECT_3); - if (!effect3) - return; - - uint32 durationPct = effect3->CalcValue(caster); + uint32 durationPct = GetEffectInfo(EFFECT_3).CalcValue(caster); if (caster->HasAura(SPELL_PRIEST_ATONEMENT)) caster->CastSpell(GetHitUnit(), SPELL_PRIEST_ATONEMENT_TRIGGERED, CastSpellExtraArgs(SPELLVALUE_DURATION_PCT, durationPct).SetTriggerFlags(TRIGGERED_FULL_MASK)); } @@ -799,19 +791,19 @@ public: bool Validate(SpellInfo const* /*spellInfo*/) override { return ValidateSpellInfo({ SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, SPELL_PRIEST_PRAYER_OF_MENDING_AURA }) - && sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, DIFFICULTY_NONE)->GetEffect(EFFECT_0); + && !sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, DIFFICULTY_NONE)->GetEffects().empty(); } bool Load() override { _spellInfoHeal = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PRAYER_OF_MENDING_HEAL, DIFFICULTY_NONE); - _healEffectDummy = _spellInfoHeal->GetEffect(EFFECT_0); + _healEffectDummy = &_spellInfoHeal->GetEffect(EFFECT_0); return true; } void CastPrayerOfMendingAura(Unit* caster, Unit* target, uint8 stack) { - uint32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy->CalcValue(caster), HEAL, _healEffectDummy); + uint32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy->CalcValue(caster), HEAL, *_healEffectDummy); CastSpellExtraArgs args; args.TriggerFlags = TRIGGERED_FULL_MASK; args.AddSpellMod(SPELLVALUE_AURA_STACK, stack); @@ -1264,7 +1256,7 @@ class spell_pri_angelic_feather_trigger : public SpellScriptLoader void HandleEffectDummy(SpellEffIndex /*effIndex*/) { Position destPos = GetHitDest()->GetPosition(); - float radius = GetEffectInfo()->CalcRadius(); + float radius = GetEffectInfo().CalcRadius(); // Caster is prioritary if (GetCaster()->IsWithinDist2d(&destPos, radius)) diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 23bc128890a..17beea16514 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -634,14 +634,19 @@ class spell_q12683_take_sputum_sample : public SpellScriptLoader { PrepareSpellScript(spell_q12683_take_sputum_sample_SpellScript); + bool Validate(SpellInfo const* spellInfo) override + { + return spellInfo->GetEffects().size() > EFFECT_1; + } + void HandleDummy(SpellEffIndex /*effIndex*/) { - uint32 reqAuraId = GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue(); + uint32 reqAuraId = GetEffectInfo(EFFECT_1).CalcValue(); Unit* caster = GetCaster(); if (caster->HasAuraEffect(reqAuraId, 0)) { - uint32 spellId = GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue(); + uint32 spellId = GetEffectInfo().CalcValue(); caster->CastSpell(caster, spellId, true); } } @@ -1916,7 +1921,8 @@ class spell_q13086_cannons_target : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() + && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } void HandleEffectDummy(SpellEffIndex /*effIndex*/) @@ -2160,7 +2166,7 @@ class spell_q12308_escape_from_silverbrook_summon_worgen : public SpellScriptLoa void ModDest(SpellDestination& dest) { - float dist = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster()); + float dist = GetEffectInfo(EFFECT_0).CalcRadius(GetCaster()); float angle = frand(0.75f, 1.25f) * float(M_PI); Position pos = GetCaster()->GetNearPosition(dist, angle); @@ -2301,7 +2307,7 @@ class spell_q12619_emblazon_runeblade : public SpellScriptLoader { PreventDefaultAction(); if (Unit* caster = GetCaster()) - caster->CastSpell(caster, aurEff->GetSpellEffectInfo()->TriggerSpell, aurEff); + caster->CastSpell(caster, aurEff->GetSpellEffectInfo().TriggerSpell, aurEff); } void Register() override diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 737012cf41f..a5728438912 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -270,27 +270,25 @@ class spell_warl_devour_magic : public SpellScriptLoader { PrepareSpellScript(spell_warl_devour_magic_SpellScript); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL }); + return ValidateSpellInfo({ SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL }) + && spellInfo->GetEffects().size() > EFFECT_1; } void OnSuccessfulDispel(SpellEffIndex /*effIndex*/) { - if (SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(EFFECT_1)) - { - Unit* caster = GetCaster(); - CastSpellExtraArgs args; - args.TriggerFlags = TRIGGERED_FULL_MASK; - args.AddSpellBP0(effect->CalcValue(caster)); + Unit* caster = GetCaster(); + CastSpellExtraArgs args; + args.TriggerFlags = TRIGGERED_FULL_MASK; + args.AddSpellBP0(GetEffectInfo(EFFECT_1).CalcValue(caster)); - caster->CastSpell(caster, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); + caster->CastSpell(caster, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); - // Glyph of Felhunter - if (Unit* owner = caster->GetOwner()) - if (owner->GetAura(SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING)) - owner->CastSpell(owner, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); - } + // Glyph of Felhunter + if (Unit* owner = caster->GetOwner()) + if (owner->GetAura(SPELL_WARLOCK_GLYPH_OF_DEMON_TRAINING)) + owner->CastSpell(owner, SPELL_WARLOCK_DEVOUR_MAGIC_HEAL, args); } void Register() override @@ -517,7 +515,7 @@ class spell_warl_seed_of_corruption_dummy : public SpellScriptLoader if (!caster) return; - amount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * ASSERT_NOTNULL(GetSpellInfo()->GetEffect(EFFECT_0))->CalcValue(caster) / 100; + amount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * GetEffectInfo(EFFECT_0).CalcValue(caster) / 100; } void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) @@ -711,7 +709,7 @@ class spell_warl_soul_swap_dot_marker : public SpellScriptLoader if (!swapSpellScript) return; - flag128 classMask = GetEffectInfo()->SpellClassMask; + flag128 classMask = GetEffectInfo().SpellClassMask; for (Unit::AuraApplicationMap::const_iterator itr = appliedAuras.begin(); itr != appliedAuras.end(); ++itr) { diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index 6cba63461fb..af1604ff994 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -437,9 +437,10 @@ class spell_warr_item_t10_prot_4p_bonus : public SpellScriptLoader { PrepareAuraScript(spell_warr_item_t10_prot_4p_bonus_AuraScript); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_WARRIOR_STOICISM }); + return ValidateSpellInfo({ SPELL_WARRIOR_STOICISM }) + && spellInfo->GetEffects().size() > EFFECT_1; } void HandleProc(ProcEventInfo& eventInfo) @@ -447,7 +448,7 @@ class spell_warr_item_t10_prot_4p_bonus : public SpellScriptLoader PreventDefaultAction(); Unit* target = eventInfo.GetActionTarget(); - int32 bp0 = CalculatePct(target->GetMaxHealth(), GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()); + int32 bp0 = CalculatePct(target->GetMaxHealth(), GetEffectInfo(EFFECT_1).CalcValue()); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.AddSpellBP0(bp0); target->CastSpell(nullptr, SPELL_WARRIOR_STOICISM, args); @@ -553,7 +554,7 @@ public: if (!ValidateSpellInfo({ SPELL_WARRIOR_SHOCKWAVE, SPELL_WARRIOR_SHOCKWAVE_STUN })) return false; - return spellInfo->GetEffect(EFFECT_0) && spellInfo->GetEffect(EFFECT_3); + return spellInfo->GetEffects().size() > EFFECT_3; } bool Load() override @@ -570,8 +571,8 @@ public: // Cooldown reduced by 20 sec if it strikes at least 3 targets. void HandleAfterCast() { - if (_targetCount >= uint32(GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue())) - GetCaster()->ToPlayer()->GetSpellHistory()->ModifyCooldown(GetSpellInfo()->Id, Seconds(-GetSpellInfo()->GetEffect(EFFECT_3)->CalcValue())); + if (_targetCount >= uint32(GetEffectInfo(EFFECT_0).CalcValue())) + GetCaster()->ToPlayer()->GetSpellHistory()->ModifyCooldown(GetSpellInfo()->Id, Seconds(-GetEffectInfo(EFFECT_3).CalcValue())); } void Register() override -- cgit v1.2.3