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

Private Member Functions

 PrepareSpellScript (spell_vehicle_throw_passenger_SpellScript)
 
void HandleScript ()
 
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

◆ HandleScript()

void spell_vehicle_throw_passenger::spell_vehicle_throw_passenger_SpellScript::HandleScript ( )
inlineprivate
1687 {
1688 Spell* baseSpell = GetSpell();
1689 SpellCastTargets targets = baseSpell->m_targets;
1690 if (Vehicle* vehicle = GetCaster()->GetVehicleKit())
1691 if (Unit* passenger = vehicle->GetPassenger(3))
1692 {
1693 // use 99 because it is 3d search
1694 std::list<WorldObject*> targetList;
1697 Cell::VisitAllObjects(GetCaster(), searcher, 99.0f);
1698 float minDist = 99 * 99;
1699 Unit* target = nullptr;
1700 for (std::list<WorldObject*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
1701 {
1702 if (Unit* unit = (*itr)->ToUnit())
1703 if (unit->GetEntry() == NPC_SEAT)
1704 if (Vehicle* seat = unit->GetVehicleKit())
1705 if (!seat->GetPassenger(0))
1706 if (Unit* device = seat->GetPassenger(2))
1707 if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
1708 {
1709 float dist = unit->GetExactDistSq(targets.GetDstPos());
1710 if (dist < minDist)
1711 {
1712 minDist = dist;
1713 target = unit;
1714 }
1715 }
1716 }
1717 if (target && target->IsWithinDist2d(targets.GetDstPos(), GetSpellInfo()->Effects[EFFECT_0].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct
1718 {
1719 passenger->ExitVehicle();
1720 passenger->EnterVehicle(target, 0);
1721 }
1722 else
1723 {
1724 passenger->ExitVehicle();
1725 float x, y, z;
1726 targets.GetDstPos()->GetPosition(x, y, z);
1727 passenger->GetMotionMaster()->MoveJump(x, y, z, targets.GetSpeedXY(), targets.GetSpeedZ());
1728 }
1729 }
1730 }
@ CURRENT_CHANNELED_SPELL
Definition: Unit.h:980
@ TARGET_CHECK_DEFAULT
Definition: SpellInfo.h:114
@ NPC_SEAT
Definition: boss_flame_leviathan.cpp:83
@ EFFECT_0
Definition: SharedDefines.h:30
Unit * ToUnit()
Definition: Object.h:200
bool IsWithinDist2d(float x, float y, float dist) const
Definition: Object.cpp:1305
void GetPosition(float &x, float &y) const
Definition: Position.h:122
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:170
Definition: Unit.h:1290
void ExitVehicle(Position const *exitPosition=nullptr)
Definition: Unit.cpp:19896
Definition: Vehicle.h:30
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:207
Definition: GridNotifiers.h:236
Definition: Spell.h:109
float GetSpeedZ() const
Definition: Spell.h:175
float GetSpeedXY() const
Definition: Spell.h:174
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:395
Definition: Spell.h:284
SpellCastTargets m_targets
Definition: Spell.h:527
WorldLocation const * GetExplTargetDest()
Definition: SpellScript.cpp:416
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
Spell * GetSpell()
Definition: SpellScript.h:442
Unit * GetCaster()
Definition: SpellScript.cpp:401

References CURRENT_CHANNELED_SPELL, EFFECT_0, Unit::ExitVehicle(), SpellCastTargets::GetDstPos(), Position::GetExactDistSq(), Position::GetPosition(), SpellCastTargets::GetSpeedXY(), SpellCastTargets::GetSpeedZ(), WorldObject::IsWithinDist2d(), Spell::m_targets, NPC_SEAT, TARGET_CHECK_DEFAULT, Object::ToUnit(), and Cell::VisitAllObjects().

◆ PrepareSpellScript()

spell_vehicle_throw_passenger::spell_vehicle_throw_passenger_SpellScript::PrepareSpellScript ( spell_vehicle_throw_passenger_SpellScript  )
private

◆ Register()

void spell_vehicle_throw_passenger::spell_vehicle_throw_passenger_SpellScript::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1733 {
1735 }
#define SpellCastFn(F)
Definition: SpellScript.h:324
HookList< CastHandler > AfterCast
Definition: SpellScript.h:323
void HandleScript()
Definition: boss_flame_leviathan.cpp:1686

References SpellCastFn.