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

Private Member Functions

 PrepareSpellScript (spell_warl_create_healthstone)
 
bool Validate (SpellInfo const *) override
 
SpellCastResult CheckCast ()
 
void HandleScriptEffect (SpellEffIndex effIndex)
 
void Register () override
 

Static Private Attributes

static uint32 const iTypes [8][3]
 

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_warl_create_healthstone::CheckCast ( )
inlineprivate
583 {
584 if (Player* caster = GetCaster()->ToPlayer())
585 {
586 uint8 spellRank = GetSpellInfo()->GetRank();
587 ItemPosCountVec dest;
588 InventoryResult msg = caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, iTypes[spellRank - 1][0], 1, nullptr);
589 if (msg != EQUIP_ERR_OK)
591 }
592 return SPELL_CAST_OK;
593 }
std::uint8_t uint8
Definition: Define.h:109
@ SPELL_FAILED_TOO_MANY_OF_ITEM
Definition: SharedDefines.h:1078
@ SPELL_CAST_OK
Definition: SharedDefines.h:1138
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:776
InventoryResult
Definition: Item.h:46
@ EQUIP_ERR_OK
Definition: Item.h:47
@ NULL_BAG
Definition: Item.h:40
@ NULL_SLOT
Definition: Item.h:41
Definition: Player.h:1081
uint8 GetRank() const
Definition: SpellInfo.cpp:2494
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
Unit * GetCaster()
Definition: SpellScript.cpp:401
static uint32 const iTypes[8][3]
Definition: spell_warlock.cpp:575

References EQUIP_ERR_OK, SpellScript::GetCaster(), SpellInfo::GetRank(), SpellScript::GetSpellInfo(), iTypes, NULL_BAG, NULL_SLOT, SPELL_CAST_OK, and SPELL_FAILED_TOO_MANY_OF_ITEM.

Referenced by Register().

◆ HandleScriptEffect()

void spell_warl_create_healthstone::HandleScriptEffect ( SpellEffIndex  effIndex)
inlineprivate
596 {
597 if (Unit* unitTarget = GetHitUnit())
598 {
599 uint32 rank = 0;
600 // Improved Healthstone
601 if (AuraEffect const* aurEff = unitTarget->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 284, 0))
602 {
603 switch (aurEff->GetId())
604 {
606 rank = 1;
607 break;
609 rank = 2;
610 break;
611 default:
612 LOG_ERROR("spells", "Unknown rank of Improved Healthstone id: {}", aurEff->GetId());
613 break;
614 }
615 }
616 uint8 spellRank = GetSpellInfo()->GetRank();
617 if (spellRank > 0 && spellRank <= 8)
618 CreateItem(effIndex, iTypes[spellRank - 1][rank]);
619 }
620 }
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
std::uint32_t uint32
Definition: Define.h:107
@ SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R1
Definition: spell_warlock.cpp:53
@ SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R2
Definition: spell_warlock.cpp:54
@ SPELLFAMILY_WARLOCK
Definition: SharedDefines.h:3533
Definition: Unit.h:630
Definition: SpellAuraEffects.h:39
Unit * GetHitUnit()
Definition: SpellScript.cpp:448
void CreateItem(uint32 effIndex, uint32 itemId)
Definition: SpellScript.cpp:625

References SpellScript::CreateItem(), SpellScript::GetHitUnit(), SpellInfo::GetRank(), SpellScript::GetSpellInfo(), iTypes, LOG_ERROR, SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R1, SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R2, and SPELLFAMILY_WARLOCK.

Referenced by Register().

◆ PrepareSpellScript()

spell_warl_create_healthstone::PrepareSpellScript ( spell_warl_create_healthstone  )
private

◆ Register()

void spell_warl_create_healthstone::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

623 {
626 }
@ EFFECT_0
Definition: SharedDefines.h:31
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:855
#define SpellCheckCastFn(F)
Definition: SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
HookList< CheckCastHandler > OnCheckCast
Definition: SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
void HandleScriptEffect(SpellEffIndex effIndex)
Definition: spell_warlock.cpp:595
SpellCastResult CheckCast()
Definition: spell_warlock.cpp:582

References CheckCast(), EFFECT_0, HandleScriptEffect(), SpellScript::OnCheckCast, SpellScript::OnEffectHitTarget, SPELL_EFFECT_SCRIPT_EFFECT, SpellCheckCastFn, and SpellEffectFn.

◆ Validate()

bool spell_warl_create_healthstone::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

578 {
580 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:125

References SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R1, SPELL_WARLOCK_IMPROVED_HEALTHSTONE_R2, and _SpellScript::ValidateSpellInfo().

Member Data Documentation

◆ iTypes

uint32 const spell_warl_create_healthstone::iTypes[8][3]
staticprivate

Referenced by CheckCast(), and HandleScriptEffect().