diff options
Diffstat (limited to 'src/server/scripts')
58 files changed, 338 insertions, 324 deletions
diff --git a/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp b/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp index cd0049eb169..e0603d9880c 100644 --- a/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp +++ b/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp @@ -604,13 +604,13 @@ class spell_garothi_fel_bombardment_periodic : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->BasePoints) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } - void HandlePeriodic(AuraEffect const* /*aurEff*/) + void HandlePeriodic(AuraEffect const* aurEff) { if (Unit* caster = GetCaster()) - caster->CastSpell(GetTarget(), uint32(GetSpellInfo()->GetEffect(EFFECT_0)->BasePoints), true); + caster->CastSpell(GetTarget(), uint32(aurEff->GetSpellEffectInfo().CalcValue(caster)), true); } void Register() override @@ -757,13 +757,13 @@ class spell_garothi_annihilation_selector : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->BasePoints) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } - void HandleHit(SpellEffIndex effIndex) + void HandleHit(SpellEffIndex /*effIndex*/) { if (Unit* caster = GetCaster()) - caster->CastSpell(GetHitUnit(), uint32(GetSpellInfo()->GetEffect(effIndex)->BasePoints), true); + caster->CastSpell(GetHitUnit(), uint32(GetEffectInfo().CalcValue(caster)), true); } void Register() override diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 8ea4aa3dc27..2481abbdffc 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -886,10 +886,10 @@ public: bool known = target && target->HasSpell(spellInfo->Id); - SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0); - bool learn = effect ? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false; + SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(EFFECT_0); + bool learn = spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL); - SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell, spellInfo->Difficulty) : nullptr; + SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, spellInfo->Difficulty); bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT); bool passive = spellInfo->IsPassive(); @@ -959,10 +959,10 @@ public: bool known = target && target->HasSpell(id); - SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_0); - bool learn = effect? (effect->Effect == SPELL_EFFECT_LEARN_SPELL) : false; + SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(EFFECT_0); + bool learn = spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL); - SpellInfo const* learnSpellInfo = effect ? sSpellMgr->GetSpellInfo(effect->TriggerSpell, DIFFICULTY_NONE) : nullptr; + SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellEffectInfo.TriggerSpell, DIFFICULTY_NONE); bool talent = spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT); bool passive = spellInfo->IsPassive(); diff --git a/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp b/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp index f2c8ef442ea..aaa627f79ec 100644 --- a/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp +++ b/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp @@ -270,7 +270,7 @@ class spell_occuthar_eyes_of_occuthar : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } bool Load() override diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index cbdc82d355e..b797436b3bd 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -500,21 +500,21 @@ public: void SpellHit(Unit* /*caster*/, SpellInfo const* spellInfo) override { - // We only care about interrupt effects and only if they are durring a spell currently being cast - if (spellInfo->HasEffect(SPELL_EFFECT_INTERRUPT_CAST) && me->IsNonMeleeSpellCast(false)) - { - // Interrupt effect - me->InterruptNonMeleeSpells(false); + //We only care about interrupt effects and only if they are durring a spell currently being cast + if (!spellInfo->HasEffect(SPELL_EFFECT_INTERRUPT_CAST) || !me->IsNonMeleeSpellCast(false)) + return; - // Normally we would set the cooldown equal to the spell duration - // but we do not have access to the DurationStore + //Interrupt effect + me->InterruptNonMeleeSpells(false); - switch (CurrentNormalSpell) - { - case SPELL_ARCMISSLE: ArcaneCooldown = 5000; break; - case SPELL_FIREBALL: FireCooldown = 5000; break; - case SPELL_FROSTBOLT: FrostCooldown = 5000; break; - } + //Normally we would set the cooldown equal to the spell duration + //but we do not have access to the DurationStore + + switch (CurrentNormalSpell) + { + case SPELL_ARCMISSLE: ArcaneCooldown = 5000; break; + case SPELL_FIREBALL: FireCooldown = 5000; break; + case SPELL_FROSTBOLT: FrostCooldown = 5000; break; } } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp index 3ef5498e7a7..fef3f9ea821 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp @@ -299,7 +299,7 @@ class spell_shadow_portal_rooms : public SpellScriptLoader return InstanceHasScript(GetCaster(), ScholomanceScriptName); } - void HandleSendEvent(SpellEffIndex effIndex) + void HandleSendEvent(SpellEffIndex /*effIndex*/) { // If only one player in threat list fail spell @@ -309,7 +309,7 @@ class spell_shadow_portal_rooms : public SpellScriptLoader int8 phase_to_set = 0; int32 gate_to_close = 0; - switch (GetSpellInfo()->GetEffect(effIndex)->MiscValue) + switch (GetEffectInfo().MiscValue) { case SPELL_EVENT_HALLOFSECRETS: pos_to_summon = 0; // Not yet spawned diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index ef29d76972b..71cd87f9b8a 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -603,12 +603,12 @@ class spell_kalecgos_tap_check : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - return spellInfo->GetEffect(EFFECT_0) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } void HandleDummy(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetCaster(), (uint32)GetEffectInfo(EFFECT_0)->CalcValue(), true); + GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().CalcValue(), true); } void Register() override diff --git a/src/server/scripts/EasternKingdoms/zone_dun_morogh_area_coldridge_valley.cpp b/src/server/scripts/EasternKingdoms/zone_dun_morogh_area_coldridge_valley.cpp index ed287bbe846..9b0d1220ebe 100644 --- a/src/server/scripts/EasternKingdoms/zone_dun_morogh_area_coldridge_valley.cpp +++ b/src/server/scripts/EasternKingdoms/zone_dun_morogh_area_coldridge_valley.cpp @@ -380,7 +380,7 @@ public: void HandleForceCast(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetHitUnit(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true); + GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell, true); } void Register() override @@ -412,7 +412,7 @@ public: void HandleForceCast(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetHitUnit(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true); + GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell, true); } void Register() override diff --git a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp index 7699375c69a..2307954145d 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp @@ -417,16 +417,16 @@ class spell_baleroc_decimating_strike : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - if (!spellInfo->GetEffect(EFFECT_0)) + if (spellInfo->GetEffects().size() <= EFFECT_2) return false; - SpellEffectInfo const* spellEffectInfo = spellInfo->GetEffect(EFFECT_2); - return spellEffectInfo && ValidateSpellInfo({ uint32(spellEffectInfo->BasePoints) }); + SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(EFFECT_2); + return ValidateSpellInfo({ uint32(spellEffectInfo.CalcValue()) }); } void ChangeDamage() { - int32 healthPctDmg = GetHitUnit()->CountPctFromMaxHealth(GetSpellInfo()->GetEffect(EFFECT_0)->BasePoints); - int32 flatDmg = GetSpellInfo()->GetEffect(EFFECT_2)->BasePoints; + int32 healthPctDmg = GetHitUnit()->CountPctFromMaxHealth(GetEffectInfo(EFFECT_0).CalcValue(GetCaster())); + int32 flatDmg = GetEffectInfo(EFFECT_2).CalcValue(GetCaster()); SetHitDamage(healthPctDmg < flatDmg ? flatDmg : healthPctDmg); } @@ -800,7 +800,8 @@ class spell_baleroc_vital_flame : public AuraScript bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_VITAL_SPARK }); + return ValidateSpellInfo({ SPELL_VITAL_SPARK }) + && !sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, DIFFICULTY_NONE)->GetEffects().empty(); } void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -812,7 +813,7 @@ class spell_baleroc_vital_flame : public AuraScript } stacks = GetCaster()->GetAuraCount(SPELL_VITAL_SPARK); - int32 healingPct = sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, GetCastDifficulty())->GetEffect(EFFECT_0)->BasePoints * stacks; + int32 healingPct = sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, GetCastDifficulty())->GetEffect(EFFECT_0).CalcValue(GetCaster()) * stacks; if (GetAura()->GetEffect(EFFECT_0)->GetAmount() < healingPct) GetAura()->GetEffect(EFFECT_0)->SetAmount(healingPct); diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp index 907ccb7abb2..d92b75fa020 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_anraphet.cpp @@ -540,7 +540,7 @@ public: /// TODO: Remove this once we find a general rule for WorldObject::MovePosition (this spell shouldn't take the Z change into consideration) Unit* caster = GetCaster(); float angle = float(rand_norm()) * static_cast<float>(2 * M_PI); - uint32 dist = caster->GetCombatReach() + GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(caster) * (float)rand_norm(); + uint32 dist = caster->GetCombatReach() + GetSpellInfo()->GetEffect(EFFECT_0).CalcRadius(caster) * (float)rand_norm(); float x = caster->GetPositionX() + dist * std::cos(angle); float y = caster->GetPositionY() + dist * std::sin(angle); diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp index e125af5d46b..7adb716efb4 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp @@ -387,7 +387,7 @@ public: { CastSpellExtraArgs args; args.AddSpellMod(SPELLVALUE_BASE_POINT0, aurEff->GetAmount()); - caster->CastSpell(GetTarget(), aurEff->GetSpellEffectInfo()->TriggerSpell, args); + caster->CastSpell(GetTarget(), aurEff->GetSpellEffectInfo().TriggerSpell, args); } } diff --git a/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp b/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp index c5cf1f86109..392706bcc5f 100644 --- a/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp +++ b/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp @@ -242,14 +242,14 @@ class spell_ooze_zap : public SpellScriptLoader { PrepareSpellScript(spell_ooze_zap_SpellScript); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_OOZE_ZAP }); + return spellInfo->GetEffects().size() > EFFECT_1 && ValidateSpellInfo({ SPELL_OOZE_ZAP }); } SpellCastResult CheckRequirement() { - if (!GetCaster()->HasAura(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue())) + if (!GetCaster()->HasAura(GetEffectInfo(EFFECT_1).CalcValue())) return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; // This is actually correct if (!GetExplTargetUnit()) @@ -330,7 +330,7 @@ class spell_energize_aoe : public SpellScriptLoader { for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end();) { - if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()) == QUEST_STATUS_INCOMPLETE) + if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetEffectInfo(EFFECT_1).CalcValue()) == QUEST_STATUS_INCOMPLETE) ++itr; else targets.erase(itr++); diff --git a/src/server/scripts/Kalimdor/zone_silithus.cpp b/src/server/scripts/Kalimdor/zone_silithus.cpp index 5f7c1745a22..16398d42ee3 100644 --- a/src/server/scripts/Kalimdor/zone_silithus.cpp +++ b/src/server/scripts/Kalimdor/zone_silithus.cpp @@ -1409,7 +1409,7 @@ class spell_silithus_summon_cultist_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) @@ -1419,7 +1419,7 @@ class spell_silithus_summon_cultist_periodic : public AuraScript // All these spells trigger a spell that requires reagents; if the // triggered spell is cast as "triggered", reagents are not consumed if (Unit* caster = GetCaster()) - caster->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, CastSpellExtraArgs(TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)).SetTriggeringAura(aurEff)); + caster->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, CastSpellExtraArgs(TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)).SetTriggeringAura(aurEff)); } void Register() override diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp index 5e896f3b462..3b6c5828ac5 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp @@ -148,7 +148,7 @@ public: // clone player->CastSpell(summon, SPELL_CLONE_PLAYER, true); // phase the summon - PhasingHandler::AddPhase(summon, spellInfo->GetEffect(EFFECT_0)->MiscValueB, true); + PhasingHandler::AddPhase(summon, spellInfo->GetEffect(EFFECT_0).MiscValueB, true); } } ++insanityHandled; diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 1356b00a181..c12fbab7b88 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -1500,7 +1500,7 @@ class spell_halion_combustion_consumption_periodic : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell }); } void HandleTick(AuraEffect const* aurEff) @@ -1510,7 +1510,7 @@ class spell_halion_combustion_consumption_periodic : public SpellScriptLoader if (!caster) return; - uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell; + uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; int32 radius = caster->GetObjectScale() * M_PI * 10000 / 3; CastSpellExtraArgs args(aurEff); @@ -1606,8 +1606,8 @@ class spell_halion_damage_aoe_summon : public SpellScriptLoader { PreventHitDefaultEffect(effIndex); Unit* caster = GetCaster(); - uint32 entry = uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValue); - SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValueB)); + uint32 entry = uint32(GetEffectInfo().MiscValue); + SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetEffectInfo().MiscValueB)); uint32 duration = uint32(GetSpellInfo()->GetDuration()); Position pos = caster->GetPosition(); @@ -1707,10 +1707,10 @@ class spell_halion_clear_debuffs : public SpellScriptLoader return ValidateSpellInfo({ SPELL_CLEAR_DEBUFFS, SPELL_TWILIGHT_REALM }); } - void HandleScript(SpellEffIndex effIndex) + void HandleScript(SpellEffIndex /*effIndex*/) { - if (GetHitUnit()->HasAura(GetSpellInfo()->GetEffect(effIndex)->CalcValue())) - GetHitUnit()->RemoveAurasDueToSpell(GetSpellInfo()->GetEffect(effIndex)->CalcValue()); + if (GetHitUnit()->HasAura(GetEffectInfo().CalcValue())) + GetHitUnit()->RemoveAurasDueToSpell(GetEffectInfo().CalcValue()); } void Register() override @@ -1891,7 +1891,7 @@ class spell_halion_blazing_aura : public SpellScriptLoader void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetHitUnit(), GetSpellInfo()->GetEffect(EFFECT_1)->TriggerSpell); + GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell); } void Register() override diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index 747546b9d12..8b341661df4 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -499,8 +499,7 @@ class spell_mistress_kiss_area : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0); - return effect0 && ValidateSpellInfo({ static_cast<uint32>(effect0->CalcValue()) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } void FilterTargets(std::list<WorldObject*>& targets) @@ -538,8 +537,7 @@ class spell_fel_streak_visual : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0); - return effect0 && ValidateSpellInfo({ static_cast<uint32>(effect0->CalcValue()) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } void HandleScript(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp index 5a067e8aad3..b2658110776 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp @@ -1189,7 +1189,7 @@ class spell_jormungars_slime_pool : 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) @@ -1199,7 +1199,7 @@ class spell_jormungars_slime_pool : public AuraScript int32 const radius = static_cast<int32>(((aurEff->GetTickNumber() / 60.f) * 0.9f + 0.1f) * 10000.f * 2.f / 3.f); CastSpellExtraArgs args(aurEff); args.AddSpellMod(SPELLVALUE_RADIUS_MOD, radius); - GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, args); + GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, args); } void Register() override @@ -1277,12 +1277,12 @@ class spell_icehowl_arctic_breath : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } - void HandleScriptEffect(SpellEffIndex effIndex) + void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - uint32 spellId = GetSpellInfo()->GetEffect(effIndex)->CalcValue(); + uint32 spellId = GetEffectInfo().CalcValue(); GetCaster()->CastSpell(GetHitUnit(), spellId, true); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index e70810e6182..06c786ff2ab 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -811,7 +811,7 @@ class spell_valkyr_essences : public SpellScriptLoader GetTarget()->CastSpell(GetTarget(), SPELL_SURGE_OF_SPEED, true); // Twin Vortex part - int32 stacksCount = dmgInfo.GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue() / 1000 - 1; + int32 stacksCount = dmgInfo.GetSpellInfo()->GetEffect(EFFECT_0).CalcValue() / 1000 - 1; if (stacksCount) { diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp index d05bff6386b..cbb468ad3dd 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp @@ -311,7 +311,7 @@ class spell_trollgore_invader_taunt : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - return spellInfo->GetEffect(EFFECT_0) && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } void HandleTaunt(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp index 84688b9a380..7cc0f87bd51 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp @@ -2791,7 +2791,7 @@ class spell_hor_evasion : public SpellScriptLoader return; float angle = pos.GetAngle(&home); - float dist = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster()); + float dist = GetEffectInfo().CalcRadius(GetCaster()); target->MovePosition(pos, dist, angle); dest.Relocate(pos); @@ -2849,7 +2849,7 @@ class spell_hor_quel_delars_will : public SpellScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0)->TriggerSpell }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell }); } void HandleReagent(SpellEffIndex effIndex) @@ -2857,7 +2857,7 @@ class spell_hor_quel_delars_will : public SpellScript PreventHitDefaultEffect(effIndex); // dummy spell consumes reagent, don't ignore it - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); + GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index a8bf0718f8b..515501dafcf 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -813,7 +813,7 @@ class spell_blood_queen_pact_of_the_darkfallen_dmg : public SpellScriptLoader void PeriodicTick(AuraEffect const* aurEff) { SpellInfo const* damageSpell = sSpellMgr->AssertSpellInfo(SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE, GetCastDifficulty()); - int32 damage = damageSpell->GetEffect(EFFECT_0)->CalcValue(); + int32 damage = damageSpell->GetEffect(EFFECT_0).CalcValue(); float multiplier = 0.3375f + 0.1f * uint32(aurEff->GetTickNumber() / 10); // do not convert to 0.01f - we need tick number/10 as INT (damage increases every 10 ticks) damage = int32(damage * multiplier); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index c29683fa748..092cd40bf29 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -1829,7 +1829,8 @@ class spell_igb_rocket_pack : public SpellScriptLoader bool Validate(SpellInfo const* /*spellInfo*/) override { - return ValidateSpellInfo({ SPELL_ROCKET_PACK_DAMAGE, SPELL_ROCKET_BURST }); + return ValidateSpellInfo({ SPELL_ROCKET_PACK_DAMAGE, SPELL_ROCKET_BURST }) + && !sSpellMgr->AssertSpellInfo(SPELL_ROCKET_PACK_DAMAGE, DIFFICULTY_NONE)->GetEffects().empty(); } void HandlePeriodic(AuraEffect const* /*aurEff*/) @@ -1843,7 +1844,7 @@ class spell_igb_rocket_pack : public SpellScriptLoader SpellInfo const* damageInfo = sSpellMgr->AssertSpellInfo(SPELL_ROCKET_PACK_DAMAGE, GetCastDifficulty()); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.CastDifficulty = GetCastDifficulty(); - args.AddSpellBP0(2 * (damageInfo->GetEffect(EFFECT_0)->CalcValue() + aurEff->GetTickNumber() * aurEff->GetPeriod())); + args.AddSpellBP0(2 * (damageInfo->GetEffect(EFFECT_0).CalcValue() + aurEff->GetTickNumber() * aurEff->GetPeriod())); GetTarget()->CastSpell(nullptr, SPELL_ROCKET_PACK_DAMAGE, args); GetTarget()->CastSpell(nullptr, SPELL_ROCKET_BURST, TRIGGERED_FULL_MASK); } @@ -1971,10 +1972,10 @@ class spell_igb_periodic_trigger_with_power_cost : public SpellScriptLoader { PrepareAuraScript(spell_igb_periodic_trigger_with_power_cost_AuraScript); - void HandlePeriodicTick(AuraEffect const* /*aurEff*/) + void HandlePeriodicTick(AuraEffect const* aurEff) { PreventDefaultAction(); - GetTarget()->CastSpell(GetTarget(), GetSpellInfo()->GetEffect(EFFECT_0)->TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); + GetTarget()->CastSpell(GetTarget(), aurEff->GetSpellEffectInfo().TriggerSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 8be4018532d..ddec000524b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -582,9 +582,8 @@ class spell_marrowgar_coldflame_damage : public SpellScriptLoader if (target->HasAura(SPELL_IMPALED)) return false; - if (SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(EFFECT_0)) - if (target->GetExactDist2d(GetOwner()) > effect->CalcRadius()) - return false; + if (target->GetExactDist2d(GetOwner()) > GetEffectInfo(EFFECT_0).CalcRadius()) + return false; if (Aura* aur = target->GetAura(GetId())) if (aur->GetOwner() != GetOwner()) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 233c1f35644..d09530233f7 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -1057,7 +1057,7 @@ class spell_putricide_unstable_experiment : public SpellScriptLoader break; } - GetCaster()->CastSpell(target, uint32(GetSpellInfo()->GetEffect(stage)->CalcValue()), true); + GetCaster()->CastSpell(target, uint32(GetEffectInfo(SpellEffIndex(stage)).CalcValue()), true); } void Register() override @@ -1114,9 +1114,8 @@ class spell_putricide_ooze_tank_protection : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0); - SpellEffectInfo const* effect1 = spellInfo->GetEffect(EFFECT_1); - return effect0 && effect1 && ValidateSpellInfo({ effect0->TriggerSpell, effect1->TriggerSpell }); + return spellInfo->GetEffects().size() > EFFECT_1 + && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell, spellInfo->GetEffect(EFFECT_1).TriggerSpell }); } void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) @@ -1124,7 +1123,7 @@ class spell_putricide_ooze_tank_protection : public SpellScriptLoader PreventDefaultAction(); Unit* actionTarget = eventInfo.GetActionTarget(); - actionTarget->CastSpell(nullptr, aurEff->GetSpellEffectInfo()->TriggerSpell, aurEff); + actionTarget->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, aurEff); } void Register() override @@ -1152,12 +1151,12 @@ class spell_putricide_choking_gas_bomb : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { uint32 skipIndex = urand(0, 2); - for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects()) + for (SpellEffectInfo const& spellEffectInfo : GetSpellInfo()->GetEffects()) { - if (!effect || effect->EffectIndex == skipIndex) + if (spellEffectInfo.EffectIndex == skipIndex) continue; - uint32 spellId = uint32(effect->CalcValue()); + uint32 spellId = uint32(spellEffectInfo.CalcValue()); GetCaster()->CastSpell(GetCaster(), spellId, GetCaster()->GetGUID()); } } @@ -1314,10 +1313,10 @@ class spell_putricide_mutated_plague : public SpellScriptLoader if (!caster) return; - uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell; + uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; SpellInfo const* spell = sSpellMgr->AssertSpellInfo(triggerSpell, GetCastDifficulty()); - int32 damage = spell->GetEffect(EFFECT_0)->CalcValue(caster); + int32 damage = spell->GetEffect(EFFECT_0).CalcValue(caster); float multiplier = 2.0f; if (GetTarget()->GetMap()->Is25ManRaid()) multiplier = 3.0f; @@ -1331,15 +1330,15 @@ class spell_putricide_mutated_plague : public SpellScriptLoader GetTarget()->CastSpell(GetTarget(), triggerSpell, args); } - void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - uint32 healSpell = uint32(GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue()); + uint32 healSpell = uint32(aurEff->GetSpellEffectInfo().CalcValue()); SpellInfo const* healSpellInfo = sSpellMgr->GetSpellInfo(healSpell, GetCastDifficulty()); if (!healSpellInfo) return; - int32 heal = healSpellInfo->GetEffect(EFFECT_0)->CalcValue() * GetStackAmount(); + int32 heal = healSpellInfo->GetEffect(EFFECT_0).CalcValue() * GetStackAmount(); CastSpellExtraArgs args(GetCasterGUID()); args.AddSpellBP0(heal); GetTarget()->CastSpell(GetTarget(), healSpell, args); @@ -1505,8 +1504,8 @@ class spell_putricide_mutated_transformation : public SpellScriptLoader return; } - uint32 entry = uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValue); - SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValueB)); + uint32 entry = uint32(GetEffectInfo().MiscValue); + SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(uint32(GetEffectInfo().MiscValueB)); uint32 duration = uint32(GetSpellInfo()->GetDuration()); Position pos = caster->GetPosition(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index f15e751157d..94bc9d0310d 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -550,14 +550,13 @@ class spell_rotface_mutated_infection : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect = spellInfo->GetEffect(EFFECT_2); - return effect && ValidateSpellInfo({ uint32(effect->CalcValue()) }); + return spellInfo->GetEffects().size() > EFFECT_2 && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_2).CalcValue()) }); } void HandleEffectRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - target->CastSpell(target, uint32(GetSpellInfo()->GetEffect(EFFECT_2)->CalcValue()), { aurEff, GetCasterGUID() }); + target->CastSpell(target, uint32(GetEffectInfo(EFFECT_2).CalcValue()), { aurEff, GetCasterGUID() }); } void Register() override @@ -776,11 +775,11 @@ class spell_rotface_unstable_ooze_explosion : public SpellScriptLoader void CheckTarget(SpellEffIndex effIndex) { - PreventHitDefaultEffect(EFFECT_0); + PreventHitDefaultEffect(effIndex); if (!GetExplTargetDest()) return; - uint32 triggered_spell_id = GetSpellInfo()->GetEffect(effIndex)->TriggerSpell; + uint32 triggered_spell_id = GetEffectInfo().TriggerSpell; float x, y, z; GetExplTargetDest()->GetPosition(x, y, z); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 158b63ab4f2..6d249e6ce16 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -1571,14 +1571,17 @@ class spell_frostwarden_handler_focus_fire : public SpellScriptLoader { PrepareAuraScript(spell_frostwarden_handler_focus_fire_AuraScript); + bool Validate(SpellInfo const* spellInfo) override + { + return spellInfo->GetEffects().size() > EFFECT_1; + } + void PeriodicTick(AuraEffect const* /*aurEff*/) { PreventDefaultAction(); if (Unit* caster = GetCaster()) { - if (SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(EFFECT_1)) - caster->GetThreatManager().AddThreat(GetTarget(), -float(effect->CalcValue()), GetSpellInfo(), true, true); - + caster->GetThreatManager().AddThreat(GetTarget(), -float(GetEffectInfo(EFFECT_1).CalcValue()), GetSpellInfo(), true, true); caster->GetAI()->SetData(DATA_WHELP_MARKER, 0); } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 54605a25996..9b33c7b53ae 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -2494,14 +2494,14 @@ class spell_the_lich_king_summon_into_air : public SpellScriptLoader { PrepareSpellScript(spell_the_lich_king_summon_into_air_SpellScript); - void ModDestHeight(SpellEffIndex effIndex) + void ModDestHeight(SpellEffIndex /*effIndex*/) { static Position const offset = {0.0f, 0.0f, 15.0f, 0.0f}; WorldLocation* dest = const_cast<WorldLocation*>(GetExplTargetDest()); dest->RelocateOffset(offset); GetHitDest()->RelocateOffset(offset); // spirit bombs get higher - if (GetSpellInfo()->GetEffect(effIndex)->MiscValue == NPC_SPIRIT_BOMB) + if (GetEffectInfo().MiscValue == NPC_SPIRIT_BOMB) { static Position const offsetExtra = { 0.0f, 0.0f, 5.0f, 0.0f }; dest->RelocateOffset(offsetExtra); @@ -2695,7 +2695,7 @@ class spell_the_lich_king_vile_spirits : public SpellScriptLoader void OnPeriodic(AuraEffect const* aurEff) { if (_is25Man || ((aurEff->GetTickNumber() - 1) % 5)) - GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo()->TriggerSpell, { aurEff, GetCasterGUID() }); + GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, { aurEff, GetCasterGUID() }); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index bbd04e7890b..baec83a7608 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -248,7 +248,7 @@ class ValithriaDespawner : public BasicEvent default: return; } - + creature->DespawnOrUnsummon(0, 10s); } @@ -1235,7 +1235,7 @@ class spell_dreamwalker_summoner : public SpellScriptLoader if (!GetHitUnit()) return; - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); + GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); } void Register() override @@ -1326,7 +1326,7 @@ class spell_dreamwalker_summon_suppresser_effect : public SpellScriptLoader if (!GetHitUnit()) return; - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); + GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, GetCaster()->GetInstanceScript()->GetGuidData(DATA_VALITHRIA_LICH_KING)); } void Register() override @@ -1462,7 +1462,7 @@ class spell_dreamwalker_twisted_nightmares : public SpellScriptLoader // return; if (InstanceScript* instance = GetHitUnit()->GetInstanceScript()) - GetHitUnit()->CastSpell(nullptr, GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); + GetHitUnit()->CastSpell(nullptr, GetEffectInfo().TriggerSpell, instance->GetGuidData(DATA_VALITHRIA_DREAMWALKER)); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index a1b4698a37c..1500349fd50 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -1847,7 +1847,7 @@ class spell_icc_sprit_alarm : public SpellScriptLoader { PreventHitDefaultEffect(effIndex); uint32 trapId = 0; - switch (GetSpellInfo()->GetEffect(effIndex)->MiscValue) + switch (GetEffectInfo().MiscValue) { case EVENT_AWAKEN_WARD_1: trapId = GO_SPIRIT_ALARM_1; diff --git a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp index c529a580917..33ba844ca4a 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp @@ -193,8 +193,8 @@ class spell_grobbulus_poison_cloud : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0); - return effect0 && ValidateSpellInfo({ effect0->TriggerSpell }); + return !spellInfo->GetEffects().empty() + && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell }); } void PeriodicTick(AuraEffect const* aurEff) @@ -203,7 +203,7 @@ class spell_grobbulus_poison_cloud : public SpellScriptLoader if (!aurEff->GetTotalTicks()) return; - uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell; + uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; int32 mod = int32(((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 10000 * 2 / 3); CastSpellExtraArgs args(aurEff); diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 60152408e4c..aa31ee41ea6 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -1899,7 +1899,7 @@ class spell_arcane_overload : public SpellScriptLoader { Creature* arcaneOverload = GetCaster()->ToCreature(); targets.remove_if(ExactDistanceCheck(arcaneOverload, - GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(arcaneOverload) * arcaneOverload->GetObjectScale())); + GetEffectInfo(EFFECT_0).CalcRadius(arcaneOverload) * arcaneOverload->GetObjectScale())); } void Register() override diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp index f61ab9bf2b3..a87a11e9076 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp @@ -453,7 +453,7 @@ class spell_oculus_ride_ruby_emerald_amber_drake_que : public SpellScriptLoader // caster of the triggered spell is wrong for an unknown reason, handle it here correctly PreventDefaultAction(); if (Unit* caster = GetCaster()) - GetTarget()->CastSpell(caster, aurEff->GetSpellEffectInfo()->TriggerSpell, true); + GetTarget()->CastSpell(caster, aurEff->GetSpellEffectInfo().TriggerSpell, true); } void Register() override diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp index a8f0924c9e4..59ca0c6e0f9 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp @@ -181,12 +181,17 @@ class spell_krystallus_shatter_effect : public SpellScriptLoader { PrepareSpellScript(spell_krystallus_shatter_effect_SpellScript); + bool Validate(SpellInfo const* spellInfo) override + { + return !spellInfo->GetEffects().empty(); + } + void CalculateDamage() { if (!GetHitUnit()) return; - float radius = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster()); + float radius = GetSpellInfo()->GetEffect(EFFECT_0).CalcRadius(GetCaster()); if (!radius) return; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index 6db930756a2..c704265493a 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -1526,13 +1526,13 @@ class spell_tar_blaze : 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) { // should we use custom damage? - GetTarget()->CastSpell(nullptr, GetSpellInfo()->GetEffect(aurEff->GetEffIndex())->TriggerSpell, true); + GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, true); } void Register() override @@ -1792,7 +1792,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader class spell_vehicle_throw_passenger_SpellScript : public SpellScript { PrepareSpellScript(spell_vehicle_throw_passenger_SpellScript); - void HandleScript(SpellEffIndex effIndex) + void HandleScript(SpellEffIndex /*effIndex*/) { Spell* baseSpell = GetSpell(); SpellCastTargets targets = baseSpell->m_targets; @@ -1825,7 +1825,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader } } } - if (target && target->IsWithinDist2d(targets.GetDstPos(), GetSpellInfo()->GetEffect(effIndex)->CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct + if (target && target->IsWithinDist2d(targets.GetDstPos(), GetEffectInfo().CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct passenger->EnterVehicle(target, 0); else { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index 083c37d4763..a0f3d711bee 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -1583,7 +1583,7 @@ class spell_freya_iron_roots : public SpellScriptLoader void HandleSummon(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - uint32 entry = uint32(GetSpellInfo()->GetEffect(effIndex)->MiscValue); + uint32 entry = uint32(GetEffectInfo().MiscValue); Position pos = GetCaster()->GetPosition(); // Not good at all, but this prevents having roots in a different position then player diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index e1c81c0a286..9d234ce1888 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -448,23 +448,22 @@ class spell_ulduar_cancel_stone_grip : public SpellScriptLoader { PrepareSpellScript(spell_ulduar_cancel_stone_gripSpellScript); + bool Validate(SpellInfo const* spellInfo) override + { + return spellInfo->GetEffects().size() > EFFECT_1; + } + void HandleScript(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); if (!target || !target->GetVehicle()) return; - switch (target->GetMap()->GetDifficultyID()) - { - case DIFFICULTY_10_N: - target->RemoveAura(GetSpellInfo()->GetEffect(EFFECT_0)->CalcValue()); - break; - case DIFFICULTY_25_N: - target->RemoveAura(GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue()); - break; - default: - break; - } + SpellEffIndex effectIndexToCancel = EFFECT_0; + if (target->GetMap()->Is25ManRaid()) + effectIndexToCancel = EFFECT_1; + + target->RemoveAura(GetEffectInfo(effectIndexToCancel).CalcValue()); } void Register() override @@ -647,7 +646,7 @@ class spell_kologarn_summon_focused_eyebeam : public SpellScriptLoader void HandleForceCast(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex)->TriggerSpell, true); + GetCaster()->CastSpell(GetCaster(), GetEffectInfo().TriggerSpell, true); } void Register() override diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp index 66f2eae6fe0..e72c83742e1 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp @@ -959,13 +959,13 @@ struct npc_thorim_trashAI : public ScriptedAI static uint32 GetTotalHeal(SpellInfo const* spellInfo, Unit const* caster) { uint32 heal = 0; - for (SpellEffectInfo const* effect : spellInfo->GetEffects()) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { - if (effect->IsEffect(SPELL_EFFECT_HEAL)) - heal += effect->CalcValue(caster); + if (spellEffectInfo.IsEffect(SPELL_EFFECT_HEAL)) + heal += spellEffectInfo.CalcValue(caster); - if (effect->IsEffect(SPELL_EFFECT_APPLY_AURA) && effect->IsAura(SPELL_AURA_PERIODIC_HEAL)) - heal += spellInfo->GetMaxTicks() * effect->CalcValue(caster); + if (spellEffectInfo.IsEffect(SPELL_EFFECT_APPLY_AURA) && spellEffectInfo.IsAura(SPELL_AURA_PERIODIC_HEAL)) + heal += spellInfo->GetMaxTicks() * spellEffectInfo.CalcValue(caster); } return heal; } diff --git a/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp b/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp index db2946ce825..2a2737bd127 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_moragg.cpp @@ -108,7 +108,7 @@ class spell_moragg_ray : public SpellScriptLoader if (Unit* target = GetTarget()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f, true)) { - uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell; + uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; GetTarget()->CastSpell(target, triggerSpell, aurEff); } } diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp index 4beecee5eed..e581a8d742d 100644 --- a/src/server/scripts/Northrend/zone_storm_peaks.cpp +++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp @@ -1327,7 +1327,7 @@ public: bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); } void HandleScript(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index a7db09490ad..0924cdf16cf 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -590,10 +590,9 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect2 = spellInfo->GetEffect(EFFECT_2); - if (!effect2) + if (spellInfo->GetEffects().size() <= EFFECT_2) return false; - uint32 triggeredSpellId = effect2->CalcValue(); + uint32 triggeredSpellId = spellInfo->GetEffect(EFFECT_2).CalcValue(); return !triggeredSpellId || ValidateSpellInfo({ triggeredSpellId }); } @@ -601,7 +600,7 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript { PreventDefaultAction(); - if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo()->CalcValue()) + if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValue()) { int32 bp = 0; if (AuraEffect const* healEffect = GetEffect(EFFECT_0)) @@ -619,7 +618,7 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo()->CalcValue()) + if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValue()) GetTarget()->RemoveAurasDueToSpell(triggeredSpellId); } diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp index f5b8418fd11..0e88b976fe1 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp @@ -262,14 +262,15 @@ class spell_mother_shahraz_saber_lash : public AuraScript bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_1)->TriggerSpell }); + return spellInfo->GetEffects().size() > EFFECT_1 + && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_1).TriggerSpell }); } void OnTrigger(AuraEffect const* aurEff) { PreventDefaultAction(); - uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell; + uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0)) GetUnitOwner()->CastSpell(target, triggerSpell, true); } @@ -290,14 +291,15 @@ class spell_mother_shahraz_generic_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 OnTrigger(AuraEffect const* aurEff) { PreventDefaultAction(); - uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell; + uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SELECT_TARGET_RANDOM, 0)) GetUnitOwner()->CastSpell(target, triggerSpell, true); } diff --git a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp index f050c1d9e39..fae7d777b32 100644 --- a/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp +++ b/src/server/scripts/Outland/GruulsLair/boss_gruul.cpp @@ -309,12 +309,17 @@ class spell_gruul_shatter_effect : public SpellScriptLoader { PrepareSpellScript(spell_gruul_shatter_effect_SpellScript); + bool Validate(SpellInfo const* spellInfo) override + { + return !spellInfo->GetEffects().empty(); + } + void CalculateDamage() { if (!GetHitUnit()) return; - float radius = GetSpellInfo()->GetEffect(EFFECT_0)->CalcRadius(GetCaster()); + float radius = GetEffectInfo(EFFECT_0).CalcRadius(GetCaster()); if (!radius) return; diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp index 334e7335ccd..23100fea7c5 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp @@ -171,8 +171,7 @@ class spell_broggok_poison_cloud : public SpellScriptLoader bool Validate(SpellInfo const* spellInfo) override { - SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0); - return effect0 && ValidateSpellInfo({ effect0->TriggerSpell }); + return !spellInfo->GetEffects().empty() && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell }); } void PeriodicTick(AuraEffect const* aurEff) @@ -181,7 +180,7 @@ class spell_broggok_poison_cloud : public SpellScriptLoader if (!aurEff->GetTotalTicks()) return; - uint32 triggerSpell = aurEff->GetSpellEffectInfo()->TriggerSpell; + uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; int32 mod = int32(((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 10000 * 2 / 3); GetTarget()->CastSpell(nullptr, triggerSpell, CastSpellExtraArgs(aurEff).AddSpellMod(SPELLVALUE_RADIUS_MOD, mod)); } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp index f7874b392f7..b3a4ae4144c 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp @@ -512,9 +512,10 @@ class spell_astromancer_wrath_of_the_astromancer : public SpellScriptLoader { PrepareAuraScript(spell_astromancer_wrath_of_the_astromancer_AuraScript); - bool Validate(SpellInfo const* /*spellInfo*/) override + bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ SPELL_WRATH_OF_THE_ASTROMANCER_DOT }); + return ValidateSpellInfo({ SPELL_WRATH_OF_THE_ASTROMANCER_DOT }) + && spellInfo->GetEffects().size() > EFFECT_1; } void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -524,7 +525,7 @@ class spell_astromancer_wrath_of_the_astromancer : public SpellScriptLoader return; Unit* target = GetUnitOwner(); - target->CastSpell(target, GetSpellInfo()->GetEffect(EFFECT_1)->CalcValue(), false); + target->CastSpell(target, GetEffectInfo(EFFECT_1).CalcValue(), false); } void Register() override 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<uint32>(spellInfo->GetEffect(EFFECT_2)->CalcValue()) }); + return spellInfo->GetEffects().size() > EFFECT_2 && ValidateSpellInfo({ static_cast<uint32>(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<TempSummon*> 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<WorldObject*>& 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<WorldObject*>& 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<uint32>(spellInfo->GetEffect(EFFECT_0)->CalcValue()) }); + return !spellInfo->GetEffects().empty() + && ValidateSpellInfo({ static_cast<uint32>(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 diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp index c7635efcef3..f49d7e92db0 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -286,12 +286,9 @@ bool EquippedOk(Player* player, uint32 spellId) if (!spell) return false; - for (SpellEffectInfo const* effect : spell->GetEffects()) + for (SpellEffectInfo const& spellEffectInfo : spell->GetEffects()) { - if (!effect) - continue; - - uint32 reqSpell = effect->TriggerSpell; + uint32 reqSpell = spellEffectInfo.TriggerSpell; if (!reqSpell) continue; diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 0e0cf7a1d85..f51f9b70cd5 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -2220,10 +2220,10 @@ public: break; } - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE)) - if (SpellEffectInfo const* effect0 = spellInfo->GetEffect(EFFECT_0)) - if (effect0->Effect == SPELL_EFFECT_SUMMON_OBJECT_WILD) - return effect0->MiscValue; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE); + + if (spellInfo && spellInfo->GetEffect(EFFECT_0).Effect == SPELL_EFFECT_SUMMON_OBJECT_WILD) + return spellInfo->GetEffect(EFFECT_0).MiscValue; return 0; } |
