mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-13 19:43:19 -04:00
176 lines
5.8 KiB
C++
176 lines
5.8 KiB
C++
/*
|
|
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
|
|
*
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/*
|
|
* 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 "ScriptPCH.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,
|
|
};
|
|
|
|
class spell_mage_cold_snap_SpellScript : public SpellScript
|
|
{
|
|
void HandleDummy(SpellEffIndex effIndex)
|
|
{
|
|
Unit *caster = GetCaster();
|
|
|
|
if (caster->GetTypeId() != TYPEID_PLAYER)
|
|
return;
|
|
|
|
// immediately finishes the cooldown on Frost spells
|
|
const SpellCooldowns& cm = caster->ToPlayer()->GetSpellCooldownMap();
|
|
for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
|
|
{
|
|
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
|
|
|
|
if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE &&
|
|
(GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) &&
|
|
spellInfo->Id != SPELL_MAGE_COLD_SNAP && GetSpellRecoveryTime(spellInfo) > 0)
|
|
{
|
|
caster->ToPlayer()->RemoveSpellCooldown((itr++)->first, true);
|
|
}
|
|
else
|
|
++itr;
|
|
}
|
|
}
|
|
|
|
void Register()
|
|
{
|
|
// add dummy effect spell handler to Cold Snap
|
|
EffectHandlers += EffectHandlerFn(spell_mage_cold_snap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
|
}
|
|
};
|
|
|
|
SpellScript * GetSpellScript_spell_mage_cold_snap()
|
|
{
|
|
return new spell_mage_cold_snap_SpellScript();
|
|
}
|
|
|
|
class spell_mage_polymorph_cast_visual_SpellScript : public SpellScript
|
|
{
|
|
static const uint32 spell_list[6];
|
|
|
|
bool Validate(SpellEntry const * spellEntry)
|
|
{
|
|
// check if spell ids exist in dbc
|
|
for (int i = 0; i < 6; i++)
|
|
if (!sSpellStore.LookupEntry(spell_list[i]))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void HandleDummy(SpellEffIndex effIndex)
|
|
{
|
|
if (Unit *unitTarget = GetHitUnit())
|
|
if (unitTarget->GetTypeId() == TYPEID_UNIT)
|
|
unitTarget->CastSpell(unitTarget, spell_list[urand(0, 5)], true);
|
|
}
|
|
|
|
void Register()
|
|
{
|
|
// add dummy effect spell handler to Polymorph visual
|
|
EffectHandlers += EffectHandlerFn(spell_mage_polymorph_cast_visual_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
|
}
|
|
};
|
|
|
|
const uint32 spell_mage_polymorph_cast_visual_SpellScript::spell_list[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
|
|
};
|
|
|
|
SpellScript * GetSpellScript_spell_mage_polymorph_visual()
|
|
{
|
|
return new spell_mage_polymorph_cast_visual_SpellScript();
|
|
}
|
|
|
|
class spell_mage_summon_water_elemental_SpellScript : public SpellScript
|
|
{
|
|
bool Validate(SpellEntry const * spellEntry)
|
|
{
|
|
if (!sSpellStore.LookupEntry(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER))
|
|
return false;
|
|
if (!sSpellStore.LookupEntry(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY))
|
|
return false;
|
|
if (!sSpellStore.LookupEntry(SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void HandleDummy(SpellEffIndex effIndex)
|
|
{
|
|
if (Unit *unitTarget = GetHitUnit())
|
|
{
|
|
// Glyph of Eternal Water
|
|
if (unitTarget->HasAura(SPELL_MAGE_GLYPH_OF_ETERNAL_WATER))
|
|
unitTarget->CastSpell(unitTarget, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_PERMANENT, true);
|
|
else
|
|
unitTarget->CastSpell(unitTarget, SPELL_MAGE_SUMMON_WATER_ELEMENTAL_TEMPORARY, true);
|
|
}
|
|
}
|
|
|
|
void Register()
|
|
{
|
|
// add dummy effect spell handler to Summon Water Elemental
|
|
EffectHandlers += EffectHandlerFn(spell_mage_summon_water_elemental_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
|
}
|
|
};
|
|
|
|
SpellScript * GetSpellScript_spell_mage_summon_water_elemental()
|
|
{
|
|
return new spell_mage_summon_water_elemental_SpellScript();
|
|
}
|
|
|
|
void AddSC_mage_spell_scripts()
|
|
{
|
|
Script *newscript;
|
|
|
|
newscript = new Script;
|
|
newscript->Name = "spell_mage_cold_snap";
|
|
newscript->GetSpellScript = &GetSpellScript_spell_mage_cold_snap;
|
|
newscript->RegisterSelf();
|
|
|
|
newscript = new Script;
|
|
newscript->Name = "spell_mage_polymorph_visual";
|
|
newscript->GetSpellScript = &GetSpellScript_spell_mage_polymorph_visual;
|
|
newscript->RegisterSelf();
|
|
|
|
newscript = new Script;
|
|
newscript->Name = "spell_mage_summon_water_elemental";
|
|
newscript->GetSpellScript = &GetSpellScript_spell_mage_summon_water_elemental;
|
|
newscript->RegisterSelf();
|
|
}
|