TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SpellScript.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __SPELL_SCRIPT_H
19 #define __SPELL_SCRIPT_H
20 
21 #include "Util.h"
22 #include "SharedDefines.h"
23 #include "SpellAuraDefines.h"
24 #include "Spell.h"
25 #include <stack>
26 
27 class Unit;
28 class SpellInfo;
29 class SpellScript;
30 class Spell;
31 class Aura;
32 class AuraEffect;
33 struct SpellModifier;
34 class Creature;
35 class GameObject;
36 class DynamicObject;
37 class Player;
38 class Item;
39 class WorldLocation;
40 class WorldObject;
41 
42 #define SPELL_EFFECT_ANY (uint16)-1
43 #define SPELL_AURA_ANY (uint16)-1
44 
46 {
51 };
52 #define SPELL_SCRIPT_STATE_END SPELL_SCRIPT_STATE_UNLOADING + 1
53 
54 // helper class from which SpellScript and SpellAura derive, use these classes instead
56 {
57  // internal use classes & functions
58  // DO NOT OVERRIDE THESE IN SCRIPTS
59  protected:
60  virtual bool _Validate(SpellInfo const* entry);
61 
62  public:
63  _SpellScript() : m_currentScriptState(SPELL_SCRIPT_STATE_NONE), m_scriptName(NULL), m_scriptSpellId(0) {}
64  virtual ~_SpellScript() { }
65  virtual void _Register();
66  virtual void _Unload();
67  virtual void _Init(std::string const* scriptname, uint32 spellId);
68  std::string const* _GetScriptName() const;
69 
70  protected:
72  {
73  public:
74  EffectHook(uint8 _effIndex);
75  virtual ~EffectHook() { }
76 
77  uint32 GetAffectedEffectsMask(SpellInfo const* spellInfo);
78  bool IsEffectAffected(SpellInfo const* spellInfo, uint8 effIndex);
79  virtual bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) = 0;
80  std::string EffIndexToString();
81  protected:
83  };
84 
86  {
87  public:
88  EffectNameCheck(uint16 _effName) { effName = _effName; }
89  bool Check(SpellInfo const* spellInfo, uint8 effIndex);
90  std::string ToString();
91  private:
93  };
94 
96  {
97  public:
98  EffectAuraNameCheck(uint16 _effAurName) { effAurName = _effAurName; }
99  bool Check(SpellInfo const* spellInfo, uint8 effIndex);
100  std::string ToString();
101  private:
103  };
104 
106  std::string const* m_scriptName;
108  public:
109  //
110  // SpellScript/AuraScript interface base
111  // these functions are safe to override, see notes below for usage instructions
112  //
113  // Function in which handler functions are registered, must be implemented in script
114  virtual void Register() = 0;
115  // Function called on server startup, if returns false script won't be used in core
116  // use for: dbc/template data presence/correctness checks
117  virtual bool Validate(SpellInfo const* /*spellInfo*/) { return true; }
118  // Function called when script is created, if returns false script will be unloaded afterwards
119  // use for: initializing local script variables (DO NOT USE CONSTRUCTOR FOR THIS PURPOSE!)
120  virtual bool Load() { return true; }
121  // Function called when script is destroyed
122  // use for: deallocating memory allocated by script
123  virtual void Unload() { }
124 };
125 
126 // SpellScript interface - enum used for runtime checks of script function calls
128 {
144 };
145 
146 #define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT_HIT
147 #define HOOK_SPELL_HIT_END SPELL_SCRIPT_HOOK_AFTER_HIT + 1
148 #define HOOK_SPELL_START SPELL_SCRIPT_HOOK_EFFECT
149 #define HOOK_SPELL_END SPELL_SCRIPT_HOOK_CHECK_CAST + 1
150 #define HOOK_SPELL_COUNT HOOK_SPELL_END - HOOK_SPELL_START
151 
153 {
154  // internal use classes & functions
155  // DO NOT OVERRIDE THESE IN SCRIPTS
156  public:
157  #define SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) \
158  typedef SpellCastResult(CLASSNAME::*SpellCheckCastFnType)(); \
159  typedef void(CLASSNAME::*SpellEffectFnType)(SpellEffIndex); \
160  typedef void(CLASSNAME::*SpellHitFnType)(); \
161  typedef void(CLASSNAME::*SpellCastFnType)(); \
162  typedef void(CLASSNAME::*SpellObjectAreaTargetSelectFnType)(std::list<WorldObject*>&); \
163  typedef void(CLASSNAME::*SpellObjectTargetSelectFnType)(WorldObject*&); \
164  typedef void(CLASSNAME::*SpellDestinationTargetSelectFnType)(SpellDestination&);
165 
167 
169  {
170  public:
171  CastHandler(SpellCastFnType _pCastHandlerScript);
172  void Call(SpellScript* spellScript);
173  private:
174  SpellCastFnType pCastHandlerScript;
175  };
176 
178  {
179  public:
180  CheckCastHandler(SpellCheckCastFnType checkCastHandlerScript);
181  SpellCastResult Call(SpellScript* spellScript);
182  private:
183  SpellCheckCastFnType _checkCastHandlerScript;
184  };
185 
187  {
188  public:
189  EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
190  std::string ToString();
191  bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
192  void Call(SpellScript* spellScript, SpellEffIndex effIndex);
193  private:
194  SpellEffectFnType pEffectHandlerScript;
195  };
196 
198  {
199  public:
200  HitHandler(SpellHitFnType _pHitHandlerScript);
201  void Call(SpellScript* spellScript);
202  private:
203  SpellHitFnType pHitHandlerScript;
204  };
205 
207  {
208  public:
209  TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest);
210  bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
211  std::string ToString();
212  uint16 GetTarget() const { return targetType; }
213  protected:
215  bool area;
216  bool dest;
217  };
218 
220  {
221  public:
222  ObjectAreaTargetSelectHandler(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType);
223  void Call(SpellScript* spellScript, std::list<WorldObject*>& targets);
224  private:
225  SpellObjectAreaTargetSelectFnType pObjectAreaTargetSelectHandlerScript;
226  };
227 
229  {
230  public:
231  ObjectTargetSelectHandler(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType);
232  void Call(SpellScript* spellScript, WorldObject*& target);
233  private:
234  SpellObjectTargetSelectFnType pObjectTargetSelectHandlerScript;
235  };
236 
238  {
239  public:
240  DestinationTargetSelectHandler(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType);
241  void Call(SpellScript* spellScript, SpellDestination& target);
242  private:
243  SpellDestinationTargetSelectFnType DestinationTargetSelectHandlerScript;
244  };
245 
246  #define SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) \
247  class CastHandlerFunction : public SpellScript::CastHandler { public: CastHandlerFunction(SpellCastFnType _pCastHandlerScript) : SpellScript::CastHandler((SpellScript::SpellCastFnType)_pCastHandlerScript) { } }; \
248  class CheckCastHandlerFunction : public SpellScript::CheckCastHandler { public: CheckCastHandlerFunction(SpellCheckCastFnType _checkCastHandlerScript) : SpellScript::CheckCastHandler((SpellScript::SpellCheckCastFnType)_checkCastHandlerScript) { } }; \
249  class EffectHandlerFunction : public SpellScript::EffectHandler { public: EffectHandlerFunction(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : SpellScript::EffectHandler((SpellScript::SpellEffectFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
250  class HitHandlerFunction : public SpellScript::HitHandler { public: HitHandlerFunction(SpellHitFnType _pHitHandlerScript) : SpellScript::HitHandler((SpellScript::SpellHitFnType)_pHitHandlerScript) { } }; \
251  class ObjectAreaTargetSelectHandlerFunction : public SpellScript::ObjectAreaTargetSelectHandler { public: ObjectAreaTargetSelectHandlerFunction(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectAreaTargetSelectHandler((SpellScript::SpellObjectAreaTargetSelectFnType)_pObjectAreaTargetSelectHandlerScript, _effIndex, _targetType) { } }; \
252  class ObjectTargetSelectHandlerFunction : public SpellScript::ObjectTargetSelectHandler { public: ObjectTargetSelectHandlerFunction(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectTargetSelectHandler((SpellScript::SpellObjectTargetSelectFnType)_pObjectTargetSelectHandlerScript, _effIndex, _targetType) { } }; \
253  class DestinationTargetSelectHandlerFunction : public SpellScript::DestinationTargetSelectHandler { public: DestinationTargetSelectHandlerFunction(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::DestinationTargetSelectHandler((SpellScript::SpellDestinationTargetSelectFnType)_DestinationTargetSelectHandlerScript, _effIndex, _targetType) { } }
254 
255  #define PrepareSpellScript(CLASSNAME) SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
256  public:
257  bool _Validate(SpellInfo const* entry) override;
258  bool _Load(Spell* spell);
259  void _InitHit();
260  bool _IsEffectPrevented(SpellEffIndex effIndex) { return (m_hitPreventEffectMask & (1 << effIndex)) != 0; }
261  bool _IsDefaultEffectPrevented(SpellEffIndex effIndex) { return (m_hitPreventDefaultEffectMask & (1 << effIndex)) != 0; }
263  void _FinishScriptCall();
264  bool IsInCheckCastHook() const;
265  bool IsInTargetHook() const;
266  bool IsInHitPhase() const;
267  bool IsInEffectHook() const;
268  private:
272  public:
273  //
274  // SpellScript interface
275  // hooks to which you can attach your functions
276  //
277  // example: BeforeCast += SpellCastFn(class::function);
279  // example: OnCast += SpellCastFn(class::function);
281  // example: AfterCast += SpellCastFn(class::function);
283  #define SpellCastFn(F) CastHandlerFunction(&F)
284 
285  // example: OnCheckCast += SpellCheckCastFn();
286  // where function is SpellCastResult function()
288  #define SpellCheckCastFn(F) CheckCastHandlerFunction(&F)
289 
290  // example: OnEffect**** += SpellEffectFn(class::function, EffectIndexSpecifier, EffectNameSpecifier);
291  // where function is void function(SpellEffIndex effIndex)
297  #define SpellEffectFn(F, I, N) EffectHandlerFunction(&F, I, N)
298 
299  // example: BeforeHit += SpellHitFn(class::function);
301  // example: OnHit += SpellHitFn(class::function);
303  // example: AfterHit += SpellHitFn(class::function);
305  // where function is: void function()
306  #define SpellHitFn(F) HitHandlerFunction(&F)
307 
308  // example: OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(class::function, EffectIndexSpecifier, TargetsNameSpecifier);
309  // where function is void function(std::list<WorldObject*>& targets)
311  #define SpellObjectAreaTargetSelectFn(F, I, N) ObjectAreaTargetSelectHandlerFunction(&F, I, N)
312 
313  // example: OnObjectTargetSelect += SpellObjectTargetSelectFn(class::function, EffectIndexSpecifier, TargetsNameSpecifier);
314  // where function is void function(WorldObject*& target)
316  #define SpellObjectTargetSelectFn(F, I, N) ObjectTargetSelectHandlerFunction(&F, I, N)
317 
318  // example: OnDestinationTargetSelect += SpellDestinationTargetSelectFn(class::function, EffectIndexSpecifier, TargetsNameSpecifier);
319  // where function is void function(SpellDestination& target)
321  #define SpellDestinationTargetSelectFn(F, I, N) DestinationTargetSelectHandlerFunction(&F, I, N)
322 
323  // hooks are executed in following order, at specified event of spell:
324  // 1. BeforeCast - executed when spell preparation is finished (when cast bar becomes full) before cast is handled
325  // 2. OnCheckCast - allows to override result of CheckCast function
326  // 3a. OnObjectAreaTargetSelect - executed just before adding selected targets to final target list (for area targets)
327  // 3b. OnObjectTargetSelect - executed just before adding selected target to final target list (for single unit targets)
328  // 3c. OnDestinationTargetSelect - executed just before adding selected target to final target list (for destination targets)
329  // 4. OnCast - executed just before spell is launched (creates missile) or executed
330  // 5. AfterCast - executed after spell missile is launched and immediate spell actions are done
331  // 6. OnEffectLaunch - executed just before specified effect handler call - when spell missile is launched
332  // 7. OnEffectLaunchTarget - executed just before specified effect handler call - when spell missile is launched - called for each target from spell target map
333  // 8. OnEffectHit - executed just before specified effect handler call - when spell missile hits dest
334  // 9. BeforeHit - executed just before spell hits a target - called for each target from spell target map
335  // 10. OnEffectHitTarget - executed just before specified effect handler call - called for each target from spell target map
336  // 11. OnHit - executed just before spell deals damage and procs auras - when spell hits target - called for each target from spell target map
337  // 12. AfterHit - executed just after spell finishes all it's jobs for target - called for each target from spell target map
338 
339  // this hook is only executed after a successful dispel of any aura
340  // OnEffectSuccessfulDispel - executed just after effect successfully dispelled aura(s)
341 
342  //
343  // methods allowing interaction with Spell object
344  //
345  // methods useable during all spell handling phases
346  Unit* GetCaster();
348  SpellInfo const* GetSpellInfo();
349  SpellValue const* GetSpellValue();
351 
352  // methods useable after spell is prepared
353  // accessors to the explicit targets of the spell
354  // explicit target - target selected by caster (player, game client, or script - DoCast(explicitTarget, ...), required for spell to be cast
355  // examples:
356  // -shadowstep - explicit target is the unit you want to go behind of
357  // -chain heal - explicit target is the unit to be healed first
358  // -holy nova/arcane explosion - explicit target = NULL because target you are selecting doesn't affect how spell targets are selected
359  // you can determine if spell requires explicit targets by dbc columns:
360  // - Targets - mask of explicit target types
361  // - ImplicitTargetXX set to TARGET_XXX_TARGET_YYY, _TARGET_ here means that explicit target is used by the effect, so spell needs one too
362 
363  // returns: WorldLocation which was selected as a spell destination or NULL
365 
366  void SetExplTargetDest(WorldLocation& loc);
367 
368  // returns: WorldObject which was selected as an explicit spell target or NULL if there's no target
370 
371  // returns: Unit which was selected as an explicit spell target or NULL if there's no target
373 
374  // returns: GameObject which was selected as an explicit spell target or NULL if there's no target
376 
377  // returns: Item which was selected as an explicit spell target or NULL if there's no target
379 
380  // methods useable only during spell hit on target, or during spell launch on target:
381  // returns: target of current effect if it was Unit otherwise NULL
382  Unit* GetHitUnit();
383  // returns: target of current effect if it was Creature otherwise NULL
385  // returns: target of current effect if it was Player otherwise NULL
386  Player* GetHitPlayer();
387  // returns: target of current effect if it was Item otherwise NULL
388  Item* GetHitItem();
389  // returns: target of current effect if it was GameObject otherwise NULL
391  // returns: destination of current effect
393  // setter/getter for for damage done by spell to target of spell hit
394  // returns damage calculated before hit, and real dmg done after hit
396  void SetHitDamage(int32 damage);
398  // setter/getter for for heal done by spell to target of spell hit
399  // returns healing calculated before hit, and real dmg done after hit
400  int32 GetHitHeal();
401  void SetHitHeal(int32 heal);
402  void PreventHitHeal() { SetHitHeal(0); }
403  Spell* GetSpell() { return m_spell; }
404  // returns current spell hit target aura
405  Aura* GetHitAura();
406  // prevents applying aura on current spell hit target
407  void PreventHitAura();
408 
409  // prevents effect execution on current spell hit target
410  // including other effect/hit scripts
411  // will not work on aura/damage/heal
412  // will not work if effects were already handled
413  void PreventHitEffect(SpellEffIndex effIndex);
414 
415  // prevents default effect execution on current spell hit target
416  // will not work on aura/damage/heal effects
417  // will not work if effects were already handled
418  void PreventHitDefaultEffect(SpellEffIndex effIndex);
419 
420  // method available only in EffectHandler method
421  SpellEffectInfo const* GetEffectInfo() const;
422  int32 GetEffectValue() const;
423  void SetEffectValue(int32 value);
424 
425  // returns: cast item if present.
426  Item* GetCastItem();
427 
428  // Creates item. Calls Spell::DoCreateItem method.
429  void CreateItem(uint32 effIndex, uint32 itemId);
430 
431  // Returns SpellInfo from the spell that triggered the current one
432  SpellInfo const* GetTriggeringSpell();
433 
434  // finishes spellcast prematurely with selected error message
435  void FinishCast(SpellCastResult result);
436 
438 };
439 
440 // AuraScript interface - enum used for runtime checks of script function calls
442 {
460  // Spell Proc Hooks
467  /*AURA_SCRIPT_HOOK_APPLY,
468  AURA_SCRIPT_HOOK_REMOVE, */
469 };
470 /*
471 #define HOOK_AURA_EFFECT_START HOOK_AURA_EFFECT_APPLY
472 #define HOOK_AURA_EFFECT_END HOOK_AURA_EFFECT_CALC_SPELLMOD + 1
473 #define HOOK_AURA_EFFECT_COUNT HOOK_AURA_EFFECT_END - HOOK_AURA_EFFECT_START
474 */
476 {
477  // internal use classes & functions
478  // DO NOT OVERRIDE THESE IN SCRIPTS
479  public:
480 
481  #define AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) \
482  typedef bool(CLASSNAME::*AuraCheckAreaTargetFnType)(Unit* target); \
483  typedef void(CLASSNAME::*AuraDispelFnType)(DispelInfo* dispelInfo); \
484  typedef void(CLASSNAME::*AuraEffectApplicationModeFnType)(AuraEffect const*, AuraEffectHandleModes); \
485  typedef void(CLASSNAME::*AuraEffectPeriodicFnType)(AuraEffect const*); \
486  typedef void(CLASSNAME::*AuraEffectUpdatePeriodicFnType)(AuraEffect*); \
487  typedef void(CLASSNAME::*AuraEffectCalcAmountFnType)(AuraEffect const*, int32 &, bool &); \
488  typedef void(CLASSNAME::*AuraEffectCalcPeriodicFnType)(AuraEffect const*, bool &, int32 &); \
489  typedef void(CLASSNAME::*AuraEffectCalcSpellModFnType)(AuraEffect const*, SpellModifier* &); \
490  typedef void(CLASSNAME::*AuraEffectAbsorbFnType)(AuraEffect*, DamageInfo &, uint32 &); \
491  typedef void(CLASSNAME::*AuraEffectSplitFnType)(AuraEffect*, DamageInfo &, uint32 &); \
492  typedef bool(CLASSNAME::*AuraCheckProcFnType)(ProcEventInfo&); \
493  typedef void(CLASSNAME::*AuraProcFnType)(ProcEventInfo&); \
494  typedef void(CLASSNAME::*AuraEffectProcFnType)(AuraEffect const*, ProcEventInfo&); \
495 
497 
499  {
500  public:
501  CheckAreaTargetHandler(AuraCheckAreaTargetFnType pHandlerScript);
502  bool Call(AuraScript* auraScript, Unit* target);
503  private:
504  AuraCheckAreaTargetFnType pHandlerScript;
505  };
507  {
508  public:
509  AuraDispelHandler(AuraDispelFnType pHandlerScript);
510  void Call(AuraScript* auraScript, DispelInfo* dispelInfo);
511  private:
512  AuraDispelFnType pHandlerScript;
513  };
515  {
516  public:
517  EffectBase(uint8 _effIndex, uint16 _effName);
518  std::string ToString();
519  bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
520  };
522  {
523  public:
524  EffectPeriodicHandler(AuraEffectPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
525  void Call(AuraScript* auraScript, AuraEffect const* _aurEff);
526  private:
527  AuraEffectPeriodicFnType pEffectHandlerScript;
528  };
530  {
531  public:
532  EffectUpdatePeriodicHandler(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
533  void Call(AuraScript* auraScript, AuraEffect* aurEff);
534  private:
535  AuraEffectUpdatePeriodicFnType pEffectHandlerScript;
536  };
538  {
539  public:
540  EffectCalcAmountHandler(AuraEffectCalcAmountFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
541  void Call(AuraScript* auraScript, AuraEffect const* aurEff, int32 & amount, bool & canBeRecalculated);
542  private:
543  AuraEffectCalcAmountFnType pEffectHandlerScript;
544  };
546  {
547  public:
548  EffectCalcPeriodicHandler(AuraEffectCalcPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
549  void Call(AuraScript* auraScript, AuraEffect const* aurEff, bool & isPeriodic, int32 & periodicTimer);
550  private:
551  AuraEffectCalcPeriodicFnType pEffectHandlerScript;
552  };
554  {
555  public:
556  EffectCalcSpellModHandler(AuraEffectCalcSpellModFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
557  void Call(AuraScript* auraScript, AuraEffect const* aurEff, SpellModifier* & spellMod);
558  private:
559  AuraEffectCalcSpellModFnType pEffectHandlerScript;
560  };
562  {
563  public:
564  EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode);
565  void Call(AuraScript* auraScript, AuraEffect const* _aurEff, AuraEffectHandleModes _mode);
566  private:
567  AuraEffectApplicationModeFnType pEffectHandlerScript;
569  };
571  {
572  public:
573  EffectAbsorbHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex);
574  void Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount);
575  private:
576  AuraEffectAbsorbFnType pEffectHandlerScript;
577  };
579  {
580  public:
581  EffectManaShieldHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex);
582  void Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount);
583  private:
584  AuraEffectAbsorbFnType pEffectHandlerScript;
585  };
587  {
588  public:
589  EffectSplitHandler(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex);
590  void Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & splitAmount);
591  private:
592  AuraEffectSplitFnType pEffectHandlerScript;
593  };
595  {
596  public:
597  CheckProcHandler(AuraCheckProcFnType handlerScript);
598  bool Call(AuraScript* auraScript, ProcEventInfo& eventInfo);
599  private:
600  AuraCheckProcFnType _HandlerScript;
601  };
603  {
604  public:
605  AuraProcHandler(AuraProcFnType handlerScript);
606  void Call(AuraScript* auraScript, ProcEventInfo& eventInfo);
607  private:
608  AuraProcFnType _HandlerScript;
609  };
611  {
612  public:
613  EffectProcHandler(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName);
614  void Call(AuraScript* auraScript, AuraEffect const* aurEff, ProcEventInfo& eventInfo);
615  private:
616  AuraEffectProcFnType _EffectHandlerScript;
617  };
618 
619  #define AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) \
620  class CheckAreaTargetFunction : public AuraScript::CheckAreaTargetHandler { public: CheckAreaTargetFunction(AuraCheckAreaTargetFnType _pHandlerScript) : AuraScript::CheckAreaTargetHandler((AuraScript::AuraCheckAreaTargetFnType)_pHandlerScript) { } }; \
621  class AuraDispelFunction : public AuraScript::AuraDispelHandler { public: AuraDispelFunction(AuraDispelFnType _pHandlerScript) : AuraScript::AuraDispelHandler((AuraScript::AuraDispelFnType)_pHandlerScript) { } }; \
622  class EffectPeriodicHandlerFunction : public AuraScript::EffectPeriodicHandler { public: EffectPeriodicHandlerFunction(AuraEffectPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectPeriodicHandler((AuraScript::AuraEffectPeriodicFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
623  class EffectUpdatePeriodicHandlerFunction : public AuraScript::EffectUpdatePeriodicHandler { public: EffectUpdatePeriodicHandlerFunction(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectUpdatePeriodicHandler((AuraScript::AuraEffectUpdatePeriodicFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
624  class EffectCalcAmountHandlerFunction : public AuraScript::EffectCalcAmountHandler { public: EffectCalcAmountHandlerFunction(AuraEffectCalcAmountFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectCalcAmountHandler((AuraScript::AuraEffectCalcAmountFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
625  class EffectCalcPeriodicHandlerFunction : public AuraScript::EffectCalcPeriodicHandler { public: EffectCalcPeriodicHandlerFunction(AuraEffectCalcPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectCalcPeriodicHandler((AuraScript::AuraEffectCalcPeriodicFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
626  class EffectCalcSpellModHandlerFunction : public AuraScript::EffectCalcSpellModHandler { public: EffectCalcSpellModHandlerFunction(AuraEffectCalcSpellModFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectCalcSpellModHandler((AuraScript::AuraEffectCalcSpellModFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
627  class EffectApplyHandlerFunction : public AuraScript::EffectApplyHandler { public: EffectApplyHandlerFunction(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode) : AuraScript::EffectApplyHandler((AuraScript::AuraEffectApplicationModeFnType)_pEffectHandlerScript, _effIndex, _effName, _mode) { } }; \
628  class EffectAbsorbFunction : public AuraScript::EffectAbsorbHandler { public: EffectAbsorbFunction(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectAbsorbHandler((AuraScript::AuraEffectAbsorbFnType)_pEffectHandlerScript, _effIndex) { } }; \
629  class EffectManaShieldFunction : public AuraScript::EffectManaShieldHandler { public: EffectManaShieldFunction(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectManaShieldHandler((AuraScript::AuraEffectAbsorbFnType)_pEffectHandlerScript, _effIndex) { } }; \
630  class EffectSplitFunction : public AuraScript::EffectSplitHandler { public: EffectSplitFunction(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectSplitHandler((AuraScript::AuraEffectSplitFnType)_pEffectHandlerScript, _effIndex) { } }; \
631  class CheckProcHandlerFunction : public AuraScript::CheckProcHandler { public: CheckProcHandlerFunction(AuraCheckProcFnType handlerScript) : AuraScript::CheckProcHandler((AuraScript::AuraCheckProcFnType)handlerScript) { } }; \
632  class AuraProcHandlerFunction : public AuraScript::AuraProcHandler { public: AuraProcHandlerFunction(AuraProcFnType handlerScript) : AuraScript::AuraProcHandler((AuraScript::AuraProcFnType)handlerScript) { } }; \
633  class EffectProcHandlerFunction : public AuraScript::EffectProcHandler { public: EffectProcHandlerFunction(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName) : AuraScript::EffectProcHandler((AuraScript::AuraEffectProcFnType)effectHandlerScript, effIndex, effName) { } }
634 
635  #define PrepareAuraScript(CLASSNAME) AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
636 
637  public:
638  AuraScript() : _SpellScript(), m_aura(NULL), m_auraApplication(NULL), m_defaultActionPrevented(false)
639  { }
640  bool _Validate(SpellInfo const* entry) override;
641  bool _Load(Aura* aura);
642  void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const* aurApp = NULL);
643  void _FinishScriptCall();
645  private:
649 
651  {
652  public:
656  ScriptStateStore(uint8 currentScriptState, AuraApplication const* auraApplication, bool defaultActionPrevented)
657  : _auraApplication(auraApplication), _currentScriptState(currentScriptState), _defaultActionPrevented(defaultActionPrevented)
658  { }
659  };
660  typedef std::stack<ScriptStateStore> ScriptStateStack;
661  ScriptStateStack m_scriptStates;
662 
663  public:
664  //
665  // AuraScript interface
666  // hooks to which you can attach your functions
667  //
668  // executed when area aura checks if it can be applied on target
669  // example: OnEffectApply += AuraEffectApplyFn(class::function);
670  // where function is: bool function (Unit* target);
672  #define AuraCheckAreaTargetFn(F) CheckAreaTargetFunction(&F)
673 
674  // executed when aura is dispelled by a unit
675  // example: OnDispel += AuraDispelFn(class::function);
676  // where function is: void function (DispelInfo* dispelInfo);
678  // executed after aura is dispelled by a unit
679  // example: AfterDispel += AuraDispelFn(class::function);
680  // where function is: void function (DispelInfo* dispelInfo);
682  #define AuraDispelFn(F) AuraDispelFunction(&F)
683 
684  // executed when aura effect is applied with specified mode to target
685  // should be used when when effect handler preventing/replacing is needed, do not use this hook for triggering spellcasts/removing auras etc - may be unsafe
686  // example: OnEffectApply += AuraEffectApplyFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
687  // where function is: void function (AuraEffect const* aurEff, AuraEffectHandleModes mode);
689  // executed after aura effect is applied with specified mode to target
690  // example: AfterEffectApply += AuraEffectApplyFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
691  // where function is: void function (AuraEffect const* aurEff, AuraEffectHandleModes mode);
693  #define AuraEffectApplyFn(F, I, N, M) EffectApplyHandlerFunction(&F, I, N, M)
694 
695  // executed after aura effect is removed with specified mode from target
696  // should be used when when effect handler preventing/replacing is needed, do not use this hook for triggering spellcasts/removing auras etc - may be unsafe
697  // example: OnEffectRemove += AuraEffectRemoveFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
698  // where function is: void function (AuraEffect const* aurEff, AuraEffectHandleModes mode);
700  // executed when aura effect is removed with specified mode from target
701  // example: AfterEffectRemove += AuraEffectRemoveFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
702  // where function is: void function (AuraEffect const* aurEff, AuraEffectHandleModes mode);
704  #define AuraEffectRemoveFn(F, I, N, M) EffectApplyHandlerFunction(&F, I, N, M)
705 
706  // executed when periodic aura effect ticks on target
707  // example: OnEffectPeriodic += AuraEffectPeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
708  // where function is: void function (AuraEffect const* aurEff);
710  #define AuraEffectPeriodicFn(F, I, N) EffectPeriodicHandlerFunction(&F, I, N)
711 
712  // executed when periodic aura effect is updated
713  // example: OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
714  // where function is: void function (AuraEffect* aurEff);
716  #define AuraEffectUpdatePeriodicFn(F, I, N) EffectUpdatePeriodicHandlerFunction(&F, I, N)
717 
718  // executed when aura effect calculates amount
719  // example: DoEffectCalcAmount += AuraEffectCalcAmounFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
720  // where function is: void function (AuraEffect* aurEff, int32& amount, bool& canBeRecalculated);
722  #define AuraEffectCalcAmountFn(F, I, N) EffectCalcAmountHandlerFunction(&F, I, N)
723 
724  // executed when aura effect calculates periodic data
725  // example: DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
726  // where function is: void function (AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude);
728  #define AuraEffectCalcPeriodicFn(F, I, N) EffectCalcPeriodicHandlerFunction(&F, I, N)
729 
730  // executed when aura effect calculates spellmod
731  // example: DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
732  // where function is: void function (AuraEffect const* aurEff, SpellModifier*& spellMod);
734  #define AuraEffectCalcSpellModFn(F, I, N) EffectCalcSpellModHandlerFunction(&F, I, N)
735 
736  // executed when absorb aura effect is going to reduce damage
737  // example: OnEffectAbsorb += AuraEffectAbsorbFn(class::function, EffectIndexSpecifier);
738  // where function is: void function (AuraEffect const* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
740  #define AuraEffectAbsorbFn(F, I) EffectAbsorbFunction(&F, I)
741 
742  // executed after absorb aura effect reduced damage to target - absorbAmount is real amount absorbed by aura
743  // example: AfterEffectAbsorb += AuraEffectAbsorbFn(class::function, EffectIndexSpecifier);
744  // where function is: void function (AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
746 
747  // executed when mana shield aura effect is going to reduce damage
748  // example: OnEffectManaShield += AuraEffectAbsorbFn(class::function, EffectIndexSpecifier);
749  // where function is: void function (AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
751  #define AuraEffectManaShieldFn(F, I) EffectManaShieldFunction(&F, I)
752 
753  // executed after mana shield aura effect reduced damage to target - absorbAmount is real amount absorbed by aura
754  // example: AfterEffectManaShield += AuraEffectAbsorbFn(class::function, EffectIndexSpecifier);
755  // where function is: void function (AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
757 
758  // executed when the caster of some spell with split dmg aura gets damaged through it
759  // example: OnEffectSplit += AuraEffectSplitFn(class::function, EffectIndexSpecifier);
760  // where function is: void function (AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& splitAmount);
762  #define AuraEffectSplitFn(F, I) EffectSplitFunction(&F, I)
763 
764  // executed when aura checks if it can proc
765  // example: DoCheckProc += AuraCheckProcFn(class::function);
766  // where function is: bool function (ProcEventInfo& eventInfo);
768  #define AuraCheckProcFn(F) CheckProcHandlerFunction(&F)
769 
770  // executed before aura procs (possibility to prevent charge drop/cooldown)
771  // example: DoPrepareProc += AuraProcFn(class::function);
772  // where function is: void function (ProcEventInfo& eventInfo);
774  // executed when aura procs
775  // example: OnProc += AuraProcFn(class::function);
776  // where function is: void function (ProcEventInfo& eventInfo);
778  // executed after aura proced
779  // example: AfterProc += AuraProcFn(class::function);
780  // where function is: void function (ProcEventInfo& eventInfo);
782  #define AuraProcFn(F) AuraProcHandlerFunction(&F)
783 
784  // executed when aura effect procs
785  // example: OnEffectProc += AuraEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
786  // where function is: void function (AuraEffect const* aurEff, ProcEventInfo& procInfo);
788  // executed after aura effect proced
789  // example: AfterEffectProc += AuraEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
790  // where function is: void function (AuraEffect const* aurEff, ProcEventInfo& procInfo);
792  #define AuraEffectProcFn(F, I, N) EffectProcHandlerFunction(&F, I, N)
793 
794  // AuraScript interface - hook/effect execution manipulators
795 
796  // prevents default action of a hook from being executed (works only while called in a hook which default action can be prevented)
797  void PreventDefaultAction();
798 
799  // AuraScript interface - functions which are redirecting to Aura class
800 
801  // returns proto of the spell
802  SpellInfo const* GetSpellInfo() const;
803  // returns spellid of the spell
804  uint32 GetId() const;
805 
806  // returns guid of object which cast the aura (m_originalCaster of the Spell class)
807  ObjectGuid GetCasterGUID() const;
808  // returns unit which cast the aura or NULL if not avalible (caster logged out for example)
809  Unit* GetCaster() const;
810  // returns object on which aura was cast, target for non-area auras, area aura source for area auras
811  WorldObject* GetOwner() const;
812  // returns owner if it's unit or unit derived object, NULL otherwise (only for persistent area auras NULL is returned)
813  Unit* GetUnitOwner() const;
814  // returns owner if it's dynobj, NULL otherwise
815  DynamicObject* GetDynobjOwner() const;
816 
817  // removes aura with remove mode (see AuraRemoveMode enum)
818  void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
819  // returns aura object of script
820  Aura* GetAura() const;
821 
822  // returns type of the aura, may be dynobj owned aura or unit owned aura
823  AuraObjectType GetType() const;
824 
825  // aura duration manipulation - when duration goes to 0 aura is removed
826  int32 GetDuration() const;
827  void SetDuration(int32 duration, bool withMods = false);
828  // sets duration to maxduration
829  void RefreshDuration();
830  time_t GetApplyTime() const;
831  int32 GetMaxDuration() const;
832  void SetMaxDuration(int32 duration);
833  int32 CalcMaxDuration() const;
834  // expired - duration just went to 0
835  bool IsExpired() const;
836  // permament - has infinite duration
837  bool IsPermanent() const;
838 
839  // charges manipulation - 0 - not charged aura
840  uint8 GetCharges() const;
841  void SetCharges(uint8 charges);
842  uint8 CalcMaxCharges() const;
843  bool ModCharges(int8 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
844  // returns true if last charge dropped
845  bool DropCharge(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
846 
847  // stack amount manipulation
848  uint8 GetStackAmount() const;
849  void SetStackAmount(uint8 num);
850  bool ModStackAmount(int32 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
851 
852  // passive - "working in background", not saved, not removed by immunities, not seen by player
853  bool IsPassive() const;
854  // death persistent - not removed on death
855  bool IsDeathPersistent() const;
856 
857  // check if aura has effect of given effindex
858  bool HasEffect(uint8 effIndex) const;
859  // returns aura effect of given effect index or NULL
860  AuraEffect* GetEffect(uint8 effIndex) const;
861 
862  // check if aura has effect of given aura type
863  bool HasEffectType(AuraType type) const;
864 
865  // AuraScript interface - functions which are redirecting to AuraApplication class
866  // Do not call these in hooks in which AuraApplication is not avalible, otherwise result will differ from expected (the functions will return NULL)
867 
868  // returns currently processed target of an aura
869  // Return value does not need to be NULL-checked, the only situation this will (always)
870  // return NULL is when the call happens in an unsupported hook, in other cases, it is always valid
871  Unit* GetTarget() const;
872  // returns AuraApplication object of currently processed target
873  AuraApplication const* GetTargetApplication() const;
874 };
875 
876 //
877 // definitions:
878 //
879 // EffectIndexSpecifier - specifies conditions for effects
880 // EFFECT_0 - first effect matches
881 // EFFECT_1 - second effect matches
882 // EFFECT_2 - third effect matches
883 // EFFECT_FIRST_FOUND - first effect matching other conditions matches
884 // EFFECT_ALL - all effects of spell match
885 //
886 // EffectNameSpecifier - specifies conditions for spell effect names
887 // SPELL_EFFECT_ANY - any effect but not 0 matches condition
888 // SPELL_EFFECT_XXX - one of values of enum SpellEffects - effect with equal name matches
889 //
890 
891 #endif // __SPELL_SCRIPT_H
SpellScriptHookType
Definition: SpellScript.h:127
Definition: SpellScript.h:135
bool _defaultActionPrevented
Definition: SpellScript.h:655
Definition: SpellScript.h:578
AuraType
Definition: SpellAuraDefines.h:58
bool Remove(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *)
Definition: TypeContainerFunctions.h:104
Definition: SpellAuraEffects.h:30
SpellEffectInfo const * GetEffectInfo() const
Definition: SpellScript.cpp:593
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Definition: SpellScript.cpp:583
bool _IsDefaultActionPrevented()
Definition: SpellScript.cpp:952
Definition: SpellScript.h:138
Definition: SpellScript.h:131
HookList< EffectAbsorbHandler > AfterEffectAbsorb
Definition: SpellScript.h:745
uint16 effName
Definition: SpellScript.h:92
GameObject * GetExplTargetGObj()
Definition: SpellScript.cpp:431
Definition: SpellScript.h:48
Unit * GetExplTargetUnit()
Definition: SpellScript.cpp:426
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:692
Definition: SpellScript.h:95
Definition: SpellScript.h:456
Definition: Position.h:228
Definition: SpellScript.h:168
virtual bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex)=0
std::string ToString()
Definition: SpellScript.cpp:148
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:310
int8_t int8
Definition: Define.h:148
#define SPELL_SCRIPT_STATE_END
Definition: SpellScript.h:52
HookList< EffectCalcSpellModHandler > DoEffectCalcSpellMod
Definition: SpellScript.h:733
HookList< HitHandler > OnHit
Definition: SpellScript.h:302
ScriptStateStack m_scriptStates
Definition: SpellScript.h:661
Definition: SpellScript.h:47
Definition: SpellScript.h:602
AuraEffectHandleModes
Definition: SpellAuraDefines.h:36
Definition: SpellScript.h:443
Definition: SpellScript.h:459
AuraCheckAreaTargetFnType pHandlerScript
Definition: SpellScript.h:504
Definition: Player.h:167
bool _IsEffectPrevented(SpellEffIndex effIndex)
Definition: SpellScript.h:260
Definition: SpellScript.h:461
HookList< CastHandler > OnCast
Definition: SpellScript.h:280
WorldLocation * GetHitDest()
Definition: SpellScript.cpp:497
SpellCustomErrors
Definition: SharedDefines.h:1541
Definition: SpellInfo.h:326
Definition: SpellScript.h:453
Definition: SpellScript.h:463
Definition: SpellScript.h:529
AuraObjectType
Definition: SpellAuraDefines.h:546
uint8 m_currentScriptState
Definition: SpellScript.h:105
Definition: SpellScript.h:650
HookList< CheckAreaTargetHandler > DoCheckAreaTarget
Definition: SpellScript.h:671
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:294
void CreateItem(uint32 effIndex, uint32 itemId)
Definition: SpellScript.cpp:627
void PreventHitDamage()
Definition: SpellScript.h:397
Definition: SpellScript.h:49
Definition: SpellScript.h:136
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
Definition: SpellScript.h:320
uint8 m_hitPreventEffectMask
Definition: SpellScript.h:270
void PreventHitHeal()
Definition: SpellScript.h:402
bool IsInEffectHook() const
Definition: SpellScript.cpp:389
Definition: SpellScript.h:570
EffectAuraNameCheck(uint16 _effAurName)
Definition: SpellScript.h:98
Definition: SpellAuras.h:50
Definition: SpellScript.h:55
Player * GetHitPlayer()
Definition: SpellScript.cpp:464
virtual ~_SpellScript()
Definition: SpellScript.h:64
Definition: SpellScript.h:452
bool _Load(Aura *aura)
Definition: SpellScript.cpp:926
Definition: SpellScript.h:152
bool IsInCheckCastHook() const
Definition: SpellScript.cpp:367
HookList< EffectManaShieldHandler > OnEffectManaShield
Definition: SpellScript.h:750
AuraEffectAbsorbFnType pEffectHandlerScript
Definition: SpellScript.h:584
arena_t NULL
Definition: jemalloc_internal.h:624
#define false
Definition: CascPort.h:18
Definition: Spell.h:265
AuraEffectPeriodicFnType pEffectHandlerScript
Definition: SpellScript.h:527
Definition: SpellScript.h:457
uint16 effAurName
Definition: SpellScript.h:102
Definition: SpellScript.h:610
void _InitHit()
Definition: SpellScript.cpp:351
Definition: Object.h:423
Definition: Creature.h:467
Definition: SpellScript.h:586
GameObject * GetHitGObj()
Definition: SpellScript.cpp:487
AuraEffectAbsorbFnType pEffectHandlerScript
Definition: SpellScript.h:576
Definition: SpellScript.h:444
SpellCastFnType pCastHandlerScript
Definition: SpellScript.h:174
Definition: SpellScript.h:445
void SetHitHeal(int32 heal)
Definition: SpellScript.cpp:537
void PreventHitAura()
Definition: SpellScript.cpp:561
Aura * GetHitAura()
Definition: SpellScript.cpp:547
Definition: SpellScript.h:186
Definition: SpellScript.h:130
HookList< EffectHandler > OnEffectLaunchTarget
Definition: SpellScript.h:293
HookList< AuraDispelHandler > AfterDispel
Definition: SpellScript.h:681
AuraApplication const * _auraApplication
Definition: SpellScript.h:653
uint8 m_hitPreventDefaultEffectMask
Definition: SpellScript.h:271
Definition: SpellScript.h:133
Definition: SpellScript.h:142
void _FinishScriptCall()
Definition: SpellScript.cpp:362
int32 GetHitHeal()
Definition: SpellScript.cpp:527
WorldLocation const * GetExplTargetDest()
Definition: SpellScript.cpp:409
AuraEffectHandleModes mode
Definition: SpellScript.h:568
Item * GetHitItem()
Definition: SpellScript.cpp:477
Definition: SpellScript.h:447
SpellEffectFnType pEffectHandlerScript
Definition: SpellScript.h:194
TC_GAME_API uint32 GetId(std::string const &username)
Definition: BattlenetAccountMgr.cpp:128
Definition: DynamicObject.h:35
uint8 effIndex
Definition: SpellScript.h:82
HookList< EffectApplyHandler > OnEffectRemove
Definition: SpellScript.h:699
HookList< EffectAbsorbHandler > OnEffectAbsorb
Definition: SpellScript.h:739
Spell * m_spell
Definition: SpellScript.h:269
Definition: Unit.h:984
Definition: Spell.h:118
Definition: SpellScript.h:514
AuraScript()
Definition: SpellScript.h:638
Definition: SpellScript.h:237
HookList< EffectSplitHandler > OnEffectSplit
Definition: SpellScript.h:761
AuraEffectApplicationModeFnType pEffectHandlerScript
Definition: SpellScript.h:567
string ToString(int i)
Definition: strutil.h:491
WorldObject * GetExplTargetWorldObject()
Definition: SpellScript.cpp:421
virtual ~EffectHook()
Definition: SpellScript.h:75
HookList< HitHandler > BeforeHit
Definition: SpellScript.h:300
Definition: SpellScript.h:134
bool _Validate(SpellInfo const *entry) override
Definition: SpellScript.cpp:305
Definition: SpellScript.h:446
HookList< CastHandler > AfterCast
Definition: SpellScript.h:282
Definition: SpellScript.h:177
uint32 m_scriptSpellId
Definition: SpellScript.h:107
Unit * GetOriginalCaster()
Definition: SpellScript.cpp:399
Spell * GetSpell()
Definition: SpellScript.h:403
uint16 targetType
Definition: SpellScript.h:214
bool IsInTargetHook() const
Definition: SpellScript.cpp:371
HookList< CheckProcHandler > DoCheckProc
Definition: SpellScript.h:767
bool area
Definition: SpellScript.h:215
Definition: SpellScript.h:465
Definition: SpellScript.h:71
AuraEffectSplitFnType pEffectHandlerScript
Definition: SpellScript.h:592
Definition: Item.h:259
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
Definition: SpellScript.h:315
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:703
SpellEffIndex
Definition: SharedDefines.h:26
Definition: SpellScript.h:466
Definition: SpellInfo.h:238
int32_t int32
Definition: Define.h:146
ScriptStateStore(uint8 currentScriptState, AuraApplication const *auraApplication, bool defaultActionPrevented)
Definition: SpellScript.h:656
Definition: SpellScript.h:545
HookList< EffectHandler > OnEffectSuccessfulDispel
Definition: SpellScript.h:296
uint32_t uint32
Definition: Define.h:150
bool m_defaultActionPrevented
Definition: SpellScript.h:648
HookList< AuraProcHandler > DoPrepareProc
Definition: SpellScript.h:773
Definition: SpellScript.h:132
AuraApplication const * m_auraApplication
Definition: SpellScript.h:647
#define AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME)
Definition: SpellScript.h:481
AuraEffectCalcSpellModFnType pEffectHandlerScript
Definition: SpellScript.h:559
Definition: SpellScript.h:448
uint16_t uint16
Definition: Define.h:151
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:295
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:404
Definition: GameObject.h:880
std::string const * m_scriptName
Definition: SpellScript.h:106
Definition: SpellScript.h:594
HookList< AuraProcHandler > OnProc
Definition: SpellScript.h:777
void SetEffectValue(int32 value)
Definition: SpellScript.cpp:611
Definition: SpellScript.h:139
EffectNameCheck(uint16 _effName)
Definition: SpellScript.h:88
Definition: SpellScript.h:137
AuraEffectUpdatePeriodicFnType pEffectHandlerScript
Definition: SpellScript.h:535
Definition: SpellScript.h:451
bool _Validate(SpellInfo const *entry) override
Definition: SpellScript.cpp:664
Definition: SpellScript.h:553
bool IsInHitPhase() const
Definition: SpellScript.cpp:384
HookList< AuraDispelHandler > OnDispel
Definition: SpellScript.h:677
Definition: SpellScript.h:219
AuraEffectCalcAmountFnType pEffectHandlerScript
Definition: SpellScript.h:543
bool dest
Definition: SpellScript.h:216
Definition: SpellScript.h:141
HookList< CheckCastHandler > OnCheckCast
Definition: SpellScript.h:287
void SetExplTargetDest(WorldLocation &loc)
Definition: SpellScript.cpp:416
_SpellScript()
Definition: SpellScript.h:63
SpellObjectTargetSelectFnType pObjectTargetSelectHandlerScript
Definition: SpellScript.h:234
HookList< EffectApplyHandler > OnEffectApply
Definition: SpellScript.h:688
Definition: SpellScript.h:143
Aura * m_aura
Definition: SpellScript.h:646
uint8 _currentScriptState
Definition: SpellScript.h:654
Definition: SpellScript.h:206
void FinishCast(SpellCastResult result)
Definition: SpellScript.cpp:637
SpellInfo const * GetTriggeringSpell()
Definition: SpellScript.cpp:632
Definition: SpellScript.h:462
SpellScriptState
Definition: SpellScript.h:45
void SetHitDamage(int32 damage)
Definition: SpellScript.cpp:517
Definition: SpellScript.h:197
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:709
SpellValue const * GetSpellValue()
Definition: SpellScript.cpp:654
Unit * GetCaster()
Definition: SpellScript.cpp:394
Definition: Unit.h:888
virtual void Unload()
Definition: SpellScript.h:123
HookList< CastHandler > BeforeCast
Definition: SpellScript.h:278
void _FinishScriptCall()
Definition: SpellScript.cpp:943
void SetCustomCastResultMessage(SpellCustomErrors result)
Definition: SpellScript.cpp:643
#define TC_GAME_API
Definition: Define.h:134
Creature * GetHitCreature()
Definition: SpellScript.cpp:451
int32 GetHitDamage()
Definition: SpellScript.cpp:507
AuraRemoveMode
Definition: Unit.h:448
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
Definition: SpellScript.h:715
Definition: SpellScript.h:454
void PreventHitEffect(SpellEffIndex effIndex)
Definition: SpellScript.cpp:572
Item * GetCastItem()
Definition: SpellScript.cpp:622
uint16 GetTarget() const
Definition: SpellScript.h:212
uint8_t uint8
Definition: Define.h:152
Definition: SpellScript.h:521
HookList< EffectProcHandler > OnEffectProc
Definition: SpellScript.h:787
void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const *aurApp=NULL)
Definition: SpellScript.cpp:935
std::stack< ScriptStateStore > ScriptStateStack
Definition: SpellScript.h:660
SpellDestinationTargetSelectFnType DestinationTargetSelectHandlerScript
Definition: SpellScript.h:243
Definition: SpellScript.h:450
HookList< EffectProcHandler > AfterEffectProc
Definition: SpellScript.h:791
SpellCastResult
Definition: SharedDefines.h:1265
virtual bool Validate(SpellInfo const *)
Definition: SpellScript.h:117
const FieldDescriptor value
Definition: descriptor.h:1522
HookList< EffectHandler > OnEffectLaunch
Definition: SpellScript.h:292
Unit * GetHitUnit()
Definition: SpellScript.cpp:441
void _PrepareScriptCall(SpellScriptHookType hookType)
Definition: SpellScript.cpp:357
Definition: ObjectGuid.h:189
int32 GetEffectValue() const
Definition: SpellScript.cpp:600
SpellHitFnType pHitHandlerScript
Definition: SpellScript.h:203
#define SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME)
Definition: SpellScript.h:157
AuraScriptHookType
Definition: SpellScript.h:441
Definition: SpellScript.h:228
Definition: SpellScript.h:506
Definition: SpellScript.h:458
Definition: SpellScript.h:475
SpellCheckCastFnType _checkCastHandlerScript
Definition: SpellScript.h:183
AuraCheckProcFnType _HandlerScript
Definition: SpellScript.h:600
Definition: SpellAuras.h:116
AuraDispelFnType pHandlerScript
Definition: SpellScript.h:512
virtual bool Load()
Definition: SpellScript.h:120
HookList< EffectManaShieldHandler > AfterEffectManaShield
Definition: SpellScript.h:756
Definition: SpellScript.h:561
Definition: SpellScript.h:129
Definition: SpellScript.h:50
Definition: Unit.h:1305
Definition: Util.h:332
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Definition: SpellScript.h:721
HookList< AuraProcHandler > AfterProc
Definition: SpellScript.h:781
Definition: SpellScript.h:464
Definition: Unit.h:451
AuraEffectProcFnType _EffectHandlerScript
Definition: SpellScript.h:616
Definition: SpellScript.h:537
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
Definition: SpellScript.h:727
AuraEffectCalcPeriodicFnType pEffectHandlerScript
Definition: SpellScript.h:551
Item * GetExplTargetItem()
Definition: SpellScript.cpp:436
SpellObjectAreaTargetSelectFnType pObjectAreaTargetSelectHandlerScript
Definition: SpellScript.h:225
bool _IsDefaultEffectPrevented(SpellEffIndex effIndex)
Definition: SpellScript.h:261
AuraProcFnType _HandlerScript
Definition: SpellScript.h:608
Definition: SpellScript.h:449
Definition: SpellScript.h:85
Definition: SpellScript.h:140
Definition: SpellScript.h:455
Definition: SpellScript.h:498
HookList< HitHandler > AfterHit
Definition: SpellScript.h:304
bool _Load(Spell *spell)
Definition: SpellScript.cpp:342
Definition: Unit.h:921
Definition: Spell.h:294