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) bool Load() override
 
bool Validate (SpellInfo const *) override
 
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 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
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ OnDummyEffect()

void spell_item_mind_amplify_dish::OnDummyEffect ( SpellEffIndex  effIndex)
inlineprivate
339 {
340 PreventHitDefaultEffect(effIndex);
341
342 Unit* caster = GetCaster();
343 Unit* target = GetHitUnit();
344 if (!caster || !target)
345 return;
346
347 // little protection
348 if (target->ToCreature() && target->ToCreature()->GetCreatureTemplate()->rank > CREATURE_ELITE_NORMAL)
349 return;
350
352
353 // 5% of the time - Backfire
354 // 65% of the time - Successful Mind Control.
355 // 30% of the time - Unsuccessful Mind Control.
356 int32 backfire = 5;
357 int32 failure = 30;
358
359 // Increased chance of failure when used against targets over level 60.
360 bool isIncreasedChanceOfFailure = GetSpellInfo()->Id == SPELL_MIND_CONTROL_CAP && target->GetLevel() > 60;
361 if (isIncreasedChanceOfFailure)
362 {
363 backfire = 20; // not verified
364 failure = 45; // not verified
365 }
366
367 int32 roll = irand(0, 99);
368 if (roll < backfire)
369 target->CastSpell(caster, charmSpell, true, GetCastItem());
370 else if (roll < backfire + failure)
371 {
372 if (roll_chance_i(50)) // not verified
373 caster->CastSpell(target, SPELL_MENTAL_BATTLE, true, GetCastItem());
374 else
375 caster->CastSpell(caster, SPELL_DULLARD, true, GetCastItem());
376 }
377 else // success
378 caster->CastSpell(target, charmSpell, true, GetCastItem());
379 }
std::int32_t int32
Definition Define.h:103
std::uint32_t uint32
Definition Define.h:107
int32 irand(int32 min, int32 max)
Definition Random.cpp:37
bool roll_chance_i(int chance)
Definition Random.h:63
@ CREATURE_ELITE_NORMAL
Definition SharedDefines.h:2964
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:207
Creature * ToCreature()
Definition Object.h:206
uint32 Id
Definition SpellInfo.h:344
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:411
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Definition SpellScript.cpp:590
Item * GetCastItem()
Definition SpellScript.cpp:620
Unit * GetHitUnit()
Definition SpellScript.cpp:448
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:664
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:1389
uint8 GetLevel() const
Definition Unit.h:1103
@ SPELL_MIND_CONTROL_CAP
Definition spell_item.cpp:316
@ SPELL_MIND_CONTROL_CAP_CHARM_10S
Definition spell_item.cpp:320
@ SPELL_MIND_CONTROL_CAP_CHARM_30S
Definition spell_item.cpp:319
@ SPELL_DULLARD
Definition spell_item.cpp:321
@ SPELL_MENTAL_BATTLE
Definition spell_item.cpp:318
@ SPELL_AMPLIFICATION_DISH
Definition spell_item.cpp:317
uint32 rank
Definition CreatureData.h:206

References Unit::CastSpell(), CREATURE_ELITE_NORMAL, SpellScript::GetCaster(), SpellScript::GetCastItem(), Creature::GetCreatureTemplate(), SpellScript::GetHitUnit(), Unit::GetLevel(), SpellScript::GetSpellInfo(), SpellInfo::Id, irand(), SpellScript::PreventHitDefaultEffect(), CreatureTemplate::rank, roll_chance_i(), SPELL_AMPLIFICATION_DISH, SPELL_DULLARD, SPELL_MENTAL_BATTLE, SPELL_MIND_CONTROL_CAP, SPELL_MIND_CONTROL_CAP_CHARM_10S, SPELL_MIND_CONTROL_CAP_CHARM_30S, and Object::ToCreature().

Referenced by Register().

◆ PrepareSpellScript()

spell_item_mind_amplify_dish::PrepareSpellScript ( spell_item_mind_amplify_dish  )
inlineoverrideprivate
329 {
330 return GetCastItem() != nullptr;
331 }

References SpellScript::GetCastItem().

◆ Register()

void spell_item_mind_amplify_dish::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

382 {
384 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_EFFECT_DUMMY
Definition SharedDefines.h:769
#define SpellEffectFn(F, I, N)
Definition SpellScript.h:337
HookList< EffectHandler > OnEffectHitTarget
Definition SpellScript.h:336
void OnDummyEffect(SpellEffIndex effIndex)
Definition spell_item.cpp:338

References EFFECT_0, OnDummyEffect(), SpellScript::OnEffectHitTarget, SPELL_EFFECT_DUMMY, and SpellEffectFn.

◆ Validate()

bool spell_item_mind_amplify_dish::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

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