AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
spell_dk_corpse_explosion Class Reference
Inheritance diagram for spell_dk_corpse_explosion:
SpellScript _SpellScript

Private Member Functions

 PrepareSpellScript (spell_dk_corpse_explosion)
 
bool Validate (SpellInfo const *) override
 
bool Load () override
 
void CheckTarget (WorldObject *&target)
 
void CheckTargets (std::list< WorldObject * > &targets)
 
void HandleDamage (SpellEffIndex effIndex, Unit *target)
 
void HandleCorpseExplosion (SpellEffIndex effIndex)
 
void Register () override
 

Private Attributes

WorldObject_target
 

Additional Inherited Members

- Public Member Functions inherited from SpellScript
bool _Validate (SpellInfo const *entry) override
 
bool _Load (Spell *spell)
 
void _InitHit ()
 
bool _IsEffectPrevented (SpellEffIndex effIndex)
 
bool _IsDefaultEffectPrevented (SpellEffIndex effIndex)
 
void _PrepareScriptCall (SpellScriptHookType hookType)
 
void _FinishScriptCall ()
 
bool IsInCheckCastHook () const
 
bool IsInTargetHook () const
 
bool IsInHitPhase () const
 
bool IsInEffectHook () const
 
UnitGetCaster ()
 
UnitGetOriginalCaster ()
 
SpellInfo const * GetSpellInfo ()
 
SpellValue const * GetSpellValue ()
 
WorldLocation const * GetExplTargetDest ()
 
void SetExplTargetDest (WorldLocation &loc)
 
WorldObjectGetExplTargetWorldObject ()
 
UnitGetExplTargetUnit ()
 
GameObjectGetExplTargetGObj ()
 
ItemGetExplTargetItem ()
 
UnitGetHitUnit ()
 
CreatureGetHitCreature ()
 
PlayerGetHitPlayer ()
 
ItemGetHitItem ()
 
GameObjectGetHitGObj ()
 
WorldLocationGetHitDest ()
 
int32 GetHitDamage ()
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal ()
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
SpellGetSpell ()
 
AuraGetHitAura ()
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
ItemGetCastItem ()
 
void CreateItem (uint32 effIndex, uint32 itemId)
 
SpellInfo const * GetTriggeringSpell ()
 
void FinishCast (SpellCastResult result)
 
void Cancel ()
 
void SetCustomCastResultMessage (SpellCustomErrors result)
 
- Public Member Functions inherited from _SpellScript
 _SpellScript ()
 
virtual ~_SpellScript ()
 
virtual void _Register ()
 
virtual void _Unload ()
 
virtual void _Init (std::string const *scriptname, uint32 spellId)
 
std::string const * _GetScriptName () const
 
virtual void Register ()=0
 
virtual bool Validate (SpellInfo const *)
 
virtual bool Load ()
 
virtual void Unload ()
 
- Static Public Member Functions inherited from _SpellScript
static bool ValidateSpellInfo (std::initializer_list< uint32 > spellIds)
 
template<class T >
static bool ValidateSpellInfo (T const &spellIds)
 
- Public Attributes inherited from SpellScript
HookList< CastHandlerBeforeCast
 
HookList< CastHandlerOnCast
 
HookList< CastHandlerAfterCast
 
HookList< CheckCastHandlerOnCheckCast
 
HookList< EffectHandlerOnEffectLaunch
 
HookList< EffectHandlerOnEffectLaunchTarget
 
HookList< EffectHandlerOnEffectHit
 
HookList< EffectHandlerOnEffectHitTarget
 
HookList< BeforeHitHandlerBeforeHit
 
HookList< HitHandlerOnHit
 
HookList< HitHandlerAfterHit
 
HookList< ObjectAreaTargetSelectHandlerOnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandlerOnObjectTargetSelect
 
HookList< DestinationTargetSelectHandlerOnDestinationTargetSelect
 
virtual bool _Validate (SpellInfo const *entry)
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ CheckTarget()

void spell_dk_corpse_explosion::CheckTarget ( WorldObject *&  target)
inlineprivate
1111 {
1112 if (CorpseExplosionCheck(GetCaster()->GetGUID(), true)(target))
1113 target = nullptr;
1114
1115 _target = target;
1116 }
Unit * GetCaster()
Definition: SpellScript.cpp:401
Definition: spell_dk.cpp:1067
WorldObject * _target
Definition: spell_dk.cpp:1179

References _target, and SpellScript::GetCaster().

Referenced by Register().

◆ CheckTargets()

void spell_dk_corpse_explosion::CheckTargets ( std::list< WorldObject * > &  targets)
inlineprivate
1119 {
1120 WorldObject* target = _target;
1121 if (!target)
1122 {
1123 targets.remove_if(CorpseExplosionCheck(GetCaster()->GetGUID(), false));
1124 if (targets.empty())
1125 {
1127 return;
1128 }
1130 targets.clear();
1131 targets.push_back(target);
1132 }
1133 else
1134 targets.clear();
1135 }
@ SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW
Definition: SharedDefines.h:1094
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:135
Definition: Object.h:393
void FinishCast(SpellCastResult result)
Definition: SpellScript.cpp:635

References _target, SpellScript::FinishCast(), SpellScript::GetCaster(), Acore::Containers::SelectRandomContainerElement(), and SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW.

Referenced by Register().

◆ HandleCorpseExplosion()

void spell_dk_corpse_explosion::HandleCorpseExplosion ( SpellEffIndex  effIndex)
inlineprivate
1146 {
1147 if (Unit* unitTarget = GetHitUnit())
1148 {
1149 if (unitTarget->IsAlive()) // Living ghoul as a target
1150 {
1151 unitTarget->ToCreature()->m_CreatureSpellCooldowns.clear();
1152 if (CharmInfo* charmInfo = unitTarget->GetCharmInfo())
1153 charmInfo->GetGlobalCooldownMgr().CancelGlobalCooldown(sSpellMgr->GetSpellInfo(SPELL_DK_GHOUL_EXPLODE));
1154
1155 unitTarget->StopMoving();
1156 unitTarget->CastSpell(unitTarget, SPELL_DK_GHOUL_EXPLODE, false);
1157 // Corpse Explosion (Suicide) and Set corpse look handled in SpellScript of SPELL_DK_GHOUL_EXPLODE
1158 }
1159 else // Some corpse
1160 {
1161 HandleDamage(effIndex, unitTarget);
1162 // Corpse Explosion (Suicide)
1163 unitTarget->CastSpell(unitTarget, SPELL_DK_CORPSE_EXPLOSION_TRIGGERED, true);
1164 // Set corpse look
1166 }
1167 }
1168 }
#define sSpellMgr
Definition: SpellMgr.h:818
@ SPELL_DK_GHOUL_EXPLODE
Definition: spell_dk.cpp:56
@ SPELL_DK_CORPSE_EXPLOSION_VISUAL
Definition: spell_dk.cpp:49
@ SPELL_DK_CORPSE_EXPLOSION_TRIGGERED
Definition: spell_dk.cpp:48
Definition: Unit.h:1094
Definition: Unit.h:1290
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169
Unit * GetHitUnit()
Definition: SpellScript.cpp:448
void HandleDamage(SpellEffIndex effIndex, Unit *target)
Definition: spell_dk.cpp:1137

References Unit::CastSpell(), SpellScript::GetCaster(), SpellScript::GetHitUnit(), HandleDamage(), SPELL_DK_CORPSE_EXPLOSION_TRIGGERED, SPELL_DK_CORPSE_EXPLOSION_VISUAL, SPELL_DK_GHOUL_EXPLODE, and sSpellMgr.

Referenced by Register().

◆ HandleDamage()

void spell_dk_corpse_explosion::HandleDamage ( SpellEffIndex  effIndex,
Unit target 
)
inlineprivate
1138 {
1139 if (effIndex == EFFECT_0)
1140 GetCaster()->CastCustomSpell(GetSpellInfo()->Effects[EFFECT_1].CalcValue(), SPELLVALUE_BASE_POINT0, GetEffectValue(), target, true);
1141 else if (effIndex == EFFECT_1)
1142 GetCaster()->CastCustomSpell(GetEffectValue(), SPELLVALUE_BASE_POINT0, GetSpell()->CalculateSpellDamage(EFFECT_0, nullptr), target, true);
1143 }
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:114
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
SpellCastResult CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1226
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
int32 GetEffectValue() const
Definition: SpellScript.cpp:600
Spell * GetSpell()
Definition: SpellScript.h:442

References Unit::CastCustomSpell(), EFFECT_0, EFFECT_1, SpellScript::GetCaster(), SpellScript::GetEffectValue(), SpellScript::GetSpell(), SpellScript::GetSpellInfo(), and SPELLVALUE_BASE_POINT0.

Referenced by HandleCorpseExplosion().

◆ Load()

bool spell_dk_corpse_explosion::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

1105 {
1106 _target = nullptr;
1107 return true;
1108 }

References _target.

◆ PrepareSpellScript()

spell_dk_corpse_explosion::PrepareSpellScript ( spell_dk_corpse_explosion  )
private

◆ Register()

void spell_dk_corpse_explosion::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1171 {
1176 }
#define SpellObjectTargetSelectFn(F, I, N)
Definition: SpellScript.h:359
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:354
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:753
@ TARGET_UNIT_TARGET_ANY
Definition: SharedDefines.h:1401
@ TARGET_UNIT_DEST_AREA_ENTRY
Definition: SharedDefines.h:1389
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
Definition: SpellScript.h:358
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:353
void HandleCorpseExplosion(SpellEffIndex effIndex)
Definition: spell_dk.cpp:1145
void CheckTargets(std::list< WorldObject * > &targets)
Definition: spell_dk.cpp:1118
void CheckTarget(WorldObject *&target)
Definition: spell_dk.cpp:1110

References CheckTarget(), CheckTargets(), EFFECT_0, EFFECT_1, HandleCorpseExplosion(), SpellScript::OnEffectHitTarget, SpellScript::OnObjectAreaTargetSelect, SpellScript::OnObjectTargetSelect, SPELL_EFFECT_DUMMY, SpellEffectFn, SpellObjectAreaTargetSelectFn, SpellObjectTargetSelectFn, TARGET_UNIT_DEST_AREA_ENTRY, and TARGET_UNIT_TARGET_ANY.

◆ Validate()

bool spell_dk_corpse_explosion::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

1095 {
1096 return ValidateSpellInfo(
1097 {
1101 });
1102 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:125

References SPELL_DK_CORPSE_EXPLOSION_TRIGGERED, SPELL_DK_CORPSE_EXPLOSION_VISUAL, SPELL_DK_GHOUL_EXPLODE, and _SpellScript::ValidateSpellInfo().

Member Data Documentation

◆ _target

WorldObject* spell_dk_corpse_explosion::_target
private

Referenced by CheckTarget(), CheckTargets(), and Load().