TrinityCore
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 "ScriptMgr.h"
21#include "Spell.h"
22#include "SpellAuras.h"
23#include "SpellMgr.h"
24#include "StringConvert.h"
25#include "Unit.h"
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);
33 return false;
34 }
35 return true;
36}
37
38SpellScriptBase::SpellScriptBase(): m_currentScriptState(SPELL_SCRIPT_STATE_NONE), m_scriptSpellId(0)
39{
40}
41
43
45{
46 if (!sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE))
47 {
48 TC_LOG_ERROR("scripts.spells", "SpellScriptBase::ValidateSpellInfo: Spell {} does not exist.", spellId);
49 return false;
50 }
51
52 return true;
53}
54
56{
57 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE);
58 if (!spellInfo)
59 {
60 TC_LOG_ERROR("scripts.spells", "SpellScriptBase::ValidateSpellEffect: Spell {} does not exist.", spellId);
61 return false;
62 }
63
64 if (spellInfo->GetEffects().size() <= effectIndex)
65 {
66 TC_LOG_ERROR("scripts.spells", "SpellScriptBase::ValidateSpellEffect: Spell {} does not have EFFECT_{}.", spellId, uint32(effectIndex));
67 return false;
68 }
69
70 return true;
71}
72
74{
76 Register();
78}
79
81{
83 Unload();
85}
86
87void SpellScriptBase::_Init(std::string const& scriptname, uint32 spellId)
88{
90 m_scriptName = scriptname;
91 m_scriptSpellId = spellId;
92
93#ifdef TRINITY_API_USE_DYNAMIC_LINKING
94 // Acquire a strong reference to the binary code
95 // to keep it loaded until all spells are destroyed.
96 m_moduleReference = sScriptMgr->AcquireModuleReferenceOfScriptName(scriptname);
97#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
98}
99
100std::string_view SpellScriptBase::GetScriptName() const
101{
102 return m_scriptName;
103}
104
106{
107 // effect index must be in range <0;2>, allow use of special effindexes
108 ASSERT(effIndex == EFFECT_ALL || effIndex == EFFECT_FIRST_FOUND || effIndex < MAX_SPELL_EFFECTS);
109 _effIndex = effIndex;
110}
111
112SpellScriptBase::EffectHook::EffectHook(EffectHook&& right) noexcept = default;
115
117{
118 uint32 mask = 0;
119 if (_effIndex == EFFECT_ALL || _effIndex == EFFECT_FIRST_FOUND)
120 {
121 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
122 {
123 if (_effIndex == EFFECT_FIRST_FOUND && mask)
124 return mask;
125 if (CheckEffect(spellInfo, i))
126 mask |= 1 << i;
127 }
128 }
129 else
130 {
131 if (CheckEffect(spellInfo, _effIndex))
132 mask |= 1 << _effIndex;
133 }
134 return mask;
135}
136
138{
139 return (GetAffectedEffectsMask(spellInfo) & 1 << effIndex) != 0;
140}
141
143{
144 if (_effIndex == EFFECT_ALL)
145 return "EFFECT_ALL";
146 if (_effIndex == EFFECT_FIRST_FOUND)
147 return "EFFECT_FIRST_FOUND";
148 if (_effIndex < MAX_SPELL_EFFECTS)
149 return Trinity::StringFormat("EFFECT_{}", uint32(_effIndex));
150 return "Invalid Value";
151}
152
154 : EffectHook(effIndex), _effName(effName)
155{
156}
157
158SpellScript::EffectBase::EffectBase(EffectBase&& right) noexcept = default;
161
163{
164 switch (_effName)
165 {
166 case SPELL_EFFECT_ANY:
167 return Trinity::StringFormat("Index: {}, Effect: SPELL_EFFECT_ANY", EffIndexToString());
168 default:
169 return Trinity::StringFormat("Index: {}, Effect: SPELL_EFFECT_{}", EffIndexToString(), _effName);
170 }
171}
172
173bool SpellScript::EffectBase::CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) const
174{
175 if (spellInfo->GetEffects().size() <= effIndex)
176 return false;
177 SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(SpellEffIndex(effIndex));
178 if (!spellEffectInfo.Effect && !_effName)
179 return true;
180 if (!spellEffectInfo.Effect)
181 return false;
182 return (_effName == SPELL_EFFECT_ANY) || (spellEffectInfo.Effect == _effName);
183}
184
185SpellScript::TargetHook::TargetHook(uint8 effectIndex, uint16 targetType, bool area, bool dest)
186 : EffectHook(effectIndex), _targetType(targetType), _area(area), _dest(dest) { }
187
188SpellScript::TargetHook::TargetHook(TargetHook&& right) noexcept = default;
191
193{
194 return Trinity::StringFormat("Index: {} Target: {}", EffIndexToString(), _targetType);
195}
196
197bool SpellScript::TargetHook::CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) const
198{
199 if (!_targetType)
200 return false;
201
202 if (spellInfo->GetEffects().size() <= effIndex)
203 return false;
204
205 SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(SpellEffIndex(effIndex));
206 if (spellEffectInfo.TargetA.GetTarget() != _targetType &&
207 spellEffectInfo.TargetB.GetTarget() != _targetType)
208 return false;
209
210 SpellImplicitTargetInfo targetInfo(_targetType);
211 switch (targetInfo.GetSelectionCategory())
212 {
213 case TARGET_SELECT_CATEGORY_CHANNEL: // SINGLE
214 return !_area;
216 return true;
217 case TARGET_SELECT_CATEGORY_CONE: // AREA
218 case TARGET_SELECT_CATEGORY_LINE: // AREA
219 return _area;
220 case TARGET_SELECT_CATEGORY_AREA: // AREA
222 return _area || _dest;
223 return _area;
225 switch (targetInfo.GetObjectType())
226 {
227 case TARGET_OBJECT_TYPE_SRC: // EMPTY
228 return false;
229 case TARGET_OBJECT_TYPE_DEST: // DEST
230 return _dest;
231 default:
232 switch (targetInfo.GetReferenceType())
233 {
234 case TARGET_REFERENCE_TYPE_CASTER: // SINGLE
235 return !_area;
236 case TARGET_REFERENCE_TYPE_TARGET: // BOTH
237 return true;
238 default:
239 break;
240 }
241 break;
242 }
243 break;
244 default:
245 break;
246 }
247
248 return false;
249}
250
252{
253}
254
255SpellScript::~SpellScript() = default;
256
258{
259 for (EffectHandler& hook : OnEffectLaunch)
260 if (!hook.GetAffectedEffectsMask(entry))
261 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, hook.ToString(), m_scriptName);
262
264 if (!hook.GetAffectedEffectsMask(entry))
265 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, hook.ToString(), m_scriptName);
266
267 for (EffectHandler& hook : OnEffectHit)
268 if (!hook.GetAffectedEffectsMask(entry))
269 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, hook.ToString(), m_scriptName);
270
271 for (EffectHandler& hook : OnEffectHitTarget)
272 if (!hook.GetAffectedEffectsMask(entry))
273 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, hook.ToString(), m_scriptName);
274
276 if (!hook.GetAffectedEffectsMask(entry))
277 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, hook.ToString(), m_scriptName);
278
280 if (!hook.GetAffectedEffectsMask(entry))
281 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, hook.ToString(), m_scriptName);
282
284 if (!hook.GetAffectedEffectsMask(entry))
285 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, hook.ToString(), m_scriptName);
286
288 if (!hook.GetAffectedEffectsMask(entry))
289 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, hook.ToString(), m_scriptName);
290
291 if (CalcDamage.size())
292 {
300 TC_LOG_ERROR("scripts", "Spell `{}` script `{}` does not have a damage effect - handler bound to hook `CalcDamage` of SpellScript won't be executed", entry->Id, m_scriptName);
301 }
302
303 if (CalcHealing.size())
304 {
305 if (!entry->HasEffect(SPELL_EFFECT_HEAL)
309 TC_LOG_ERROR("scripts", "Spell `{}` script `{}` does not have a damage effect - handler bound to hook `CalcHealing` of SpellScript won't be executed", entry->Id, m_scriptName);
310 }
311
312 return SpellScriptBase::_Validate(entry);
313}
314
316{
317 m_spell = spell;
319 bool load = Load();
321 return load;
322}
323
325{
328}
329
331{
332 m_currentScriptState = hookType;
333}
334
336{
338}
339
341{
343}
344
346{
347 return IsInHitPhase()
348 || IsInEffectHook()
354}
355
357{
358 switch (m_currentScriptState)
359 {
366 return true;
367 }
368 return false;
369}
370
372{
373 // after hit hook executed after damage/healing is already done
374 // modifying it at this point has no effect
375 switch (m_currentScriptState)
376 {
381 return true;
382 }
383 return false;
384}
385
387{
389}
390
392{
395}
396
398{
399 return m_spell->GetCaster()->ToUnit();
400}
401
403{
404 return m_spell->GetCaster()->ToGameObject();
405}
406
408{
409 return m_spell->GetOriginalCaster();
410}
411
413{
414 return m_spell->GetSpellInfo();
415}
416
418{
419 return GetSpellInfo()->GetEffect(effIndex);
420}
421
423{
424 return m_spell->m_spellValue;
425}
426
428{
429 if (m_spell->m_targets.HasDst())
430 return m_spell->m_targets.GetDstPos();
431 return nullptr;
432}
433
435{
437}
438
440{
442}
443
445{
447}
448
450{
451 return m_spell->m_targets.GetGOTarget();
452}
453
455{
457}
458
460{
462 {
463 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetUnitTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
465 return 0;
466 }
467 return m_spell->GetUnitTargetCountForEffect(effect);
468}
469
471{
473 {
474 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetGameObjectTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
476 return 0;
477 }
479}
480
482{
484 {
485 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetItemTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
487 return 0;
488 }
489 return m_spell->GetItemTargetCountForEffect(effect);
490}
491
493{
495 {
496 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetCorpseTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
498 return 0;
499 }
501}
502
504{
505 if (!IsInTargetHook())
506 {
507 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitUnit was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
508 return nullptr;
509 }
510 return m_spell->unitTarget;
511}
512
514{
515 if (!IsInTargetHook())
516 {
517 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitCreature was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
518 return nullptr;
519 }
520 if (m_spell->unitTarget)
521 return m_spell->unitTarget->ToCreature();
522 return nullptr;
523}
524
526{
527 if (!IsInTargetHook())
528 {
529 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitPlayer was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
530 return nullptr;
531 }
532 if (m_spell->unitTarget)
533 return m_spell->unitTarget->ToPlayer();
534 return nullptr;
535}
536
538{
539 if (!IsInTargetHook())
540 {
541 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitItem was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
542 return nullptr;
543 }
544 return m_spell->itemTarget;
545}
546
548{
549 if (!IsInTargetHook())
550 {
551 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitGObj was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
552 return nullptr;
553 }
554 return m_spell->gameObjTarget;
555}
556
558{
559 if (!IsInTargetHook())
560 {
561 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitCorpse was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
562 return nullptr;
563 }
564 return m_spell->m_corpseTarget;
565}
566
568{
569 if (!IsInEffectHook())
570 {
571 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitDest was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
572 return nullptr;
573 }
574 return m_spell->destTarget;
575}
576
578{
579 if (!IsInTargetHook())
580 {
581 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitDamage was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
582 return 0;
583 }
584 return m_spell->m_damage;
585}
586
588{
589 if (!IsInModifiableHook())
590 {
591 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetHitDamage was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
592 return;
593 }
594 m_spell->m_damage = damage;
595}
596
598{
599 if (!IsInTargetHook())
600 {
601 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitHeal was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
602 return 0;
603 }
604 return m_spell->m_healing;
605}
606
608{
609 if (!IsInModifiableHook())
610 {
611 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetHitHeal was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
612 return;
613 }
614 m_spell->m_healing = heal;
615}
616
618{
619 if (!IsInTargetHook())
620 {
621 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::IsHitCrit was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
622 return false;
623 }
624 if (Unit* hitUnit = GetHitUnit())
625 {
626 auto itr = std::find_if(m_spell->m_UniqueTargetInfo.begin(), m_spell->m_UniqueTargetInfo.end(), [hitUnit](Spell::TargetInfo const& targetInfo)
627 {
628 return targetInfo.TargetGUID == hitUnit->GetGUID();
629 });
630 ASSERT(itr != m_spell->m_UniqueTargetInfo.end());
631 return itr->IsCrit;
632 }
633 return false;
634}
635
636Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/) const
637{
638 if (!IsInTargetHook())
639 {
640 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetHitAura was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
641 return nullptr;
642 }
643
644 Aura* aura = m_spell->_spellAura;
645 if (dynObjAura)
646 aura = m_spell->_dynObjAura;
647
648 if (!aura || aura->IsRemoved())
649 return nullptr;
650
651 return aura;
652}
653
655{
656 if (!IsInTargetHook())
657 {
658 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::PreventHitAura was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
659 return;
660 }
661 if (UnitAura* aura = m_spell->_spellAura)
662 aura->Remove();
663 if (DynObjAura* aura = m_spell->_dynObjAura)
664 aura->Remove();
665}
666
668{
669 if (!IsInHitPhase() && !IsInEffectHook())
670 {
671 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::PreventHitEffect was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
672 return;
673 }
674 m_hitPreventEffectMask |= 1 << effIndex;
675 PreventHitDefaultEffect(effIndex);
676}
677
679{
680 if (!IsInHitPhase() && !IsInEffectHook())
681 {
682 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::PreventHitDefaultEffect was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
683 return;
684 }
685 m_hitPreventDefaultEffectMask |= 1 << effIndex;
686}
687
689{
690 ASSERT(IsInEffectHook(), "Script: `" STRING_VIEW_FMT "` Spell: `%u`: function SpellScript::GetEffectInfo was called, but function has no effect in current hook!", STRING_VIEW_FMT_ARG(m_scriptName), m_scriptSpellId);
691
692 return *m_spell->effectInfo;
693}
694
696{
697 if (!IsInEffectHook())
698 {
699 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetEffectValue was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
700 return 0;
701 }
702
703 return m_spell->damage;
704}
705
707{
708 if (!IsInEffectHook())
709 {
710 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetEffectValue was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
711 return;
712 }
713
714 m_spell->damage = value;
715}
716
718{
719 if (!IsInEffectHook())
720 {
721 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::GetEffectVariance was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
722 return 0.0f;
723 }
724
725 return m_spell->variance;
726}
727
729{
730 if (!IsInEffectHook())
731 {
732 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetEffectVariance was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
733 return;
734 }
735
736 m_spell->variance = variance;
737}
738
740{
741 return m_spell->m_CastItem;
742}
743
745{
746 m_spell->DoCreateItem(itemId, context);
747}
748
750{
752}
753
754void SpellScript::FinishCast(SpellCastResult result, int32* param1 /*= nullptr*/, int32* param2 /*= nullptr*/)
755{
756 m_spell->SendCastResult(result, param1, param2);
757 m_spell->finish(result);
758}
759
761{
762 if (!IsInCheckCastHook())
763 {
764 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}`: function SpellScript::SetCustomCastResultMessage was called while spell not in check cast phase!", m_scriptName, m_scriptSpellId);
765 return;
766 }
767
768 m_spell->m_customError = result;
769}
770
772{
773 return m_spell->GetCastDifficulty();
774}
775
777{
778 for (auto itr = DoCheckAreaTarget.begin(); itr != DoCheckAreaTarget.end(); ++itr)
780 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);
781
782 for (auto itr = OnDispel.begin(); itr != OnDispel.end(); ++itr)
783 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
784 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);
785
786 for (auto itr = AfterDispel.begin(); itr != AfterDispel.end(); ++itr)
787 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
788 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);
789
790 for (auto itr = OnEffectApply.begin(); itr != OnEffectApply.end(); ++itr)
791 if (!itr->GetAffectedEffectsMask(entry))
792 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);
793
794 for (auto itr = OnEffectRemove.begin(); itr != OnEffectRemove.end(); ++itr)
795 if (!itr->GetAffectedEffectsMask(entry))
796 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);
797
798 for (auto itr = AfterEffectApply.begin(); itr != AfterEffectApply.end(); ++itr)
799 if (!itr->GetAffectedEffectsMask(entry))
800 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);
801
802 for (auto itr = AfterEffectRemove.begin(); itr != AfterEffectRemove.end(); ++itr)
803 if (!itr->GetAffectedEffectsMask(entry))
804 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);
805
806 for (auto itr = OnEffectPeriodic.begin(); itr != OnEffectPeriodic.end(); ++itr)
807 if (!itr->GetAffectedEffectsMask(entry))
808 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);
809
810 for (auto itr = OnEffectUpdatePeriodic.begin(); itr != OnEffectUpdatePeriodic.end(); ++itr)
811 if (!itr->GetAffectedEffectsMask(entry))
812 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);
813
814 for (auto itr = DoEffectCalcAmount.begin(); itr != DoEffectCalcAmount.end(); ++itr)
815 if (!itr->GetAffectedEffectsMask(entry))
816 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);
817
818 for (auto itr = DoEffectCalcPeriodic.begin(); itr != DoEffectCalcPeriodic.end(); ++itr)
819 if (!itr->GetAffectedEffectsMask(entry))
820 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);
821
822 for (auto itr = DoEffectCalcSpellMod.begin(); itr != DoEffectCalcSpellMod.end(); ++itr)
823 if (!itr->GetAffectedEffectsMask(entry))
824 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);
825
826 for (auto itr = DoEffectCalcCritChance.begin(); itr != DoEffectCalcCritChance.end(); ++itr)
827 if (!itr->GetAffectedEffectsMask(entry))
828 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `DoEffectCalcCritChance` of AuraScript won't be executed", entry->Id, itr->ToString(), m_scriptName);
829
831 if (!hook.GetAffectedEffectsMask(entry))
832 TC_LOG_ERROR("scripts", "Spell `{}` Effect `{}` of script `{}` did not match dbc effect data - handler bound to hook `DoEffectCalcDamageAndHealing` of AuraScript won't be executed", entry->Id, hook.ToString(), m_scriptName);
833
834 for (auto itr = OnEffectAbsorb.begin(); itr != OnEffectAbsorb.end(); ++itr)
835 if (!itr->GetAffectedEffectsMask(entry))
836 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);
837
838 for (auto itr = AfterEffectAbsorb.begin(); itr != AfterEffectAbsorb.end(); ++itr)
839 if (!itr->GetAffectedEffectsMask(entry))
840 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);
841
842 for (auto itr = OnEffectManaShield.begin(); itr != OnEffectManaShield.end(); ++itr)
843 if (!itr->GetAffectedEffectsMask(entry))
844 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);
845
846 for (auto itr = AfterEffectManaShield.begin(); itr != AfterEffectManaShield.end(); ++itr)
847 if (!itr->GetAffectedEffectsMask(entry))
848 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);
849
850 for (auto itr = OnEffectSplit.begin(); itr != OnEffectSplit.end(); ++itr)
851 if (!itr->GetAffectedEffectsMask(entry))
852 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);
853
854 for (auto itr = DoCheckProc.begin(); itr != DoCheckProc.end(); ++itr)
855 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
856 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);
857
858 for (auto itr = DoCheckEffectProc.begin(); itr != DoCheckEffectProc.end(); ++itr)
859 if (!itr->GetAffectedEffectsMask(entry))
860 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);
861
862 for (auto itr = DoPrepareProc.begin(); itr != DoPrepareProc.end(); ++itr)
863 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
864 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);
865
866 for (auto itr = OnProc.begin(); itr != OnProc.end(); ++itr)
867 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
868 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);
869
870 for (auto itr = AfterProc.begin(); itr != AfterProc.end(); ++itr)
871 if (!entry->HasEffect(SPELL_EFFECT_APPLY_AURA) && !entry->HasAreaAuraEffect())
872 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);
873
874 for (auto itr = OnEffectProc.begin(); itr != OnEffectProc.end(); ++itr)
875 if (!itr->GetAffectedEffectsMask(entry))
876 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);
877
878 for (auto itr = AfterEffectProc.begin(); itr != AfterEffectProc.end(); ++itr)
879 if (!itr->GetAffectedEffectsMask(entry))
880 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);
881
882 return SpellScriptBase::_Validate(entry);
883}
884
886 : EffectHook(effIndex), _auraType(auraType) { }
887
888AuraScript::EffectBase::EffectBase(EffectBase&& right) noexcept = default;
891
892bool AuraScript::EffectBase::CheckEffect(SpellInfo const* spellInfo, uint8 effIndex) const
893{
894 if (spellInfo->GetEffects().size() <= effIndex)
895 return false;
896 SpellEffectInfo const& spellEffectInfo = spellInfo->GetEffect(SpellEffIndex(effIndex));
897 if (!spellEffectInfo.ApplyAuraName && !_auraType)
898 return true;
899 if (!spellEffectInfo.ApplyAuraName)
900 return false;
901 return (_auraType == SPELL_AURA_ANY) || (spellEffectInfo.ApplyAuraName == _auraType);
902}
903
905{
906 switch (_auraType)
907 {
908 case SPELL_AURA_ANY:
909 return Trinity::StringFormat("Index: {}, AuraName: SPELL_AURA_ANY", EffIndexToString());
910 default:
911 return Trinity::StringFormat("Index: {}, AuraName: SPELL_AURA_{}", EffIndexToString(), _auraType);
912 }
913}
914
916{
917}
918
919AuraScript::~AuraScript() = default;
920
922{
923 m_aura = aura;
925 bool load = Load();
927 return load;
928}
929
931{
933 m_currentScriptState = hookType;
935 m_auraApplication = aurApp;
936}
937
939{
940 ScriptStateStore stateStore = m_scriptStates.top();
944 m_scriptStates.pop();
945}
946
948{
949 switch (m_currentScriptState)
950 {
960 default:
961 ABORT_MSG("AuraScript::_IsDefaultActionPrevented is called in a wrong place");
962 return false;
963 }
964}
965
967{
968 switch (m_currentScriptState)
969 {
979 break;
980 default:
981 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}` AuraScript::PreventDefaultAction called in a hook in which the call won't have effect!", m_scriptName, m_scriptSpellId);
982 break;
983 }
984}
985
987{
988 return m_aura->GetSpellInfo();
989}
990
992{
993 return m_aura->GetSpellInfo()->GetEffect(effIndex);
994}
995
997{
998 return m_aura->GetId();
999}
1000
1002{
1003 return m_aura->GetCasterGUID();
1004}
1005
1007{
1008 if (WorldObject* caster = m_aura->GetCaster())
1009 return caster->ToUnit();
1010 return nullptr;
1011}
1012
1014{
1015 if (WorldObject* caster = m_aura->GetCaster())
1016 return caster->ToGameObject();
1017 return nullptr;
1018}
1019
1021{
1022 return m_aura->GetOwner();
1023}
1024
1026{
1027 return m_aura->GetUnitOwner();
1028}
1029
1031{
1032 return m_aura->GetDynobjOwner();
1033}
1034
1036{
1037 m_aura->Remove(removeMode);
1038}
1039
1041{
1042 return m_aura;
1043}
1044
1046{
1047 return m_aura->GetType();
1048}
1049
1051{
1052 return m_aura->GetDuration();
1053}
1054
1055void AuraScript::SetDuration(int32 duration, bool withMods)
1056{
1057 m_aura->SetDuration(duration, withMods);
1058}
1059
1061{
1063}
1064
1066{
1067 return m_aura->GetApplyTime();
1068}
1069
1071{
1072 return m_aura->GetMaxDuration();
1073}
1074
1076{
1077 m_aura->SetMaxDuration(duration);
1078}
1079
1081{
1082 return m_aura->CalcMaxDuration();
1083}
1084
1086{
1087 return m_aura->IsExpired();
1088}
1089
1091{
1092 return m_aura->IsPermanent();
1093}
1094
1096{
1097 return m_aura->GetCharges();
1098}
1099
1101{
1102 m_aura->SetCharges(charges);
1103}
1104
1106{
1107 return m_aura->CalcMaxCharges();
1108}
1109
1110bool AuraScript::ModCharges(int8 num, AuraRemoveMode removeMode /*= AURA_REMOVE_BY_DEFAULT*/)
1111{
1112 return m_aura->ModCharges(num, removeMode);
1113}
1114
1116{
1117 return m_aura->DropCharge(removeMode);
1118}
1119
1121{
1122 return m_aura->GetStackAmount();
1123}
1124
1126{
1127 m_aura->SetStackAmount(num);
1128}
1129
1131{
1132 return m_aura->ModStackAmount(num, removeMode);
1133}
1134
1136{
1137 return m_aura->IsPassive();
1138}
1139
1141{
1142 return m_aura->IsDeathPersistent();
1143}
1144
1145bool AuraScript::HasEffect(uint8 effIndex) const
1146{
1147 return m_aura->HasEffect(effIndex);
1148}
1149
1151{
1152 return m_aura->GetEffect(effIndex);
1153}
1154
1156{
1157 return m_aura->HasEffectType(type);
1158}
1159
1161{
1162 switch (m_currentScriptState)
1163 {
1184 return m_auraApplication->GetTarget();
1185 default:
1186 TC_LOG_ERROR("scripts", "Script: `{}` Spell: `{}` AuraScript::GetTarget called in a hook in which the call won't have effect!", m_scriptName, m_scriptSpellId);
1187 }
1188
1189 return nullptr;
1190}
1191
1193{
1194 return m_auraApplication;
1195}
1196
1198{
1199 return GetAura()->GetCastDifficulty();
1200}
Difficulty
Definition: DBCEnums.h:873
@ DIFFICULTY_NONE
Definition: DBCEnums.h:874
ItemContext
Definition: DBCEnums.h:1063
#define MAX_SPELL_EFFECTS
Definition: DBCEnums.h:1953
uint8_t uint8
Definition: Define.h:145
#define STRING_VIEW_FMT_ARG(str)
Definition: Define.h:136
int64_t int64
Definition: Define.h:138
int8_t int8
Definition: Define.h:141
#define STRING_VIEW_FMT
Definition: Define.h:135
int32_t int32
Definition: Define.h:139
uint16_t uint16
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:143
#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:1418
SpellEffIndex
Definition: SharedDefines.h:29
#define EFFECT_FIRST_FOUND
Definition: SharedDefines.h:71
@ SPELL_EFFECT_HEALTH_LEECH
@ SPELL_EFFECT_WEAPON_DAMAGE
@ SPELL_EFFECT_HEAL
@ SPELL_EFFECT_NORMALIZED_WEAPON_DMG
@ SPELL_EFFECT_HEAL_MECHANICAL
@ SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
@ SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
@ SPELL_EFFECT_POWER_DRAIN
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ SPELL_EFFECT_HEAL_PCT
@ SPELL_EFFECT_APPLY_AURA
SpellCustomErrors
SpellCastResult
#define EFFECT_ALL
Definition: SharedDefines.h:72
AuraRemoveMode
AuraType
AuraObjectType
@ TARGET_SELECT_CATEGORY_CONE
Definition: SpellInfo.h:48
@ TARGET_SELECT_CATEGORY_AREA
Definition: SpellInfo.h:49
@ TARGET_SELECT_CATEGORY_DEFAULT
Definition: SpellInfo.h:45
@ TARGET_SELECT_CATEGORY_NEARBY
Definition: SpellInfo.h:47
@ TARGET_SELECT_CATEGORY_LINE
Definition: SpellInfo.h:51
@ TARGET_SELECT_CATEGORY_CHANNEL
Definition: SpellInfo.h:46
@ TARGET_OBJECT_TYPE_UNIT_AND_DEST
Definition: SpellInfo.h:70
@ TARGET_OBJECT_TYPE_DEST
Definition: SpellInfo.h:68
@ TARGET_OBJECT_TYPE_SRC
Definition: SpellInfo.h:67
@ TARGET_REFERENCE_TYPE_TARGET
Definition: SpellInfo.h:58
@ TARGET_REFERENCE_TYPE_CASTER
Definition: SpellInfo.h:57
#define sSpellMgr
Definition: SpellMgr.h:849
AuraScriptHookType
Definition: SpellScript.h:1031
@ AURA_SCRIPT_HOOK_CHECK_EFFECT_PROC
Definition: SpellScript.h:1054
@ AURA_SCRIPT_HOOK_EFFECT_CALC_DAMAGE_AND_HEALING
Definition: SpellScript.h:1042
@ AURA_SCRIPT_HOOK_EFFECT_REMOVE
Definition: SpellScript.h:1034
@ AURA_SCRIPT_HOOK_EFFECT_CALC_CRIT_CHANCE
Definition: SpellScript.h:1041
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_MANASHIELD
Definition: SpellScript.h:1046
@ AURA_SCRIPT_HOOK_PREPARE_PROC
Definition: SpellScript.h:1055
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_APPLY
Definition: SpellScript.h:1033
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_REMOVE
Definition: SpellScript.h:1035
@ AURA_SCRIPT_HOOK_AFTER_PROC
Definition: SpellScript.h:1059
@ AURA_SCRIPT_HOOK_EFFECT_MANASHIELD
Definition: SpellScript.h:1045
@ AURA_SCRIPT_HOOK_PROC
Definition: SpellScript.h:1056
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_ABSORB
Definition: SpellScript.h:1044
@ AURA_SCRIPT_HOOK_EFFECT_APPLY
Definition: SpellScript.h:1032
@ AURA_SCRIPT_HOOK_EFFECT_PERIODIC
Definition: SpellScript.h:1036
@ AURA_SCRIPT_HOOK_EFFECT_AFTER_PROC
Definition: SpellScript.h:1058
@ AURA_SCRIPT_HOOK_EFFECT_ABSORB
Definition: SpellScript.h:1043
@ AURA_SCRIPT_HOOK_EFFECT_PROC
Definition: SpellScript.h:1057
@ AURA_SCRIPT_HOOK_EFFECT_SPLIT
Definition: SpellScript.h:1047
@ AURA_SCRIPT_HOOK_CHECK_PROC
Definition: SpellScript.h:1053
@ AURA_SCRIPT_HOOK_ENTER_LEAVE_COMBAT
Definition: SpellScript.h:1051
@ SPELL_SCRIPT_STATE_NONE
Definition: SpellScript.h:63
@ SPELL_SCRIPT_STATE_LOADING
Definition: SpellScript.h:65
@ SPELL_SCRIPT_STATE_UNLOADING
Definition: SpellScript.h:66
@ SPELL_SCRIPT_STATE_REGISTRATION
Definition: SpellScript.h:64
#define HOOK_SPELL_HIT_START
Definition: SpellScript.h:243
#define HOOK_SPELL_HIT_END
Definition: SpellScript.h:244
SpellScriptHookType
Definition: SpellScript.h:219
@ SPELL_SCRIPT_HOOK_AFTER_CAST
Definition: SpellScript.h:235
@ SPELL_SCRIPT_HOOK_AFTER_HIT
Definition: SpellScript.h:227
@ SPELL_SCRIPT_HOOK_EFFECT_SUCCESSFUL_DISPEL
Definition: SpellScript.h:224
@ SPELL_SCRIPT_HOOK_CALC_HEALING
Definition: SpellScript.h:238
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH
Definition: SpellScript.h:220
@ SPELL_SCRIPT_HOOK_BEFORE_HIT
Definition: SpellScript.h:225
@ SPELL_SCRIPT_HOOK_CALC_DAMAGE
Definition: SpellScript.h:237
@ SPELL_SCRIPT_HOOK_CHECK_CAST
Definition: SpellScript.h:231
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET
Definition: SpellScript.h:221
@ SPELL_SCRIPT_HOOK_HIT
Definition: SpellScript.h:226
@ SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET
Definition: SpellScript.h:223
@ SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE
Definition: SpellScript.h:236
@ SPELL_SCRIPT_HOOK_ON_CAST
Definition: SpellScript.h:233
#define SPELL_EFFECT_ANY
Definition: SpellScript.h:58
#define SPELL_AURA_ANY
Definition: SpellScript.h:59
Unit * GetTarget() const
Definition: SpellAuras.h:76
std::string ToString() const
EffectBase & operator=(EffectBase const &right)=delete
EffectBase(uint8 effIndex, uint16 auraType)
bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex) const override
AuraApplication const * _auraApplication
Definition: SpellScript.h:1989
bool IsPermanent() const
HookList< EffectAbsorbHandler > OnEffectManaShield
Definition: SpellScript.h:2112
HookList< EffectCalcDamageAndHealingHandler > DoEffectCalcDamageAndHealing
Definition: SpellScript.h:2082
void PreventDefaultAction()
AuraObjectType GetType() const
bool IsExpired() const
void _PrepareScriptCall(AuraScriptHookType hookType, AuraApplication const *aurApp=nullptr)
void SetMaxDuration(int32 duration)
HookList< EffectCalcPeriodicHandler > DoEffectCalcPeriodic
Definition: SpellScript.h:2063
AuraApplication const * GetTargetApplication() const
int32 GetDuration() const
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
AuraApplication const * m_auraApplication
Definition: SpellScript.h:1983
HookList< CheckEffectProcHandler > DoCheckEffectProc
Definition: SpellScript.h:2135
bool ModCharges(int8 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
bool m_defaultActionPrevented
Definition: SpellScript.h:1984
SpellInfo const * GetSpellInfo() const
WorldObject * GetOwner() const
uint8 CalcMaxCharges() const
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
HookList< EffectProcHandler > AfterEffectProc
Definition: SpellScript.h:2159
int32 GetMaxDuration() const
time_t GetApplyTime() const
void SetCharges(uint8 charges)
HookList< EffectAbsorbHandler > AfterEffectAbsorb
Definition: SpellScript.h:2096
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Definition: SpellScript.h:2057
Unit * GetCaster() const
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
Definition: SpellScript.h:2051
HookList< EffectCalcSpellModHandler > DoEffectCalcSpellMod
Definition: SpellScript.h:2069
void SetDuration(int32 duration, bool withMods=false)
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
SpellEffectInfo const & GetEffectInfo(SpellEffIndex effIndex) const
AuraEffect * GetEffect(uint8 effIndex) const
bool HasEffectType(AuraType type) const
HookList< EffectAbsorbHandler > OnEffectAbsorb
Definition: SpellScript.h:2089
bool _Validate(SpellInfo const *entry) override
HookList< EffectCalcCritChanceHandler > DoEffectCalcCritChance
Definition: SpellScript.h:2075
Aura * GetAura() const
HookList< EffectAbsorbHandler > AfterEffectManaShield
Definition: SpellScript.h:2118
HookList< CheckAreaTargetHandler > DoCheckAreaTarget
Definition: SpellScript.h:2007
Unit * GetTarget() const
ObjectGuid GetCasterGUID() const
void RefreshDuration()
bool IsDeathPersistent() const
Aura * m_aura
Definition: SpellScript.h:1982
GameObject * GetGObjCaster() const
HookList< AuraProcHandler > AfterProc
Definition: SpellScript.h:2149
HookList< AuraDispelHandler > OnDispel
Definition: SpellScript.h:2013
Difficulty GetCastDifficulty() const
HookList< CheckProcHandler > DoCheckProc
Definition: SpellScript.h:2129
bool _Load(Aura *aura)
HookList< EffectApplyHandler > OnEffectRemove
Definition: SpellScript.h:2035
HookList< AuraDispelHandler > AfterDispel
Definition: SpellScript.h:2017
void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
ScriptStateStack m_scriptStates
Definition: SpellScript.h:1997
int32 CalcMaxDuration() const
uint8 GetCharges() const
void SetStackAmount(uint8 num)
HookList< EffectProcHandler > OnEffectProc
Definition: SpellScript.h:2155
Unit * GetUnitOwner() const
HookList< AuraProcHandler > DoPrepareProc
Definition: SpellScript.h:2141
bool _IsDefaultActionPrevented() const
HookList< AuraProcHandler > OnProc
Definition: SpellScript.h:2145
void _FinishScriptCall()
bool HasEffect(uint8 effIndex) const
uint8 GetStackAmount() const
HookList< EffectApplyHandler > OnEffectApply
Definition: SpellScript.h:2024
DynamicObject * GetDynobjOwner() const
bool IsPassive() const
HookList< EffectAbsorbHandler > OnEffectSplit
Definition: SpellScript.h:2123
uint32 GetId() const
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
int32 GetMaxDuration() const
Definition: SpellAuras.h:167
void SetStackAmount(uint8 num)
Unit * GetUnitOwner() const
Definition: SpellAuras.h:146
void RefreshDuration(bool withMods=false)
Definition: SpellAuras.cpp:901
DynamicObject * GetDynobjOwner() const
Definition: SpellAuras.h:147
ObjectGuid GetCasterGUID() const
Definition: SpellAuras.h:138
bool HasEffect(uint8 effIndex) const
Definition: SpellAuras.h:224
bool IsRemoved() const
Definition: SpellAuras.h:204
WorldObject * GetOwner() const
Definition: SpellAuras.h:145
bool ModCharges(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.cpp:971
uint32 GetId() const
Definition: SpellAuras.h:134
int32 GetDuration() const
Definition: SpellAuras.h:172
bool IsDeathPersistent() const
bool HasEffectType(AuraType type) const
AuraEffect * GetEffect(uint32 index) const
Definition: SpellAuras.cpp:529
Unit * GetCaster() const
Definition: SpellAuras.cpp:513
uint8 CalcMaxCharges(Unit *caster) const
Definition: SpellAuras.cpp:958
void SetCharges(uint8 charges)
Definition: SpellAuras.cpp:948
bool ModStackAmount(int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, bool resetPeriodicTimer=true)
int32 CalcMaxDuration() const
Definition: SpellAuras.h:169
void SetDuration(int32 duration, bool withMods=false)
Definition: SpellAuras.cpp:890
AuraObjectType GetType() const
Definition: SpellAuras.cpp:537
uint8 GetStackAmount() const
Definition: SpellAuras.h:188
uint8 GetCharges() const
Definition: SpellAuras.h:179
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:133
void SetMaxDuration(int32 duration)
Definition: SpellAuras.h:168
Difficulty GetCastDifficulty() const
Definition: SpellAuras.h:135
bool IsExpired() const
Definition: SpellAuras.h:176
bool IsPassive() const
time_t GetApplyTime() const
Definition: SpellAuras.h:166
bool IsPermanent() const
Definition: SpellAuras.h:177
virtual void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)=0
bool DropCharge(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: SpellAuras.h:184
Definition: Corpse.h:53
Definition: Item.h:170
static Creature * ToCreature(Object *o)
Definition: Object.h:206
static Unit * ToUnit(Object *o)
Definition: Object.h:212
static GameObject * ToGameObject(Object *o)
Definition: Object.h:218
static Player * ToPlayer(Object *o)
Definition: Object.h:200
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:277
GameObject * GetGOTarget() const
Definition: Spell.cpp:243
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:372
bool HasDst() const
Definition: Spell.cpp:424
Item * GetItemTarget() const
Definition: SpellDefines.h:360
Unit * GetUnitTarget() const
Definition: Spell.cpp:217
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:367
AuraType ApplyAuraName
Definition: SpellInfo.h:219
SpellEffectName Effect
Definition: SpellInfo.h:218
SpellImplicitTargetInfo TargetA
Definition: SpellInfo.h:231
SpellImplicitTargetInfo TargetB
Definition: SpellInfo.h:232
SpellTargetReferenceTypes GetReferenceType() const
Definition: SpellInfo.cpp:85
SpellTargetSelectionCategories GetSelectionCategory() const
Definition: SpellInfo.cpp:80
SpellTargetObjectTypes GetObjectType() const
Definition: SpellInfo.cpp:90
Targets GetTarget() const
Definition: SpellInfo.cpp:132
bool HasEffect(SpellEffectName effect) const
Definition: SpellInfo.cpp:1391
uint32 const Id
Definition: SpellInfo.h:325
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
std::vector< SpellEffectInfo > const & GetEffects() const
Definition: SpellInfo.h:576
bool HasAreaAuraEffect() const
Definition: SpellInfo.cpp:1409
bool IsEffectAffected(SpellInfo const *spellInfo, uint8 effIndex) const
uint32 GetAffectedEffectsMask(SpellInfo const *spellInfo) const
EffectHook & operator=(EffectHook const &right)=delete
std::string EffIndexToString() const
uint32 m_scriptSpellId
Definition: SpellScript.h:134
uint8 m_currentScriptState
Definition: SpellScript.h:132
void _Init(std::string const &scriptname, uint32 spellId)
Definition: SpellScript.cpp:87
virtual void Register()=0
virtual bool Validate(SpellInfo const *spellInfo)
Definition: SpellScript.h:154
std::string_view m_scriptName
Definition: SpellScript.h:133
static bool ValidateSpellInfoImpl(Iterator begin, Iterator end)
Definition: SpellScript.h:186
static bool ValidateSpellEffectImpl(uint32 spellId, SpellEffIndex effectIndex)
Definition: SpellScript.cpp:55
virtual bool Load()
Definition: SpellScript.h:157
virtual ~SpellScriptBase()
std::string_view GetScriptName() const
virtual void Unload()
Definition: SpellScript.h:160
virtual bool _Validate(SpellInfo const *entry)
Definition: SpellScript.cpp:28
bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex) const override
EffectBase & operator=(EffectBase const &right)=delete
EffectBase(uint8 effIndex, uint16 effName)
std::string ToString() const
std::string ToString() const
bool CheckEffect(SpellInfo const *spellInfo, uint8 effIndex) const override
TargetHook(uint8 effectIndex, uint16 targetType, bool area, bool dest)
TargetHook & operator=(TargetHook const &right)=delete
bool IsHitCrit() const
HookList< DamageAndHealingCalcHandler > CalcDamage
Definition: SpellScript.h:878
WorldLocation * GetHitDest() const
Creature * GetHitCreature() const
Player * GetHitPlayer() const
void SetEffectValue(int32 value)
int32 GetHitDamage() const
int64 GetCorpseTargetCountForEffect(SpellEffIndex effect) const
Unit * GetCaster() const
bool IsInEffectHook() const
void SetEffectVariance(float variance)
bool _Load(Spell *spell)
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
Definition: SpellScript.h:873
void CreateItem(uint32 itemId, ItemContext context)
uint32 m_hitPreventDefaultEffectMask
Definition: SpellScript.h:809
bool IsInTargetHook() const
uint32 m_hitPreventEffectMask
Definition: SpellScript.h:808
bool IsAfterTargetSelectionPhase() const
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
void PreventHitDefaultEffect(SpellEffIndex effIndex)
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const
SpellInfo const * GetTriggeringSpell() const
Unit * GetHitUnit() const
SpellValue const * GetSpellValue() const
bool IsInHitPhase() const
int32 GetEffectValue() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
Corpse * GetHitCorpse() const
void PreventHitEffect(SpellEffIndex effIndex)
Item * GetCastItem() const
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
Definition: SpellScript.h:868
bool _Validate(SpellInfo const *entry) override
void SetExplTargetDest(WorldLocation const &loc)
Aura * GetHitAura(bool dynObjAura=false) const
Spell * m_spell
Definition: SpellScript.h:807
void SetCustomCastResultMessage(SpellCustomErrors result)
void FinishCast(SpellCastResult result, int32 *param1=nullptr, int32 *param2=nullptr)
WorldObject * GetExplTargetWorldObject() const
HookList< EffectHandler > OnEffectLaunchTarget
Definition: SpellScript.h:838
Item * GetHitItem() const
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const
Difficulty GetCastDifficulty() const
int32 GetHitHeal() const
void SetHitDamage(int32 damage)
HookList< EffectHandler > OnEffectSuccessfulDispel
Definition: SpellScript.h:841
WorldLocation const * GetExplTargetDest() const
bool IsInCheckCastHook() const
HookList< EffectHandler > OnEffectLaunch
Definition: SpellScript.h:837
void SetHitHeal(int32 heal)
HookList< DamageAndHealingCalcHandler > CalcHealing
Definition: SpellScript.h:883
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
float GetEffectVariance() const
void _InitHit()
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
Unit * GetOriginalCaster() const
GameObject * GetHitGObj() const
void _FinishScriptCall()
Definition: Spell.h:254
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:649
GameObject * gameObjTarget
Definition: Spell.h:730
DynObjAura * _dynObjAura
Definition: Spell.h:741
int64 GetCorpseTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2690
SpellCastTargets m_targets
Definition: Spell.h:606
Difficulty GetCastDifficulty() const
Definition: Spell.cpp:8031
int32 damage
Definition: Spell.h:733
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:804
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2682
Item * itemTarget
Definition: Spell.h:729
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, SpellCastVisual spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, int32 *param1=nullptr, int32 *param2=nullptr)
Definition: Spell.cpp:4636
float variance
Definition: Spell.h:735
int32 m_damage
Definition: Spell.h:747
void DoCreateItem(uint32 itemId, ItemContext context=ItemContext::NONE, std::vector< int32 > const *bonusListIDs=nullptr)
int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2674
SpellCustomErrors m_customError
Definition: Spell.h:607
int32 m_healing
Definition: Spell.h:748
SpellEffectInfo const * effectInfo
Definition: Spell.h:737
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:920
UnitAura * _spellAura
Definition: Spell.h:740
Unit * unitTarget
Definition: Spell.h:728
WorldObject * GetCaster() const
Definition: Spell.h:646
Unit * GetOriginalCaster() const
Definition: Spell.h:648
Corpse * m_corpseTarget
Definition: Spell.h:731
WorldLocation * destTarget
Definition: Spell.h:732
Item * m_CastItem
Definition: Spell.h:563
SpellValue *const m_spellValue
Definition: Spell.h:688
void finish(SpellCastResult result=SPELL_CAST_OK)
Definition: Spell.cpp:4304
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2666
Definition: Unit.h:622
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
Definition: StringFormat.h:37