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

2087 {
2094 return _result;
2095 }
Spell * GetSpell()
Definition SpellScript.h:442
void CleanupTargetList()
Definition Spell.cpp:2284
void SelectSpellTargets()
Definition Spell.cpp:822
SpellCastResult _result
Definition spell_dk.cpp:2183

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

2098 {
2100 SpellInfo const* reagentSpell = sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT);
2101 Player* player = GetCaster()->ToPlayer();
2102 if (!player->CanNoReagentCast(reagentSpell))
2103 {
2104 for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
2105 {
2106 if (reagentSpell->Reagent[i] <= 0)
2107 continue;
2108
2109 if (!player->HasItemCount(reagentSpell->Reagent[i], reagentSpell->ReagentCount[i]))
2110 {
2111 Spell::SendCastResult(player, reagentSpell, 0, SPELL_FAILED_REAGENTS);
2113 }
2114 }
2115 }
2116 return SPELL_CAST_OK;
2117 }
#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:836
Player * ToPlayer()
Definition Object.h:202
Definition Player.h:1084
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition PlayerStorage.cpp:658
bool CanNoReagentCast(SpellInfo const *spellInfo) const
Definition Player.cpp:12598
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:4619
@ 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
2138 {
2139 // Don't add caster to target map, if we found a corpse to raise dead
2140 if (_corpse)
2141 target = nullptr;
2142 }
bool _corpse
Definition spell_dk.cpp:2184

References _corpse.

Referenced by Register().

◆ CheckTargets()

void spell_dk_raise_dead::CheckTargets ( std::list< WorldObject * > &  targets)
inlineprivate
2120 {
2121 targets.remove_if(RaiseDeadCheck(GetCaster()->ToPlayer()));
2122
2123 if (targets.empty())
2124 {
2125 if (GetSpell()->getState() == SPELL_STATE_PREPARING)
2127
2128 return;
2129 }
2130
2132 targets.clear();
2133 targets.push_back(target);
2134 _corpse = true;
2135 }
@ SPELL_STATE_PREPARING
Definition Spell.h:237
Definition spell_dk.cpp:2043
Definition Object.h:475
SpellCastResult CheckReagents()
Definition spell_dk.cpp:2097
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
2145 {
2146 // No corpse found, take reagents
2147 if (!_corpse)
2149 }
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:1375

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
2152 {
2153 // Do we have talent Master of Ghouls?
2154 if (GetCaster()->HasAura(SPELL_DK_MASTER_OF_GHOULS))
2155 // summon as pet
2156 return GetSpellInfo()->Effects[EFFECT_2].CalcValue();
2157
2158 // or guardian
2159 return GetSpellInfo()->Effects[EFFECT_1].CalcValue();
2160 }
@ 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
2163 {
2164 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(GetGhoulSpellId());
2165 SpellCastTargets targets;
2166 targets.SetDst(*GetHitUnit());
2167
2168 GetCaster()->CastSpell(targets, spellInfo, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCaster()->GetGUID());
2170 }
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition Player.cpp:3525
Definition Spell.h:121
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition Spell.cpp:405
Unit * GetHitUnit()
Definition SpellScript.cpp:448
uint32 GetGhoulSpellId()
Definition spell_dk.cpp:2151

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.

2080 {
2082 _corpse = false;
2083 return GetCaster()->IsPlayer();
2084 }
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.

2173 {
2180 }
@ 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:2086
void HandleRaiseDead(SpellEffIndex)
Definition spell_dk.cpp:2162
void ConsumeReagents()
Definition spell_dk.cpp:2144
void CheckTarget(WorldObject *&target)
Definition spell_dk.cpp:2137
void CheckTargets(std::list< WorldObject * > &targets)
Definition spell_dk.cpp:2119

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.

2071 {
2072 return ValidateSpellInfo(
2073 {
2076 });
2077 }
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: