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

Private Member Functions

 PrepareSpellScript (spell_gen_mounted_charge) bool Validate(SpellInfo const *) override
 
void HandleScriptEffect (SpellEffIndex effIndex)
 
void HandleChargeEffect (SpellEffIndex)
 
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

◆ HandleChargeEffect()

void spell_gen_mounted_charge::HandleChargeEffect ( SpellEffIndex  )
inlineprivate
2969 {
2970 uint32 spellId;
2971
2972 switch (GetSpellInfo()->Id)
2973 {
2975 spellId = SPELL_CHARGE_DAMAGE_8K5;
2976 break;
2979 spellId = SPELL_CHARGE_DAMAGE_20K;
2980 break;
2983 spellId = SPELL_CHARGE_DAMAGE_45K;
2984 break;
2985 default:
2986 return;
2987 }
2988
2989 if (Unit* rider = GetCaster()->GetCharmer())
2990 rider->CastSpell(GetHitUnit(), spellId, false);
2991 else
2992 GetCaster()->CastSpell(GetHitUnit(), spellId, false);
2993 }
std::uint32_t uint32
Definition: Define.h:108
@ SPELL_CHARGE_CHARGING_EFFECT_8K5
Definition: spell_generic.cpp:2876
@ SPELL_CHARGE_CHARGING_EFFECT_20K_2
Definition: spell_generic.cpp:2878
@ SPELL_CHARGE_DAMAGE_45K
Definition: spell_generic.cpp:2874
@ SPELL_CHARGE_CHARGING_EFFECT_20K_1
Definition: spell_generic.cpp:2877
@ SPELL_CHARGE_DAMAGE_8K5
Definition: spell_generic.cpp:2872
@ SPELL_CHARGE_CHARGING_EFFECT_45K_1
Definition: spell_generic.cpp:2879
@ SPELL_CHARGE_DAMAGE_20K
Definition: spell_generic.cpp:2873
@ SPELL_CHARGE_CHARGING_EFFECT_45K_2
Definition: spell_generic.cpp:2880
Definition: Unit.h:1290
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:1169
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
Unit * GetHitUnit()
Definition: SpellScript.cpp:448
Unit * GetCaster()
Definition: SpellScript.cpp:401

References Unit::CastSpell(), SpellScript::GetCaster(), SpellScript::GetHitUnit(), SpellScript::GetSpellInfo(), SPELL_CHARGE_CHARGING_EFFECT_20K_1, SPELL_CHARGE_CHARGING_EFFECT_20K_2, SPELL_CHARGE_CHARGING_EFFECT_45K_1, SPELL_CHARGE_CHARGING_EFFECT_45K_2, SPELL_CHARGE_CHARGING_EFFECT_8K5, SPELL_CHARGE_DAMAGE_20K, SPELL_CHARGE_DAMAGE_45K, and SPELL_CHARGE_DAMAGE_8K5.

Referenced by Register().

◆ HandleScriptEffect()

void spell_gen_mounted_charge::HandleScriptEffect ( SpellEffIndex  effIndex)
inlineprivate
2912 {
2913 Unit* target = GetHitUnit();
2914
2915 switch (effIndex)
2916 {
2917 case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual)
2918 {
2919 uint32 spellId;
2920
2921 switch (GetSpellInfo()->Id)
2922 {
2925 break;
2928 break;
2929 default:
2930 return;
2931 }
2932
2933 // If target isn't a training dummy there's a chance of failing the charge
2934 if (!target->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE) && roll_chance_f(12.5f))
2935 spellId = SPELL_CHARGE_MISS_EFFECT;
2936
2937 if (Unit* vehicle = GetCaster()->GetVehicleBase())
2938 vehicle->CastSpell(target, spellId, false);
2939 else
2940 GetCaster()->CastSpell(target, spellId, false);
2941 break;
2942 }
2943 case EFFECT_1: // On damaging spells, for removing a defend layer
2944 case EFFECT_2:
2945 {
2946 Unit::AuraApplicationMap const& auras = target->GetAppliedAuras();
2947 for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
2948 {
2949 if (Aura* aura = itr->second->GetBase())
2950 {
2951 SpellInfo const* auraInfo = aura->GetSpellInfo();
2952 if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN))
2953 {
2954 aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
2955 // Remove dummys from rider (Necessary for updating visual shields)
2956 if (Unit* rider = target->GetCharmer())
2957 if (Aura* defend = rider->GetAura(aura->GetId()))
2958 defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
2959 break;
2960 }
2961 }
2962 }
2963 break;
2964 }
2965 }
2966 }
bool roll_chance_f(float chance)
Definition: Random.h:53
@ UNIT_FLAG_DISABLE_MOVE
Definition: Unit.h:450
@ SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
Definition: SpellAuraDefines.h:150
@ AURA_REMOVE_BY_ENEMY_SPELL
Definition: SpellAuraDefines.h:394
@ SPELL_CHARGE_TRIGGER_FACTION_MOUNTS
Definition: spell_generic.cpp:2882
@ SPELL_CHARGE_TRIGGER_TRIAL_CHAMPION
Definition: spell_generic.cpp:2883
@ SPELL_CHARGE_MISS_EFFECT
Definition: spell_generic.cpp:2885
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ EFFECT_2
Definition: SharedDefines.h:32
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1299
Unit * GetCharmer() const
Definition: Unit.cpp:10568
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:1480
AuraApplicationMap & GetAppliedAuras()
Definition: Unit.h:1924
Definition: SpellAuras.h:87
Definition: SpellInfo.h:314
uint32 SpellIconID
Definition: SpellInfo.h:378

References AURA_REMOVE_BY_ENEMY_SPELL, Unit::CastSpell(), EFFECT_0, EFFECT_1, EFFECT_2, Unit::GetAppliedAuras(), SpellScript::GetCaster(), Unit::GetCharmer(), SpellScript::GetHitUnit(), SpellScript::GetSpellInfo(), Unit::HasUnitFlag(), roll_chance_f(), SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, SPELL_CHARGE_CHARGING_EFFECT_20K_1, SPELL_CHARGE_CHARGING_EFFECT_8K5, SPELL_CHARGE_MISS_EFFECT, SPELL_CHARGE_TRIGGER_FACTION_MOUNTS, SPELL_CHARGE_TRIGGER_TRIAL_CHAMPION, SpellInfo::SpellIconID, and UNIT_FLAG_DISABLE_MOVE.

Referenced by Register().

◆ PrepareSpellScript()

◆ Register()

void spell_gen_mounted_charge::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

2996 {
2997 SpellInfo const* spell = sSpellMgr->AssertSpellInfo(m_scriptSpellId);
2998
3001
3002 if (spell->Effects[EFFECT_0].Effect == SPELL_EFFECT_CHARGE)
3004 }
#define sSpellMgr
Definition: SpellMgr.h:818
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
#define EFFECT_FIRST_FOUND
Definition: SharedDefines.h:36
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:827
@ SPELL_EFFECT_CHARGE
Definition: SharedDefines.h:846
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:391
bool HasEffect(SpellEffects effect) const
Definition: SpellInfo.cpp:869
uint32 m_scriptSpellId
Definition: SpellScript.h:107
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
void HandleScriptEffect(SpellEffIndex effIndex)
Definition: spell_generic.cpp:2911
void HandleChargeEffect(SpellEffIndex)
Definition: spell_generic.cpp:2968

References EFFECT_0, EFFECT_FIRST_FOUND, SpellInfo::Effects, HandleChargeEffect(), HandleScriptEffect(), SpellInfo::HasEffect(), _SpellScript::m_scriptSpellId, SpellScript::OnEffectHitTarget, SPELL_EFFECT_CHARGE, SPELL_EFFECT_SCRIPT_EFFECT, SpellEffectFn, and sSpellMgr.