AzerothCore 3.3.5a
OpenSource WoW Emulator
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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

1889 {
1896 return _result;
1897 }
Spell * GetSpell()
Definition SpellScript.h:442
void CleanupTargetList()
Definition Spell.cpp:2380
void SelectSpellTargets()
Definition Spell.cpp:819
SpellCastResult _result
Definition spell_dk.cpp:1985

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

1900 {
1902 SpellInfo const* reagentSpell = sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT);
1903 Player* player = GetCaster()->ToPlayer();
1904 if (!player->CanNoReagentCast(reagentSpell))
1905 {
1906 for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
1907 {
1908 if (reagentSpell->Reagent[i] <= 0)
1909 continue;
1910
1911 if (!player->HasItemCount(reagentSpell->Reagent[i], reagentSpell->ReagentCount[i]))
1912 {
1913 Spell::SendCastResult(player, reagentSpell, 0, SPELL_FAILED_REAGENTS);
1915 }
1916 }
1917 }
1918 return SPELL_CAST_OK;
1919 }
#define MAX_SPELL_REAGENTS
Definition DBCStructure.h:1640
std::uint32_t uint32
Definition Define.h:107
@ SPELL_FAILED_DONT_REPORT
Definition SharedDefines.h:976
@ SPELL_FAILED_REAGENTS
Definition SharedDefines.h:1049
@ SPELL_CAST_OK
Definition SharedDefines.h:1138
#define sSpellMgr
Definition SpellMgr.h:825
Player * ToPlayer()
Definition Object.h:202
Definition Player.h:1082
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition PlayerStorage.cpp:655
bool CanNoReagentCast(SpellInfo const *spellInfo) const
Definition Player.cpp:12540
Definition SpellInfo.h:316
std::array< int32, MAX_SPELL_REAGENTS > Reagent
Definition SpellInfo.h:373
std::array< uint32, MAX_SPELL_REAGENTS > ReagentCount
Definition SpellInfo.h:374
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:4685
@ 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
1940 {
1941 // Don't add caster to target map, if we found a corpse to raise dead
1942 if (_corpse)
1943 target = nullptr;
1944 }
bool _corpse
Definition spell_dk.cpp:1986

References _corpse.

Referenced by Register().

◆ CheckTargets()

void spell_dk_raise_dead::CheckTargets ( std::list< WorldObject * > &  targets)
inlineprivate
1922 {
1923 targets.remove_if(RaiseDeadCheck(GetCaster()->ToPlayer()));
1924
1925 if (targets.empty())
1926 {
1927 if (GetSpell()->getState() == SPELL_STATE_PREPARING)
1929
1930 return;
1931 }
1932
1934 targets.clear();
1935 targets.push_back(target);
1936 _corpse = true;
1937 }
@ SPELL_STATE_PREPARING
Definition Spell.h:227
Definition spell_dk.cpp:1845
Definition Object.h:411
SpellCastResult CheckReagents()
Definition spell_dk.cpp:1899
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
1947 {
1948 // No corpse found, take reagents
1949 if (!_corpse)
1951 }
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:1179

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
1954 {
1955 // Do we have talent Master of Ghouls?
1956 if (GetCaster()->HasAura(SPELL_DK_MASTER_OF_GHOULS))
1957 // summon as pet
1958 return GetSpellInfo()->Effects[EFFECT_2].CalcValue();
1959
1960 // or guardian
1961 return GetSpellInfo()->Effects[EFFECT_1].CalcValue();
1962 }
@ EFFECT_1
Definition SharedDefines.h:32
@ EFFECT_2
Definition SharedDefines.h:33
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:393
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
1965 {
1966 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(GetGhoulSpellId());
1967 SpellCastTargets targets;
1968 targets.SetDst(*GetHitUnit());
1969
1970 GetCaster()->CastSpell(targets, spellInfo, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCaster()->GetGUID());
1972 }
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition Player.cpp:3523
Definition Spell.h:111
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:1953

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.

1882 {
1884 _corpse = false;
1885 return GetCaster()->IsPlayer();
1886 }
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.

1975 {
1982 }
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:781
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:855
@ TARGET_UNIT_DEST_AREA_ENTRY
Definition SharedDefines.h:1417
@ TARGET_UNIT_CASTER
Definition SharedDefines.h:1410
#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:1888
void HandleRaiseDead(SpellEffIndex)
Definition spell_dk.cpp:1964
void ConsumeReagents()
Definition spell_dk.cpp:1946
void CheckTarget(WorldObject *&target)
Definition spell_dk.cpp:1939
void CheckTargets(std::list< WorldObject * > &targets)
Definition spell_dk.cpp:1921

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.

1873 {
1874 return ValidateSpellInfo(
1875 {
1878 });
1879 }
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: