TrinityCore
SpellScript Class Reference

#include <SpellScript.h>

Classes

class  BeforeHitHandler
 
class  CastHandler
 
class  CheckCastHandler
 
class  DamageAndHealingCalcHandler
 
class  DestinationTargetSelectHandler
 
class  EffectBase
 
class  EffectHandler
 
class  HitHandler
 
class  ObjectAreaTargetSelectHandler
 
class  ObjectTargetSelectHandler
 
class  OnCalcCritChanceHandler
 
class  OnCalculateResistAbsorbHandler
 
class  TargetHook
 

Public Member Functions

 SpellScript ()
 
 ~SpellScript ()
 
bool _Validate (SpellInfo const *entry) override
 
bool _Load (Spell *spell)
 
void _InitHit ()
 
bool _IsEffectPrevented (SpellEffIndex effIndex) const
 
bool _IsDefaultEffectPrevented (SpellEffIndex effIndex) const
 
void _PrepareScriptCall (SpellScriptHookType hookType)
 
void _FinishScriptCall ()
 
bool IsInCheckCastHook () const
 
bool IsAfterTargetSelectionPhase () const
 
bool IsInTargetHook () const
 
bool IsInModifiableHook () const
 
bool IsInHitPhase () const
 
bool IsInEffectHook () const
 
virtual void OnPrecast ()
 
virtual int32 CalcCastTime (int32 castTime)
 
UnitGetCaster () const
 
GameObjectGetGObjCaster () const
 
UnitGetOriginalCaster () const
 
SpellInfo const * GetSpellInfo () const
 
SpellEffectInfo const & GetEffectInfo (SpellEffIndex effIndex) const
 
SpellValue const * GetSpellValue () const
 
WorldLocation const * GetExplTargetDest () const
 
void SetExplTargetDest (WorldLocation const &loc)
 
WorldObjectGetExplTargetWorldObject () const
 
UnitGetExplTargetUnit () const
 
GameObjectGetExplTargetGObj () const
 
ItemGetExplTargetItem () const
 
int64 GetUnitTargetCountForEffect (SpellEffIndex effect) const
 
int64 GetGameObjectTargetCountForEffect (SpellEffIndex effect) const
 
int64 GetItemTargetCountForEffect (SpellEffIndex effect) const
 
int64 GetCorpseTargetCountForEffect (SpellEffIndex effect) const
 
UnitGetHitUnit () const
 
CreatureGetHitCreature () const
 
PlayerGetHitPlayer () const
 
ItemGetHitItem () const
 
GameObjectGetHitGObj () const
 
CorpseGetHitCorpse () const
 
WorldLocationGetHitDest () const
 
int32 GetHitDamage () const
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal () const
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
bool IsHitCrit () const
 
SpellGetSpell () const
 
AuraGetHitAura (bool dynObjAura=false) const
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
SpellEffectInfo const & GetEffectInfo () const
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
float GetEffectVariance () const
 
void SetEffectVariance (float variance)
 
ItemGetCastItem () const
 
void CreateItem (uint32 itemId, ItemContext context)
 
SpellInfo const * GetTriggeringSpell () const
 
void FinishCast (SpellCastResult result, int32 *param1=nullptr, int32 *param2=nullptr)
 
void SetCustomCastResultMessage (SpellCustomErrors result)
 
Difficulty GetCastDifficulty () const
 
- Public Member Functions inherited from SpellScriptBase
 SpellScriptBase ()
 
virtual ~SpellScriptBase ()
 
 SpellScriptBase (SpellScriptBase const &right)=delete
 
 SpellScriptBase (SpellScriptBase &&right)=delete
 
SpellScriptBaseoperator= (SpellScriptBase const &right)=delete
 
SpellScriptBaseoperator= (SpellScriptBase &&right)=delete
 
void _Register ()
 
void _Unload ()
 
void _Init (std::string const &scriptname, uint32 spellId)
 
std::string_view GetScriptName () const
 
virtual void Register ()=0
 
virtual bool Validate (SpellInfo const *spellInfo)
 
virtual bool Load ()
 
virtual void Unload ()
 

Public Attributes

HookList< CastHandlerBeforeCast
 
HookList< CastHandlerOnCast
 
HookList< CastHandlerAfterCast
 
HookList< CheckCastHandlerOnCheckCast
 
HookList< EffectHandlerOnEffectLaunch
 
HookList< EffectHandlerOnEffectLaunchTarget
 
HookList< EffectHandlerOnEffectHit
 
HookList< EffectHandlerOnEffectHitTarget
 
HookList< EffectHandlerOnEffectSuccessfulDispel
 
HookList< BeforeHitHandlerBeforeHit
 
HookList< HitHandlerOnHit
 
HookList< HitHandlerAfterHit
 
HookList< OnCalcCritChanceHandlerOnCalcCritChance
 
HookList< ObjectAreaTargetSelectHandlerOnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandlerOnObjectTargetSelect
 
HookList< DestinationTargetSelectHandlerOnDestinationTargetSelect
 
HookList< DamageAndHealingCalcHandlerCalcDamage
 
HookList< DamageAndHealingCalcHandlerCalcHealing
 
HookList< OnCalculateResistAbsorbHandlerOnCalculateResistAbsorb
 

Private Attributes

Spellm_spell
 
uint32 m_hitPreventEffectMask
 
uint32 m_hitPreventDefaultEffectMask
 

Additional Inherited Members

- Static Public Member Functions inherited from SpellScriptBase
static bool ValidateSpellInfo (std::initializer_list< uint32 > spellIds)
 
template<class T >
static bool ValidateSpellInfo (T const &spellIds)
 
static bool ValidateSpellEffect (std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
 
template<class T >
static bool ValidateSpellEffect (T const &spellEffects)
 
- Protected Types inherited from SpellScriptBase
template<typename ScriptFunc >
using GetScriptClass_t = typename GetScriptClass< ScriptFunc >::type
 
virtual bool _Validate (SpellInfo const *entry)
 
- Protected Attributes inherited from SpellScriptBase
uint8 m_currentScriptState
 
std::string_view m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Definition at line 246 of file SpellScript.h.

Constructor & Destructor Documentation

◆ SpellScript()

SpellScript::SpellScript ( )

Definition at line 251 of file SpellScript.cpp.

252{
253}
uint32 m_hitPreventDefaultEffectMask
Definition: SpellScript.h:809
uint32 m_hitPreventEffectMask
Definition: SpellScript.h:808
Spell * m_spell
Definition: SpellScript.h:807

◆ ~SpellScript()

SpellScript::~SpellScript ( )
default

Member Function Documentation

◆ _FinishScriptCall()

void SpellScript::_FinishScriptCall ( )

Definition at line 335 of file SpellScript.cpp.

336{
338}
@ SPELL_SCRIPT_STATE_NONE
Definition: SpellScript.h:63
uint8 m_currentScriptState
Definition: SpellScript.h:132
+ Here is the caller graph for this function:

◆ _InitHit()

void SpellScript::_InitHit ( )

Definition at line 324 of file SpellScript.cpp.

◆ _IsDefaultEffectPrevented()

bool SpellScript::_IsDefaultEffectPrevented ( SpellEffIndex  effIndex) const
inline

Definition at line 797 of file SpellScript.h.

797{ return (m_hitPreventDefaultEffectMask & (1 << effIndex)) != 0; }

◆ _IsEffectPrevented()

bool SpellScript::_IsEffectPrevented ( SpellEffIndex  effIndex) const
inline

Definition at line 796 of file SpellScript.h.

796{ return (m_hitPreventEffectMask & (1 << effIndex)) != 0; }

◆ _Load()

bool SpellScript::_Load ( Spell spell)

Definition at line 315 of file SpellScript.cpp.

316{
317 m_spell = spell;
319 bool load = Load();
321 return load;
322}
@ SPELL_SCRIPT_STATE_LOADING
Definition: SpellScript.h:65
SpellScriptHookType
Definition: SpellScript.h:219
virtual bool Load()
Definition: SpellScript.h:157
void _PrepareScriptCall(SpellScriptHookType hookType)
void _FinishScriptCall()
+ Here is the call graph for this function:

◆ _PrepareScriptCall()

void SpellScript::_PrepareScriptCall ( SpellScriptHookType  hookType)

Definition at line 330 of file SpellScript.cpp.

331{
332 m_currentScriptState = hookType;
333}
+ Here is the caller graph for this function:

◆ _Validate()

bool SpellScript::_Validate ( SpellInfo const *  entry)
overridevirtual

Reimplemented from SpellScriptBase.

Definition at line 257 of file SpellScript.cpp.

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
263 for (EffectHandler& hook : OnEffectLaunchTarget)
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
275 for (EffectHandler& hook : OnEffectSuccessfulDispel)
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
279 for (ObjectAreaTargetSelectHandler& hook : OnObjectAreaTargetSelect)
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
283 for (ObjectTargetSelectHandler& hook : OnObjectTargetSelect)
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
287 for (DestinationTargetSelectHandler& hook : OnDestinationTargetSelect)
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 {
293 if (!entry->HasEffect(SPELL_EFFECT_SCHOOL_DAMAGE)
294 && !entry->HasEffect(SPELL_EFFECT_POWER_DRAIN)
295 && !entry->HasEffect(SPELL_EFFECT_HEALTH_LEECH)
296 && !entry->HasEffect(SPELL_EFFECT_WEAPON_DAMAGE)
297 && !entry->HasEffect(SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL)
298 && !entry->HasEffect(SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
299 && !entry->HasEffect(SPELL_EFFECT_WEAPON_PERCENT_DAMAGE))
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)
306 && !entry->HasEffect(SPELL_EFFECT_HEAL_PCT)
307 && !entry->HasEffect(SPELL_EFFECT_HEAL_MECHANICAL)
308 && !entry->HasEffect(SPELL_EFFECT_HEALTH_LEECH))
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}
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
@ 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_POWER_DRAIN
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ SPELL_EFFECT_HEAL_PCT
std::string_view m_scriptName
Definition: SpellScript.h:133
virtual bool _Validate(SpellInfo const *entry)
Definition: SpellScript.cpp:28
HookList< DamageAndHealingCalcHandler > CalcDamage
Definition: SpellScript.h:878
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
Definition: SpellScript.h:873
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
Definition: SpellScript.h:868
HookList< EffectHandler > OnEffectLaunchTarget
Definition: SpellScript.h:838
HookList< EffectHandler > OnEffectSuccessfulDispel
Definition: SpellScript.h:841
HookList< EffectHandler > OnEffectLaunch
Definition: SpellScript.h:837
HookList< DamageAndHealingCalcHandler > CalcHealing
Definition: SpellScript.h:883
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
+ Here is the call graph for this function:

◆ CalcCastTime()

virtual int32 SpellScript::CalcCastTime ( int32  castTime)
inlinevirtual

Definition at line 833 of file SpellScript.h.

833{ return castTime; }

◆ CreateItem()

void SpellScript::CreateItem ( uint32  itemId,
ItemContext  context 
)

Definition at line 744 of file SpellScript.cpp.

745{
746 m_spell->DoCreateItem(itemId, context);
747}
void DoCreateItem(uint32 itemId, ItemContext context=ItemContext::NONE, std::vector< int32 > const *bonusListIDs=nullptr)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FinishCast()

void SpellScript::FinishCast ( SpellCastResult  result,
int32 param1 = nullptr,
int32 param2 = nullptr 
)

Definition at line 754 of file SpellScript.cpp.

755{
756 m_spell->SendCastResult(result, param1, param2);
757 m_spell->finish(result);
758}
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
void finish(SpellCastResult result=SPELL_CAST_OK)
Definition: Spell.cpp:4304
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCastDifficulty()

Difficulty SpellScript::GetCastDifficulty ( ) const

Definition at line 771 of file SpellScript.cpp.

772{
773 return m_spell->GetCastDifficulty();
774}
Difficulty GetCastDifficulty() const
Definition: Spell.cpp:8031
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCaster()

Unit * SpellScript::GetCaster ( ) const

Definition at line 397 of file SpellScript.cpp.

398{
399 return m_spell->GetCaster()->ToUnit();
400}
static Unit * ToUnit(Object *o)
Definition: Object.h:212
WorldObject * GetCaster() const
Definition: Spell.h:646
+ Here is the call graph for this function:

◆ GetCastItem()

Item * SpellScript::GetCastItem ( ) const

Definition at line 739 of file SpellScript.cpp.

740{
741 return m_spell->m_CastItem;
742}
Item * m_CastItem
Definition: Spell.h:563
+ Here is the caller graph for this function:

◆ GetCorpseTargetCountForEffect()

int64 SpellScript::GetCorpseTargetCountForEffect ( SpellEffIndex  effect) const

Definition at line 492 of file SpellScript.cpp.

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}
uint32 m_scriptSpellId
Definition: SpellScript.h:134
bool IsAfterTargetSelectionPhase() const
int64 GetCorpseTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2690
+ Here is the call graph for this function:

◆ GetEffectInfo() [1/2]

SpellEffectInfo const & SpellScript::GetEffectInfo ( ) const

Definition at line 688 of file SpellScript.cpp.

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}
#define STRING_VIEW_FMT_ARG(str)
Definition: Define.h:136
#define STRING_VIEW_FMT
Definition: Define.h:135
#define ASSERT
Definition: Errors.h:68
bool IsInEffectHook() const
SpellEffectInfo const * effectInfo
Definition: Spell.h:737
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetEffectInfo() [2/2]

SpellEffectInfo const & SpellScript::GetEffectInfo ( SpellEffIndex  effIndex) const

Definition at line 417 of file SpellScript.cpp.

418{
419 return GetSpellInfo()->GetEffect(effIndex);
420}
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
SpellInfo const * GetSpellInfo() const
+ Here is the call graph for this function:

◆ GetEffectValue()

int32 SpellScript::GetEffectValue ( ) const

Definition at line 695 of file SpellScript.cpp.

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}
int32 damage
Definition: Spell.h:733
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetEffectVariance()

float SpellScript::GetEffectVariance ( ) const

Definition at line 717 of file SpellScript.cpp.

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}
float variance
Definition: Spell.h:735
+ Here is the call graph for this function:

◆ GetExplTargetDest()

WorldLocation const * SpellScript::GetExplTargetDest ( ) const

Definition at line 427 of file SpellScript.cpp.

428{
429 if (m_spell->m_targets.HasDst())
430 return m_spell->m_targets.GetDstPos();
431 return nullptr;
432}
bool HasDst() const
Definition: Spell.cpp:424
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:367
SpellCastTargets m_targets
Definition: Spell.h:606
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetExplTargetGObj()

GameObject * SpellScript::GetExplTargetGObj ( ) const

Definition at line 449 of file SpellScript.cpp.

450{
451 return m_spell->m_targets.GetGOTarget();
452}
GameObject * GetGOTarget() const
Definition: Spell.cpp:243
+ Here is the call graph for this function:

◆ GetExplTargetItem()

Item * SpellScript::GetExplTargetItem ( ) const

Definition at line 454 of file SpellScript.cpp.

455{
457}
Item * GetItemTarget() const
Definition: SpellDefines.h:360
+ Here is the call graph for this function:

◆ GetExplTargetUnit()

Unit * SpellScript::GetExplTargetUnit ( ) const

Definition at line 444 of file SpellScript.cpp.

445{
447}
Unit * GetUnitTarget() const
Definition: Spell.cpp:217
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetExplTargetWorldObject()

WorldObject * SpellScript::GetExplTargetWorldObject ( ) const

Definition at line 439 of file SpellScript.cpp.

440{
442}
WorldObject * GetObjectTarget() const
Definition: Spell.cpp:277
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGameObjectTargetCountForEffect()

int64 SpellScript::GetGameObjectTargetCountForEffect ( SpellEffIndex  effect) const

Definition at line 470 of file SpellScript.cpp.

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}
int64 GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2674
+ Here is the call graph for this function:

◆ GetGObjCaster()

GameObject * SpellScript::GetGObjCaster ( ) const

Definition at line 402 of file SpellScript.cpp.

403{
404 return m_spell->GetCaster()->ToGameObject();
405}
static GameObject * ToGameObject(Object *o)
Definition: Object.h:218
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitAura()

Aura * SpellScript::GetHitAura ( bool  dynObjAura = false) const

Definition at line 636 of file SpellScript.cpp.

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}
bool IsRemoved() const
Definition: SpellAuras.h:204
bool IsInTargetHook() const
DynObjAura * _dynObjAura
Definition: Spell.h:741
UnitAura * _spellAura
Definition: Spell.h:740
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitCorpse()

Corpse * SpellScript::GetHitCorpse ( ) const

Definition at line 557 of file SpellScript.cpp.

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}
Corpse * m_corpseTarget
Definition: Spell.h:731
+ Here is the call graph for this function:

◆ GetHitCreature()

Creature * SpellScript::GetHitCreature ( ) const

Definition at line 513 of file SpellScript.cpp.

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}
static Creature * ToCreature(Object *o)
Definition: Object.h:206
Unit * unitTarget
Definition: Spell.h:728
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitDamage()

int32 SpellScript::GetHitDamage ( ) const

Definition at line 577 of file SpellScript.cpp.

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}
int32 m_damage
Definition: Spell.h:747
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitDest()

WorldLocation * SpellScript::GetHitDest ( ) const

Definition at line 567 of file SpellScript.cpp.

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}
WorldLocation * destTarget
Definition: Spell.h:732
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitGObj()

GameObject * SpellScript::GetHitGObj ( ) const

Definition at line 547 of file SpellScript.cpp.

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}
GameObject * gameObjTarget
Definition: Spell.h:730
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitHeal()

int32 SpellScript::GetHitHeal ( ) const

Definition at line 597 of file SpellScript.cpp.

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}
int32 m_healing
Definition: Spell.h:748
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitItem()

Item * SpellScript::GetHitItem ( ) const

Definition at line 537 of file SpellScript.cpp.

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}
Item * itemTarget
Definition: Spell.h:729
+ Here is the call graph for this function:

◆ GetHitPlayer()

Player * SpellScript::GetHitPlayer ( ) const

Definition at line 525 of file SpellScript.cpp.

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}
static Player * ToPlayer(Object *o)
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitUnit()

Unit * SpellScript::GetHitUnit ( ) const

Definition at line 503 of file SpellScript.cpp.

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}
+ Here is the call graph for this function:

◆ GetItemTargetCountForEffect()

int64 SpellScript::GetItemTargetCountForEffect ( SpellEffIndex  effect) const

Definition at line 481 of file SpellScript.cpp.

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}
int64 GetItemTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2682
+ Here is the call graph for this function:

◆ GetOriginalCaster()

Unit * SpellScript::GetOriginalCaster ( ) const

Definition at line 407 of file SpellScript.cpp.

408{
409 return m_spell->GetOriginalCaster();
410}
Unit * GetOriginalCaster() const
Definition: Spell.h:648
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSpell()

Spell * SpellScript::GetSpell ( ) const
inline

Definition at line 987 of file SpellScript.h.

987{ return m_spell; }
+ Here is the caller graph for this function:

◆ GetSpellInfo()

SpellInfo const * SpellScript::GetSpellInfo ( ) const

Definition at line 412 of file SpellScript.cpp.

413{
414 return m_spell->GetSpellInfo();
415}
SpellInfo const * GetSpellInfo() const
Definition: Spell.h:649
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSpellValue()

SpellValue const * SpellScript::GetSpellValue ( ) const

Definition at line 422 of file SpellScript.cpp.

423{
424 return m_spell->m_spellValue;
425}
SpellValue *const m_spellValue
Definition: Spell.h:688
+ Here is the caller graph for this function:

◆ GetTriggeringSpell()

SpellInfo const * SpellScript::GetTriggeringSpell ( ) const

Definition at line 749 of file SpellScript.cpp.

750{
752}
SpellInfo const * m_triggeredByAuraSpell
Definition: Spell.h:920
+ Here is the caller graph for this function:

◆ GetUnitTargetCountForEffect()

int64 SpellScript::GetUnitTargetCountForEffect ( SpellEffIndex  effect) const

Definition at line 459 of file SpellScript.cpp.

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}
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const
Definition: Spell.cpp:2666
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsAfterTargetSelectionPhase()

bool SpellScript::IsAfterTargetSelectionPhase ( ) const

Definition at line 345 of file SpellScript.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsHitCrit()

bool SpellScript::IsHitCrit ( ) const

Definition at line 617 of file SpellScript.cpp.

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}
Unit * GetHitUnit() const
std::vector< TargetInfo > m_UniqueTargetInfo
Definition: Spell.h:804
Definition: Unit.h:622
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInCheckCastHook()

bool SpellScript::IsInCheckCastHook ( ) const

Definition at line 340 of file SpellScript.cpp.

341{
343}
@ SPELL_SCRIPT_HOOK_CHECK_CAST
Definition: SpellScript.h:231
+ Here is the caller graph for this function:

◆ IsInEffectHook()

bool SpellScript::IsInEffectHook ( ) const

Definition at line 391 of file SpellScript.cpp.

+ Here is the caller graph for this function:

◆ IsInHitPhase()

bool SpellScript::IsInHitPhase ( ) const

Definition at line 386 of file SpellScript.cpp.

387{
389}
#define HOOK_SPELL_HIT_START
Definition: SpellScript.h:243
#define HOOK_SPELL_HIT_END
Definition: SpellScript.h:244
+ Here is the caller graph for this function:

◆ IsInModifiableHook()

bool SpellScript::IsInModifiableHook ( ) const

Definition at line 371 of file SpellScript.cpp.

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}
@ SPELL_SCRIPT_HOOK_BEFORE_HIT
Definition: SpellScript.h:225
@ SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET
Definition: SpellScript.h:221
@ SPELL_SCRIPT_HOOK_HIT
Definition: SpellScript.h:226
+ Here is the caller graph for this function:

◆ IsInTargetHook()

bool SpellScript::IsInTargetHook ( ) const

Definition at line 356 of file SpellScript.cpp.

357{
358 switch (m_currentScriptState)
359 {
366 return true;
367 }
368 return false;
369}
@ SPELL_SCRIPT_HOOK_AFTER_HIT
Definition: SpellScript.h:227
+ Here is the caller graph for this function:

◆ OnPrecast()

virtual void SpellScript::OnPrecast ( )
inlinevirtual

◆ PreventHitAura()

void SpellScript::PreventHitAura ( )

Definition at line 654 of file SpellScript.cpp.

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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PreventHitDamage()

void SpellScript::PreventHitDamage ( )
inline

Definition at line 979 of file SpellScript.h.

979{ SetHitDamage(0); }
void SetHitDamage(int32 damage)
+ Here is the caller graph for this function:

◆ PreventHitDefaultEffect()

void SpellScript::PreventHitDefaultEffect ( SpellEffIndex  effIndex)

Definition at line 678 of file SpellScript.cpp.

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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PreventHitEffect()

void SpellScript::PreventHitEffect ( SpellEffIndex  effIndex)

Definition at line 667 of file SpellScript.cpp.

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}
void PreventHitDefaultEffect(SpellEffIndex effIndex)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PreventHitHeal()

void SpellScript::PreventHitHeal ( )
inline

Definition at line 984 of file SpellScript.h.

984{ SetHitHeal(0); }
void SetHitHeal(int32 heal)

◆ SetCustomCastResultMessage()

void SpellScript::SetCustomCastResultMessage ( SpellCustomErrors  result)

Definition at line 760 of file SpellScript.cpp.

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}
bool IsInCheckCastHook() const
SpellCustomErrors m_customError
Definition: Spell.h:607
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetEffectValue()

void SpellScript::SetEffectValue ( int32  value)

Definition at line 706 of file SpellScript.cpp.

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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetEffectVariance()

void SpellScript::SetEffectVariance ( float  variance)

Definition at line 728 of file SpellScript.cpp.

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}
+ Here is the call graph for this function:

◆ SetExplTargetDest()

void SpellScript::SetExplTargetDest ( WorldLocation const &  loc)

Definition at line 434 of file SpellScript.cpp.

435{
437}
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:372
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetHitDamage()

void SpellScript::SetHitDamage ( int32  damage)

Definition at line 587 of file SpellScript.cpp.

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}
bool IsInModifiableHook() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetHitHeal()

void SpellScript::SetHitHeal ( int32  heal)

Definition at line 607 of file SpellScript.cpp.

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}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ AfterCast

HookList<CastHandler> SpellScript::AfterCast

Definition at line 824 of file SpellScript.h.

◆ AfterHit

HookList<HitHandler> SpellScript::AfterHit

Definition at line 852 of file SpellScript.h.

◆ BeforeCast

HookList<CastHandler> SpellScript::BeforeCast

Definition at line 820 of file SpellScript.h.

◆ BeforeHit

HookList<BeforeHitHandler> SpellScript::BeforeHit

Definition at line 846 of file SpellScript.h.

◆ CalcDamage

HookList<DamageAndHealingCalcHandler> SpellScript::CalcDamage

Definition at line 878 of file SpellScript.h.

◆ CalcHealing

HookList<DamageAndHealingCalcHandler> SpellScript::CalcHealing

Definition at line 883 of file SpellScript.h.

◆ m_hitPreventDefaultEffectMask

uint32 SpellScript::m_hitPreventDefaultEffectMask
private

Definition at line 809 of file SpellScript.h.

◆ m_hitPreventEffectMask

uint32 SpellScript::m_hitPreventEffectMask
private

Definition at line 808 of file SpellScript.h.

◆ m_spell

Spell* SpellScript::m_spell
private

Definition at line 807 of file SpellScript.h.

◆ OnCalcCritChance

HookList<OnCalcCritChanceHandler> SpellScript::OnCalcCritChance

Definition at line 858 of file SpellScript.h.

◆ OnCalculateResistAbsorb

HookList<OnCalculateResistAbsorbHandler> SpellScript::OnCalculateResistAbsorb

Definition at line 888 of file SpellScript.h.

◆ OnCast

HookList<CastHandler> SpellScript::OnCast

Definition at line 822 of file SpellScript.h.

◆ OnCheckCast

HookList<CheckCastHandler> SpellScript::OnCheckCast

Definition at line 829 of file SpellScript.h.

◆ OnDestinationTargetSelect

HookList<DestinationTargetSelectHandler> SpellScript::OnDestinationTargetSelect

Definition at line 873 of file SpellScript.h.

◆ OnEffectHit

HookList<EffectHandler> SpellScript::OnEffectHit

Definition at line 839 of file SpellScript.h.

◆ OnEffectHitTarget

HookList<EffectHandler> SpellScript::OnEffectHitTarget

Definition at line 840 of file SpellScript.h.

◆ OnEffectLaunch

HookList<EffectHandler> SpellScript::OnEffectLaunch

Definition at line 837 of file SpellScript.h.

◆ OnEffectLaunchTarget

HookList<EffectHandler> SpellScript::OnEffectLaunchTarget

Definition at line 838 of file SpellScript.h.

◆ OnEffectSuccessfulDispel

HookList<EffectHandler> SpellScript::OnEffectSuccessfulDispel

Definition at line 841 of file SpellScript.h.

◆ OnHit

HookList<HitHandler> SpellScript::OnHit

Definition at line 850 of file SpellScript.h.

◆ OnObjectAreaTargetSelect

HookList<ObjectAreaTargetSelectHandler> SpellScript::OnObjectAreaTargetSelect

Definition at line 863 of file SpellScript.h.

◆ OnObjectTargetSelect

HookList<ObjectTargetSelectHandler> SpellScript::OnObjectTargetSelect

Definition at line 868 of file SpellScript.h.


The documentation for this class was generated from the following files: