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
 
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 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< 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

◆ HandleChargeEffect()

void spell_gen_mounted_charge::HandleChargeEffect ( SpellEffIndex  )
inlineprivate
3205 {
3206 uint32 spellId;
3207
3208 switch (GetSpellInfo()->Id)
3209 {
3211 spellId = SPELL_CHARGE_DAMAGE_8K5;
3212 break;
3215 spellId = SPELL_CHARGE_DAMAGE_20K;
3216 break;
3219 spellId = SPELL_CHARGE_DAMAGE_45K;
3220 break;
3221 default:
3222 return;
3223 }
3224
3225 if (Unit* rider = GetCaster()->GetCharmer())
3226 rider->CastSpell(GetHitUnit(), spellId, false);
3227 else
3228 GetCaster()->CastSpell(GetHitUnit(), spellId, false);
3229 }
std::uint32_t uint32
Definition Define.h:107
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:416
Unit * GetHitUnit()
Definition SpellScript.cpp:453
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:667
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:1372
@ SPELL_CHARGE_CHARGING_EFFECT_8K5
Definition spell_generic.cpp:3112
@ SPELL_CHARGE_CHARGING_EFFECT_20K_2
Definition spell_generic.cpp:3114
@ SPELL_CHARGE_DAMAGE_45K
Definition spell_generic.cpp:3110
@ SPELL_CHARGE_CHARGING_EFFECT_20K_1
Definition spell_generic.cpp:3113
@ SPELL_CHARGE_DAMAGE_8K5
Definition spell_generic.cpp:3108
@ SPELL_CHARGE_CHARGING_EFFECT_45K_1
Definition spell_generic.cpp:3115
@ SPELL_CHARGE_DAMAGE_20K
Definition spell_generic.cpp:3109
@ SPELL_CHARGE_CHARGING_EFFECT_45K_2
Definition spell_generic.cpp:3116

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
3148 {
3149 Unit* target = GetHitUnit();
3150
3151 switch (effIndex)
3152 {
3153 case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual)
3154 {
3155 uint32 spellId;
3156
3157 switch (GetSpellInfo()->Id)
3158 {
3161 break;
3164 break;
3165 default:
3166 return;
3167 }
3168
3169 // If target isn't a training dummy there's a chance of failing the charge
3170 if (!target->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE) && roll_chance_f(12.5f))
3171 spellId = SPELL_CHARGE_MISS_EFFECT;
3172
3173 if (Unit* vehicle = GetCaster()->GetVehicleBase())
3174 vehicle->CastSpell(target, spellId, false);
3175 else
3176 GetCaster()->CastSpell(target, spellId, false);
3177 break;
3178 }
3179 case EFFECT_1: // On damaging spells, for removing a defend layer
3180 case EFFECT_2:
3181 {
3182 Unit::AuraApplicationMap const& auras = target->GetAppliedAuras();
3183 for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
3184 {
3185 if (Aura* aura = itr->second->GetBase())
3186 {
3187 SpellInfo const* auraInfo = aura->GetSpellInfo();
3188 if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN))
3189 {
3190 aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
3191 // Remove dummys from rider (Necessary for updating visual shields)
3192 if (Unit* rider = target->GetCharmer())
3193 if (Aura* defend = rider->GetAura(aura->GetId()))
3194 defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
3195 break;
3196 }
3197 }
3198 }
3199 break;
3200 }
3201 }
3202 }
bool roll_chance_f(float chance)
Definition Random.h:57
@ EFFECT_1
Definition SharedDefines.h:32
@ EFFECT_0
Definition SharedDefines.h:31
@ EFFECT_2
Definition SharedDefines.h:33
@ SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
Definition SpellAuraDefines.h:150
@ AURA_REMOVE_BY_ENEMY_SPELL
Definition SpellAuraDefines.h:394
@ UNIT_FLAG_DISABLE_MOVE
Definition UnitDefines.h:259
Definition SpellAuras.h:88
Definition SpellInfo.h:340
uint32 SpellIconID
Definition SpellInfo.h:404
Unit * GetCharmer() const
Definition Unit.cpp:7495
bool HasUnitFlag(UnitFlags flags) const
Definition Unit.h:750
boost::container::flat_multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:676
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:1391
@ SPELL_CHARGE_TRIGGER_FACTION_MOUNTS
Definition spell_generic.cpp:3118
@ SPELL_CHARGE_TRIGGER_TRIAL_CHAMPION
Definition spell_generic.cpp:3119
@ SPELL_CHARGE_MISS_EFFECT
Definition spell_generic.cpp:3121

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.

3232 {
3233 SpellInfo const* spell = sSpellMgr->AssertSpellInfo(m_scriptSpellId);
3234
3237
3238 if (spell->Effects[EFFECT_0].Effect == SPELL_EFFECT_CHARGE)
3240 }
#define EFFECT_FIRST_FOUND
Definition SharedDefines.h:37
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:843
@ SPELL_EFFECT_CHARGE
Definition SharedDefines.h:862
#define sSpellMgr
Definition SpellMgr.h:847
#define SpellEffectFn(F, I, N)
Definition SpellScript.h:337
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417
bool HasEffect(SpellEffects effect) const
Definition SpellInfo.cpp:889
HookList< EffectHandler > OnEffectHitTarget
Definition SpellScript.h:336
uint32 m_scriptSpellId
Definition SpellScript.h:107
void HandleScriptEffect(SpellEffIndex effIndex)
Definition spell_generic.cpp:3147
void HandleChargeEffect(SpellEffIndex)
Definition spell_generic.cpp:3204

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.


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