TrinityCore
Loading...
Searching...
No Matches
SpellScript.cpp
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#include "SpellScript.h"
19#include "Log.h"
20#include "Spell.h"
21#include "ScriptMgr.h"
22#include "SpellAuras.h"
23#include "SpellMgr.h"
24#include "Unit.h"
25#include <sstream>
26#include <string>
27
29{
30 if (!Validate(entry))
31 {
32 TC_LOG_ERROR("scripts", "Spell `{}` did not pass Validate() function of script `{}` - script will be not added to the spell", entry->Id, m_scriptName->c_str());
33 return false;
34 }
35 return true;
36}
37
39{
40 if (!sSpellMgr->GetSpellInfo(spellId))
41 {
42 TC_LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell {} does not exist.", spellId);
43 return false;
44 }
45
46 return true;
47}
48
55
62
63void _SpellScript::_Init(std::string const* scriptname, uint32 spellId)
64{
66 m_scriptName = scriptname;
67 m_scriptSpellId = spellId;
68
69#ifdef TRINITY_API_USE_DYNAMIC_LINKING
70 // Acquire a strong reference to the binary code
71 // to keep it loaded until all spells are destroyed.
72 m_moduleReference = sScriptMgr->AcquireModuleReferenceOfScriptName(*scriptname);
73#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
74}
75
76std::string const* _SpellScript::_GetScriptName() const
77{
78 return m_scriptName;
79}
80
82{
83 // effect index must be in range <0;2>, allow use of special effindexes
84 ASSERT(_effIndex == EFFECT_ALL || _effIndex == EFFECT_FIRST_FOUND || _effIndex < MAX_SPELL_EFFECTS);
85 effIndex = _effIndex;
86}
87
89{
90 uint8 mask = 0;
91 if ((effIndex == EFFECT_ALL) || (effIndex == EFFECT_FIRST_FOUND))
92 {
93 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
94 {
95 if ((effIndex == EFFECT_FIRST_FOUND) && mask)
96 return mask;
97 if (CheckEffect(spellEntry, i))
98 mask |= (uint8)1<<i;
99 }
100 }
101 else
102 {
103 if (CheckEffect(spellEntry, effIndex))
104 mask |= (uint8)1<<effIndex;
105 }
106 return mask;
107}
108
109bool _SpellScript::EffectHook::IsEffectAffected(SpellInfo const* spellEntry, uint8 effIndexToCheck)
110{
111 return (GetAffectedEffectsMask(spellEntry) & 1 << effIndexToCheck) != 0;
112}
113
115{
116 switch (effIndex)
117 {
118 case EFFECT_ALL:
119 return "EFFECT_ALL";
121 return "EFFECT_FIRST_FOUND";
122 case EFFECT_0:
123 return "EFFECT_0";
124 case EFFECT_1:
125 return "EFFECT_1";
126 case EFFECT_2:
127 return "EFFECT_2";
128 }
129 return "Invalid Value";
130}
131
132bool _SpellScript::EffectNameCheck::Check(SpellInfo const* spellEntry, uint8 effIndex)
133{
134 SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndex));
135 if (!spellEffectInfo.Effect && !effName)
136 return true;
137 if (!spellEffectInfo.Effect)
138 return false;
139 return (effName == SPELL_EFFECT_ANY) || (spellEffectInfo.Effect == effName);
140}
141
143{
144 switch (effName)
145 {
146 case SPELL_EFFECT_ANY:
147 return "SPELL_EFFECT_ANY";
148 default:
149 return Trinity::StringFormat("SPELL_EFFECT_{}", effName);
150 }
151}
152
154{
155 SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndex));
156 if (!spellEffectInfo.ApplyAuraName && !effAurName)
157 return true;
158 if (!spellEffectInfo.ApplyAuraName)
159 return false;
160 return (effAurName == SPELL_AURA_ANY) || (spellEffectInfo.ApplyAuraName == effAurName);
161}
162
164{
165 switch (effAurName)
166 {
167 case SPELL_AURA_ANY:
168 return "SPELL_AURA_ANY";
169 default:
170 return Trinity::StringFormat("SPELL_AURA_{}", effAurName);
171 }
172}
173
174SpellScript::CastHandler::CastHandler(SpellCastFnType _pCastHandlerScript)
175{
176 pCastHandlerScript = _pCastHandlerScript;
177}
178
180{
181 (spellScript->*pCastHandlerScript)();
182}
183
184SpellScript::CheckCastHandler::CheckCastHandler(SpellCheckCastFnType checkCastHandlerScript)
185{
186 _checkCastHandlerScript = checkCastHandlerScript;
187}
188
190{
191 return (spellScript->*_checkCastHandlerScript)();
192}
193
194SpellScript::OnCalculateResistAbsorbHandler::OnCalculateResistAbsorbHandler(SpellOnResistAbsorbCalculateFnType onResistAbsorbCalculateHandlerScript)
195{
196 pOnCalculateResistAbsorbHandlerScript = onResistAbsorbCalculateHandlerScript;
197}
198
199void SpellScript::OnCalculateResistAbsorbHandler::Call(SpellScript* spellScript, DamageInfo const& damageInfo, uint32& resistAmount, int32& absorbAmount)
200{
201 return (spellScript->*pOnCalculateResistAbsorbHandlerScript)(damageInfo, resistAmount, absorbAmount);
202}
203
204SpellScript::EffectHandler::EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
205 : _SpellScript::EffectNameCheck(_effName), _SpellScript::EffectHook(_effIndex)
206{
207 pEffectHandlerScript = _pEffectHandlerScript;
208}
209
211{
212 return "Index: " + EffIndexToString() + " Name: " +_SpellScript::EffectNameCheck::ToString();
213}
214
215bool SpellScript::EffectHandler::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
216{
217 return _SpellScript::EffectNameCheck::Check(spellEntry, effIndexToCheck);
218}
219
221{
222 (spellScript->*pEffectHandlerScript)(effIndexToHandle);
223}
224
225SpellScript::BeforeHitHandler::BeforeHitHandler(SpellBeforeHitFnType pBeforeHitHandlerScript)
226{
227 _pBeforeHitHandlerScript = pBeforeHitHandlerScript;
228}
229
231{
232 (spellScript->*_pBeforeHitHandlerScript)(missInfo);
233}
234
235SpellScript::HitHandler::HitHandler(SpellHitFnType _pHitHandlerScript)
236{
237 pHitHandlerScript = _pHitHandlerScript;
238}
239
241{
242 (spellScript->*pHitHandlerScript)();
243}
244
245SpellScript::TargetHook::TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest)
246 : _SpellScript::EffectHook(_effectIndex), targetType(_targetType), area(_area), dest(_dest) { }
247
249{
250 std::ostringstream oss;
251 oss << "Index: " << EffIndexToString() << " Target: " << targetType;
252 return oss.str();
253}
254
255bool SpellScript::TargetHook::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
256{
257 if (!targetType)
258 return false;
259
260 SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndexToCheck));
261 if (spellEffectInfo.TargetA.GetTarget() != targetType &&
262 spellEffectInfo.TargetB.GetTarget() != targetType)
263 return false;
264
265 SpellImplicitTargetInfo targetInfo(targetType);
266 switch (targetInfo.GetSelectionCategory())
267 {
268 case TARGET_SELECT_CATEGORY_CHANNEL: // SINGLE
269 return !area;
271 return true;
272 case TARGET_SELECT_CATEGORY_CONE: // AREA
273 case TARGET_SELECT_CATEGORY_AREA: // AREA
274 return area;
276 switch (targetInfo.GetObjectType())
277 {
278 case TARGET_OBJECT_TYPE_SRC: // EMPTY
279 return false;
280 case TARGET_OBJECT_TYPE_DEST: // DEST
281 return dest;
282 default:
283 switch (targetInfo.GetReferenceType())
284 {
285 case TARGET_REFERENCE_TYPE_CASTER: // SINGLE
286 return !area;
287 case TARGET_REFERENCE_TYPE_TARGET: // BOTH
288 return true;
289 default:
290 break;
291 }
292 break;
293 }
294 break;
295 default:
296 break;
297 }
298
299 return false;
300}
301
302SpellScript::ObjectAreaTargetSelectHandler::ObjectAreaTargetSelectHandler(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
303 : TargetHook(_effIndex, _targetType, true, false)
304{
305 pObjectAreaTargetSelectHandlerScript = _pObjectAreaTargetSelectHandlerScript;
306}
307
308void SpellScript::ObjectAreaTargetSelectHandler::Call(SpellScript* spellScript, std::list<WorldObject*>& targets)
309{
310 (spellScript->*pObjectAreaTargetSelectHandlerScript)(targets);
311}
312
313SpellScript::ObjectTargetSelectHandler::ObjectTargetSelectHandler(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
314 : TargetHook(_effIndex, _targetType, false, false)
315{
316 pObjectTargetSelectHandlerScript = _pObjectTargetSelectHandlerScript;
317}
318
320{
321 (spellScript->*pObjectTargetSelectHandlerScript)(target);
322}
323
324SpellScript::DestinationTargetSelectHandler::DestinationTargetSelectHandler(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
325 : TargetHook(_effIndex, _targetType, false, true)
326{
327 DestinationTargetSelectHandlerScript = _DestinationTargetSelectHandlerScript;
328}
329
331{
332 (spellScript->*DestinationTargetSelectHandlerScript)(target);
333}
334
338
339SpellScript::~SpellScript() = default;
340
342{
343 for (auto itr = OnEffectLaunch.begin(); itr != OnEffectLaunch.end(); ++itr)
344 if (!(*itr).GetAffectedEffectsMask(entry))
345 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectLaunch` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
346
347 for (auto itr = OnEffectLaunchTarget.begin(); itr != OnEffectLaunchTarget.end(); ++itr)
348 if (!(*itr).GetAffectedEffectsMask(entry))
349 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectLaunchTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
350
351 for (auto itr = OnEffectHit.begin(); itr != OnEffectHit.end(); ++itr)
352 if (!(*itr).GetAffectedEffectsMask(entry))
353 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectHit` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
354
355 for (auto itr = OnEffectHitTarget.begin(); itr != OnEffectHitTarget.end(); ++itr)
356 if (!(*itr).GetAffectedEffectsMask(entry))
357 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectHitTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
358
359 for (auto itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.end(); ++itr)
360 if (!(*itr).GetAffectedEffectsMask(entry))
361 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectSuccessfulDispel` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
362
363 for (auto itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.end(); ++itr)
364 if (!(*itr).GetAffectedEffectsMask(entry))
365 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnObjectAreaTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
366
367 for (auto itr = OnObjectTargetSelect.begin(); itr != OnObjectTargetSelect.end(); ++itr)
368 if (!(*itr).GetAffectedEffectsMask(entry))
369 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnObjectTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
370
371 for (auto itr = OnDestinationTargetSelect.begin(); itr != OnDestinationTargetSelect.end(); ++itr)
372 if (!(*itr).GetAffectedEffectsMask(entry))
373 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnDestinationTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
374
375 return _SpellScript::_Validate(entry);
376}
377
379{
380 m_spell = spell;
382 bool load = Load();
384 return load;
385}
386
392
397
402
407
414
416{
417 switch (m_currentScriptState)
418 {
424 return true;
425 }
426 return false;
427}
428
430{
431 // after hit hook executed after damage/healing is already done
432 // modifying it at this point has no effect
433 switch (m_currentScriptState)
434 {
439 return true;
440 }
441 return false;
442}
443
448
453
455{
456 return m_spell->GetCaster()->ToUnit();
457}
458
463
468
470{
471 return m_spell->GetSpellInfo();
472}
473
475{
476 return GetSpellInfo()->GetEffect(effIndex);
477}
478
480{
481 return m_spell->m_spellValue;
482}
483
485{
486 if (m_spell->m_targets.HasDst())
487 return m_spell->m_targets.GetDstPos();
488 return nullptr;
489}
490
495
500
505
510
515
517{
519 {
520 TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetUnitTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
521 m_scriptName->c_str(), m_scriptSpellId);
522 return 0;
523 }
524 return m_spell->GetUnitTargetCountForEffect(effect);
525}
526
528{
530 {
531 TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetGameObjectTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
532 m_scriptName->c_str(), m_scriptSpellId);
533 return 0;
534 }
536}
537
539{
541 {
542 TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetItemTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
543 m_scriptName->c_str(), m_scriptSpellId);
544 return 0;
545 }
546 return m_spell->GetItemTargetCountForEffect(effect);
547}
548
550{
551 if (!IsInTargetHook())
552 {
553 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitUnit was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
554 return nullptr;
555 }
556 return m_spell->unitTarget;
557}
558
560{
561 if (!IsInTargetHook())
562 {
563 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitCreature was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
564 return nullptr;
565 }
566 if (m_spell->unitTarget)
567 return m_spell->unitTarget->ToCreature();
568 else
569 return nullptr;
570}
571
573{
574 if (!IsInTargetHook())
575 {
576 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitPlayer was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
577 return nullptr;
578 }
579 if (m_spell->unitTarget)
580 return m_spell->unitTarget->ToPlayer();
581 else
582 return nullptr;
583}
584
586{
587 if (!IsInTargetHook())
588 {
589 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitItem was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
590 return nullptr;
591 }
592 return m_spell->itemTarget;
593}
594
596{
597 if (!IsInTargetHook())
598 {
599 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitGObj was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
600 return nullptr;
601 }
602 return m_spell->gameObjTarget;
603}
604
606{
607 if (!IsInTargetHook())
608 {
609 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitCorpse was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
610 return nullptr;
611 }
612 return m_spell->m_corpseTarget;
613}
614
616{
617 if (!IsInEffectHook())
618 {
619 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitDest was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
620 return nullptr;
621 }
622 return m_spell->destTarget;
623}
624
626{
627 if (!IsInTargetHook())
628 {
629 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitDamage was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
630 return 0;
631 }
632 return m_spell->m_damage;
633}
634
636{
637 if (!IsInModifiableHook())
638 {
639 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetHitDamage was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
640 return;
641 }
642 m_spell->m_damage = damage;
643}
644
646{
647 if (!IsInTargetHook())
648 {
649 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitHeal was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
650 return 0;
651 }
652 return m_spell->m_healing;
653}
654
656{
657 if (!IsInModifiableHook())
658 {
659 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetHitHeal was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
660 return;
661 }
662 m_spell->m_healing = heal;
663}
664
665Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/) const
666{
667 if (!IsInTargetHook())
668 {
669 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitAura was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
670 return nullptr;
671 }
672
673 Aura* aura = m_spell->_spellAura;
674 if (dynObjAura)
675 aura = m_spell->_dynObjAura;
676
677 if (!aura || aura->IsRemoved())
678 return nullptr;
679
680 return aura;
681}
682
684{
685 if (!IsInTargetHook())
686 {
687 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::PreventHitAura was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
688 return;
689 }
690 if (UnitAura* aura = m_spell->_spellAura)
691 aura->Remove();
692 if (DynObjAura* aura = m_spell->_dynObjAura)
693 aura->Remove();
694}
695
697{
698 if (!IsInHitPhase() && !IsInEffectHook())
699 {
700 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::PreventHitEffect was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
701 return;
702 }
703 m_hitPreventEffectMask |= 1 << effIndex;
704 PreventHitDefaultEffect(effIndex);
705}
706
708{
709 if (!IsInHitPhase() && !IsInEffectHook())
710 {
711 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::PreventHitDefaultEffect was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
712 return;
713 }
714 m_hitPreventDefaultEffectMask |= 1 << effIndex;
715}
716
718{
719 ASSERT(IsInEffectHook(), "Script: `%s` Spell: `%u`: function SpellScript::GetEffectInfo was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
720
721 return *m_spell->effectInfo;
722}
723
725{
726 if (!IsInEffectHook())
727 {
728 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetEffectValue was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
729 return 0;
730 }
731
732 return m_spell->damage;
733}
734
736{
737 if (!IsInEffectHook())
738 {
739 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetEffectValue was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
740 return;
741 }
742
743 m_spell->damage = value;
744}
745
747{
748 return m_spell->m_CastItem;
749}
750
752{
753 m_spell->DoCreateItem(itemId);
754}
755
760
761void SpellScript::FinishCast(SpellCastResult result, uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/)
762{
763 m_spell->SendCastResult(result, param1, param2);
764 m_spell->finish(result == SPELL_CAST_OK);
765}
766
768{
769 if (!IsInCheckCastHook())
770 {
771 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetCustomCastResultMessage was called while spell not in check cast phase!", m_scriptName->c_str(), m_scriptSpellId);
772 return;
773 }
774
775 m_spell->m_customError = result;
776}
777
779{
780 for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
782 TC_LOG_ERROR("scripts", "Spell `{}` of script `{}` does not have apply aura effect - handler bound to hook `DoCheckAreaTarget` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
783
784 for (auto itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
785 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
786 TC_LOG_ERROR("scripts", "Spell `{}` of script `{}` does not have apply aura effect - handler bound to hook `OnDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
787
788 for (auto itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
789 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
790 TC_LOG_ERROR("scripts", "Spell `{}` of script `{}` does not have apply aura effect - handler bound to hook `AfterDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
791
792 for (auto itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
793 if (!(*itr).GetAffectedEffectsMask(entry))
794 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
795
796 for (auto itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
797 if (!(*itr).GetAffectedEffectsMask(entry))
798 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
799
800 for (auto itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
801 if (!(*itr).GetAffectedEffectsMask(entry))
802 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `AfterEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
803
804 for (auto itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
805 if (!(*itr).GetAffectedEffectsMask(entry))
806 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `AfterEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
807
808 for (auto itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
809 if (!(*itr).GetAffectedEffectsMask(entry))
810 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
811
812 for (auto itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
813 if (!(*itr).GetAffectedEffectsMask(entry))
814 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectUpdatePeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
815
816 for (auto itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
817 if (!(*itr).GetAffectedEffectsMask(entry))
818 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `DoEffectCalcAmount` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
819
820 for (auto itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
821 if (!(*itr).GetAffectedEffectsMask(entry))
822 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `DoEffectCalcPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
823
824 for (auto itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
825 if (!(*itr).GetAffectedEffectsMask(entry))
826 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `DoEffectCalcSpellMod` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
827
828 for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
829 if (!(*itr).GetAffectedEffectsMask(entry))
830 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
831
832 for (auto itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
833 if (!(*itr).GetAffectedEffectsMask(entry))
834 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `AfterEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
835
836 for (auto itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
837 if (!(*itr).GetAffectedEffectsMask(entry))
838 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
839
840 for (auto itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
841 if (!(*itr).GetAffectedEffectsMask(entry))
842 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `AfterEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
843
844 for (auto itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
845 if (!(*itr).GetAffectedEffectsMask(entry))
846 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectSplit` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
847
848 for (auto itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
849 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
850 TC_LOG_ERROR("scripts", "Spell `{}` of script `{}` does not have apply aura effect - handler bound to hook `DoCheckProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
851
852 for (auto itr = DoCheckEffectProc.begin(); itr != DoCheckEffectProc.end(); ++itr)
853 if (!itr->GetAffectedEffectsMask(entry))
854 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `DoCheckEffectProc` of AuraScript won't be executed", entry->Id, itr->ToString(), m_scriptName->c_str());
855
856 for (auto itr = DoPrepareProc.begin(); itr != DoPrepareProc.end(); ++itr)
857 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
858 TC_LOG_ERROR("scripts", "Spell `{}` of script `{}` does not have apply aura effect - handler bound to hook `DoPrepareProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
859
860 for (auto itr = OnProc.begin(); itr != OnProc.end(); ++itr)
861 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
862 TC_LOG_ERROR("scripts", "Spell `{}` of script `{}` does not have apply aura effect - handler bound to hook `OnProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
863
864 for (auto itr = AfterProc.begin(); itr != AfterProc.end(); ++itr)
865 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
866 TC_LOG_ERROR("scripts", "Spell `{}` of script `{}` does not have apply aura effect - handler bound to hook `AfterProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
867
868 for (auto itr = OnEffectProc.begin(); itr != OnEffectProc.end(); ++itr)
869 if (!(*itr).GetAffectedEffectsMask(entry))
870 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `OnEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
871
872 for (auto itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
873 if (!(*itr).GetAffectedEffectsMask(entry))
874 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `AfterEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
875
876 return _SpellScript::_Validate(entry);
877}
878
879AuraScript::CheckAreaTargetHandler::CheckAreaTargetHandler(AuraCheckAreaTargetFnType _pHandlerScript)
880{
881 pHandlerScript = _pHandlerScript;
882}
883
885{
886 return (auraScript->*pHandlerScript)(_target);
887}
888
890{
891 pHandlerScript = _pHandlerScript;
892}
893
895{
896 (auraScript->*pHandlerScript)(_dispelInfo);
897}
898
901
902bool AuraScript::EffectBase::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
903{
904 return _SpellScript::EffectAuraNameCheck::Check(spellEntry, effIndexToCheck);
905}
906
908{
909 return "Index: " + EffIndexToString() + " AuraName: " +_SpellScript::EffectAuraNameCheck::ToString();
910}
911
912AuraScript::EffectPeriodicHandler::EffectPeriodicHandler(AuraEffectPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
913 : AuraScript::EffectBase(_effIndex, _effName)
914{
915 pEffectHandlerScript = _pEffectHandlerScript;
916}
917
919{
920 (auraScript->*pEffectHandlerScript)(_aurEff);
921}
922
923AuraScript::EffectUpdatePeriodicHandler::EffectUpdatePeriodicHandler(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
924 : AuraScript::EffectBase(_effIndex, _effName)
925{
926 pEffectHandlerScript = _pEffectHandlerScript;
927}
928
930{
931 (auraScript->*pEffectHandlerScript)(aurEff);
932}
933
934AuraScript::EffectCalcAmountHandler::EffectCalcAmountHandler(AuraEffectCalcAmountFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
935 : AuraScript::EffectBase(_effIndex, _effName)
936{
937 pEffectHandlerScript = _pEffectHandlerScript;
938}
939
940void AuraScript::EffectCalcAmountHandler::Call(AuraScript* auraScript, AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)
941{
942 (auraScript->*pEffectHandlerScript)(aurEff, amount, canBeRecalculated);
943}
944
945AuraScript::EffectCalcPeriodicHandler::EffectCalcPeriodicHandler(AuraEffectCalcPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
946 : AuraScript::EffectBase(_effIndex, _effName)
947{
948 pEffectHandlerScript = _pEffectHandlerScript;
949}
950
951void AuraScript::EffectCalcPeriodicHandler::Call(AuraScript* auraScript, AuraEffect const* aurEff, bool& isPeriodic, int32& periodicTimer)
952{
953 (auraScript->*pEffectHandlerScript)(aurEff, isPeriodic, periodicTimer);
954}
955
956AuraScript::EffectCalcSpellModHandler::EffectCalcSpellModHandler(AuraEffectCalcSpellModFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
957 : AuraScript::EffectBase(_effIndex, _effName)
958{
959 pEffectHandlerScript = _pEffectHandlerScript;
960}
961
963{
964 (auraScript->*pEffectHandlerScript)(aurEff, spellMod);
965}
966
967AuraScript::EffectApplyHandler::EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode)
968 : AuraScript::EffectBase(_effIndex, _effName)
969{
970 pEffectHandlerScript = _pEffectHandlerScript;
971 mode = _mode;
972}
973
975{
976 if (_mode & mode)
977 (auraScript->*pEffectHandlerScript)(_aurEff, _mode);
978}
979
980AuraScript::EffectAbsorbHandler::EffectAbsorbHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex)
982{
983 pEffectHandlerScript = _pEffectHandlerScript;
984}
985
986void AuraScript::EffectAbsorbHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
987{
988 (auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, absorbAmount);
989}
990
991AuraScript::EffectManaShieldHandler::EffectManaShieldHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex)
993{
994 pEffectHandlerScript = _pEffectHandlerScript;
995}
996
997void AuraScript::EffectManaShieldHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
998{
999 (auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, absorbAmount);
1000}
1001
1002AuraScript::EffectSplitHandler::EffectSplitHandler(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex)
1004{
1005 pEffectHandlerScript = _pEffectHandlerScript;
1006}
1007
1008void AuraScript::EffectSplitHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& splitAmount)
1009{
1010 (auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, splitAmount);
1011}
1012
1013AuraScript::CheckProcHandler::CheckProcHandler(AuraCheckProcFnType handlerScript)
1014{
1015 _HandlerScript = handlerScript;
1016}
1017
1019{
1020 return (auraScript->*_HandlerScript)(eventInfo);
1021}
1022
1023AuraScript::CheckEffectProcHandler::CheckEffectProcHandler(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName)
1024 : AuraScript::EffectBase(effIndex, effName)
1025{
1026 _HandlerScript = handlerScript;
1027}
1028
1030{
1031 return (auraScript->*_HandlerScript)(aurEff, eventInfo);
1032}
1033
1035{
1036 _HandlerScript = handlerScript;
1037}
1038
1040{
1041 (auraScript->*_HandlerScript)(eventInfo);
1042}
1043
1044AuraScript::EffectProcHandler::EffectProcHandler(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName)
1045 : AuraScript::EffectBase(effIndex, effName)
1046{
1047 _EffectHandlerScript = effectHandlerScript;
1048}
1049
1051{
1052 (auraScript->*_EffectHandlerScript)(aurEff, eventInfo);
1053}
1054
1058
1059AuraScript::~AuraScript() = default;
1060
1062{
1063 m_aura = aura;
1065 bool load = Load();
1067 return load;
1068}
1069
1077
1086
1088{
1089 switch (m_currentScriptState)
1090 {
1100 default:
1101 ABORT_MSG("AuraScript::_IsDefaultActionPrevented is called in a wrong place");
1102 return false;
1103 }
1104}
1105
1107{
1108 switch (m_currentScriptState)
1109 {
1119 break;
1120 default:
1121 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}` AuraScript::PreventDefaultAction called in a hook in which the call won't have effect!", m_scriptName->c_str(), m_scriptSpellId);
1122 break;
1123 }
1124}
1125
1127{
1128 return m_aura->GetSpellInfo();
1129}
1130
1132{
1133 return m_aura->GetSpellInfo()->GetEffect(effIndex);
1134}
1135
1137{
1138 return m_aura->GetId();
1139}
1140
1142{
1143 return m_aura->GetCasterGUID();
1144}
1145
1147{
1148 if (WorldObject* caster = m_aura->GetCaster())
1149 return caster->ToUnit();
1150 return nullptr;
1151}
1152
1154{
1155 if (WorldObject* caster = m_aura->GetCaster())
1156 return caster->ToGameObject();
1157 return nullptr;
1158}
1159
1161{
1162 return m_aura->GetOwner();
1163}
1164
1166{
1167 return m_aura->GetUnitOwner();
1168}
1169
1174
1176{
1177 m_aura->Remove(removeMode);
1178}
1179
1181{
1182 return m_aura;
1183}
1184
1186{
1187 return m_aura->GetType();
1188}
1189
1191{
1192 return m_aura->GetDuration();
1193}
1194
1195void AuraScript::SetDuration(int32 duration, bool withMods)
1196{
1197 m_aura->SetDuration(duration, withMods);
1198}
1199
1204
1206{
1207 return m_aura->GetApplyTime();
1208}
1209
1211{
1212 return m_aura->GetMaxDuration();
1213}
1214
1216{
1217 m_aura->SetMaxDuration(duration);
1218}
1219
1221{
1222 return m_aura->CalcMaxDuration();
1223}
1224
1226{
1227 return m_aura->IsExpired();
1228}
1229
1231{
1232 return m_aura->IsPermanent();
1233}
1234
1236{
1237 return m_aura->GetCharges();
1238}
1239
1241{
1242 m_aura->SetCharges(charges);
1243}
1244
1246{
1247 return m_aura->CalcMaxCharges();
1248}
1249
1250bool AuraScript::ModCharges(int8 num, AuraRemoveMode removeMode /*= AURA_REMOVE_BY_DEFAULT*/)
1251{
1252 return m_aura->ModCharges(num, removeMode);
1253}
1254
1256{
1257 return m_aura->DropCharge(removeMode);
1258}
1259
1261{
1262 return m_aura->GetStackAmount();
1263}
1264
1266{
1267 m_aura->SetStackAmount(num);
1268}
1269
1271{
1272 return m_aura->ModStackAmount(num, removeMode);
1273}
1274
1276{
1277 return m_aura->IsPassive();
1278}
1279
1281{
1282 return m_aura->IsDeathPersistent();
1283}
1284
1285bool AuraScript::HasEffect(uint8 effIndex) const
1286{
1287 return m_aura->HasEffect(effIndex);
1288}
1289
1291{
1292 return m_aura->GetEffect(effIndex);
1293}
1294
1296{
1297 return m_aura->HasEffectType(type);
1298}
1299
1301{
1302 switch (m_currentScriptState)
1303 {
1321 return m_auraApplication->GetTarget();
1322 default:
1323 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}` AuraScript::GetTarget called in a hook in which the call won't have effect!", m_scriptName->c_str(), m_scriptSpellId);
1324 }
1325
1326 return nullptr;
1327}
1328
#define MAX_SPELL_EFFECTS
Definition DBCEnums.h:386
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
#define ABORT_MSG
Definition Errors.h:75
#define ASSERT
Definition Errors.h:68
#define TC_LOG_ERROR(filterType__,...)
Definition Log.h:165
#define sScriptMgr
Definition ScriptMgr.h:1168
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
#define EFFECT_FIRST_FOUND
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
@ SPELL_EFFECT_APPLY_AURA
SpellCustomErrors
SpellMissInfo
#define EFFECT_ALL
SpellCastResult
@ SPELL_CAST_OK
AuraRemoveMode
AuraEffectHandleModes
@ SPELL_AURA_MANA_SHIELD
@ SPELL_AURA_SPLIT_DAMAGE_PCT
@ SPELL_AURA_SCHOOL_ABSORB
AuraObjectType
@ TARGET_SELECT_CATEGORY_CONE
Definition SpellInfo.h:46
@ TARGET_SELECT_CATEGORY_AREA
Definition SpellInfo.h:47
@ TARGET_SELECT_CATEGORY_DEFAULT
Definition SpellInfo.h:43
@ TARGET_SELECT_CATEGORY_NEARBY
Definition SpellInfo.h:45
@ TARGET_SELECT_CATEGORY_CHANNEL
Definition SpellInfo.h:44
@ TARGET_OBJECT_TYPE_DEST
Definition SpellInfo.h:65
@ TARGET_OBJECT_TYPE_SRC
Definition SpellInfo.h:64
@ TARGET_REFERENCE_TYPE_TARGET
Definition SpellInfo.h:55
@ TARGET_REFERENCE_TYPE_CASTER
Definition SpellInfo.h:54
#define sSpellMgr
Definition SpellMgr.h:738
AuraScriptHookType
@ AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC
@ 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_EFFECT_MANASHIELD
@ AURA_SCRIPT_HOOK_PROC
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB
@ 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_CHECK_PROC
@ 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 HOOK_SPELL_HIT_START
#define HOOK_SPELL_HIT_END
SpellScriptHookType
@ SPELL_SCRIPT_HOOK_AFTER_CAST
@ SPELL_SCRIPT_HOOK_AFTER_HIT
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH
@ SPELL_SCRIPT_HOOK_BEFORE_HIT
@ SPELL_SCRIPT_HOOK_CHECK_CAST
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET
@ SPELL_SCRIPT_HOOK_HIT
@ SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET
@ SPELL_SCRIPT_HOOK_ON_CAST
#define SPELL_EFFECT_ANY
Definition SpellScript.h:52
#define SPELL_AURA_ANY
Definition SpellScript.h:53
Unit * GetTarget() const
Definition SpellAuras.h:74
void Call(AuraScript *auraScript, DispelInfo *dispelInfo)
AuraDispelHandler(AuraDispelFnType pHandlerScript)
AuraProcHandler(AuraProcFnType handlerScript)
void Call(AuraScript *auraScript, ProcEventInfo &eventInfo)
CheckAreaTargetHandler(AuraCheckAreaTargetFnType pHandlerScript)
AuraCheckAreaTargetFnType pHandlerScript
bool Call(AuraScript *auraScript, Unit *target)
AuraCheckEffectProcFnType _HandlerScript
CheckEffectProcHandler(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName)
bool Call(AuraScript *auraScript, AuraEffect const *aurEff, ProcEventInfo &eventInfo)
CheckProcHandler(AuraCheckProcFnType handlerScript)
bool Call(AuraScript *auraScript, ProcEventInfo &eventInfo)
EffectAbsorbHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex)
AuraEffectAbsorbFnType pEffectHandlerScript
void Call(AuraScript *auraScript, AuraEffect *aurEff, DamageInfo &dmgInfo, uint32 &absorbAmount)
void Call(AuraScript *auraScript, AuraEffect const *_aurEff, AuraEffectHandleModes _mode)
EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode)
AuraEffectHandleModes mode
AuraEffectApplicationModeFnType pEffectHandlerScript
bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex) override
EffectBase(uint8 _effIndex, uint16 _effName)
void Call(AuraScript *auraScript, AuraEffect const *aurEff, int32 &amount, bool &canBeRecalculated)
EffectCalcAmountHandler(AuraEffectCalcAmountFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
AuraEffectCalcAmountFnType pEffectHandlerScript
EffectCalcPeriodicHandler(AuraEffectCalcPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
AuraEffectCalcPeriodicFnType pEffectHandlerScript
void Call(AuraScript *auraScript, AuraEffect const *aurEff, bool &isPeriodic, int32 &periodicTimer)
AuraEffectCalcSpellModFnType pEffectHandlerScript
void Call(AuraScript *auraScript, AuraEffect const *aurEff, SpellModifier *&spellMod)
EffectCalcSpellModHandler(AuraEffectCalcSpellModFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
AuraEffectAbsorbFnType pEffectHandlerScript
EffectManaShieldHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex)
void Call(AuraScript *auraScript, AuraEffect *aurEff, DamageInfo &dmgInfo, uint32 &absorbAmount)
AuraEffectPeriodicFnType pEffectHandlerScript
void Call(AuraScript *auraScript, AuraEffect const *_aurEff)
EffectPeriodicHandler(AuraEffectPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
EffectProcHandler(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName)
AuraEffectProcFnType _EffectHandlerScript
void Call(AuraScript *auraScript, AuraEffect const *aurEff, ProcEventInfo &eventInfo)
AuraEffectSplitFnType pEffectHandlerScript
EffectSplitHandler(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex)
void Call(AuraScript *auraScript, AuraEffect *aurEff, DamageInfo &dmgInfo, uint32 &splitAmount)
AuraEffectUpdatePeriodicFnType pEffectHandlerScript
void Call(AuraScript *auraScript, AuraEffect *aurEff)
EffectUpdatePeriodicHandler(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
AuraApplication const * _auraApplication
bool IsPermanent() const
HookList< EffectManaShieldHandler > AfterEffectManaShield
void PreventDefaultAction()
AuraObjectType GetType() const
bool IsExpired() const
void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const *aurApp=nullptr)
void SetMaxDuration(int32 duration)
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
AuraApplication const * GetTargetApplication() const
int32 GetDuration() const
HookList< EffectApplyHandler > AfterEffectRemove
AuraApplication const * m_auraApplication
HookList< CheckEffectProcHandler > DoCheckEffectProc
bool ModCharges(int8 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
HookList< EffectPeriodicHandler > OnEffectPeriodic
bool m_defaultActionPrevented
SpellInfo const * GetSpellInfo() const
WorldObject * GetOwner() const
uint8 CalcMaxCharges() const
HookList< EffectApplyHandler > AfterEffectApply
HookList< EffectProcHandler > AfterEffectProc
int32 GetMaxDuration() const
time_t GetApplyTime() const
void SetCharges(uint8 charges)
HookList< EffectAbsorbHandler > AfterEffectAbsorb
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Unit * GetCaster() const
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
HookList< EffectCalcSpellModHandler > DoEffectCalcSpellMod
void SetDuration(int32 duration, bool withMods=false)
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
SpellEffectInfo const & GetEffectInfo(SpellEffIndex effIndex) const
HookList< EffectManaShieldHandler > OnEffectManaShield
AuraEffect * GetEffect(uint8 effIndex) const
bool HasEffectType(AuraType type) const
HookList< EffectAbsorbHandler > OnEffectAbsorb
bool _Validate(SpellInfo const *entry) override
Aura * GetAura() const
HookList< CheckAreaTargetHandler > DoCheckAreaTarget
Unit * GetTarget() const
ObjectGuid GetCasterGUID() const
void RefreshDuration()
bool IsDeathPersistent() const
Aura * m_aura
bool _IsDefaultActionPrevented()
GameObject * GetGObjCaster() const
HookList< AuraProcHandler > AfterProc
HookList< AuraDispelHandler > OnDispel
HookList< CheckProcHandler > DoCheckProc
bool _Load(Aura *aura)
HookList< EffectApplyHandler > OnEffectRemove
HookList< AuraDispelHandler > AfterDispel
void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
ScriptStateStack m_scriptStates
int32 CalcMaxDuration() const
uint8 GetCharges() const
void SetStackAmount(uint8 num)
HookList< EffectProcHandler > OnEffectProc
Unit * GetUnitOwner() const
HookList< AuraProcHandler > DoPrepareProc
HookList< AuraProcHandler > OnProc
HookList< EffectSplitHandler > OnEffectSplit
void _FinishScriptCall()
bool HasEffect(uint8 effIndex) const
uint8 GetStackAmount() const
HookList< EffectApplyHandler > OnEffectApply
DynamicObject * GetDynobjOwner() const
bool IsPassive() const
uint32 GetId() const
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
int32 GetMaxDuration() const
Definition SpellAuras.h:168
void SetStackAmount(uint8 num)
Unit * GetUnitOwner() const
Definition SpellAuras.h:147
void RefreshDuration(bool withMods=false)
DynamicObject * GetDynobjOwner() const
Definition SpellAuras.h:148
ObjectGuid GetCasterGUID() const
Definition SpellAuras.h:144
bool HasEffect(uint8 effIndex) const
Definition SpellAuras.h:224
bool IsRemoved() const
Definition SpellAuras.h:209
WorldObject * GetOwner() const
Definition SpellAuras.h:146
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
uint32 GetId() const
Definition SpellAuras.h:141
int32 GetDuration() const
Definition SpellAuras.h:173
bool IsDeathPersistent() const
bool HasEffectType(AuraType type) const
AuraEffect * GetEffect(uint8 effIndex) const
Definition SpellAuras.h:226
Unit * GetCaster() const
uint8 CalcMaxCharges(Unit *caster) const
void SetCharges(uint8 charges)
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, bool resetPeriodicTimer=true)
int32 CalcMaxDuration() const
Definition SpellAuras.h:170
void SetDuration(int32 duration, bool withMods=false)
AuraObjectType GetType() const
uint8 GetStackAmount() const
Definition SpellAuras.h:189
uint8 GetCharges() const
Definition SpellAuras.h:180
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:140
void SetMaxDuration(int32 duration)
Definition SpellAuras.h:169
bool IsExpired() const
Definition SpellAuras.h:177
bool IsPassive() const
time_t GetApplyTime() const
Definition SpellAuras.h:167
bool IsPermanent() const
Definition SpellAuras.h:178
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition SpellAuras.h:185
Definition Item.h:62
static Creature * ToCreature(Object *o)
Definition Object.h:189
static Unit * ToUnit(Object *o)
Definition Object.h:195
static GameObject * ToGameObject(Object *o)
Definition Object.h:201
static Player * ToPlayer(Object *o)
Definition Object.h:183
WorldObject * GetObjectTarget() const
Definition Spell.cpp:333
GameObject * GetGOTarget() const
Definition Spell.cpp:299
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition Spell.cpp:428
bool HasDst() const
Definition Spell.cpp:480
Item * GetItemTarget() const
Unit * GetUnitTarget() const
Definition Spell.cpp:273
WorldLocation const * GetDstPos() const
Definition Spell.cpp:423
AuraType ApplyAuraName
Definition SpellInfo.h:211
SpellEffects Effect
Definition SpellInfo.h:210
SpellImplicitTargetInfo TargetA
Definition SpellInfo.h:223
SpellImplicitTargetInfo TargetB
Definition SpellInfo.h:224
SpellTargetReferenceTypes GetReferenceType() const
Definition SpellInfo.cpp:79
SpellTargetSelectionCategories GetSelectionCategory() const
Definition SpellInfo.cpp:74
SpellTargetObjectTypes GetObjectType() const
Definition SpellInfo.cpp:84
Targets GetTarget() const
uint32 Id
Definition SpellInfo.h:289
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:483
bool HasAreaAuraEffect() const
bool HasEffect(SpellEffects effect) const
BeforeHitHandler(SpellBeforeHitFnType pBeforeHitHandlerScript)
void Call(SpellScript *spellScript, SpellMissInfo missInfo)
CastHandler(SpellCastFnType _pCastHandlerScript)
void Call(SpellScript *spellScript)
SpellCastResult Call(SpellScript *spellScript)
CheckCastHandler(SpellCheckCastFnType checkCastHandlerScript)
void Call(SpellScript *spellScript, SpellDestination &target)
SpellDestinationTargetSelectFnType DestinationTargetSelectHandlerScript
DestinationTargetSelectHandler(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
void Call(SpellScript *spellScript, SpellEffIndex effIndex)
SpellEffectFnType pEffectHandlerScript
bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex) override
EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
void Call(SpellScript *spellScript)
HitHandler(SpellHitFnType _pHitHandlerScript)
SpellObjectAreaTargetSelectFnType pObjectAreaTargetSelectHandlerScript
void Call(SpellScript *spellScript, std::list< WorldObject * > &targets)
ObjectAreaTargetSelectHandler(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
SpellObjectTargetSelectFnType pObjectTargetSelectHandlerScript
void Call(SpellScript *spellScript, WorldObject *&target)
ObjectTargetSelectHandler(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
void Call(SpellScript *spellScript, DamageInfo const &damageInfo, uint32 &resistAmount, int32 &absorbAmount)
OnCalculateResistAbsorbHandler(SpellOnResistAbsorbCalculateFnType _pOnCalculateResistAbsorbHandlerScript)
bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex) override
TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest)
WorldLocation * GetHitDest() const
Creature * GetHitCreature() const
Player * GetHitPlayer() const
void SetEffectValue(int32 value)
int32 GetHitDamage() const
void SetExplTargetDest(WorldLocation &loc)
Unit * GetCaster() const
bool IsInEffectHook() const
bool _Load(Spell *spell)
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
bool IsInTargetHook() const
bool IsAfterTargetSelectionPhase() const
HookList< EffectHandler > OnEffectHit
void PreventHitDefaultEffect(SpellEffIndex effIndex)
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const
SpellInfo const * GetTriggeringSpell() const
Unit * GetHitUnit() const
SpellValue const * GetSpellValue() const
bool IsInHitPhase() const
uint8 m_hitPreventEffectMask
int32 GetEffectValue() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
Corpse * GetHitCorpse() const
void PreventHitEffect(SpellEffIndex effIndex)
Item * GetCastItem() const
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
bool _Validate(SpellInfo const *entry) override
Aura * GetHitAura(bool dynObjAura=false) const
Spell * m_spell
void SetCustomCastResultMessage(SpellCustomErrors result)
WorldObject * GetExplTargetWorldObject() const
HookList< EffectHandler > OnEffectLaunchTarget
Item * GetHitItem() const
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const
uint8 m_hitPreventDefaultEffectMask
int32 GetHitHeal() const
void SetHitDamage(int32 damage)
HookList< EffectHandler > OnEffectSuccessfulDispel
void CreateItem(uint32 itemId)
WorldLocation const * GetExplTargetDest() const
bool IsInCheckCastHook() const
HookList< EffectHandler > OnEffectLaunch
void SetHitHeal(int32 heal)
GameObject * GetExplTargetGObj() const
GameObject * GetGObjCaster() const
void PreventHitAura()
Item * GetExplTargetItem() const
bool IsInModifiableHook() const
Unit * GetExplTargetUnit() const
int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
void _PrepareScriptCall(SpellScriptHookType hookType)
SpellInfo const * GetSpellInfo() const
void FinishCast(SpellCastResult result, uint32 *param1=nullptr, uint32 *param2=nullptr)
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Unit * GetOriginalCaster() const
GameObject * GetHitGObj() const
void _FinishScriptCall()
Definition Spell.h:152
SpellInfo const * GetSpellInfo() const
Definition Spell.h:459
GameObject * gameObjTarget
Definition Spell.h:533
DynObjAura * _dynObjAura
Definition Spell.h:543
SpellCastTargets m_targets
Definition Spell.h:409
int32 damage
Definition Spell.h:536
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const
Definition Spell.cpp:2402
Item * itemTarget
Definition Spell.h:532
int32 m_damage
Definition Spell.h:550
void DoCreateItem(uint32 itemId)
int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
Definition Spell.cpp:2394
SpellCustomErrors m_customError
Definition Spell.h:423
int32 m_healing
Definition Spell.h:551
SpellEffectInfo const * effectInfo
Definition Spell.h:539
SpellInfo const * m_triggeredByAuraSpell
Definition Spell.h:714
UnitAura * _spellAura
Definition Spell.h:542
Unit * unitTarget
Definition Spell.h:531
WorldObject * GetCaster() const
Definition Spell.h:457
Unit * GetOriginalCaster() const
Definition Spell.h:458
Corpse * m_corpseTarget
Definition Spell.h:534
WorldLocation * destTarget
Definition Spell.h:535
Item * m_CastItem
Definition Spell.h:397
SpellValue *const m_spellValue
Definition Spell.h:492
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const
Definition Spell.cpp:2386
void finish(bool ok=true)
Definition Spell.cpp:3943
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, uint32 *param1=nullptr, uint32 *param2=nullptr)
Definition Spell.cpp:4150
Definition Unit.h:783
bool Check(SpellInfo const *spellInfo, uint8 effIndex)
uint8 GetAffectedEffectsMask(SpellInfo const *spellInfo)
EffectHook(uint8 _effIndex)
bool IsEffectAffected(SpellInfo const *spellInfo, uint8 effIndex)
std::string EffIndexToString()
bool Check(SpellInfo const *spellInfo, uint8 effIndex)
std::string const * m_scriptName
uint8 m_currentScriptState
static bool _ValidateSpellInfo(Iterator begin, Iterator end)
virtual bool Validate(SpellInfo const *)
virtual void Register()=0
virtual bool Load()
std::string const * _GetScriptName() const
virtual void Unload()
uint32 m_scriptSpellId
void _Init(std::string const *scriptname, uint32 spellId)
virtual bool _Validate(SpellInfo const *entry)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.