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

Private Member Functions

 PrepareSpellScript (spell_warl_life_tap)
 
bool Load () override
 
bool Validate (SpellInfo const *) override
 
float GetDownrankFactor (Player const *caster)
 
void HandleDummy (SpellEffIndex)
 
SpellCastResult CheckCast ()
 
void Register () override
 

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
 
Unit * GetCaster ()
 
GameObject * GetGObjCaster ()
 
Unit * GetOriginalCaster ()
 
SpellInfo const * GetSpellInfo ()
 
SpellValue const * GetSpellValue ()
 
WorldLocation const * GetExplTargetDest ()
 
void SetExplTargetDest (WorldLocation &loc)
 
WorldObject * GetExplTargetWorldObject ()
 
Unit * GetExplTargetUnit ()
 
GameObject * GetExplTargetGObj ()
 
Item * GetExplTargetItem ()
 
Unit * GetHitUnit ()
 
Creature * GetHitCreature ()
 
Player * GetHitPlayer ()
 
Item * GetHitItem ()
 
GameObject * GetHitGObj ()
 
WorldLocation * GetHitDest ()
 
int32 GetHitDamage ()
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal ()
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
Spell * GetSpell ()
 
Aura * GetHitAura ()
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
Item * GetCastItem ()
 
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< CastHandler > BeforeCast
 
HookList< CastHandler > OnCast
 
HookList< CastHandler > AfterCast
 
HookList< CheckCastHandler > OnCheckCast
 
HookList< EffectHandler > OnEffectLaunch
 
HookList< EffectHandler > OnEffectLaunchTarget
 
HookList< EffectHandler > OnEffectHit
 
HookList< EffectHandler > OnEffectHitTarget
 
HookList< BeforeHitHandler > BeforeHit
 
HookList< HitHandler > OnHit
 
HookList< HitHandler > AfterHit
 
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
 
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
 
- 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_life_tap::CheckCast ( )
inlineprivate
869 {
870 if ((int32(GetCaster()->GetHealth()) > GetSpellInfo()->Effects[EFFECT_0].CalcValue(GetCaster())))
871 return SPELL_CAST_OK;
872 return SPELL_FAILED_FIZZLE;
873 }
std::int32_t int32
Definition Define.h:103
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_FAILED_FIZZLE
Definition SharedDefines.h:970
@ SPELL_CAST_OK
Definition SharedDefines.h:1126
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:416
Unit * GetCaster()
Definition SpellScript.cpp:401

References EFFECT_0, SpellScript::GetCaster(), SpellScript::GetSpellInfo(), SPELL_CAST_OK, and SPELL_FAILED_FIZZLE.

Referenced by Register().

◆ GetDownrankFactor()

float spell_warl_life_tap::GetDownrankFactor ( Player const *  caster)
inlineprivate
828 {
829 uint32 maxLevel = GetSpellInfo()->MaxLevel;
830 if (!maxLevel)
831 return 1.0f;
832
833 return std::clamp((22.0f + float(maxLevel) - float(caster->GetLevel())) / 20.0f, 0.0f, 1.0f);
834 }
std::uint32_t uint32
Definition Define.h:107
uint32 MaxLevel
Definition SpellInfo.h:382

References Unit::GetLevel(), SpellScript::GetSpellInfo(), and SpellInfo::MaxLevel.

Referenced by HandleDummy().

◆ HandleDummy()

void spell_warl_life_tap::HandleDummy ( SpellEffIndex  )
inlineprivate
837 {
838 Player* caster = GetCaster()->ToPlayer();
839 if (Unit* target = GetHitUnit())
840 {
841 // Health cost scales with caster level up to the rank's max level (DBC RealPointsPerLevel)
842 int32 spellEffect = GetEffectValue();
843 float spellPowerBonus = caster->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW) * 0.5f * GetDownrankFactor(caster);
844 int32 mana = int32(std::round(spellEffect + spellPowerBonus));
845
846 // Shouldn't Appear in Combat Log
847 target->ModifyHealth(-spellEffect);
848
849 // Improved Life Tap mod
851 AddPct(mana, aurEff->GetAmount());
852
853 caster->CastCustomSpell(target, SPELL_WARLOCK_LIFE_TAP_ENERGIZE, &mana, nullptr, nullptr, false);
854
855 // Mana Feed
856 int32 manaFeedVal = 0;
858 manaFeedVal = aurEff->GetAmount();
859
860 if (manaFeedVal > 0)
861 {
862 ApplyPct(manaFeedVal, mana);
863 caster->CastCustomSpell(caster, SPELL_WARLOCK_LIFE_TAP_ENERGIZE_2, &manaFeedVal, nullptr, nullptr, true, nullptr);
864 }
865 }
866 }
@ SPELLFAMILY_WARLOCK
Definition SharedDefines.h:3789
@ SPELL_SCHOOL_MASK_SHADOW
Definition SharedDefines.h:290
@ SPELL_AURA_ADD_FLAT_MODIFIER
Definition SpellAuraDefines.h:170
T AddPct(T &base, U pct)
Definition Util.h:58
T ApplyPct(T &base, U pct)
Definition Util.h:64
Definition SpellAuraEffects.h:39
Player * ToPlayer()
Definition Object.h:208
Definition Player.h:1086
int32 GetEffectValue() const
Definition SpellScript.cpp:605
Unit * GetHitUnit()
Definition SpellScript.cpp:453
Definition Unit.h:670
SpellCastResult CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1435
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition Unit.cpp:5571
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
Definition Unit.cpp:8848
AuraEffect * GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
Definition Unit.h:1454
float GetDownrankFactor(Player const *caster)
Definition spell_warlock.cpp:827
@ SPELL_WARLOCK_LIFE_TAP_ENERGIZE_2
Definition spell_warlock.cpp:65
@ SPELL_WARLOCK_LIFE_TAP_ENERGIZE
Definition spell_warlock.cpp:64
@ WARLOCK_ICON_ID_MANA_FEED
Definition spell_warlock.cpp:99
@ WARLOCK_ICON_ID_IMPROVED_LIFE_TAP
Definition spell_warlock.cpp:98

References AddPct(), ApplyPct(), Unit::CastCustomSpell(), Unit::GetAuraEffect(), SpellScript::GetCaster(), GetDownrankFactor(), Unit::GetDummyAuraEffect(), SpellScript::GetEffectValue(), SpellScript::GetHitUnit(), SPELL_AURA_ADD_FLAT_MODIFIER, SPELL_SCHOOL_MASK_SHADOW, SPELL_WARLOCK_LIFE_TAP_ENERGIZE, SPELL_WARLOCK_LIFE_TAP_ENERGIZE_2, Unit::SpellBaseDamageBonusDone(), SPELLFAMILY_WARLOCK, Object::ToPlayer(), WARLOCK_ICON_ID_IMPROVED_LIFE_TAP, and WARLOCK_ICON_ID_MANA_FEED.

Referenced by Register().

◆ Load()

bool spell_warl_life_tap::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

816 {
817 return GetCaster()->IsPlayer();
818 }
bool IsPlayer() const
Definition Object.h:207

References SpellScript::GetCaster(), and Object::IsPlayer().

◆ PrepareSpellScript()

spell_warl_life_tap::PrepareSpellScript ( spell_warl_life_tap  )
private

◆ Register()

void spell_warl_life_tap::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

876 {
879 }
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:769
#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
SpellCastResult CheckCast()
Definition spell_warlock.cpp:868
void HandleDummy(SpellEffIndex)
Definition spell_warlock.cpp:836

References CheckCast(), EFFECT_0, HandleDummy(), SpellScript::OnCheckCast, SpellScript::OnEffectHitTarget, SPELL_EFFECT_DUMMY, SpellCheckCastFn, and SpellEffectFn.

◆ Validate()

bool spell_warl_life_tap::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

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

References SPELL_WARLOCK_LIFE_TAP_ENERGIZE, SPELL_WARLOCK_LIFE_TAP_ENERGIZE_2, and _SpellScript::ValidateSpellInfo().


The documentation for this class was generated from the following file: