mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Spells cleanup: move spells from the core to scripts. * Shaman spells: 39610 Mana Tide Totem, 1535 Fire Nova (and ranks) * Death Knight spells: 55090 Scourge Strike (and ranks), 49158 Corpse Explosion (and ranks), 50524 Runic Power Feed * Druid spells: 54846 Glyph of Starfire * Warlock spells: 6201 Create Healthstone (and ranks), 47422 Everlasting Affliction, 47193 Demonic Empowerment, 63521 Guarded by The Light * Hunter spells: 37506 Scatter Shot, 53412 Invigoration, 53209 Chimera Shot * Quest spells: 45449 Arcane Prisoner Rescue (quest 11587), 46023 The Ultrasonic Screwdriver (quest 11730). Closes issue #3068 Clean old code for hunter's Heart of the Phoenix, move script effect of hunter's Master's Call to corresponding script. Move DK's Hungering Cold to spell_scripts table (needs DB support) --HG-- branch : trunk
191 lines
7.2 KiB
C++
191 lines
7.2 KiB
C++
/*
|
|
* Copyright (C) 2008-2010 Trinity <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, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef __SPELL_SCRIPT_H
|
|
#define __SPELL_SCRIPT_H
|
|
|
|
#include "Util.h"
|
|
#include "SharedDefines.h"
|
|
|
|
class Unit;
|
|
struct SpellEntry;
|
|
class SpellScript;
|
|
class Spell;
|
|
class Creature;
|
|
class GameObject;
|
|
class Player;
|
|
class Item;
|
|
class WorldLocation;
|
|
|
|
typedef void(SpellScript::*EffectHandlerFnType)(SpellEffIndex);
|
|
|
|
#define SPELL_EFFECT_ANY (uint16)-1
|
|
#define SPELL_AURA_ANY (uint16)-1
|
|
|
|
// helper class from which SpellScript and SpellAura derive, use these classes instead
|
|
class _SpellScript
|
|
{
|
|
// internal use classes & functions
|
|
// DO NOT OVERRIDE THESE IN SCRIPTS
|
|
protected:
|
|
virtual bool _Validate(SpellEntry const * entry, const char * scriptname);
|
|
protected:
|
|
class EffectHook
|
|
{
|
|
public:
|
|
EffectHook(uint8 _effIndex);
|
|
uint8 GetAffectedEffectsMask(SpellEntry const * spellEntry);
|
|
bool IsEffectAffected(SpellEntry const * spellEntry, uint8 effIndex);
|
|
virtual bool CheckEffect(SpellEntry const * spellEntry, uint8 effIndex) = 0;
|
|
std::string EffIndexToString();
|
|
protected:
|
|
uint8 effIndex;
|
|
};
|
|
class EffectNameCheck
|
|
{
|
|
public:
|
|
EffectNameCheck(uint16 _effName) {effName = _effName;};
|
|
bool Check(SpellEntry const * spellEntry, uint8 effIndex);
|
|
std::string ToString();
|
|
private:
|
|
uint16 effName;
|
|
};
|
|
class EffectAuraNameCheck
|
|
{
|
|
public:
|
|
EffectAuraNameCheck(uint16 _effAurName) { effAurName = _effAurName; }
|
|
bool Check(SpellEntry const * spellEntry, uint8 effIndex);
|
|
std::string ToString();
|
|
private:
|
|
uint16 effAurName;
|
|
};
|
|
public:
|
|
//
|
|
// SpellScript/AuraScript interface base
|
|
// these functions are safe to override, see notes below for usage instructions
|
|
//
|
|
// Function in which handler functions are registered, must be implemented in script
|
|
virtual void Register() = 0;
|
|
// Function called on server startup, if returns false script won't be used in core
|
|
// use for: dbc/template data presence/correctness checks
|
|
virtual bool Validate(SpellEntry const * spellEntry) {return true;};
|
|
// Function called when script is created, if returns false script will be unloaded afterwards
|
|
// use for: initializing local script variables (DO NOT USE CONSTRUCTOR FOR THIS PURPOSE!)
|
|
virtual bool Load() {return true;};
|
|
// Function called when script is destroyed
|
|
// use for: deallocating memory allocated by script
|
|
virtual void Unload() {};
|
|
};
|
|
|
|
class SpellScript : public _SpellScript
|
|
{
|
|
// internal use classes & functions
|
|
// DO NOT OVERRIDE THESE IN SCRIPTS
|
|
public:
|
|
class EffectHandler : public _SpellScript::EffectNameCheck, public _SpellScript::EffectHook
|
|
{
|
|
public:
|
|
EffectHandler(EffectHandlerFnType _pEffectHandlerScript,uint8 _effIndex, uint16 _effName);
|
|
std::string ToString();
|
|
bool CheckEffect(SpellEntry const * spellEntry, uint8 effIndex);
|
|
void Call(SpellScript * spellScript, SpellEffIndex effIndex);
|
|
private:
|
|
EffectHandlerFnType pEffectHandlerScript;
|
|
};
|
|
public:
|
|
bool _Validate(SpellEntry const * entry, const char * scriptname);
|
|
bool _Load(Spell * spell);
|
|
private:
|
|
Spell * m_spell;
|
|
public:
|
|
//
|
|
// SpellScript interface
|
|
// hooks to which you can attach your functions
|
|
//
|
|
// List of functions registered by EffectHandlerFn
|
|
// allows more than one hook
|
|
// example EffectHandlers += EffectHandlerFn(class::function, EffectIndexSpecifier, EffectNameSpecifier);
|
|
HookList<EffectHandler> EffectHandlers;
|
|
|
|
//
|
|
// methods allowing interaction with Spell object
|
|
//
|
|
// methods useable during all spell handling phases
|
|
Unit * GetCaster();
|
|
Unit * GetOriginalCaster();
|
|
SpellEntry const * GetSpellInfo();
|
|
|
|
// methods useable after spell targets are set
|
|
// returns: destination of the spell if exists, otherwise NULL
|
|
WorldLocation * GetDest();
|
|
|
|
// methods useable only during spell hit on target phase:
|
|
|
|
// returns: target of current effect if it was Unit otherwise NULL
|
|
Unit * GetHitUnit();
|
|
// returns: target of current effect if it was Creature otherwise NULL
|
|
Creature * GetHitCreature();
|
|
// returns: target of current effect if it was Player otherwise NULL
|
|
Player * GetHitPlayer();
|
|
// returns: target of current effect if it was Item otherwise NULL
|
|
Item * GetHitItem();
|
|
// returns: target of current effect if it was GameObject otherwise NULL
|
|
GameObject * GetHitGObj();
|
|
// setter/getter for for damage done by spell to target of spell hit
|
|
int32 GetHitDamage();
|
|
void SetHitDamage(int32 damage);
|
|
// setter/getter for for heal done by spell to target of spell hit
|
|
int32 GetHitHeal();
|
|
void SetHitHeal(int32 heal);
|
|
|
|
// method avalible only in EffectHandler method
|
|
int32 GetEffectValue();
|
|
|
|
// returns: cast item if present.
|
|
Item * GetCastItem();
|
|
|
|
// Creates item. Calls Spell::DoCreateItem method.
|
|
void CreateItem(uint32 effIndex, uint32 itemId);
|
|
};
|
|
// SpellScript interface
|
|
//
|
|
// function registering macros, should be used only in Register()
|
|
//
|
|
// EffectHandlerFn
|
|
// called at: Spell hit on unit, just before default effect handler, called for effects matching EffectIndexSpecifier and EffectNameSpecifier conditions
|
|
// hook parameter is current effect index
|
|
// parameters: function to call, EffectIndexSpecifier, EffectNameSpecifier
|
|
#define EffectHandlerFn(F, I, N) EffectHandler((EffectHandlerFnType)&F, I, N)
|
|
|
|
//
|
|
// definitions:
|
|
//
|
|
// EffectIndexSpecifier - specifies conditions for effects
|
|
// EFFECT_0 - first effect matches
|
|
// EFFECT_1 - second effect matches
|
|
// EFFECT_2 - third effect matches
|
|
// EFFECT_FIRST_FOUND - first effect matching other conditions matches
|
|
// EFFECT_ALL - all effects of spell match
|
|
//
|
|
// EffectNameSpecifier - specifies conditions for spell effect names
|
|
// SPELL_EFFECT_ANY - any effect but not 0 matches condition
|
|
// SPELL_EFFECT_XXX - one of values of enum SpellEffects - effect with equal name matches
|
|
//
|
|
|
|
#endif // __SPELL_SCRIPT_H
|