TrinityCore
Loading...
Searching...
No Matches
SpellScript.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
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 "ObjectGuid.h"
22#include "SharedDefines.h"
23#include "SpellAuraDefines.h"
24#include "Util.h"
25#include <memory>
26#include <stack>
27
28class Aura;
29class AuraApplication;
30class AuraEffect;
31class Creature;
32class Corpse;
33class DamageInfo;
34class DispelInfo;
35class DynamicObject;
36class GameObject;
37class Item;
38class ModuleReference;
39class Player;
40class ProcEventInfo;
41class Spell;
42class SpellEffectInfo;
43class SpellInfo;
44class SpellScript;
45class Unit;
46class WorldLocation;
47class WorldObject;
48struct SpellDestination;
49struct SpellModifier;
50struct SpellValue;
51
52#define SPELL_EFFECT_ANY (uint16)-1
53#define SPELL_AURA_ANY (uint16)-1
54
62#define SPELL_SCRIPT_STATE_END SPELL_SCRIPT_STATE_UNLOADING + 1
63
64// helper class from which SpellScript and SpellAura derive, use these classes instead
66{
67 // internal use classes & functions
68 // DO NOT OVERRIDE THESE IN SCRIPTS
69 protected:
70 virtual bool _Validate(SpellInfo const* entry);
71
72 public:
73 _SpellScript() : m_currentScriptState(SPELL_SCRIPT_STATE_NONE), m_scriptName(nullptr), m_scriptSpellId(0) {}
74 virtual ~_SpellScript() { }
75 void _Register();
76 void _Unload();
77 void _Init(std::string const* scriptname, uint32 spellId);
78 std::string const* _GetScriptName() const;
79
80 protected:
82 {
83 public:
84 EffectHook(uint8 _effIndex);
85 virtual ~EffectHook() { }
86
87 uint8 GetAffectedEffectsMask(SpellInfo const* spellInfo);
88 bool IsEffectAffected(SpellInfo const* spellInfo, uint8 effIndex);
89 virtual bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) = 0;
90 std::string EffIndexToString();
91 protected:
93 };
94
96 {
97 public:
98 EffectNameCheck(uint16 _effName) { effName = _effName; }
99 bool Check(SpellInfo const* spellInfo, uint8 effIndex);
100 std::string ToString();
101 private:
103 };
104
106 {
107 public:
108 EffectAuraNameCheck(uint16 _effAurName) { effAurName = _effAurName; }
109 bool Check(SpellInfo const* spellInfo, uint8 effIndex);
110 std::string ToString();
111 private:
113 };
114
116 std::string const* m_scriptName;
118
119 private:
120
121#ifdef TRINITY_API_USE_DYNAMIC_LINKING
122
123 // Strong reference to keep the binary code loaded
124 std::shared_ptr<ModuleReference> m_moduleReference;
125
126#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
127
128 public:
129 //
130 // SpellScript/AuraScript interface base
131 // these functions are safe to override, see notes below for usage instructions
132 //
133 // Function in which handler functions are registered, must be implemented in script
134 virtual void Register() = 0;
135 // Function called on server startup, if returns false script won't be used in core
136 // use for: dbc/template data presence/correctness checks
137 virtual bool Validate(SpellInfo const* /*spellInfo*/) { return true; }
138 // Function called when script is created, if returns false script will be unloaded afterwards
139 // use for: initializing local script variables (DO NOT USE CONSTRUCTOR FOR THIS PURPOSE!)
140 virtual bool Load() { return true; }
141 // Function called when script is destroyed
142 // use for: deallocating memory allocated by script
143 virtual void Unload() { }
144 // Helpers
145 static bool ValidateSpellInfo(std::initializer_list<uint32> spellIds)
146 {
147 return _ValidateSpellInfo(spellIds.begin(), spellIds.end());
148 }
149
150 template <class T>
151 static bool ValidateSpellInfo(T const& spellIds)
152 {
153 return _ValidateSpellInfo(std::begin(spellIds), std::end(spellIds));
154 }
155
156 private:
157 template<typename Iterator>
158 static bool _ValidateSpellInfo(Iterator begin, Iterator end)
159 {
160 bool allValid = true;
161 while (begin != end)
162 {
163 if (!_ValidateSpellInfo(*begin))
164 allValid = false;
165
166 ++begin;
167 }
168 return allValid;
169 }
170
171 static bool _ValidateSpellInfo(uint32 spellId);
172};
173
174// SpellScript interface - enum used for runtime checks of script function calls
194
195#define HOOK_SPELL_HIT_START SPELL_SCRIPT_HOOK_EFFECT_HIT
196#define HOOK_SPELL_HIT_END SPELL_SCRIPT_HOOK_AFTER_HIT + 1
197
199{
200 // internal use classes & functions
201 // DO NOT OVERRIDE THESE IN SCRIPTS
202 public:
203 #define SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) \
204 typedef SpellCastResult(CLASSNAME::*SpellCheckCastFnType)(); \
205 typedef void(CLASSNAME::*SpellEffectFnType)(SpellEffIndex); \
206 typedef void(CLASSNAME::*SpellBeforeHitFnType)(SpellMissInfo missInfo); \
207 typedef void(CLASSNAME::*SpellHitFnType)(); \
208 typedef void(CLASSNAME::*SpellCastFnType)(); \
209 typedef void(CLASSNAME::*SpellOnResistAbsorbCalculateFnType)(DamageInfo const& damageInfo, uint32& resistAmount, int32& absorbAmount); \
210 typedef void(CLASSNAME::*SpellObjectAreaTargetSelectFnType)(std::list<WorldObject*>&); \
211 typedef void(CLASSNAME::*SpellObjectTargetSelectFnType)(WorldObject*&); \
212 typedef void(CLASSNAME::*SpellDestinationTargetSelectFnType)(SpellDestination&);
213
215
217 {
218 public:
219 CastHandler(SpellCastFnType _pCastHandlerScript);
220 void Call(SpellScript* spellScript);
221 private:
222 SpellCastFnType pCastHandlerScript;
223 };
224
226 {
227 public:
228 CheckCastHandler(SpellCheckCastFnType checkCastHandlerScript);
229 SpellCastResult Call(SpellScript* spellScript);
230 private:
231 SpellCheckCastFnType _checkCastHandlerScript;
232 };
233
235 {
236 public:
237 EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
238 std::string ToString();
239 bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
240 void Call(SpellScript* spellScript, SpellEffIndex effIndex);
241 private:
242 SpellEffectFnType pEffectHandlerScript;
243 };
244
246 {
247 public:
248 HitHandler(SpellHitFnType _pHitHandlerScript);
249 void Call(SpellScript* spellScript);
250 private:
251 SpellHitFnType pHitHandlerScript;
252 };
253
255 {
256 public:
257 BeforeHitHandler(SpellBeforeHitFnType pBeforeHitHandlerScript);
258 void Call(SpellScript* spellScript, SpellMissInfo missInfo);
259 private:
260 SpellBeforeHitFnType _pBeforeHitHandlerScript;
261 };
262
264 {
265 public:
266 TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest);
267 bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
268 std::string ToString();
269 uint16 GetTarget() const { return targetType; }
270 protected:
272 bool area;
273 bool dest;
274 };
275
277 {
278 public:
279 ObjectAreaTargetSelectHandler(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType);
280 void Call(SpellScript* spellScript, std::list<WorldObject*>& targets);
282 {
283 return pObjectAreaTargetSelectHandlerScript == other.pObjectAreaTargetSelectHandlerScript;
284 }
285 private:
286 SpellObjectAreaTargetSelectFnType pObjectAreaTargetSelectHandlerScript;
287 };
288
290 {
291 public:
292 ObjectTargetSelectHandler(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType);
293 void Call(SpellScript* spellScript, WorldObject*& target);
295 {
296 return pObjectTargetSelectHandlerScript == other.pObjectTargetSelectHandlerScript;
297 }
298 private:
299 SpellObjectTargetSelectFnType pObjectTargetSelectHandlerScript;
300 };
301
303 {
304 public:
305 DestinationTargetSelectHandler(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType);
306 void Call(SpellScript* spellScript, SpellDestination& target);
307 private:
308 SpellDestinationTargetSelectFnType DestinationTargetSelectHandlerScript;
309 };
310
312 {
313 public:
314 OnCalculateResistAbsorbHandler(SpellOnResistAbsorbCalculateFnType _pOnCalculateResistAbsorbHandlerScript);
315 void Call(SpellScript* spellScript, DamageInfo const& damageInfo, uint32& resistAmount, int32& absorbAmount);
316 private:
317 SpellOnResistAbsorbCalculateFnType pOnCalculateResistAbsorbHandlerScript;
318 };
319
320 #define SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) \
321 class CastHandlerFunction : public SpellScript::CastHandler { public: explicit CastHandlerFunction(SpellCastFnType _pCastHandlerScript) : SpellScript::CastHandler((SpellScript::SpellCastFnType)_pCastHandlerScript) { } }; \
322 class CheckCastHandlerFunction : public SpellScript::CheckCastHandler { public: explicit CheckCastHandlerFunction(SpellCheckCastFnType _checkCastHandlerScript) : SpellScript::CheckCastHandler((SpellScript::SpellCheckCastFnType)_checkCastHandlerScript) { } }; \
323 class EffectHandlerFunction : public SpellScript::EffectHandler { public: explicit EffectHandlerFunction(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : SpellScript::EffectHandler((SpellScript::SpellEffectFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
324 class HitHandlerFunction : public SpellScript::HitHandler { public: explicit HitHandlerFunction(SpellHitFnType _pHitHandlerScript) : SpellScript::HitHandler((SpellScript::SpellHitFnType)_pHitHandlerScript) { } }; \
325 class BeforeHitHandlerFunction : public SpellScript::BeforeHitHandler { public: explicit BeforeHitHandlerFunction(SpellBeforeHitFnType pBeforeHitHandlerScript) : SpellScript::BeforeHitHandler((SpellScript::SpellBeforeHitFnType)pBeforeHitHandlerScript) { } }; \
326 class OnCalculateResistAbsorbHandlerFunction : public SpellScript::OnCalculateResistAbsorbHandler { public: explicit OnCalculateResistAbsorbHandlerFunction(SpellOnResistAbsorbCalculateFnType _onCalculateResistAbsorbScript) : SpellScript::OnCalculateResistAbsorbHandler((SpellScript::SpellOnResistAbsorbCalculateFnType)_onCalculateResistAbsorbScript) { } }; \
327 class ObjectAreaTargetSelectHandlerFunction : public SpellScript::ObjectAreaTargetSelectHandler { public: explicit ObjectAreaTargetSelectHandlerFunction(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectAreaTargetSelectHandler((SpellScript::SpellObjectAreaTargetSelectFnType)_pObjectAreaTargetSelectHandlerScript, _effIndex, _targetType) { } }; \
328 class ObjectTargetSelectHandlerFunction : public SpellScript::ObjectTargetSelectHandler { public: explicit ObjectTargetSelectHandlerFunction(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectTargetSelectHandler((SpellScript::SpellObjectTargetSelectFnType)_pObjectTargetSelectHandlerScript, _effIndex, _targetType) { } }; \
329 class DestinationTargetSelectHandlerFunction : public SpellScript::DestinationTargetSelectHandler { public: explicit DestinationTargetSelectHandlerFunction(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::DestinationTargetSelectHandler((SpellScript::SpellDestinationTargetSelectFnType)_DestinationTargetSelectHandlerScript, _effIndex, _targetType) { } }
330
331 #define PrepareSpellScript(CLASSNAME) SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
332 public:
333 SpellScript();
335 bool _Validate(SpellInfo const* entry) override;
336 bool _Load(Spell* spell);
337 void _InitHit();
338 bool _IsEffectPrevented(SpellEffIndex effIndex) { return (m_hitPreventEffectMask & (1 << effIndex)) != 0; }
339 bool _IsDefaultEffectPrevented(SpellEffIndex effIndex) { return (m_hitPreventDefaultEffectMask & (1 << effIndex)) != 0; }
340 void _PrepareScriptCall(SpellScriptHookType hookType);
341 void _FinishScriptCall();
342 bool IsInCheckCastHook() const;
343 bool IsAfterTargetSelectionPhase() const;
344 bool IsInTargetHook() const;
345 bool IsInModifiableHook() const;
346 bool IsInHitPhase() const;
347 bool IsInEffectHook() const;
348 private:
352 public:
353 //
354 // SpellScript interface
355 // hooks to which you can attach your functions
356 //
357 // example: BeforeCast += SpellCastFn(class::function);
359 // example: OnCast += SpellCastFn(class::function);
361 // example: AfterCast += SpellCastFn(class::function);
363 #define SpellCastFn(F) CastHandlerFunction(&F)
364
365 // example: OnCheckCast += SpellCheckCastFn();
366 // where function is SpellCastResult function()
368 #define SpellCheckCastFn(F) CheckCastHandlerFunction(&F)
369
370 // example: OnCalculateResistAbsorb += SpellOnResistAbsorbCalculateFn(class::function);
371 // where function is void function(DamageInfo const& damageInfo, uint32& resistAmount, int32& absorbAmount)
373 #define SpellOnResistAbsorbCalculateFn(F) OnCalculateResistAbsorbHandlerFunction(&F)
374
375 // example: OnEffect**** += SpellEffectFn(class::function, EffectIndexSpecifier, EffectNameSpecifier);
376 // where function is void function(SpellEffIndex effIndex)
382 #define SpellEffectFn(F, I, N) EffectHandlerFunction(&F, I, N)
383
384 // example: BeforeHit += BeforeSpellHitFn(class::function);
385 // where function is void function(SpellMissInfo missInfo)
387 #define BeforeSpellHitFn(F) BeforeHitHandlerFunction(&F)
388
389 // example: OnHit += SpellHitFn(class::function);
391 // example: AfterHit += SpellHitFn(class::function);
393 // where function is: void function()
394 #define SpellHitFn(F) HitHandlerFunction(&F)
395
396 // example: OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(class::function, EffectIndexSpecifier, TargetsNameSpecifier);
397 // where function is void function(std::list<WorldObject*>& targets)
399 #define SpellObjectAreaTargetSelectFn(F, I, N) ObjectAreaTargetSelectHandlerFunction(&F, I, N)
400
401 // example: OnObjectTargetSelect += SpellObjectTargetSelectFn(class::function, EffectIndexSpecifier, TargetsNameSpecifier);
402 // where function is void function(WorldObject*& target)
404 #define SpellObjectTargetSelectFn(F, I, N) ObjectTargetSelectHandlerFunction(&F, I, N)
405
406 // example: OnDestinationTargetSelect += SpellDestinationTargetSelectFn(class::function, EffectIndexSpecifier, TargetsNameSpecifier);
407 // where function is void function(SpellDestination& target)
409 #define SpellDestinationTargetSelectFn(F, I, N) DestinationTargetSelectHandlerFunction(&F, I, N)
410
411 // hooks are executed in following order, at specified event of spell:
412 // 1. BeforeCast - executed when spell preparation is finished (when cast bar becomes full) before cast is handled
413 // 2. OnCheckCast - allows to override result of CheckCast function
414 // 3a. OnObjectAreaTargetSelect - executed just before adding selected targets to final target list (for area targets)
415 // 3b. OnObjectTargetSelect - executed just before adding selected target to final target list (for single unit targets)
416 // 3c. OnDestinationTargetSelect - executed just before adding selected target to final target list (for destination targets)
417 // 4. OnCast - executed just before spell is launched (creates missile) or executed
418 // 5. AfterCast - executed after spell missile is launched and immediate spell actions are done
419 // 6. OnEffectLaunch - executed just before specified effect handler call - when spell missile is launched
420 // 7. OnEffectLaunchTarget - executed just before specified effect handler call - when spell missile is launched - called for each target from spell target map
421 // 8. OnCalculateResistAbsorb - executed when damage resist/absorbs is calculated - before spell hit target
422 // 9. OnEffectHit - executed just before specified effect handler call - when spell missile hits dest
423 // 10. BeforeHit - executed just before spell hits a target - called for each target from spell target map
424 // 11. OnEffectHitTarget - executed just before specified effect handler call - called for each target from spell target map
425 // 12. OnHit - executed just before spell deals damage and procs auras - when spell hits target - called for each target from spell target map
426 // 13. AfterHit - executed just after spell finishes all it's jobs for target - called for each target from spell target map
427
428 // this hook is only executed after a successful dispel of any aura
429 // OnEffectSuccessfulDispel - executed just after effect successfully dispelled aura(s)
430
431 //
432 // methods allowing interaction with Spell object
433 //
434 // methods useable during all spell handling phases
435 Unit* GetCaster() const;
436 GameObject* GetGObjCaster() const;
437 Unit* GetOriginalCaster() const;
438 SpellInfo const* GetSpellInfo() const;
439 SpellEffectInfo const& GetEffectInfo(SpellEffIndex effIndex) const;
440 SpellValue const* GetSpellValue() const;
441
442 // methods useable after spell is prepared
443 // accessors to the explicit targets of the spell
444 // explicit target - target selected by caster (player, game client, or script - DoCast(explicitTarget, ...), required for spell to be cast
445 // examples:
446 // -shadowstep - explicit target is the unit you want to go behind of
447 // -chain heal - explicit target is the unit to be healed first
448 // -holy nova/arcane explosion - explicit target = NULL because target you are selecting doesn't affect how spell targets are selected
449 // you can determine if spell requires explicit targets by dbc columns:
450 // - Targets - mask of explicit target types
451 // - ImplicitTargetXX set to TARGET_XXX_TARGET_YYY, _TARGET_ here means that explicit target is used by the effect, so spell needs one too
452
453 // returns: WorldLocation which was selected as a spell destination or NULL
454 WorldLocation const* GetExplTargetDest() const;
455
456 void SetExplTargetDest(WorldLocation& loc);
457
458 // returns: WorldObject which was selected as an explicit spell target or NULL if there's no target
459 WorldObject* GetExplTargetWorldObject() const;
460
461 // returns: Unit which was selected as an explicit spell target or NULL if there's no target
462 Unit* GetExplTargetUnit() const;
463
464 // returns: GameObject which was selected as an explicit spell target or NULL if there's no target
465 GameObject* GetExplTargetGObj() const;
466
467 // returns: Item which was selected as an explicit spell target or NULL if there's no target
468 Item* GetExplTargetItem() const;
469
470 // methods usable only after spell targets have been fully selected
471 int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const;
472 int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const;
473 int64 GetItemTargetCountForEffect(SpellEffIndex effect) const;
474
475 // methods useable only during spell hit on target, or during spell launch on target:
476 // returns: target of current effect if it was Unit otherwise NULL
477 Unit* GetHitUnit() const;
478 // returns: target of current effect if it was Creature otherwise NULL
479 Creature* GetHitCreature() const;
480 // returns: target of current effect if it was Player otherwise NULL
481 Player* GetHitPlayer() const;
482 // returns: target of current effect if it was Item otherwise NULL
483 Item* GetHitItem() const;
484 // returns: target of current effect if it was GameObject otherwise NULL
485 GameObject* GetHitGObj() const;
486 // returns: target of current effect if it was Corpse otherwise nullptr
487 Corpse* GetHitCorpse() const;
488 // returns: destination of current effect
489 WorldLocation* GetHitDest() const;
490 // setter/getter for for damage done by spell to target of spell hit
491 // returns damage calculated before hit, and real dmg done after hit
492 int32 GetHitDamage() const;
493 void SetHitDamage(int32 damage);
494 void PreventHitDamage() { SetHitDamage(0); }
495 // setter/getter for for heal done by spell to target of spell hit
496 // returns healing calculated before hit, and real dmg done after hit
497 int32 GetHitHeal() const;
498 void SetHitHeal(int32 heal);
499 void PreventHitHeal() { SetHitHeal(0); }
500 Spell* GetSpell() const { return m_spell; }
501 // returns current spell hit target aura
502 Aura* GetHitAura(bool dynObjAura = false) const;
503 // prevents applying aura on current spell hit target
504 void PreventHitAura();
505
506 // prevents effect execution on current spell hit target
507 // including other effect/hit scripts
508 // will not work on aura/damage/heal
509 // will not work if effects were already handled
510 void PreventHitEffect(SpellEffIndex effIndex);
511
512 // prevents default effect execution on current spell hit target
513 // will not work on aura/damage/heal effects
514 // will not work if effects were already handled
515 void PreventHitDefaultEffect(SpellEffIndex effIndex);
516
517 // method avalible only in EffectHandler method
518 SpellEffectInfo const& GetEffectInfo() const;
519 int32 GetEffectValue() const;
520 void SetEffectValue(int32 value);
521
522 // returns: cast item if present.
523 Item* GetCastItem() const;
524
525 // Creates item. Calls Spell::DoCreateItem method.
526 void CreateItem(uint32 itemId);
527
528 // Returns SpellInfo from the spell that triggered the current one
529 SpellInfo const* GetTriggeringSpell() const;
530
531 // finishes spellcast prematurely with selected error message
532 void FinishCast(SpellCastResult result, uint32* param1 = nullptr, uint32* param2 = nullptr);
533
534 void SetCustomCastResultMessage(SpellCustomErrors result);
535};
536
537// AuraScript interface - enum used for runtime checks of script function calls
568/*
569#define HOOK_AURA_EFFECT_START HOOK_AURA_EFFECT_APPLY
570#define HOOK_AURA_EFFECT_END HOOK_AURA_EFFECT_CALC_SPELLMOD + 1
571#define HOOK_AURA_EFFECT_COUNT HOOK_AURA_EFFECT_END - HOOK_AURA_EFFECT_START
572*/
574{
575 // internal use classes & functions
576 // DO NOT OVERRIDE THESE IN SCRIPTS
577 public:
578
579 #define AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) \
580 typedef bool(CLASSNAME::*AuraCheckAreaTargetFnType)(Unit* target); \
581 typedef void(CLASSNAME::*AuraDispelFnType)(DispelInfo* dispelInfo); \
582 typedef void(CLASSNAME::*AuraEffectApplicationModeFnType)(AuraEffect const*, AuraEffectHandleModes); \
583 typedef void(CLASSNAME::*AuraEffectPeriodicFnType)(AuraEffect const*); \
584 typedef void(CLASSNAME::*AuraEffectUpdatePeriodicFnType)(AuraEffect*); \
585 typedef void(CLASSNAME::*AuraEffectCalcAmountFnType)(AuraEffect const*, int32 &, bool &); \
586 typedef void(CLASSNAME::*AuraEffectCalcPeriodicFnType)(AuraEffect const*, bool &, int32 &); \
587 typedef void(CLASSNAME::*AuraEffectCalcSpellModFnType)(AuraEffect const*, SpellModifier* &); \
588 typedef void(CLASSNAME::*AuraEffectAbsorbFnType)(AuraEffect*, DamageInfo &, uint32 &); \
589 typedef void(CLASSNAME::*AuraEffectSplitFnType)(AuraEffect*, DamageInfo &, uint32 &); \
590 typedef bool(CLASSNAME::*AuraCheckProcFnType)(ProcEventInfo&); \
591 typedef bool(CLASSNAME::*AuraCheckEffectProcFnType)(AuraEffect const*, ProcEventInfo&); \
592 typedef void(CLASSNAME::*AuraProcFnType)(ProcEventInfo&); \
593 typedef void(CLASSNAME::*AuraEffectProcFnType)(AuraEffect const*, ProcEventInfo&); \
594
596
598 {
599 public:
600 CheckAreaTargetHandler(AuraCheckAreaTargetFnType pHandlerScript);
601 bool Call(AuraScript* auraScript, Unit* target);
602 private:
603 AuraCheckAreaTargetFnType pHandlerScript;
604 };
606 {
607 public:
608 AuraDispelHandler(AuraDispelFnType pHandlerScript);
609 void Call(AuraScript* auraScript, DispelInfo* dispelInfo);
610 private:
611 AuraDispelFnType pHandlerScript;
612 };
614 {
615 public:
616 EffectBase(uint8 _effIndex, uint16 _effName);
617 std::string ToString();
618 bool CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) override;
619 };
621 {
622 public:
623 EffectPeriodicHandler(AuraEffectPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
624 void Call(AuraScript* auraScript, AuraEffect const* _aurEff);
625 private:
626 AuraEffectPeriodicFnType pEffectHandlerScript;
627 };
629 {
630 public:
631 EffectUpdatePeriodicHandler(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
632 void Call(AuraScript* auraScript, AuraEffect* aurEff);
633 private:
634 AuraEffectUpdatePeriodicFnType pEffectHandlerScript;
635 };
637 {
638 public:
639 EffectCalcAmountHandler(AuraEffectCalcAmountFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
640 void Call(AuraScript* auraScript, AuraEffect const* aurEff, int32 & amount, bool & canBeRecalculated);
641 private:
642 AuraEffectCalcAmountFnType pEffectHandlerScript;
643 };
645 {
646 public:
647 EffectCalcPeriodicHandler(AuraEffectCalcPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
648 void Call(AuraScript* auraScript, AuraEffect const* aurEff, bool & isPeriodic, int32 & periodicTimer);
649 private:
650 AuraEffectCalcPeriodicFnType pEffectHandlerScript;
651 };
653 {
654 public:
655 EffectCalcSpellModHandler(AuraEffectCalcSpellModFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName);
656 void Call(AuraScript* auraScript, AuraEffect const* aurEff, SpellModifier* & spellMod);
657 private:
658 AuraEffectCalcSpellModFnType pEffectHandlerScript;
659 };
661 {
662 public:
663 EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode);
664 void Call(AuraScript* auraScript, AuraEffect const* _aurEff, AuraEffectHandleModes _mode);
665 private:
666 AuraEffectApplicationModeFnType pEffectHandlerScript;
668 };
670 {
671 public:
672 EffectAbsorbHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex);
673 void Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount);
674 private:
675 AuraEffectAbsorbFnType pEffectHandlerScript;
676 };
678 {
679 public:
680 EffectManaShieldHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex);
681 void Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount);
682 private:
683 AuraEffectAbsorbFnType pEffectHandlerScript;
684 };
686 {
687 public:
688 EffectSplitHandler(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex);
689 void Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & splitAmount);
690 private:
691 AuraEffectSplitFnType pEffectHandlerScript;
692 };
694 {
695 public:
696 CheckProcHandler(AuraCheckProcFnType handlerScript);
697 bool Call(AuraScript* auraScript, ProcEventInfo& eventInfo);
698 private:
699 AuraCheckProcFnType _HandlerScript;
700 };
702 {
703 public:
704 CheckEffectProcHandler(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName);
705 bool Call(AuraScript* auraScript, AuraEffect const* aurEff, ProcEventInfo& eventInfo);
706 private:
707 AuraCheckEffectProcFnType _HandlerScript;
708 };
710 {
711 public:
712 AuraProcHandler(AuraProcFnType handlerScript);
713 void Call(AuraScript* auraScript, ProcEventInfo& eventInfo);
714 private:
715 AuraProcFnType _HandlerScript;
716 };
718 {
719 public:
720 EffectProcHandler(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName);
721 void Call(AuraScript* auraScript, AuraEffect const* aurEff, ProcEventInfo& eventInfo);
722 private:
723 AuraEffectProcFnType _EffectHandlerScript;
724 };
725
726 #define AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) \
727 class CheckAreaTargetFunction : public AuraScript::CheckAreaTargetHandler { public: explicit CheckAreaTargetFunction(AuraCheckAreaTargetFnType _pHandlerScript) : AuraScript::CheckAreaTargetHandler((AuraScript::AuraCheckAreaTargetFnType)_pHandlerScript) { } }; \
728 class AuraDispelFunction : public AuraScript::AuraDispelHandler { public: explicit AuraDispelFunction(AuraDispelFnType _pHandlerScript) : AuraScript::AuraDispelHandler((AuraScript::AuraDispelFnType)_pHandlerScript) { } }; \
729 class EffectPeriodicHandlerFunction : public AuraScript::EffectPeriodicHandler { public: explicit EffectPeriodicHandlerFunction(AuraEffectPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectPeriodicHandler((AuraScript::AuraEffectPeriodicFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
730 class EffectUpdatePeriodicHandlerFunction : public AuraScript::EffectUpdatePeriodicHandler { public: explicit EffectUpdatePeriodicHandlerFunction(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectUpdatePeriodicHandler((AuraScript::AuraEffectUpdatePeriodicFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
731 class EffectCalcAmountHandlerFunction : public AuraScript::EffectCalcAmountHandler { public: explicit EffectCalcAmountHandlerFunction(AuraEffectCalcAmountFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectCalcAmountHandler((AuraScript::AuraEffectCalcAmountFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
732 class EffectCalcPeriodicHandlerFunction : public AuraScript::EffectCalcPeriodicHandler { public: explicit EffectCalcPeriodicHandlerFunction(AuraEffectCalcPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectCalcPeriodicHandler((AuraScript::AuraEffectCalcPeriodicFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
733 class EffectCalcSpellModHandlerFunction : public AuraScript::EffectCalcSpellModHandler { public: explicit EffectCalcSpellModHandlerFunction(AuraEffectCalcSpellModFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName) : AuraScript::EffectCalcSpellModHandler((AuraScript::AuraEffectCalcSpellModFnType)_pEffectHandlerScript, _effIndex, _effName) { } }; \
734 class EffectApplyHandlerFunction : public AuraScript::EffectApplyHandler { public: explicit EffectApplyHandlerFunction(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode) : AuraScript::EffectApplyHandler((AuraScript::AuraEffectApplicationModeFnType)_pEffectHandlerScript, _effIndex, _effName, _mode) { } }; \
735 class EffectAbsorbFunction : public AuraScript::EffectAbsorbHandler { public: explicit EffectAbsorbFunction(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectAbsorbHandler((AuraScript::AuraEffectAbsorbFnType)_pEffectHandlerScript, _effIndex) { } }; \
736 class EffectManaShieldFunction : public AuraScript::EffectManaShieldHandler { public: explicit EffectManaShieldFunction(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectManaShieldHandler((AuraScript::AuraEffectAbsorbFnType)_pEffectHandlerScript, _effIndex) { } }; \
737 class EffectSplitFunction : public AuraScript::EffectSplitHandler { public: explicit EffectSplitFunction(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectSplitHandler((AuraScript::AuraEffectSplitFnType)_pEffectHandlerScript, _effIndex) { } }; \
738 class CheckProcHandlerFunction : public AuraScript::CheckProcHandler { public: explicit CheckProcHandlerFunction(AuraCheckProcFnType handlerScript) : AuraScript::CheckProcHandler((AuraScript::AuraCheckProcFnType)handlerScript) { } }; \
739 class CheckEffectProcHandlerFunction : public AuraScript::CheckEffectProcHandler { public: explicit CheckEffectProcHandlerFunction(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName) : AuraScript::CheckEffectProcHandler((AuraScript::AuraCheckEffectProcFnType)handlerScript, effIndex, effName) { } }; \
740 class AuraProcHandlerFunction : public AuraScript::AuraProcHandler { public: explicit AuraProcHandlerFunction(AuraProcFnType handlerScript) : AuraScript::AuraProcHandler((AuraScript::AuraProcFnType)handlerScript) { } }; \
741 class EffectProcHandlerFunction : public AuraScript::EffectProcHandler { public: explicit EffectProcHandlerFunction(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName) : AuraScript::EffectProcHandler((AuraScript::AuraEffectProcFnType)effectHandlerScript, effIndex, effName) { } }
742
743 #define PrepareAuraScript(CLASSNAME) AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME)
744
745 public:
746 AuraScript();
748 bool _Validate(SpellInfo const* entry) override;
749 bool _Load(Aura* aura);
750 void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const* aurApp = nullptr);
751 void _FinishScriptCall();
752 bool _IsDefaultActionPrevented();
753 private:
757
759 {
760 public:
764 ScriptStateStore(uint8 currentScriptState, AuraApplication const* auraApplication, bool defaultActionPrevented)
765 : _auraApplication(auraApplication), _currentScriptState(currentScriptState), _defaultActionPrevented(defaultActionPrevented)
766 { }
767 };
768 typedef std::stack<ScriptStateStore> ScriptStateStack;
770
771 public:
772 //
773 // AuraScript interface
774 // hooks to which you can attach your functions
775 //
776 // executed when area aura checks if it can be applied on target
777 // example: OnEffectApply += AuraEffectApplyFn(class::function);
778 // where function is: bool function (Unit* target);
780 #define AuraCheckAreaTargetFn(F) CheckAreaTargetFunction(&F)
781
782 // executed when aura is dispelled by a unit
783 // example: OnDispel += AuraDispelFn(class::function);
784 // where function is: void function (DispelInfo* dispelInfo);
786 // executed after aura is dispelled by a unit
787 // example: AfterDispel += AuraDispelFn(class::function);
788 // where function is: void function (DispelInfo* dispelInfo);
790 #define AuraDispelFn(F) AuraDispelFunction(&F)
791
792 // executed when aura effect is applied with specified mode to target
793 // 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
794 // example: OnEffectApply += AuraEffectApplyFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
795 // where function is: void function(AuraEffect const* aurEff, AuraEffectHandleModes mode);
797 // executed after aura effect is applied with specified mode to target
798 // example: AfterEffectApply += AuraEffectApplyFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
799 // where function is: void function(AuraEffect const* aurEff, AuraEffectHandleModes mode);
801 #define AuraEffectApplyFn(F, I, N, M) EffectApplyHandlerFunction(&F, I, N, M)
802
803 // executed after aura effect is removed with specified mode from target
804 // should be used when effect handler preventing/replacing is needed, do not use this hook for triggering spellcasts/removing auras etc - may be unsafe
805 // example: OnEffectRemove += AuraEffectRemoveFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
806 // where function is: void function(AuraEffect const* aurEff, AuraEffectHandleModes mode);
808 // executed when aura effect is removed with specified mode from target
809 // example: AfterEffectRemove += AuraEffectRemoveFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
810 // where function is: void function(AuraEffect const* aurEff, AuraEffectHandleModes mode);
812 #define AuraEffectRemoveFn(F, I, N, M) EffectApplyHandlerFunction(&F, I, N, M)
813
814 // executed when periodic aura effect ticks on target
815 // example: OnEffectPeriodic += AuraEffectPeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
816 // where function is: void function(AuraEffect const* aurEff);
818 #define AuraEffectPeriodicFn(F, I, N) EffectPeriodicHandlerFunction(&F, I, N)
819
820 // executed when periodic aura effect is updated
821 // example: OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
822 // where function is: void function(AuraEffect* aurEff);
824 #define AuraEffectUpdatePeriodicFn(F, I, N) EffectUpdatePeriodicHandlerFunction(&F, I, N)
825
826 // executed when aura effect calculates amount
827 // example: DoEffectCalcAmount += AuraEffectCalcAmounFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
828 // where function is: void function(AuraEffect* aurEff, int32& amount, bool& canBeRecalculated);
830 #define AuraEffectCalcAmountFn(F, I, N) EffectCalcAmountHandlerFunction(&F, I, N)
831
832 // executed when aura effect calculates periodic data
833 // example: DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
834 // where function is: void function(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude);
836 #define AuraEffectCalcPeriodicFn(F, I, N) EffectCalcPeriodicHandlerFunction(&F, I, N)
837
838 // executed when aura effect calculates spellmod
839 // example: DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
840 // where function is: void function(AuraEffect const* aurEff, SpellModifier*& spellMod);
842 #define AuraEffectCalcSpellModFn(F, I, N) EffectCalcSpellModHandlerFunction(&F, I, N)
843
844 // executed when absorb aura effect is going to reduce damage
845 // example: OnEffectAbsorb += AuraEffectAbsorbFn(class::function, EffectIndexSpecifier);
846 // where function is: void function(AuraEffect const* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
848 #define AuraEffectAbsorbFn(F, I) EffectAbsorbFunction(&F, I)
849
850 // executed after absorb aura effect reduced damage to target - absorbAmount is real amount absorbed by aura
851 // example: AfterEffectAbsorb += AuraEffectAbsorbFn(class::function, EffectIndexSpecifier);
852 // where function is: void function(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
854
855 // executed when mana shield aura effect is going to reduce damage
856 // example: OnEffectManaShield += AuraEffectManaShieldFn(class::function, EffectIndexSpecifier);
857 // where function is: void function(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
859 #define AuraEffectManaShieldFn(F, I) EffectManaShieldFunction(&F, I)
860
861 // executed after mana shield aura effect reduced damage to target - absorbAmount is real amount absorbed by aura
862 // example: AfterEffectManaShield += AuraEffectManaShieldFn(class::function, EffectIndexSpecifier);
863 // where function is: void function(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount);
865
866 // executed when the caster of some spell with split dmg aura gets damaged through it
867 // example: OnEffectSplit += AuraEffectSplitFn(class::function, EffectIndexSpecifier);
868 // where function is: void function(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& splitAmount);
870 #define AuraEffectSplitFn(F, I) EffectSplitFunction(&F, I)
871
872 // executed when aura checks if it can proc
873 // example: DoCheckProc += AuraCheckProcFn(class::function);
874 // where function is: bool function(ProcEventInfo& eventInfo);
876 #define AuraCheckProcFn(F) CheckProcHandlerFunction(&F)
877
878 // executed when aura effect checks if it can proc the aura
879 // example: DoCheckEffectProc += AuraCheckEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
880 // where function is bool function(AuraEffect const* aurEff, ProcEventInfo& eventInfo);
882 #define AuraCheckEffectProcFn(F, I, N) CheckEffectProcHandlerFunction(&F, I, N)
883
884 // executed before aura procs (possibility to prevent charge drop/cooldown)
885 // example: DoPrepareProc += AuraProcFn(class::function);
886 // where function is: void function(ProcEventInfo& eventInfo);
888 // executed when aura procs
889 // example: OnProc += AuraProcFn(class::function);
890 // where function is: void function(ProcEventInfo& eventInfo);
892 // executed after aura proced
893 // example: AfterProc += AuraProcFn(class::function);
894 // where function is: void function(ProcEventInfo& eventInfo);
896 #define AuraProcFn(F) AuraProcHandlerFunction(&F)
897
898 // executed when aura effect procs
899 // example: OnEffectProc += AuraEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
900 // where function is: void function(AuraEffect const* aurEff, ProcEventInfo& procInfo);
902 // executed after aura effect proced
903 // example: AfterEffectProc += AuraEffectProcFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
904 // where function is: void function(AuraEffect const* aurEff, ProcEventInfo& procInfo);
906 #define AuraEffectProcFn(F, I, N) EffectProcHandlerFunction(&F, I, N)
907
908 // AuraScript interface - hook/effect execution manipulators
909
910 // prevents default action of a hook from being executed (works only while called in a hook which default action can be prevented)
911 void PreventDefaultAction();
912
913 // AuraScript interface - functions which are redirecting to Aura class
914
915 // returns proto of the spell
916 SpellInfo const* GetSpellInfo() const;
917 SpellEffectInfo const& GetEffectInfo(SpellEffIndex effIndex) const;
918 // returns spellid of the spell
919 uint32 GetId() const;
920
921 // returns guid of object which cast the aura (m_originalCaster of the Spell class)
922 ObjectGuid GetCasterGUID() const;
923 // returns unit which cast the aura or NULL if not avalible (caster logged out for example)
924 Unit* GetCaster() const;
925 // returns gameobject which cast the aura or NULL if not available
926 GameObject* GetGObjCaster() const;
927 // returns object on which aura was cast, target for non-area auras, area aura source for area auras
928 WorldObject* GetOwner() const;
929 // returns owner if it's unit or unit derived object, NULL otherwise (only for persistent area auras NULL is returned)
930 Unit* GetUnitOwner() const;
931 // returns owner if it's dynobj, NULL otherwise
932 DynamicObject* GetDynobjOwner() const;
933
934 // removes aura with remove mode (see AuraRemoveMode enum)
935 void Remove(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
936 // returns aura object of script
937 Aura* GetAura() const;
938
939 // returns type of the aura, may be dynobj owned aura or unit owned aura
940 AuraObjectType GetType() const;
941
942 // aura duration manipulation - when duration goes to 0 aura is removed
943 int32 GetDuration() const;
944 void SetDuration(int32 duration, bool withMods = false);
945 // sets duration to maxduration
946 void RefreshDuration();
947 time_t GetApplyTime() const;
948 int32 GetMaxDuration() const;
949 void SetMaxDuration(int32 duration);
950 int32 CalcMaxDuration() const;
951 // expired - duration just went to 0
952 bool IsExpired() const;
953 // permament - has infinite duration
954 bool IsPermanent() const;
955
956 // charges manipulation - 0 - not charged aura
957 uint8 GetCharges() const;
958 void SetCharges(uint8 charges);
959 uint8 CalcMaxCharges() const;
960 bool ModCharges(int8 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
961 // returns true if last charge dropped
962 bool DropCharge(AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
963
964 // stack amount manipulation
965 uint8 GetStackAmount() const;
966 void SetStackAmount(uint8 num);
967 bool ModStackAmount(int32 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
968
969 // passive - "working in background", not saved, not removed by immunities, not seen by player
970 bool IsPassive() const;
971 // death persistent - not removed on death
972 bool IsDeathPersistent() const;
973
974 // check if aura has effect of given effindex
975 bool HasEffect(uint8 effIndex) const;
976 // returns aura effect of given effect index or NULL
977 AuraEffect* GetEffect(uint8 effIndex) const;
978
979 // check if aura has effect of given aura type
980 bool HasEffectType(AuraType type) const;
981
982 // AuraScript interface - functions which are redirecting to AuraApplication class
983 // Do not call these in hooks in which AuraApplication is not avalible, otherwise result will differ from expected (the functions will return NULL)
984
985 // returns currently processed target of an aura
986 // Return value does not need to be NULL-checked, the only situation this will (always)
987 // return NULL is when the call happens in an unsupported hook, in other cases, it is always valid
988 Unit* GetTarget() const;
989 // returns AuraApplication object of currently processed target
990 AuraApplication const* GetTargetApplication() const;
991};
992
993//
994// definitions:
995//
996// EffectIndexSpecifier - specifies conditions for effects
997// EFFECT_0 - first effect matches
998// EFFECT_1 - second effect matches
999// EFFECT_2 - third effect matches
1000// EFFECT_FIRST_FOUND - first effect matching other conditions matches
1001// EFFECT_ALL - all effects of spell match
1002//
1003// EffectNameSpecifier - specifies conditions for spell effect names
1004// SPELL_EFFECT_ANY - any effect but not 0 matches condition
1005// SPELL_EFFECT_XXX - one of values of enum SpellEffects - effect with equal name matches
1006//
1007
1008#endif // __SPELL_SCRIPT_H
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
int64_t int64
Definition Define.h:128
int8_t int8
Definition Define.h:131
int32_t int32
Definition Define.h:129
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
SpellEffIndex
SpellCustomErrors
SpellMissInfo
SpellCastResult
AuraRemoveMode
@ AURA_REMOVE_BY_DEFAULT
AuraEffectHandleModes
AuraObjectType
AuraScriptHookType
@ AURA_SCRIPT_HOOK_EFFECT_CALC_PERIODIC
@ AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC
@ AURA_SCRIPT_HOOK_EFFECT_CALC_AMOUNT
@ AURA_SCRIPT_HOOK_EFFECT_REMOVE
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD
@ AURA_SCRIPT_HOOK_PREPARE_PROC
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE
@ AURA_SCRIPT_HOOK_AFTER_PROC
@ AURA_SCRIPT_HOOK_CHECK_AREA_TARGET
@ AURA_SCRIPT_HOOK_EFFECT_MANASHIELD
@ AURA_SCRIPT_HOOK_PROC
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB
@ AURA_SCRIPT_HOOK_DISPEL
@ AURA_SCRIPT_HOOK_EFFECT_APPLY
@ AURA_SCRIPT_HOOK_EFFECT_PERIODIC
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC
@ AURA_SCRIPT_HOOK_EFFECT_ABSORB
@ AURA_SCRIPT_HOOK_EFFECT_PROC
@ AURA_SCRIPT_HOOK_EFFECT_SPLIT
@ AURA_SCRIPT_HOOK_EFFECT_CALC_SPELLMOD
@ AURA_SCRIPT_HOOK_AFTER_DISPEL
@ AURA_SCRIPT_HOOK_CHECK_PROC
@ AURA_SCRIPT_HOOK_EFFECT_UPDATE_PERIODIC
#define AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME)
SpellScriptState
Definition SpellScript.h:56
@ SPELL_SCRIPT_STATE_NONE
Definition SpellScript.h:57
@ SPELL_SCRIPT_STATE_LOADING
Definition SpellScript.h:59
@ SPELL_SCRIPT_STATE_UNLOADING
Definition SpellScript.h:60
@ SPELL_SCRIPT_STATE_REGISTRATION
Definition SpellScript.h:58
#define SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME)
#define SPELL_SCRIPT_STATE_END
Definition SpellScript.h:62
SpellScriptHookType
@ SPELL_SCRIPT_HOOK_AFTER_CAST
@ SPELL_SCRIPT_HOOK_EFFECT_HIT
@ SPELL_SCRIPT_HOOK_AFTER_HIT
@ SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH
@ SPELL_SCRIPT_HOOK_OBJECT_AREA_TARGET_SELECT
@ SPELL_SCRIPT_HOOK_BEFORE_HIT
@ SPELL_SCRIPT_HOOK_CHECK_CAST
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET
@ SPELL_SCRIPT_HOOK_HIT
@ SPELL_SCRIPT_HOOK_BEFORE_CAST
@ SPELL_SCRIPT_HOOK_ON_RESIST_ABSORB_CALCULATION
@ SPELL_SCRIPT_HOOK_DESTINATION_TARGET_SELECT
@ SPELL_SCRIPT_HOOK_OBJECT_TARGET_SELECT
@ SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET
@ SPELL_SCRIPT_HOOK_ON_CAST
AuraDispelFnType pHandlerScript
AuraProcFnType _HandlerScript
AuraCheckAreaTargetFnType pHandlerScript
AuraCheckEffectProcFnType _HandlerScript
AuraCheckProcFnType _HandlerScript
AuraEffectAbsorbFnType pEffectHandlerScript
AuraEffectHandleModes mode
AuraEffectApplicationModeFnType pEffectHandlerScript
AuraEffectCalcAmountFnType pEffectHandlerScript
AuraEffectCalcPeriodicFnType pEffectHandlerScript
AuraEffectCalcSpellModFnType pEffectHandlerScript
AuraEffectAbsorbFnType pEffectHandlerScript
AuraEffectPeriodicFnType pEffectHandlerScript
AuraEffectProcFnType _EffectHandlerScript
AuraEffectSplitFnType pEffectHandlerScript
AuraEffectUpdatePeriodicFnType pEffectHandlerScript
ScriptStateStore(uint8 currentScriptState, AuraApplication const *auraApplication, bool defaultActionPrevented)
AuraApplication const * _auraApplication
HookList< EffectManaShieldHandler > AfterEffectManaShield
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
HookList< EffectApplyHandler > AfterEffectRemove
AuraApplication const * m_auraApplication
HookList< CheckEffectProcHandler > DoCheckEffectProc
HookList< EffectPeriodicHandler > OnEffectPeriodic
bool m_defaultActionPrevented
HookList< EffectApplyHandler > AfterEffectApply
HookList< EffectProcHandler > AfterEffectProc
HookList< EffectAbsorbHandler > AfterEffectAbsorb
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
HookList< EffectCalcSpellModHandler > DoEffectCalcSpellMod
HookList< EffectManaShieldHandler > OnEffectManaShield
HookList< EffectAbsorbHandler > OnEffectAbsorb
std::stack< ScriptStateStore > ScriptStateStack
HookList< CheckAreaTargetHandler > DoCheckAreaTarget
Aura * m_aura
HookList< AuraProcHandler > AfterProc
HookList< AuraDispelHandler > OnDispel
HookList< CheckProcHandler > DoCheckProc
HookList< EffectApplyHandler > OnEffectRemove
HookList< AuraDispelHandler > AfterDispel
ScriptStateStack m_scriptStates
HookList< EffectProcHandler > OnEffectProc
HookList< AuraProcHandler > DoPrepareProc
HookList< AuraProcHandler > OnProc
HookList< EffectSplitHandler > OnEffectSplit
HookList< EffectApplyHandler > OnEffectApply
Definition Item.h:62
SpellBeforeHitFnType _pBeforeHitHandlerScript
SpellCastFnType pCastHandlerScript
SpellCheckCastFnType _checkCastHandlerScript
SpellDestinationTargetSelectFnType DestinationTargetSelectHandlerScript
SpellEffectFnType pEffectHandlerScript
SpellHitFnType pHitHandlerScript
SpellObjectAreaTargetSelectFnType pObjectAreaTargetSelectHandlerScript
bool HasSameTargetFunctionAs(ObjectAreaTargetSelectHandler const &other) const
bool HasSameTargetFunctionAs(ObjectTargetSelectHandler const &other) const
SpellObjectTargetSelectFnType pObjectTargetSelectHandlerScript
SpellOnResistAbsorbCalculateFnType pOnCalculateResistAbsorbHandlerScript
uint16 GetTarget() const
HookList< CastHandler > AfterCast
HookList< CheckCastHandler > OnCheckCast
HookList< HitHandler > AfterHit
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
HookList< HitHandler > OnHit
void PreventHitDamage()
HookList< EffectHandler > OnEffectHit
uint8 m_hitPreventEffectMask
HookList< EffectHandler > OnEffectHitTarget
void PreventHitHeal()
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
HookList< CastHandler > OnCast
HookList< OnCalculateResistAbsorbHandler > OnCalculateResistAbsorb
HookList< CastHandler > BeforeCast
Spell * m_spell
Spell * GetSpell() const
HookList< EffectHandler > OnEffectLaunchTarget
uint8 m_hitPreventDefaultEffectMask
HookList< BeforeHitHandler > BeforeHit
bool _IsDefaultEffectPrevented(SpellEffIndex effIndex)
bool _IsEffectPrevented(SpellEffIndex effIndex)
HookList< EffectHandler > OnEffectSuccessfulDispel
HookList< EffectHandler > OnEffectLaunch
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition Spell.h:152
Definition Unit.h:769
EffectAuraNameCheck(uint16 _effAurName)
virtual bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex)=0
EffectNameCheck(uint16 _effName)
Definition SpellScript.h:98
static bool ValidateSpellInfo(T const &spellIds)
std::string const * m_scriptName
uint8 m_currentScriptState
static bool _ValidateSpellInfo(Iterator begin, Iterator end)
virtual ~_SpellScript()
Definition SpellScript.h:74
virtual bool Validate(SpellInfo const *)
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
virtual void Register()=0
virtual bool Load()
virtual void Unload()
uint32 m_scriptSpellId