/* * Copyright (C) 2008-2013 TrinityCore * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ /* * Scripts for spells with SPELLFAMILY_MAGE and SPELLFAMILY_GENERIC spells used by mage players. * Ordered alphabetically using scriptname. * Scriptnames of files in this file should be prefixed with "spell_mage_". */ #include "Player.h" #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" enum MageSpells { SPELL_MAGE_COLD_SNAP = 11958, SPELL_MAGE_SQUIRREL_FORM = 32813, SPELL_MAGE_GIRAFFE_FORM = 32816, SPELL_MAGE_SERPENT_FORM = 32817, SPELL_MAGE_DRAGONHAWK_FORM = 32818, SPELL_MAGE_WORGEN_FORM = 32819, SPELL_MAGE_SHEEP_FORM = 32820, SPELL_MAGE_GLYPH_OF_ETERNAL_WATER = 70937, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT = 70908, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY = 70907, SPELL_MAGE_GLYPH_OF_BLAST_WAVE = 62126, SPELL_MAGE_CONJURE_REFRESHMENT = 42955, SPELL_MAGE_FLAMESTRIKE = 2120, SPELL_MAGE_CHILLED_R1 = 12484, SPELL_MAGE_CHILLED_R2 = 12485, SPELL_MAGE_INCANTER_S_ABSORPTION_TRIGGERED = 44413, SPELL_MAGE_INCANTER_S_ABSORPTION_KNOCKBACK = 86261, SPELL_MAGE_IMPROVED_MANA_GEM_TRIGGERED = 83098, SPELL_MAGE_SHATTERED_BARRIER_R1 = 44745, SPELL_MAGE_SHATTERED_BARRIER_R2 = 54787, SPELL_MAGE_SHATTERED_BARRIER_FREEZE_R1 = 55080, SPELL_MAGE_SHATTERED_BARRIER_FREEZE_R2 = 83073, SPELL_MAGE_FINGERS_OF_FROST = 44544, }; enum MageIcons { ICON_MAGE_SHATTER = 976, ICON_MAGE_IMPROVED_FLAMESTRIKE = 37, ICON_MAGE_IMPROVED_FREEZE = 94, ICON_MAGE_INCANTER_S_ABSORPTION = 2941, ICON_MAGE_IMPROVED_MANA_GEM = 1036, }; class spell_mage_blast_wave : public SpellScriptLoader { public: spell_mage_blast_wave() : SpellScriptLoader("spell_mage_blast_wave") { } class spell_mage_blast_wave_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_blast_wave_SpellScript); bool Validate(SpellInfo const* /*spellInfo*/) { if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_FLAMESTRIKE)) return false; return true; } void CountTargets(std::list& targetList) { _targetCount = targetList.size(); } void HandleImprovedFlamestrike() { if (_targetCount >= 2) if (AuraEffect* aurEff = GetCaster()->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, ICON_MAGE_IMPROVED_FLAMESTRIKE, EFFECT_0)) if (roll_chance_i(aurEff->GetAmount())) { float x, y, z; WorldLocation const* loc = GetExplTargetDest(); if (!loc) return; loc->GetPosition(x, y, z); GetCaster()->CastSpell(x, y, z, SPELL_MAGE_FLAMESTRIKE, true); } } void Register() { OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mage_blast_wave_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); AfterCast += SpellCastFn(spell_mage_blast_wave_SpellScript::HandleImprovedFlamestrike); } private: uint32 _targetCount; }; SpellScript* GetSpellScript() const { return new spell_mage_blast_wave_SpellScript(); } }; class spell_mage_cold_snap : public SpellScriptLoader { public: spell_mage_cold_snap() : SpellScriptLoader("spell_mage_cold_snap") { } class spell_mage_cold_snap_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_cold_snap_SpellScript); bool Load() { return GetCaster()->GetTypeId() == TYPEID_PLAYER; } void HandleDummy(SpellEffIndex /*effIndex*/) { Player* caster = GetCaster()->ToPlayer(); // immediately finishes the cooldown on Frost spells const SpellCooldowns& cm = caster->GetSpellCooldownMap(); for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (spellInfo->GetSchoolMask() & SPELL_SCHOOL_MASK_FROST) && spellInfo->Id != SPELL_MAGE_COLD_SNAP && spellInfo->GetRecoveryTime() > 0) { caster->RemoveSpellCooldown((itr++)->first, true); } else ++itr; } } void Register() { OnEffectHit += SpellEffectFn(spell_mage_cold_snap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; SpellScript* GetSpellScript() const { return new spell_mage_cold_snap_SpellScript(); } }; enum SilvermoonPolymorph { NPC_AUROSALIA = 18744, }; // TODO: move out of here and rename - not a mage spell class spell_mage_polymorph_cast_visual : public SpellScriptLoader { public: spell_mage_polymorph_cast_visual() : SpellScriptLoader("spell_mage_polymorph_visual") { } class spell_mage_polymorph_cast_visual_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_polymorph_cast_visual_SpellScript); static const uint32 PolymorhForms[6]; bool Validate(SpellInfo const* /*spellEntry*/) { // check if spell ids exist in dbc for (uint32 i = 0; i < 6; i++) if (!sSpellMgr->GetSpellInfo(PolymorhForms[i])) return false; return true; } void HandleDummy(SpellEffIndex /*effIndex*/) { if (Unit* target = GetCaster()->FindNearestCreature(NPC_AUROSALIA, 30.0f)) if (target->GetTypeId() == TYPEID_UNIT) target->CastSpell(target, PolymorhForms[urand(0, 5)], true); } void Register() { // add dummy effect spell handler to Polymorph visual OnEffectHitTarget += SpellEffectFn(spell_mage_polymorph_cast_visual_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; SpellScript* GetSpellScript() const { return new spell_mage_polymorph_cast_visual_SpellScript(); } }; const uint32 spell_mage_polymorph_cast_visual::spell_mage_polymorph_cast_visual_SpellScript::PolymorhForms[6] = { SPELL_MAGE_SQUIRREL_FORM, SPELL_MAGE_GIRAFFE_FORM, SPELL_MAGE_SERPENT_FORM, SPELL_MAGE_DRAGONHAWK_FORM, SPELL_MAGE_WORGEN_FORM, SPELL_MAGE_SHEEP_FORM }; class spell_mage_summon_water_elemental : public SpellScriptLoader { public: spell_mage_summon_water_elemental() : SpellScriptLoader("spell_mage_summon_water_elemental") { } class spell_mage_summon_water_elemental_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_summon_water_elemental_SpellScript); bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER) || !sSpellMgr->GetSpellInfo(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY) || !sSpellMgr->GetSpellInfo(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT)) return false; return true; } void HandleDummy(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); // Glyph of Eternal Water if (caster->HasAura(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER)) caster->CastSpell(caster, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT, true); else caster->CastSpell(caster, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY, true); } void Register() { // add dummy effect spell handler to Summon Water Elemental OnEffectHit += SpellEffectFn(spell_mage_summon_water_elemental_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; SpellScript* GetSpellScript() const { return new spell_mage_summon_water_elemental_SpellScript(); } }; // Frost Warding class spell_mage_frost_warding_trigger : public SpellScriptLoader { public: spell_mage_frost_warding_trigger() : SpellScriptLoader("spell_mage_frost_warding_trigger") { } class spell_mage_frost_warding_trigger_AuraScript : public AuraScript { PrepareAuraScript(spell_mage_frost_warding_trigger_AuraScript); enum Spells { SPELL_MAGE_FROST_WARDING_TRIGGERED = 57776, SPELL_MAGE_FROST_WARDING_R1 = 28332, }; bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_FROST_WARDING_TRIGGERED) || !sSpellMgr->GetSpellInfo(SPELL_MAGE_FROST_WARDING_R1)) return false; return true; } void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount) { Unit* target = GetTarget(); if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_MAGE_FROST_WARDING_R1, EFFECT_0)) { int32 chance = talentAurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(); if (roll_chance_i(chance)) { int32 bp = dmgInfo.GetDamage(); dmgInfo.AbsorbDamage(bp); target->CastCustomSpell(target, SPELL_MAGE_FROST_WARDING_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff); absorbAmount = 0; PreventDefaultAction(); } } } void Register() { OnEffectAbsorb += AuraEffectAbsorbFn(spell_mage_frost_warding_trigger_AuraScript::Absorb, EFFECT_0); } }; AuraScript* GetAuraScript() const { return new spell_mage_frost_warding_trigger_AuraScript(); } }; class spell_mage_living_bomb : public SpellScriptLoader { public: spell_mage_living_bomb() : SpellScriptLoader("spell_mage_living_bomb") { } class spell_mage_living_bomb_AuraScript : public AuraScript { PrepareAuraScript(spell_mage_living_bomb_AuraScript); bool Validate(SpellInfo const* spell) { if (!sSpellMgr->GetSpellInfo(uint32(spell->Effects[EFFECT_1].CalcValue()))) return false; return true; } void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { AuraRemoveMode removeMode = GetTargetApplication()->GetRemoveMode(); if (removeMode != AURA_REMOVE_BY_ENEMY_SPELL && removeMode != AURA_REMOVE_BY_EXPIRE) return; if (Unit* caster = GetCaster()) caster->CastSpell(GetTarget(), uint32(aurEff->GetAmount()), true, NULL, aurEff); } void Register() { AfterEffectRemove += AuraEffectRemoveFn(spell_mage_living_bomb_AuraScript::AfterRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL); } }; AuraScript* GetAuraScript() const { return new spell_mage_living_bomb_AuraScript(); } }; enum ConeOfColdSpells { SPELL_CONE_OF_COLD_AURA_R1 = 11190, // Improved Cone of Cold Rank 1 aura SPELL_CONE_OF_COLD_AURA_R2 = 12489, // Improved Cone of Cold Rank 2 aura SPELL_CONE_OF_COLD_TRIGGER_R1 = 83301, // Improved Cone of Cold Rank 1 Trigger SPELL_CONE_OF_COLD_TRIGGER_R2 = 83302, // Improved Cone of Cold Rank 2 Trigger }; // 120 Cone of Cold /// Updated 4.3.4 class spell_mage_cone_of_cold : public SpellScriptLoader { public: spell_mage_cone_of_cold() : SpellScriptLoader("spell_mage_cone_of_cold") { } class spell_mage_cone_of_cold_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_cone_of_cold_SpellScript); void HandleConeOfColdScript(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); if (Unit* unitTarget = GetHitUnit()) { if (caster->HasAura(SPELL_CONE_OF_COLD_AURA_R1)) // Improved Cone of Cold Rank 1 unitTarget->CastSpell(unitTarget, SPELL_CONE_OF_COLD_TRIGGER_R1, true); else if (caster->HasAura(SPELL_CONE_OF_COLD_AURA_R2)) // Improved Cone of Cold Rank 2 unitTarget->CastSpell(unitTarget, SPELL_CONE_OF_COLD_TRIGGER_R2, true); } } void Register() { OnEffectHitTarget += SpellEffectFn(spell_mage_cone_of_cold_SpellScript::HandleConeOfColdScript, EFFECT_0, SPELL_EFFECT_APPLY_AURA); } }; SpellScript* GetSpellScript() const { return new spell_mage_cone_of_cold_SpellScript(); } }; // 42955 Conjure Refreshment /// Updated 4.3.4 struct ConjureRefreshmentData { uint32 minLevel; uint32 maxLevel; uint32 spellId; }; uint8 const MAX_CONJURE_REFRESHMENT_SPELLS = 7; const ConjureRefreshmentData _conjureData[MAX_CONJURE_REFRESHMENT_SPELLS] = { { 33, 43, 92739 }, { 44, 53, 92799 }, { 54, 63, 92802 }, { 64, 73, 92805 }, { 74, 79, 74625 }, { 80, 84, 92822 }, { 85, 85, 92727 } }; class spell_mage_conjure_refreshment : public SpellScriptLoader { public: spell_mage_conjure_refreshment() : SpellScriptLoader("spell_mage_conjure_refreshment") { } class spell_mage_conjure_refreshment_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_conjure_refreshment_SpellScript); bool Validate(SpellInfo const* /*spellEntry*/) { for (uint8 i = 0; i < MAX_CONJURE_REFRESHMENT_SPELLS; ++i) if (!sSpellMgr->GetSpellInfo(_conjureData[i].spellId)) return false; return true; } bool Load() { if (GetCaster()->GetTypeId() != TYPEID_PLAYER) return false; return true; } void HandleDummy(SpellEffIndex /*effIndex*/) { uint8 level = GetHitUnit()->getLevel(); for (uint8 i = 0; i < MAX_CONJURE_REFRESHMENT_SPELLS; ++i) { ConjureRefreshmentData const& spellData = _conjureData[i]; if (level < spellData.minLevel || level > spellData.maxLevel) continue; GetHitUnit()->CastSpell(GetHitUnit(), spellData.spellId); break; } } void Register() { OnEffectHitTarget += SpellEffectFn(spell_mage_conjure_refreshment_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); } }; SpellScript* GetSpellScript() const { return new spell_mage_conjure_refreshment_SpellScript(); } }; // 42208 Blizzard /// Updated 4.3.4 class spell_mage_blizzard : public SpellScriptLoader { public: spell_mage_blizzard() : SpellScriptLoader("spell_mage_blizzard") { } class spell_mage_blizzard_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_blizzard_SpellScript); bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_CHILLED_R1)) return false; if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_CHILLED_R2)) return false; return true; } void AddChillEffect(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); if (Unit* unitTarget = GetHitUnit()) { if (caster->IsScriptOverriden(GetSpellInfo(), 836)) caster->CastSpell(unitTarget, SPELL_MAGE_CHILLED_R1, true); else if (caster->IsScriptOverriden(GetSpellInfo(), 988)) caster->CastSpell(unitTarget, SPELL_MAGE_CHILLED_R2, true); } } void Register() { OnEffectHitTarget += SpellEffectFn(spell_mage_blizzard_SpellScript::AddChillEffect, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); } }; SpellScript* GetSpellScript() const { return new spell_mage_blizzard_SpellScript(); } }; // 116 Frostbolt /// Updated 4.3.4 class spell_mage_frostbolt : public SpellScriptLoader { public: spell_mage_frostbolt() : SpellScriptLoader("spell_mage_frostbolt") { } class spell_mage_frostbolt_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_frostbolt_SpellScript); void RecalculateDamage(SpellEffIndex /*effIndex*/) { if (GetHitUnit() && GetHitUnit()->HasAuraState(AURA_STATE_FROZEN, GetSpellInfo(), GetCaster())) { if (AuraEffect* aurEff = GetCaster()->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, ICON_MAGE_SHATTER, EFFECT_1)) { int32 damage = GetHitDamage(); AddPct(damage, aurEff->GetAmount()); SetHitDamage(damage); } } } void Register() { OnEffectHitTarget += SpellEffectFn(spell_mage_frostbolt_SpellScript::RecalculateDamage, EFFECT_1, SPELL_EFFECT_SCHOOL_DAMAGE); } }; SpellScript* GetSpellScript() const { return new spell_mage_frostbolt_SpellScript(); } }; // 11426 Ice Barrier /// Updated 4.3.4 class spell_mage_ice_barrier : public SpellScriptLoader { public: spell_mage_ice_barrier() : SpellScriptLoader("spell_mage_ice_barrier") { } class spell_mage_ice_barrier_AuraScript : public AuraScript { PrepareAuraScript(spell_mage_ice_barrier_AuraScript); void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL) return; if (GetTarget()->HasAura(SPELL_MAGE_SHATTERED_BARRIER_R1)) GetTarget()->CastSpell(GetTarget(), SPELL_MAGE_SHATTERED_BARRIER_FREEZE_R1, true); else if (GetTarget()->HasAura(SPELL_MAGE_SHATTERED_BARRIER_R2)) GetTarget()->CastSpell(GetTarget(), SPELL_MAGE_SHATTERED_BARRIER_FREEZE_R2, true); } void Register() { AfterEffectRemove += AuraEffectRemoveFn(spell_mage_ice_barrier_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB, AURA_EFFECT_HANDLE_REAL); } }; AuraScript* GetAuraScript() const { return new spell_mage_ice_barrier_AuraScript(); } }; // 1463 Mana Shield /// Updated 4.3.4 class spell_mage_mana_shield : public SpellScriptLoader { public: spell_mage_mana_shield() : SpellScriptLoader("spell_mage_mana_shield") { } class spell_mage_mana_shield_AuraScript : public AuraScript { PrepareAuraScript(spell_mage_mana_shield_AuraScript); void HandleAbsorb(AuraEffect* /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount) { if (AuraEffect* aurEff = GetTarget()->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_GENERIC, ICON_MAGE_INCANTER_S_ABSORPTION, EFFECT_0)) { int32 bp = CalculatePct(absorbAmount, aurEff->GetAmount()); GetTarget()->CastCustomSpell(GetTarget(), SPELL_MAGE_INCANTER_S_ABSORPTION_TRIGGERED, &bp, NULL, NULL, true); } } void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_ENEMY_SPELL) GetTarget()->CastSpell(GetTarget(), SPELL_MAGE_INCANTER_S_ABSORPTION_KNOCKBACK, true); } void Register() { AfterEffectManaShield += AuraEffectManaShieldFn(spell_mage_mana_shield_AuraScript::HandleAbsorb, EFFECT_0); AfterEffectRemove += AuraEffectRemoveFn(spell_mage_mana_shield_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_MANA_SHIELD, AURA_EFFECT_HANDLE_REAL); } }; AuraScript* GetAuraScript() const { return new spell_mage_mana_shield_AuraScript(); } }; // 543 Mage Ward /// Updated 4.3.4 class spell_mage_mage_ward : public SpellScriptLoader { public: spell_mage_mage_ward() : SpellScriptLoader("spell_mage_mage_ward") { } class spell_mage_mage_ward_AuraScript : public AuraScript { PrepareAuraScript(spell_mage_mage_ward_AuraScript); void HandleAbsorb(AuraEffect* /*aurEff*/, DamageInfo & /*dmgInfo*/, uint32 & absorbAmount) { if (AuraEffect* aurEff = GetTarget()->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_GENERIC, ICON_MAGE_INCANTER_S_ABSORPTION, EFFECT_0)) { int32 bp = CalculatePct(absorbAmount, aurEff->GetAmount()); GetTarget()->CastCustomSpell(GetTarget(), SPELL_MAGE_INCANTER_S_ABSORPTION_TRIGGERED, &bp, NULL, NULL, true); } } void Register() { AfterEffectAbsorb += AuraEffectAbsorbFn(spell_mage_mage_ward_AuraScript::HandleAbsorb, EFFECT_0); } }; AuraScript* GetAuraScript() const { return new spell_mage_mage_ward_AuraScript(); } }; // 5405 Replenish Mana (Mana Gem) /// Updated 4.3.4 class spell_mage_replenish_mana : public SpellScriptLoader { public: spell_mage_replenish_mana() : SpellScriptLoader("spell_mage_replenish_mana") { } class spell_mage_replenish_mana_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_replenish_mana_SpellScript); bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_IMPROVED_MANA_GEM_TRIGGERED)) return false; return true; } void HandleImprovedManaGem() { if (AuraEffect* aurEff = GetCaster()->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, ICON_MAGE_IMPROVED_MANA_GEM, EFFECT_0)) { int32 bp = CalculatePct(GetCaster()->GetMaxPower(POWER_MANA), aurEff->GetAmount()); GetCaster()->CastCustomSpell(GetCaster(), SPELL_MAGE_IMPROVED_MANA_GEM_TRIGGERED, &bp, &bp, NULL, true); } } void Register() { AfterCast += SpellCastFn(spell_mage_replenish_mana_SpellScript::HandleImprovedManaGem); } }; SpellScript* GetSpellScript() const { return new spell_mage_replenish_mana_SpellScript(); } }; // 33395 Water Elemental's Freeze /// Updated 4.3.4 class spell_mage_water_elemental_freeze : public SpellScriptLoader { public: spell_mage_water_elemental_freeze() : SpellScriptLoader("spell_mage_water_elemental_freeze") { } class spell_mage_water_elemental_freeze_SpellScript : public SpellScript { PrepareSpellScript(spell_mage_water_elemental_freeze_SpellScript); bool Validate(SpellInfo const* /*spellEntry*/) { if (!sSpellMgr->GetSpellInfo(SPELL_MAGE_FINGERS_OF_FROST)) return false; return true; } void CountTargets(std::list& targetList) { _didHit = !targetList.empty(); } void HandleImprovedFreeze() { if (!_didHit) return; Unit* owner = GetCaster()->GetOwner(); if (!owner) return; if (AuraEffect* aurEff = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, ICON_MAGE_IMPROVED_FREEZE, EFFECT_0)) { if (roll_chance_i(aurEff->GetAmount())) owner->CastCustomSpell(SPELL_MAGE_FINGERS_OF_FROST, SPELLVALUE_AURA_STACK, 2, owner, true); } } void Register() { OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_mage_water_elemental_freeze_SpellScript::CountTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY); AfterCast += SpellCastFn(spell_mage_water_elemental_freeze_SpellScript::HandleImprovedFreeze); } private: bool _didHit; }; SpellScript* GetSpellScript() const { return new spell_mage_water_elemental_freeze_SpellScript(); } }; void AddSC_mage_spell_scripts() { new spell_mage_blast_wave(); new spell_mage_cold_snap(); new spell_mage_cone_of_cold(); new spell_mage_conjure_refreshment(); new spell_mage_frost_warding_trigger(); new spell_mage_polymorph_cast_visual(); new spell_mage_summon_water_elemental(); new spell_mage_living_bomb(); new spell_mage_blizzard(); new spell_mage_frostbolt(); new spell_mage_ice_barrier(); new spell_mage_mana_shield(); new spell_mage_mage_ward(); new spell_mage_replenish_mana(); new spell_mage_water_elemental_freeze(); }