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

◆ 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

1888 {
1895 return _result;
1896 }
void CleanupTargetList()
Definition: Spell.cpp:2375
void SelectSpellTargets()
Definition: Spell.cpp:819
Spell * GetSpell()
Definition: SpellScript.h:442
SpellCastResult _result
Definition: spell_dk.cpp:1984

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

1899 {
1901 SpellInfo const* reagentSpell = sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT);
1902 Player* player = GetCaster()->ToPlayer();
1903 if (!player->CanNoReagentCast(reagentSpell))
1904 {
1905 for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++)
1906 {
1907 if (reagentSpell->Reagent[i] <= 0)
1908 continue;
1909
1910 if (!player->HasItemCount(reagentSpell->Reagent[i], reagentSpell->ReagentCount[i]))
1911 {
1912 Spell::SendCastResult(player, reagentSpell, 0, SPELL_FAILED_REAGENTS);
1914 }
1915 }
1916 }
1917 return SPELL_CAST_OK;
1918 }
std::uint32_t uint32
Definition: Define.h:107
@ SPELL_DK_RAISE_DEAD_USE_REAGENT
Definition: spell_dk.cpp:68
#define MAX_SPELL_REAGENTS
Definition: DBCStructure.h:1638
@ 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:198
Definition: Player.h:1064
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition: PlayerStorage.cpp:655
bool CanNoReagentCast(SpellInfo const *spellInfo) const
Definition: Player.cpp:12570
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4674
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

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
1939 {
1940 // Don't add caster to target map, if we found a corpse to raise dead
1941 if (_corpse)
1942 target = nullptr;
1943 }
bool _corpse
Definition: spell_dk.cpp:1985

References _corpse.

Referenced by Register().

◆ CheckTargets()

void spell_dk_raise_dead::CheckTargets ( std::list< WorldObject * > &  targets)
inlineprivate
1921 {
1922 targets.remove_if(RaiseDeadCheck(GetCaster()->ToPlayer()));
1923
1924 if (targets.empty())
1925 {
1926 if (GetSpell()->getState() == SPELL_STATE_PREPARING)
1928
1929 return;
1930 }
1931
1933 targets.clear();
1934 targets.push_back(target);
1935 _corpse = true;
1936 }
@ SPELL_STATE_PREPARING
Definition: Spell.h:227
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:133
Definition: Object.h:405
Definition: spell_dk.cpp:1844
SpellCastResult CheckReagents()
Definition: spell_dk.cpp:1898

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
1946 {
1947 // No corpse found, take reagents
1948 if (!_corpse)
1950 }
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:1167

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
1953 {
1954 // Do we have talent Master of Ghouls?
1955 if (GetCaster()->HasAura(SPELL_DK_MASTER_OF_GHOULS))
1956 // summon as pet
1957 return GetSpellInfo()->Effects[EFFECT_2].CalcValue();
1958
1959 // or guardian
1960 return GetSpellInfo()->Effects[EFFECT_1].CalcValue();
1961 }
@ SPELL_DK_MASTER_OF_GHOULS
Definition: spell_dk.cpp:66
@ 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

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
1964 {
1965 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(GetGhoulSpellId());
1966 SpellCastTargets targets;
1967 targets.SetDst(*GetHitUnit());
1968
1969 GetCaster()->CastSpell(targets, spellInfo, nullptr, TRIGGERED_FULL_MASK, nullptr, nullptr, GetCaster()->GetGUID());
1971 }
void RemoveSpellCooldown(uint32 spell_id, bool update=false)
Definition: Player.cpp:3514
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:1952

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.

1881 {
1883 _corpse = false;
1884 return GetCaster()->IsPlayer();
1885 }
bool IsPlayer() const
Definition: Object.h:197

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.

1974 {
1981 }
@ 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:1887
void HandleRaiseDead(SpellEffIndex)
Definition: spell_dk.cpp:1963
void ConsumeReagents()
Definition: spell_dk.cpp:1945
void CheckTarget(WorldObject *&target)
Definition: spell_dk.cpp:1938
void CheckTargets(std::list< WorldObject * > &targets)
Definition: spell_dk.cpp:1920

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.

1872 {
1873 return ValidateSpellInfo(
1874 {
1877 });
1878 }
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().