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
 
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 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
 
- 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

2095 {
2102 return _result;
2103 }
Spell * GetSpell()
Definition SpellScript.h:442
void CleanupTargetList()
Definition Spell.cpp:2332
void SelectSpellTargets()
Definition Spell.cpp:829
SpellCastResult _result
Definition spell_dk.cpp:2191

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

2106 {
2108 SpellInfo const* reagentSpell = sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT);
2109 Player* player = GetCaster()->ToPlayer();
2110 if (!player->CanNoReagentCast(reagentSpell))
2111 {
2112 for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
2113 {
2114 if (reagentSpell->Reagent[i] <= 0)
2115 continue;
2116
2117 if (!player->HasItemCount(reagentSpell->Reagent[i], reagentSpell->ReagentCount[i]))
2118 {
2119 Spell::SendCastResult(player, reagentSpell, 0, SPELL_FAILED_REAGENTS);
2121 }
2122 }
2123 }
2124 return SPELL_CAST_OK;
2125 }
#define MAX_SPELL_REAGENTS
Definition DBCStructure.h:1639
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:847
Player * ToPlayer()
Definition Object.h:202
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:12847
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:4671
@ 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
2146 {
2147 // Don't add caster to target map, if we found a corpse to raise dead
2148 if (_corpse)
2149 target = nullptr;
2150 }
bool _corpse
Definition spell_dk.cpp:2192

References _corpse.

Referenced by Register().

◆ CheckTargets()

void spell_dk_raise_dead::CheckTargets ( std::list< WorldObject * > &  targets)
inlineprivate
2128 {
2129 targets.remove_if(RaiseDeadCheck(GetCaster()->ToPlayer()));
2130
2131 if (targets.empty())
2132 {
2133 if (GetSpell()->getState() == SPELL_STATE_PREPARING)
2135
2136 return;
2137 }
2138
2140 targets.clear();
2141 targets.push_back(target);
2142 _corpse = true;
2143 }
@ SPELL_STATE_PREPARING
Definition Spell.h:237
Definition spell_dk.cpp:2051
Definition Object.h:476
SpellCastResult CheckReagents()
Definition spell_dk.cpp:2105
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
2153 {
2154 // No corpse found, take reagents
2155 if (!_corpse)
2157 }
TriggerCastFlags
Definition SpellDefines.h:132
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
Definition SpellDefines.h:150
@ TRIGGERED_IGNORE_POWER_AND_REAGENT_COST
Will ignore Spell and Category cooldowns.
Definition SpellDefines.h:136
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:1361

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
2160 {
2161 // Do we have talent Master of Ghouls?
2162 if (GetCaster()->HasAura(SPELL_DK_MASTER_OF_GHOULS))
2163 // summon as pet
2164 return GetSpellInfo()->Effects[EFFECT_2].CalcValue();
2165
2166 // or guardian
2167 return GetSpellInfo()->Effects[EFFECT_1].CalcValue();
2168 }
@ 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:411
@ 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
2171 {
2172 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(GetGhoulSpellId());
2173 SpellCastTargets targets;
2174 targets.SetDst(*GetHitUnit());
2175
2176 GetCaster()->CastSpell(targets, spellInfo, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCaster()->GetGUID());
2178 }
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition Player.cpp:3683
Definition Spell.h:121
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition Spell.cpp:406
Unit * GetHitUnit()
Definition SpellScript.cpp:448
uint32 GetGhoulSpellId()
Definition spell_dk.cpp:2159

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.

2088 {
2090 _corpse = false;
2091 return GetCaster()->IsPlayer();
2092 }
bool IsPlayer() const
Definition Object.h:201

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.

2181 {
2188 }
@ 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:2094
void HandleRaiseDead(SpellEffIndex)
Definition spell_dk.cpp:2170
void ConsumeReagents()
Definition spell_dk.cpp:2152
void CheckTarget(WorldObject *&target)
Definition spell_dk.cpp:2145
void CheckTargets(std::list< WorldObject * > &targets)
Definition spell_dk.cpp:2127

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.

2079 {
2080 return ValidateSpellInfo(
2081 {
2084 });
2085 }
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: