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 char num[10];
150 sprintf (num, "%u", effName);
151 return num;
152 }
153}
154
156{
157 SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndex));
158 if (!spellEffectInfo.ApplyAuraName && !effAurName)
159 return true;
160 if (!spellEffectInfo.ApplyAuraName)
161 return false;
162 return (effAurName == SPELL_AURA_ANY) || (spellEffectInfo.ApplyAuraName == effAurName);
163}
164
166{
167 switch (effAurName)
168 {
169 case SPELL_AURA_ANY:
170 return "SPELL_AURA_ANY";
171 default:
172 char num[10];
173 sprintf (num, "%u", effAurName);
174 return num;
175 }
176}
177
178SpellScript::CastHandler::CastHandler(SpellCastFnType _pCastHandlerScript)
179{
180 pCastHandlerScript = _pCastHandlerScript;
181}
182
184{
185 (spellScript->*pCastHandlerScript)();
186}
187
188SpellScript::CheckCastHandler::CheckCastHandler(SpellCheckCastFnType checkCastHandlerScript)
189{
190 _checkCastHandlerScript = checkCastHandlerScript;
191}
192
194{
195 return (spellScript->*_checkCastHandlerScript)();
196}
197
198SpellScript::OnCalculateResistAbsorbHandler::OnCalculateResistAbsorbHandler(SpellOnResistAbsorbCalculateFnType onResistAbsorbCalculateHandlerScript)
199{
200 pOnCalculateResistAbsorbHandlerScript = onResistAbsorbCalculateHandlerScript;
201}
202
203void SpellScript::OnCalculateResistAbsorbHandler::Call(SpellScript* spellScript, DamageInfo const& damageInfo, uint32& resistAmount, int32& absorbAmount)
204{
205 return (spellScript->*pOnCalculateResistAbsorbHandlerScript)(damageInfo, resistAmount, absorbAmount);
206}
207
208SpellScript::EffectHandler::EffectHandler(SpellEffectFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
209 : _SpellScript::EffectNameCheck(_effName), _SpellScript::EffectHook(_effIndex)
210{
211 pEffectHandlerScript = _pEffectHandlerScript;
212}
213
215{
216 return "Index: " + EffIndexToString() + " Name: " +_SpellScript::EffectNameCheck::ToString();
217}
218
219bool SpellScript::EffectHandler::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
220{
221 return _SpellScript::EffectNameCheck::Check(spellEntry, effIndexToCheck);
222}
223
225{
226 (spellScript->*pEffectHandlerScript)(effIndexToHandle);
227}
228
229SpellScript::BeforeHitHandler::BeforeHitHandler(SpellBeforeHitFnType pBeforeHitHandlerScript)
230{
231 _pBeforeHitHandlerScript = pBeforeHitHandlerScript;
232}
233
235{
236 (spellScript->*_pBeforeHitHandlerScript)(missInfo);
237}
238
239SpellScript::HitHandler::HitHandler(SpellHitFnType _pHitHandlerScript)
240{
241 pHitHandlerScript = _pHitHandlerScript;
242}
243
245{
246 (spellScript->*pHitHandlerScript)();
247}
248
249SpellScript::TargetHook::TargetHook(uint8 _effectIndex, uint16 _targetType, bool _area, bool _dest)
250 : _SpellScript::EffectHook(_effectIndex), targetType(_targetType), area(_area), dest(_dest) { }
251
253{
254 std::ostringstream oss;
255 oss << "Index: " << EffIndexToString() << " Target: " << targetType;
256 return oss.str();
257}
258
259bool SpellScript::TargetHook::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
260{
261 if (!targetType)
262 return false;
263
264 SpellEffectInfo const& spellEffectInfo = spellEntry->GetEffect(SpellEffIndex(effIndexToCheck));
265 if (spellEffectInfo.TargetA.GetTarget() != targetType &&
266 spellEffectInfo.TargetB.GetTarget() != targetType)
267 return false;
268
269 SpellImplicitTargetInfo targetInfo(targetType);
270 switch (targetInfo.GetSelectionCategory())
271 {
272 case TARGET_SELECT_CATEGORY_CHANNEL: // SINGLE
273 return !area;
275 return true;
276 case TARGET_SELECT_CATEGORY_CONE: // AREA
277 case TARGET_SELECT_CATEGORY_AREA: // AREA
278 return area;
280 switch (targetInfo.GetObjectType())
281 {
282 case TARGET_OBJECT_TYPE_SRC: // EMPTY
283 return false;
284 case TARGET_OBJECT_TYPE_DEST: // DEST
285 return dest;
286 default:
287 switch (targetInfo.GetReferenceType())
288 {
289 case TARGET_REFERENCE_TYPE_CASTER: // SINGLE
290 return !area;
291 case TARGET_REFERENCE_TYPE_TARGET: // BOTH
292 return true;
293 default:
294 break;
295 }
296 break;
297 }
298 break;
299 default:
300 break;
301 }
302
303 return false;
304}
305
306SpellScript::ObjectAreaTargetSelectHandler::ObjectAreaTargetSelectHandler(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
307 : TargetHook(_effIndex, _targetType, true, false)
308{
309 pObjectAreaTargetSelectHandlerScript = _pObjectAreaTargetSelectHandlerScript;
310}
311
312void SpellScript::ObjectAreaTargetSelectHandler::Call(SpellScript* spellScript, std::list<WorldObject*>& targets)
313{
314 (spellScript->*pObjectAreaTargetSelectHandlerScript)(targets);
315}
316
317SpellScript::ObjectTargetSelectHandler::ObjectTargetSelectHandler(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
318 : TargetHook(_effIndex, _targetType, false, false)
319{
320 pObjectTargetSelectHandlerScript = _pObjectTargetSelectHandlerScript;
321}
322
324{
325 (spellScript->*pObjectTargetSelectHandlerScript)(target);
326}
327
328SpellScript::DestinationTargetSelectHandler::DestinationTargetSelectHandler(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType)
329 : TargetHook(_effIndex, _targetType, false, true)
330{
331 DestinationTargetSelectHandlerScript = _DestinationTargetSelectHandlerScript;
332}
333
335{
336 (spellScript->*DestinationTargetSelectHandlerScript)(target);
337}
338
342
343SpellScript::~SpellScript() = default;
344
346{
347 for (auto itr = OnEffectLaunch.begin(); itr != OnEffectLaunch.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 `OnEffectLaunch` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
350
351 for (auto itr = OnEffectLaunchTarget.begin(); itr != OnEffectLaunchTarget.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 `OnEffectLaunchTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
354
355 for (auto itr = OnEffectHit.begin(); itr != OnEffectHit.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 `OnEffectHit` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
358
359 for (auto itr = OnEffectHitTarget.begin(); itr != OnEffectHitTarget.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 `OnEffectHitTarget` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
362
363 for (auto itr = OnEffectSuccessfulDispel.begin(); itr != OnEffectSuccessfulDispel.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 `OnEffectSuccessfulDispel` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
366
367 for (auto itr = OnObjectAreaTargetSelect.begin(); itr != OnObjectAreaTargetSelect.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 `OnObjectAreaTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
370
371 for (auto itr = OnObjectTargetSelect.begin(); itr != OnObjectTargetSelect.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 `OnObjectTargetSelect` of SpellScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
374
375 for (auto itr = OnDestinationTargetSelect.begin(); itr != OnDestinationTargetSelect.end(); ++itr)
376 if (!(*itr).GetAffectedEffectsMask(entry))
377 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());
378
379 return _SpellScript::_Validate(entry);
380}
381
383{
384 m_spell = spell;
386 bool load = Load();
388 return load;
389}
390
396
401
406
411
418
420{
421 switch (m_currentScriptState)
422 {
428 return true;
429 }
430 return false;
431}
432
434{
435 // after hit hook executed after damage/healing is already done
436 // modifying it at this point has no effect
437 switch (m_currentScriptState)
438 {
443 return true;
444 }
445 return false;
446}
447
452
457
459{
460 return m_spell->GetCaster()->ToUnit();
461}
462
467
472
474{
475 return m_spell->GetSpellInfo();
476}
477
479{
480 return GetSpellInfo()->GetEffect(effIndex);
481}
482
484{
485 return m_spell->m_spellValue;
486}
487
489{
490 if (m_spell->m_targets.HasDst())
491 return m_spell->m_targets.GetDstPos();
492 return nullptr;
493}
494
499
504
509
514
519
521{
523 {
524 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)",
525 m_scriptName->c_str(), m_scriptSpellId);
526 return 0;
527 }
528 return m_spell->GetUnitTargetCountForEffect(effect);
529}
530
532{
534 {
535 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)",
536 m_scriptName->c_str(), m_scriptSpellId);
537 return 0;
538 }
540}
541
543{
545 {
546 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)",
547 m_scriptName->c_str(), m_scriptSpellId);
548 return 0;
549 }
550 return m_spell->GetItemTargetCountForEffect(effect);
551}
552
554{
555 if (!IsInTargetHook())
556 {
557 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);
558 return nullptr;
559 }
560 return m_spell->unitTarget;
561}
562
564{
565 if (!IsInTargetHook())
566 {
567 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);
568 return nullptr;
569 }
570 if (m_spell->unitTarget)
571 return m_spell->unitTarget->ToCreature();
572 else
573 return nullptr;
574}
575
577{
578 if (!IsInTargetHook())
579 {
580 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);
581 return nullptr;
582 }
583 if (m_spell->unitTarget)
584 return m_spell->unitTarget->ToPlayer();
585 else
586 return nullptr;
587}
588
590{
591 if (!IsInTargetHook())
592 {
593 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);
594 return nullptr;
595 }
596 return m_spell->itemTarget;
597}
598
600{
601 if (!IsInTargetHook())
602 {
603 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);
604 return nullptr;
605 }
606 return m_spell->gameObjTarget;
607}
608
610{
611 if (!IsInTargetHook())
612 {
613 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);
614 return nullptr;
615 }
616 return m_spell->m_corpseTarget;
617}
618
620{
621 if (!IsInEffectHook())
622 {
623 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);
624 return nullptr;
625 }
626 return m_spell->destTarget;
627}
628
630{
631 if (!IsInTargetHook())
632 {
633 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);
634 return 0;
635 }
636 return m_spell->m_damage;
637}
638
640{
641 if (!IsInModifiableHook())
642 {
643 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);
644 return;
645 }
646 m_spell->m_damage = damage;
647}
648
650{
651 if (!IsInTargetHook())
652 {
653 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);
654 return 0;
655 }
656 return m_spell->m_healing;
657}
658
660{
661 if (!IsInModifiableHook())
662 {
663 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);
664 return;
665 }
666 m_spell->m_healing = heal;
667}
668
669Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/) const
670{
671 if (!IsInTargetHook())
672 {
673 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);
674 return nullptr;
675 }
676
677 Aura* aura = m_spell->_spellAura;
678 if (dynObjAura)
679 aura = m_spell->_dynObjAura;
680
681 if (!aura || aura->IsRemoved())
682 return nullptr;
683
684 return aura;
685}
686
688{
689 if (!IsInTargetHook())
690 {
691 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);
692 return;
693 }
694 if (UnitAura* aura = m_spell->_spellAura)
695 aura->Remove();
696 if (DynObjAura* aura = m_spell->_dynObjAura)
697 aura->Remove();
698}
699
701{
702 if (!IsInHitPhase() && !IsInEffectHook())
703 {
704 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);
705 return;
706 }
707 m_hitPreventEffectMask |= 1 << effIndex;
708 PreventHitDefaultEffect(effIndex);
709}
710
712{
713 if (!IsInHitPhase() && !IsInEffectHook())
714 {
715 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);
716 return;
717 }
718 m_hitPreventDefaultEffectMask |= 1 << effIndex;
719}
720
722{
723 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);
724
725 return *m_spell->effectInfo;
726}
727
729{
730 if (!IsInEffectHook())
731 {
732 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);
733 return 0;
734 }
735
736 return m_spell->damage;
737}
738
740{
741 if (!IsInEffectHook())
742 {
743 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);
744 return;
745 }
746
747 m_spell->damage = value;
748}
749
751{
752 return m_spell->m_CastItem;
753}
754
756{
757 m_spell->DoCreateItem(itemId);
758}
759
764
765void SpellScript::FinishCast(SpellCastResult result, uint32* param1 /*= nullptr*/, uint32* param2 /*= nullptr*/)
766{
767 m_spell->SendCastResult(result, param1, param2);
768 m_spell->finish(result == SPELL_CAST_OK);
769}
770
772{
773 if (!IsInCheckCastHook())
774 {
775 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetCustomCastResultMessage was called while spell not in check cast phase!", m_scriptName->c_str(), m_scriptSpellId);
776 return;
777 }
778
779 m_spell->m_customError = result;
780}
781
783{
784 for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
786 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());
787
788 for (auto itr = OnDispel.begin(); itr != OnDispel.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 `OnDispel` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
791
792 for (auto itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
793 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
794 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());
795
796 for (auto itr = OnEffectApply.begin(); itr != OnEffectApply.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 `OnEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
799
800 for (auto itr = OnEffectRemove.begin(); itr != OnEffectRemove.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 `OnEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
803
804 for (auto itr = AfterEffectApply.begin(); itr != AfterEffectApply.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 `AfterEffectApply` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
807
808 for (auto itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.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 `AfterEffectRemove` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
811
812 for (auto itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.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 `OnEffectPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
815
816 for (auto itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.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 `OnEffectUpdatePeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
819
820 for (auto itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.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 `DoEffectCalcAmount` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
823
824 for (auto itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.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 `DoEffectCalcPeriodic` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
827
828 for (auto itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.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 `DoEffectCalcSpellMod` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
831
832 for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.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 `OnEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
835
836 for (auto itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.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 `AfterEffectAbsorb` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
839
840 for (auto itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.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 `OnEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
843
844 for (auto itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.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 `AfterEffectManaShield` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
847
848 for (auto itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
849 if (!(*itr).GetAffectedEffectsMask(entry))
850 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());
851
852 for (auto itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
853 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
854 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());
855
856 for (auto itr = DoCheckEffectProc.begin(); itr != DoCheckEffectProc.end(); ++itr)
857 if (!itr->GetAffectedEffectsMask(entry))
858 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());
859
860 for (auto itr = DoPrepareProc.begin(); itr != DoPrepareProc.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 `DoPrepareProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
863
864 for (auto itr = OnProc.begin(); itr != OnProc.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 `OnProc` of AuraScript won't be executed", entry->Id, m_scriptName->c_str());
867
868 for (auto itr = AfterProc.begin(); itr != AfterProc.end(); ++itr)
869 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
870 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());
871
872 for (auto itr = OnEffectProc.begin(); itr != OnEffectProc.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 `OnEffectProc` of AuraScript won't be executed", entry->Id, (*itr).ToString(), m_scriptName->c_str());
875
876 for (auto itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
877 if (!(*itr).GetAffectedEffectsMask(entry))
878 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());
879
880 return _SpellScript::_Validate(entry);
881}
882
883AuraScript::CheckAreaTargetHandler::CheckAreaTargetHandler(AuraCheckAreaTargetFnType _pHandlerScript)
884{
885 pHandlerScript = _pHandlerScript;
886}
887
889{
890 return (auraScript->*pHandlerScript)(_target);
891}
892
894{
895 pHandlerScript = _pHandlerScript;
896}
897
899{
900 (auraScript->*pHandlerScript)(_dispelInfo);
901}
902
905
906bool AuraScript::EffectBase::CheckEffect(SpellInfo const* spellEntry, uint8 effIndexToCheck)
907{
908 return _SpellScript::EffectAuraNameCheck::Check(spellEntry, effIndexToCheck);
909}
910
912{
913 return "Index: " + EffIndexToString() + " AuraName: " +_SpellScript::EffectAuraNameCheck::ToString();
914}
915
916AuraScript::EffectPeriodicHandler::EffectPeriodicHandler(AuraEffectPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
917 : AuraScript::EffectBase(_effIndex, _effName)
918{
919 pEffectHandlerScript = _pEffectHandlerScript;
920}
921
923{
924 (auraScript->*pEffectHandlerScript)(_aurEff);
925}
926
927AuraScript::EffectUpdatePeriodicHandler::EffectUpdatePeriodicHandler(AuraEffectUpdatePeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
928 : AuraScript::EffectBase(_effIndex, _effName)
929{
930 pEffectHandlerScript = _pEffectHandlerScript;
931}
932
934{
935 (auraScript->*pEffectHandlerScript)(aurEff);
936}
937
938AuraScript::EffectCalcAmountHandler::EffectCalcAmountHandler(AuraEffectCalcAmountFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
939 : AuraScript::EffectBase(_effIndex, _effName)
940{
941 pEffectHandlerScript = _pEffectHandlerScript;
942}
943
944void AuraScript::EffectCalcAmountHandler::Call(AuraScript* auraScript, AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)
945{
946 (auraScript->*pEffectHandlerScript)(aurEff, amount, canBeRecalculated);
947}
948
949AuraScript::EffectCalcPeriodicHandler::EffectCalcPeriodicHandler(AuraEffectCalcPeriodicFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
950 : AuraScript::EffectBase(_effIndex, _effName)
951{
952 pEffectHandlerScript = _pEffectHandlerScript;
953}
954
955void AuraScript::EffectCalcPeriodicHandler::Call(AuraScript* auraScript, AuraEffect const* aurEff, bool& isPeriodic, int32& periodicTimer)
956{
957 (auraScript->*pEffectHandlerScript)(aurEff, isPeriodic, periodicTimer);
958}
959
960AuraScript::EffectCalcSpellModHandler::EffectCalcSpellModHandler(AuraEffectCalcSpellModFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName)
961 : AuraScript::EffectBase(_effIndex, _effName)
962{
963 pEffectHandlerScript = _pEffectHandlerScript;
964}
965
967{
968 (auraScript->*pEffectHandlerScript)(aurEff, spellMod);
969}
970
971AuraScript::EffectApplyHandler::EffectApplyHandler(AuraEffectApplicationModeFnType _pEffectHandlerScript, uint8 _effIndex, uint16 _effName, AuraEffectHandleModes _mode)
972 : AuraScript::EffectBase(_effIndex, _effName)
973{
974 pEffectHandlerScript = _pEffectHandlerScript;
975 mode = _mode;
976}
977
979{
980 if (_mode & mode)
981 (auraScript->*pEffectHandlerScript)(_aurEff, _mode);
982}
983
984AuraScript::EffectAbsorbHandler::EffectAbsorbHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex)
986{
987 pEffectHandlerScript = _pEffectHandlerScript;
988}
989
990void AuraScript::EffectAbsorbHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
991{
992 (auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, absorbAmount);
993}
994
995AuraScript::EffectManaShieldHandler::EffectManaShieldHandler(AuraEffectAbsorbFnType _pEffectHandlerScript, uint8 _effIndex)
997{
998 pEffectHandlerScript = _pEffectHandlerScript;
999}
1000
1001void AuraScript::EffectManaShieldHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
1002{
1003 (auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, absorbAmount);
1004}
1005
1006AuraScript::EffectSplitHandler::EffectSplitHandler(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex)
1008{
1009 pEffectHandlerScript = _pEffectHandlerScript;
1010}
1011
1012void AuraScript::EffectSplitHandler::Call(AuraScript* auraScript, AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& splitAmount)
1013{
1014 (auraScript->*pEffectHandlerScript)(aurEff, dmgInfo, splitAmount);
1015}
1016
1017AuraScript::CheckProcHandler::CheckProcHandler(AuraCheckProcFnType handlerScript)
1018{
1019 _HandlerScript = handlerScript;
1020}
1021
1023{
1024 return (auraScript->*_HandlerScript)(eventInfo);
1025}
1026
1027AuraScript::CheckEffectProcHandler::CheckEffectProcHandler(AuraCheckEffectProcFnType handlerScript, uint8 effIndex, uint16 effName)
1028 : AuraScript::EffectBase(effIndex, effName)
1029{
1030 _HandlerScript = handlerScript;
1031}
1032
1034{
1035 return (auraScript->*_HandlerScript)(aurEff, eventInfo);
1036}
1037
1039{
1040 _HandlerScript = handlerScript;
1041}
1042
1044{
1045 (auraScript->*_HandlerScript)(eventInfo);
1046}
1047
1048AuraScript::EffectProcHandler::EffectProcHandler(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName)
1049 : AuraScript::EffectBase(effIndex, effName)
1050{
1051 _EffectHandlerScript = effectHandlerScript;
1052}
1053
1055{
1056 (auraScript->*_EffectHandlerScript)(aurEff, eventInfo);
1057}
1058
1062
1063AuraScript::~AuraScript() = default;
1064
1066{
1067 m_aura = aura;
1069 bool load = Load();
1071 return load;
1072}
1073
1081
1090
1092{
1093 switch (m_currentScriptState)
1094 {
1104 default:
1105 ABORT_MSG("AuraScript::_IsDefaultActionPrevented is called in a wrong place");
1106 return false;
1107 }
1108}
1109
1111{
1112 switch (m_currentScriptState)
1113 {
1123 break;
1124 default:
1125 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);
1126 break;
1127 }
1128}
1129
1131{
1132 return m_aura->GetSpellInfo();
1133}
1134
1136{
1137 return m_aura->GetSpellInfo()->GetEffect(effIndex);
1138}
1139
1141{
1142 return m_aura->GetId();
1143}
1144
1146{
1147 return m_aura->GetCasterGUID();
1148}
1149
1151{
1152 if (WorldObject* caster = m_aura->GetCaster())
1153 return caster->ToUnit();
1154 return nullptr;
1155}
1156
1158{
1159 if (WorldObject* caster = m_aura->GetCaster())
1160 return caster->ToGameObject();
1161 return nullptr;
1162}
1163
1165{
1166 return m_aura->GetOwner();
1167}
1168
1170{
1171 return m_aura->GetUnitOwner();
1172}
1173
1178
1180{
1181 m_aura->Remove(removeMode);
1182}
1183
1185{
1186 return m_aura;
1187}
1188
1190{
1191 return m_aura->GetType();
1192}
1193
1195{
1196 return m_aura->GetDuration();
1197}
1198
1199void AuraScript::SetDuration(int32 duration, bool withMods)
1200{
1201 m_aura->SetDuration(duration, withMods);
1202}
1203
1208
1210{
1211 return m_aura->GetApplyTime();
1212}
1213
1215{
1216 return m_aura->GetMaxDuration();
1217}
1218
1220{
1221 m_aura->SetMaxDuration(duration);
1222}
1223
1225{
1226 return m_aura->CalcMaxDuration();
1227}
1228
1230{
1231 return m_aura->IsExpired();
1232}
1233
1235{
1236 return m_aura->IsPermanent();
1237}
1238
1240{
1241 return m_aura->GetCharges();
1242}
1243
1245{
1246 m_aura->SetCharges(charges);
1247}
1248
1250{
1251 return m_aura->CalcMaxCharges();
1252}
1253
1254bool AuraScript::ModCharges(int8 num, AuraRemoveMode removeMode /*= AURA_REMOVE_BY_DEFAULT*/)
1255{
1256 return m_aura->ModCharges(num, removeMode);
1257}
1258
1260{
1261 return m_aura->DropCharge(removeMode);
1262}
1263
1265{
1266 return m_aura->GetStackAmount();
1267}
1268
1270{
1271 m_aura->SetStackAmount(num);
1272}
1273
1275{
1276 return m_aura->ModStackAmount(num, removeMode);
1277}
1278
1280{
1281 return m_aura->IsPassive();
1282}
1283
1285{
1286 return m_aura->IsDeathPersistent();
1287}
1288
1289bool AuraScript::HasEffect(uint8 effIndex) const
1290{
1291 return m_aura->HasEffect(effIndex);
1292}
1293
1295{
1296 return m_aura->GetEffect(effIndex);
1297}
1298
1300{
1301 return m_aura->HasEffectType(type);
1302}
1303
1305{
1306 switch (m_currentScriptState)
1307 {
1325 return m_auraApplication->GetTarget();
1326 default:
1327 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);
1328 }
1329
1330 return nullptr;
1331}
1332
#define MAX_SPELL_EFFECTS
Definition DBCEnums.h:388
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:66
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:143
void SetStackAmount(uint8 num)
Unit * GetUnitOwner() const
Definition SpellAuras.h:122
void RefreshDuration(bool withMods=false)
DynamicObject * GetDynobjOwner() const
Definition SpellAuras.h:123
ObjectGuid GetCasterGUID() const
Definition SpellAuras.h:119
bool HasEffect(uint8 effIndex) const
Definition SpellAuras.h:199
bool IsRemoved() const
Definition SpellAuras.h:184
WorldObject * GetOwner() const
Definition SpellAuras.h:121
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
uint32 GetId() const
Definition SpellAuras.h:116
int32 GetDuration() const
Definition SpellAuras.h:148
bool IsDeathPersistent() const
bool HasEffectType(AuraType type) const
AuraEffect * GetEffect(uint8 effIndex) const
Definition SpellAuras.h:201
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:145
void SetDuration(int32 duration, bool withMods=false)
AuraObjectType GetType() const
uint8 GetStackAmount() const
Definition SpellAuras.h:164
uint8 GetCharges() const
Definition SpellAuras.h:155
SpellInfo const * GetSpellInfo() const
Definition SpellAuras.h:115
void SetMaxDuration(int32 duration)
Definition SpellAuras.h:144
bool IsExpired() const
Definition SpellAuras.h:152
bool IsPassive() const
time_t GetApplyTime() const
Definition SpellAuras.h:142
bool IsPermanent() const
Definition SpellAuras.h:153
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition SpellAuras.h:160
Definition Item.h:62
static Creature * ToCreature(Object *o)
Definition Object.h:186
static Unit * ToUnit(Object *o)
Definition Object.h:192
static GameObject * ToGameObject(Object *o)
Definition Object.h:198
static Player * ToPlayer(Object *o)
Definition Object.h:180
WorldObject * GetObjectTarget() const
Definition Spell.cpp:289
GameObject * GetGOTarget() const
Definition Spell.cpp:255
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition Spell.cpp:384
bool HasDst() const
Definition Spell.cpp:436
Item * GetItemTarget() const
Unit * GetUnitTarget() const
Definition Spell.cpp:229
WorldLocation const * GetDstPos() const
Definition Spell.cpp:379
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:452
GameObject * gameObjTarget
Definition Spell.h:525
DynObjAura * _dynObjAura
Definition Spell.h:535
SpellCastTargets m_targets
Definition Spell.h:402
int32 damage
Definition Spell.h:528
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const
Definition Spell.cpp:2381
Item * itemTarget
Definition Spell.h:524
int32 m_damage
Definition Spell.h:542
void DoCreateItem(uint32 itemId)
int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
Definition Spell.cpp:2373
SpellCustomErrors m_customError
Definition Spell.h:416
int32 m_healing
Definition Spell.h:543
SpellEffectInfo const * effectInfo
Definition Spell.h:531
SpellInfo const * m_triggeredByAuraSpell
Definition Spell.h:706
UnitAura * _spellAura
Definition Spell.h:534
Unit * unitTarget
Definition Spell.h:523
WorldObject * GetCaster() const
Definition Spell.h:450
Unit * GetOriginalCaster() const
Definition Spell.h:451
Corpse * m_corpseTarget
Definition Spell.h:526
WorldLocation * destTarget
Definition Spell.h:527
Item * m_CastItem
Definition Spell.h:396
SpellValue *const m_spellValue
Definition Spell.h:484
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const
Definition Spell.cpp:2365
void finish(bool ok=true)
Definition Spell.cpp:3912
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:4177
Definition Unit.h:769
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)