Files
TCPlayerbotCore/src/server/scripts/Spells/spell_generic.cpp
T
QAston 07a3a1254b *Add AuraScript class for scripting aura objects - scripts are registered same way as SpellScripts, bound to SpellScriptNames table. For more details see example_spell.cpp and SpellScript.h
*Rename SpellHandlerScript to SpellScriptLoader, EffectHandlerFn to SpellEffectFn, HitHandlerFn to SpellHitFn, SpellScript::EffectHandlers to SpellScript::OnEffect, these changes were neccesary to prevent namespace collisions, happily you can solve these by simple find and replace
*Make spells 66244 and 5581 example scripts.

--HG--
branch : trunk
2010-08-24 00:10:49 +02:00

124 lines
4.0 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_GENERIC which cannot be included in AI script file
* of creature using it or can't be bound to any player class.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_gen_"
*/
#include "ScriptPCH.h"
enum NPCEntries
{
NPC_DOOMGUARD = 11859,
NPC_INFERNAL = 89,
NPC_IMP = 416,
};
class spell_gen_remove_flight_auras : public SpellScriptLoader
{
public:
spell_gen_remove_flight_auras() : SpellScriptLoader("spell_gen_remove_flight_auras") {}
class spell_gen_remove_flight_auras_SpellScript : public SpellScript
{
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit *target = GetHitUnit();
if (!target)
return;
target->RemoveAurasByType(SPELL_AURA_FLY);
target->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED);
}
void Register()
{
OnEffect += SpellEffectFn(spell_gen_remove_flight_auras_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_gen_remove_flight_auras_SpellScript;
}
};
class spell_gen_pet_summoned : public SpellScriptLoader
{
public:
spell_gen_pet_summoned() : SpellScriptLoader("spell_gen_pet_summoned") { }
class spell_gen_pet_summonedSpellScript : public SpellScript
{
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit *caster = GetCaster();
if (caster->GetTypeId() != TYPEID_PLAYER)
return;
Player* plr = caster->ToPlayer();
if (plr && plr->GetLastPetNumber())
{
PetType NewPetType = (plr->getClass() == CLASS_HUNTER) ? HUNTER_PET : SUMMON_PET;
if (Pet* NewPet = new Pet(plr, NewPetType))
{
if (NewPet->LoadPetFromDB(plr, 0, plr->GetLastPetNumber(), true))
{
// revive the pet if it is dead
if (NewPet->getDeathState() == DEAD)
NewPet->setDeathState(ALIVE);
NewPet->SetHealth(NewPet->GetMaxHealth());
NewPet->SetPower(NewPet->getPowerType(),NewPet->GetMaxPower(NewPet->getPowerType()));
switch (NewPet->GetEntry())
{
case NPC_DOOMGUARD:
case NPC_INFERNAL:
NewPet->SetEntry(NPC_IMP);
break;
default:
break;
}
}
else
delete NewPet;
}
}
}
void Register()
{
OnEffect += SpellEffectFn(spell_gen_pet_summonedSpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_gen_pet_summonedSpellScript;
}
};
void AddSC_generic_spell_scripts()
{
new spell_gen_remove_flight_auras;
new spell_gen_pet_summoned;
}