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

Private Member Functions

 PrepareSpellScript (spell_item_mind_amplify_dish) void OnDummyEffect(SpellEffIndex effIndex)
 
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
 
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

◆ PrepareSpellScript()

spell_item_mind_amplify_dish::PrepareSpellScript ( spell_item_mind_amplify_dish  )
inlineprivate
114 {
115 PreventHitDefaultEffect(effIndex);
116
117 Unit* caster = GetCaster();
118 if (Player* player = caster->ToPlayer())
119 {
120 if (Unit* target = GetHitUnit())
121 {
122 // little protection
123 if (target->ToCreature())
124 if (target->ToCreature()->GetCreatureTemplate()->rank > CREATURE_ELITE_NORMAL)
125 return;
126
127 if (GetSpellInfo()->Id != SPELL_AMPLIFY_10S)
128 if (target->GetLevel() > 60)
129 return;
130
131 uint8 pct = std::max(0, 20 + player->GetLevel() - target->GetLevel());
132 if (roll_chance_i(pct))
133 player->CastSpell(target, SPELL_MENTAL_BATTLE, true);
134 else if (roll_chance_i(pct))
135 player->CastSpell(target, GetSpellInfo()->Id == SPELL_AMPLIFY_10S ? SPELL_AMPLIFY_CHARM_10S : SPELL_AMPLIFY_CHARM_30S, true);
136 }
137 }
138 }
std::uint8_t uint8
Definition: Define.h:110
bool roll_chance_i(int chance)
Definition: Random.h:59
@ SPELL_AMPLIFY_CHARM_10S
Definition: spell_item.cpp:106
@ SPELL_AMPLIFY_CHARM_30S
Definition: spell_item.cpp:105
@ SPELL_MENTAL_BATTLE
Definition: spell_item.cpp:104
@ SPELL_AMPLIFY_10S
Definition: spell_item.cpp:103
@ CREATURE_ELITE_NORMAL
Definition: SharedDefines.h:2731
Player * ToPlayer()
Definition: Object.h:195
Definition: Player.h:1056
Definition: Unit.h:1302
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Definition: SpellScript.cpp:590
Unit * GetHitUnit()
Definition: SpellScript.cpp:448
Unit * GetCaster()
Definition: SpellScript.cpp:401

References CREATURE_ELITE_NORMAL, SpellScript::GetCaster(), SpellScript::GetHitUnit(), SpellScript::GetSpellInfo(), SpellScript::PreventHitDefaultEffect(), roll_chance_i(), SPELL_AMPLIFY_10S, SPELL_AMPLIFY_CHARM_10S, SPELL_AMPLIFY_CHARM_30S, SPELL_MENTAL_BATTLE, and Object::ToPlayer().

◆ Register()

void spell_item_mind_amplify_dish::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

141 {
142 OnEffectHitTarget += SpellEffectFn(spell_item_mind_amplify_dish::OnDummyEffect, EFFECT_0, SPELL_EFFECT_DUMMY);
143 }
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
@ EFFECT_0
Definition: SharedDefines.h:31
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:781
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336

References EFFECT_0, SpellScript::OnEffectHitTarget, SPELL_EFFECT_DUMMY, and SpellEffectFn.