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

Private Member Functions

 PrepareSpellScript (spell_dk_raise_dead)
 
bool Validate (SpellInfo const *) override
 
bool Load () override
 
SpellCastResult CheckCast ()
 
SpellCastResult CheckReagents ()
 
void CheckTargets (std::list< WorldObject * > &targets)
 
void CheckTarget (WorldObject *&target)
 
void ConsumeReagents ()
 
uint32 GetGhoulSpellId ()
 
void HandleRaiseDead (SpellEffIndex)
 
void Register () override
 

Private Attributes

SpellCastResult _result
 
bool _corpse
 

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
 
Unit * GetCaster ()
 
GameObject * GetGObjCaster ()
 
Unit * GetOriginalCaster ()
 
SpellInfo const * GetSpellInfo ()
 
SpellValue const * GetSpellValue ()
 
WorldLocation const * GetExplTargetDest ()
 
void SetExplTargetDest (WorldLocation &loc)
 
WorldObject * GetExplTargetWorldObject ()
 
Unit * GetExplTargetUnit ()
 
GameObject * GetExplTargetGObj ()
 
Item * GetExplTargetItem ()
 
Unit * GetHitUnit ()
 
Creature * GetHitCreature ()
 
Player * GetHitPlayer ()
 
Item * GetHitItem ()
 
GameObject * GetHitGObj ()
 
WorldLocation * GetHitDest ()
 
int32 GetHitDamage ()
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal ()
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
Spell * GetSpell ()
 
Aura * GetHitAura ()
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
Item * GetCastItem ()
 
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 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< CastHandler > BeforeCast
 
HookList< CastHandler > OnCast
 
HookList< CastHandler > AfterCast
 
HookList< CheckCastHandler > OnCheckCast
 
HookList< EffectHandler > OnEffectLaunch
 
HookList< EffectHandler > OnEffectLaunchTarget
 
HookList< EffectHandler > OnEffectHit
 
HookList< EffectHandler > OnEffectHitTarget
 
HookList< BeforeHitHandler > BeforeHit
 
HookList< HitHandler > OnHit
 
HookList< HitHandler > AfterHit
 
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
 
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ CheckCast()

SpellCastResult spell_dk_raise_dead::CheckCast ( )
inlineprivate

process spell target selection before cast starts targets of effect_1 are used to check cast

cleanup spell target map, and fill it again on normal way

_result is set in spell target selection

2100 {
2107 return _result;
2108 }
Spell * GetSpell()
Definition SpellScript.h:443
void CleanupTargetList()
Definition Spell.cpp:2386
void SelectSpellTargets()
Definition Spell.cpp:869
SpellCastResult _result
Definition spell_dk.cpp:2196

References _result, Spell::CleanupTargetList(), SpellScript::GetSpell(), and Spell::SelectSpellTargets().

Referenced by Register().

◆ CheckReagents()

SpellCastResult spell_dk_raise_dead::CheckReagents ( )
inlineprivate

@workaround: there is no access to castresult of other spells, check it manually

2111 {
2113 SpellInfo const* reagentSpell = sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT);
2114 Player* player = GetCaster()->ToPlayer();
2115 if (!player->CanNoReagentCast(reagentSpell))
2116 {
2117 for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
2118 {
2119 if (reagentSpell->Reagent[i] <= 0)
2120 continue;
2121
2122 if (!player->HasItemCount(reagentSpell->Reagent[i], reagentSpell->ReagentCount[i]))
2123 {
2124 Spell::SendCastResult(player, reagentSpell, 0, SPELL_FAILED_REAGENTS);
2126 }
2127 }
2128 }
2129 return SPELL_CAST_OK;
2130 }
#define MAX_SPELL_REAGENTS
Definition DBCStructure.h:1675
std::uint32_t uint32
Definition Define.h:107
@ SPELL_FAILED_DONT_REPORT
Definition SharedDefines.h:964
@ SPELL_FAILED_REAGENTS
Definition SharedDefines.h:1037
@ SPELL_CAST_OK
Definition SharedDefines.h:1126
#define sSpellMgr
Definition SpellMgr.h:851
Player * ToPlayer()
Definition Object.h:208
Definition Player.h:1086
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition PlayerStorage.cpp:659
bool CanNoReagentCast(SpellInfo const *spellInfo) const
Definition Player.cpp:12887
Definition SpellInfo.h:340
std::array< int32, MAX_SPELL_REAGENTS > Reagent
Definition SpellInfo.h:397
std::array< uint32, MAX_SPELL_REAGENTS > ReagentCount
Definition SpellInfo.h:398
Unit * GetCaster()
Definition SpellScript.cpp:401
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition Spell.cpp:4831
@ SPELL_DK_RAISE_DEAD_USE_REAGENT
Definition spell_dk.cpp:69

References Player::CanNoReagentCast(), SpellScript::GetCaster(), Player::HasItemCount(), MAX_SPELL_REAGENTS, SpellInfo::Reagent, SpellInfo::ReagentCount, Spell::SendCastResult(), SPELL_CAST_OK, SPELL_DK_RAISE_DEAD_USE_REAGENT, SPELL_FAILED_DONT_REPORT, SPELL_FAILED_REAGENTS, sSpellMgr, and Object::ToPlayer().

Referenced by CheckTargets().

◆ CheckTarget()

void spell_dk_raise_dead::CheckTarget ( WorldObject *&  target)
inlineprivate
2151 {
2152 // Don't add caster to target map, if we found a corpse to raise dead
2153 if (_corpse)
2154 target = nullptr;
2155 }
bool _corpse
Definition spell_dk.cpp:2197

References _corpse.

Referenced by Register().

◆ CheckTargets()

void spell_dk_raise_dead::CheckTargets ( std::list< WorldObject * > &  targets)
inlineprivate
2133 {
2134 targets.remove_if(RaiseDeadCheck(GetCaster()->ToPlayer()));
2135
2136 if (targets.empty())
2137 {
2138 if (GetSpell()->getState() == SPELL_STATE_PREPARING)
2140
2141 return;
2142 }
2143
2145 targets.clear();
2146 targets.push_back(target);
2147 _corpse = true;
2148 }
@ SPELL_STATE_PREPARING
Definition Spell.h:237
Definition spell_dk.cpp:2056
Definition Object.h:482
SpellCastResult CheckReagents()
Definition spell_dk.cpp:2110
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:133

References _corpse, _result, CheckReagents(), SpellScript::GetCaster(), SpellScript::GetSpell(), Acore::Containers::SelectRandomContainerElement(), and SPELL_STATE_PREPARING.

Referenced by Register().

◆ ConsumeReagents()

void spell_dk_raise_dead::ConsumeReagents ( )
inlineprivate
2158 {
2159 // No corpse found, take reagents
2160 if (!_corpse)
2162 }
TriggerCastFlags
Definition SpellDefines.h:140
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition SpellDefines.h:158
@ TRIGGERED_IGNORE_POWER_AND_REAGENT_COST
Will ignore Spell and Category cooldowns.
Definition SpellDefines.h:144
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:1378

References _corpse, Unit::CastSpell(), SpellScript::GetCaster(), SPELL_DK_RAISE_DEAD_USE_REAGENT, TRIGGERED_FULL_MASK, and TRIGGERED_IGNORE_POWER_AND_REAGENT_COST.

Referenced by Register().

◆ GetGhoulSpellId()

uint32 spell_dk_raise_dead::GetGhoulSpellId ( )
inlineprivate
2165 {
2166 // Do we have talent Master of Ghouls?
2167 if (GetCaster()->HasAura(SPELL_DK_MASTER_OF_GHOULS))
2168 // summon as pet
2169 return GetSpellInfo()->Effects[EFFECT_2].CalcValue();
2170
2171 // or guardian
2172 return GetSpellInfo()->Effects[EFFECT_1].CalcValue();
2173 }
@ EFFECT_1
Definition SharedDefines.h:32
@ EFFECT_2
Definition SharedDefines.h:33
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:416
@ SPELL_DK_MASTER_OF_GHOULS
Definition spell_dk.cpp:67

References EFFECT_1, EFFECT_2, SpellInfo::Effects, SpellScript::GetCaster(), SpellScript::GetSpellInfo(), and SPELL_DK_MASTER_OF_GHOULS.

Referenced by HandleRaiseDead().

◆ HandleRaiseDead()

void spell_dk_raise_dead::HandleRaiseDead ( SpellEffIndex  )
inlineprivate
2176 {
2177 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(GetGhoulSpellId());
2178 SpellCastTargets targets;
2179 targets.SetDst(*GetHitUnit());
2180
2181 GetCaster()->CastSpell(targets, spellInfo, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCaster()->GetGUID());
2183 }
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition Player.cpp:3704
Definition Spell.h:121
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition Spell.cpp:443
Unit * GetHitUnit()
Definition SpellScript.cpp:453
uint32 GetGhoulSpellId()
Definition spell_dk.cpp:2164

References Unit::CastSpell(), SpellScript::GetCaster(), GetGhoulSpellId(), SpellScript::GetHitUnit(), SpellScript::GetSpellInfo(), Player::RemoveSpellCooldown(), SpellCastTargets::SetDst(), sSpellMgr, Object::ToPlayer(), and TRIGGERED_FULL_MASK.

Referenced by Register().

◆ Load()

bool spell_dk_raise_dead::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

2093 {
2095 _corpse = false;
2096 return GetCaster()->IsPlayer();
2097 }
bool IsPlayer() const
Definition Object.h:207

References _corpse, _result, SpellScript::GetCaster(), Object::IsPlayer(), and SPELL_CAST_OK.

◆ PrepareSpellScript()

spell_dk_raise_dead::PrepareSpellScript ( spell_dk_raise_dead  )
private

◆ Register()

void spell_dk_raise_dead::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

2186 {
2193 }
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:769
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:843
@ TARGET_UNIT_DEST_AREA_ENTRY
Definition SharedDefines.h:1421
@ TARGET_UNIT_CASTER
Definition SharedDefines.h:1414
#define SpellObjectTargetSelectFn(F, I, N)
Definition SpellScript.h:359
#define SpellCheckCastFn(F)
Definition SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition SpellScript.h:337
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition SpellScript.h:354
#define SpellCastFn(F)
Definition SpellScript.h:324
HookList< CheckCastHandler > OnCheckCast
Definition SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition SpellScript.h:336
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
Definition SpellScript.h:358
HookList< CastHandler > OnCast
Definition SpellScript.h:321
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition SpellScript.h:353
SpellCastResult CheckCast()
Definition spell_dk.cpp:2099
void HandleRaiseDead(SpellEffIndex)
Definition spell_dk.cpp:2175
void ConsumeReagents()
Definition spell_dk.cpp:2157
void CheckTarget(WorldObject *&target)
Definition spell_dk.cpp:2150
void CheckTargets(std::list< WorldObject * > &targets)
Definition spell_dk.cpp:2132

References CheckCast(), CheckTarget(), CheckTargets(), ConsumeReagents(), EFFECT_1, EFFECT_2, HandleRaiseDead(), SpellScript::OnCast, SpellScript::OnCheckCast, SpellScript::OnEffectHitTarget, SpellScript::OnObjectAreaTargetSelect, SpellScript::OnObjectTargetSelect, SPELL_EFFECT_DUMMY, SPELL_EFFECT_SCRIPT_EFFECT, SpellCastFn, SpellCheckCastFn, SpellEffectFn, SpellObjectAreaTargetSelectFn, SpellObjectTargetSelectFn, TARGET_UNIT_CASTER, and TARGET_UNIT_DEST_AREA_ENTRY.

◆ Validate()

bool spell_dk_raise_dead::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

2084 {
2085 return ValidateSpellInfo(
2086 {
2089 });
2090 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition SpellScript.h:125

References SPELL_DK_MASTER_OF_GHOULS, SPELL_DK_RAISE_DEAD_USE_REAGENT, and _SpellScript::ValidateSpellInfo().

Member Data Documentation

◆ _corpse

bool spell_dk_raise_dead::_corpse
private

◆ _result

SpellCastResult spell_dk_raise_dead::_result
private

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


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