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

Private Member Functions

 PrepareSpellScript (spell_vehicle_throw_passenger)
 
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::HandleScript ( )
inlineprivate
1662 {
1663 Spell* baseSpell = GetSpell();
1664 SpellCastTargets targets = baseSpell->m_targets;
1665 if (Vehicle* vehicle = GetCaster()->GetVehicleKit())
1666 if (Unit* passenger = vehicle->GetPassenger(3))
1667 {
1668 // use 99 because it is 3d search
1669 std::list<WorldObject*> targetList;
1672 Cell::VisitAllObjects(GetCaster(), searcher, 99.0f);
1673 float minDist = 99 * 99;
1674 Unit* target = nullptr;
1675 for (std::list<WorldObject*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
1676 {
1677 if (Unit* unit = (*itr)->ToUnit())
1678 if (unit->GetEntry() == NPC_SEAT)
1679 if (Vehicle* seat = unit->GetVehicleKit())
1680 if (!seat->GetPassenger(0))
1681 if (Unit* device = seat->GetPassenger(2))
1682 if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
1683 {
1684 float dist = unit->GetExactDistSq(targets.GetDstPos());
1685 if (dist < minDist)
1686 {
1687 minDist = dist;
1688 target = unit;
1689 }
1690 }
1691 }
1692 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
1693 {
1694 passenger->ExitVehicle();
1695 passenger->EnterVehicle(target, 0);
1696 }
1697 else
1698 {
1699 passenger->ExitVehicle();
1700 float x, y, z;
1701 targets.GetDstPos()->GetPosition(x, y, z);
1702 passenger->GetMotionMaster()->MoveJump(x, y, z, targets.GetSpeedXY(), targets.GetSpeedZ());
1703 }
1704 }
1705 }
@ NPC_SEAT
Definition: boss_flame_leviathan.cpp:91
@ EFFECT_0
Definition: SharedDefines.h:31
@ TARGET_CHECK_DEFAULT
Definition: SpellInfo.h:114
@ CURRENT_CHANNELED_SPELL
Definition: Unit.h:539
Unit * ToUnit()
Definition: Object.h:209
bool IsWithinDist2d(float x, float y, float dist) const
Definition: Object.cpp:1316
void GetPosition(float &x, float &y) const
Definition: Position.h:121
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:169
Definition: Unit.h:630
void ExitVehicle(Position const *exitPosition=nullptr)
Definition: Unit.cpp:19735
Definition: Vehicle.h:28
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:206
Definition: GridNotifiers.h:239
Definition: Spell.h:111
float GetSpeedZ() const
Definition: Spell.h:177
float GetSpeedXY() const
Definition: Spell.h:176
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:401
Definition: Spell.h:287
SpellCastTargets m_targets
Definition: Spell.h:530
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().

Referenced by Register().

◆ PrepareSpellScript()

spell_vehicle_throw_passenger::PrepareSpellScript ( spell_vehicle_throw_passenger  )
private

◆ Register()

void spell_vehicle_throw_passenger::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

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

References HandleScript(), and SpellCastFn.