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
560 {
561 if (Player* caster = GetCaster()->ToPlayer())
562 {
563 uint8 spellRank = GetSpellInfo()->GetRank();
564 ItemPosCountVec dest;
565 InventoryResult msg = caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, iTypes[spellRank - 1][0], 1, nullptr);
566 if (msg != EQUIP_ERR_OK)
568 }
569 return SPELL_CAST_OK;
570 }
std::uint8_t uint8
Definition: Define.h:110
InventoryResult
Definition: Item.h:40
@ EQUIP_ERR_OK
Definition: Item.h:41
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:772
@ NULL_BAG
Definition: Unit.h:210
@ NULL_SLOT
Definition: Unit.h:211
@ SPELL_FAILED_TOO_MANY_OF_ITEM
Definition: SharedDefines.h:1050
@ SPELL_CAST_OK
Definition: SharedDefines.h:1110
Definition: Player.h:1046
uint8 GetRank() const
Definition: SpellInfo.cpp:2477
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
Unit * GetCaster()
Definition: SpellScript.cpp:401
static uint32 const iTypes[8][3]
Definition: spell_warlock.cpp:552

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
573 {
574 if (Unit* unitTarget = GetHitUnit())
575 {
576 uint32 rank = 0;
577 // Improved Healthstone
578 if (AuraEffect const* aurEff = unitTarget->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 284, 0))
579 {
580 switch (aurEff->GetId())
581 {
583 rank = 1;
584 break;
586 rank = 2;
587 break;
588 default:
589 LOG_ERROR("spells", "Unknown rank of Improved Healthstone id: {}", aurEff->GetId());
590 break;
591 }
592 }
593 uint8 spellRank = GetSpellInfo()->GetRank();
594 if (spellRank > 0 && spellRank <= 8)
595 CreateItem(effIndex, iTypes[spellRank - 1][rank]);
596 }
597 }
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
@ 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:3505
Definition: Unit.h:1290
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.

600 {
603 }
#define SpellCheckCastFn(F)
Definition: SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:827
HookList< CheckCastHandler > OnCheckCast
Definition: SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
void HandleScriptEffect(SpellEffIndex effIndex)
Definition: spell_warlock.cpp:572
SpellCastResult CheckCast()
Definition: spell_warlock.cpp:559

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.

555 {
557 }
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().