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 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
 
- 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
1366 {
1367 Spell* baseSpell = GetSpell();
1368 SpellCastTargets targets = baseSpell->m_targets;
1369 if (Vehicle* vehicle = GetCaster()->GetVehicleKit())
1370 if (Unit* passenger = vehicle->GetPassenger(3))
1371 {
1372 // use 99 because it is 3d search
1373 std::list<WorldObject*> targetList;
1376 Cell::VisitObjects(GetCaster(), searcher, 99.0f);
1377 float minDist = 99 * 99;
1378 Unit* target = nullptr;
1379 for (std::list<WorldObject*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
1380 {
1381 if (Unit* unit = (*itr)->ToUnit())
1382 if (unit->GetEntry() == NPC_SEAT)
1383 if (Vehicle* seat = unit->GetVehicleKit())
1384 if (!seat->GetPassenger(0))
1385 if (Unit* device = seat->GetPassenger(2))
1386 if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
1387 {
1388 float dist = unit->GetExactDistSq(targets.GetDstPos());
1389 if (dist < minDist)
1390 {
1391 minDist = dist;
1392 target = unit;
1393 }
1394 }
1395 }
1396 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
1397 {
1398 passenger->ExitVehicle();
1399 passenger->EnterVehicle(target, 0);
1400 }
1401 else
1402 {
1403 passenger->ExitVehicle();
1404 float x, y, z;
1405 targets.GetDstPos()->GetPosition(x, y, z);
1406 passenger->GetMotionMaster()->MoveJump(x, y, z, targets.GetSpeedXY(), targets.GetSpeedZ());
1407 }
1408 }
1409 }
@ EFFECT_0
Definition SharedDefines.h:31
@ TARGET_CHECK_DEFAULT
Definition SpellInfo.h:115
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:557
@ NPC_SEAT
Definition boss_flame_leviathan.cpp:92
Unit * ToUnit()
Definition Object.h:210
Definition Spell.h:121
float GetSpeedZ() const
Definition Spell.h:187
float GetSpeedXY() const
Definition Spell.h:186
WorldLocation const * GetDstPos() const
Definition Spell.cpp:400
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
Definition Spell.h:298
SpellCastTargets m_targets
Definition Spell.h:542
Definition Unit.h:664
void ExitVehicle(Position const *exitPosition=nullptr)
Definition Unit.cpp:15674
Definition Vehicle.h:28
bool IsWithinDist2d(float x, float y, float dist) const
Definition Object.cpp:1355
Definition GridNotifiers.h:230
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165
void GetPosition(float &x, float &y) const
Definition Position.h:126
float GetExactDistSq(float x, float y, float z) const
Definition Position.h:174

References CURRENT_CHANNELED_SPELL, EFFECT_0, Unit::ExitVehicle(), SpellScript::GetCaster(), SpellCastTargets::GetDstPos(), Position::GetExactDistSq(), SpellScript::GetExplTargetDest(), Position::GetPosition(), SpellCastTargets::GetSpeedXY(), SpellCastTargets::GetSpeedZ(), SpellScript::GetSpell(), SpellScript::GetSpellInfo(), WorldObject::IsWithinDist2d(), Spell::m_targets, NPC_SEAT, TARGET_CHECK_DEFAULT, Object::ToUnit(), and Cell::VisitObjects().

Referenced by Register().

◆ PrepareSpellScript()

spell_vehicle_throw_passenger::PrepareSpellScript ( spell_vehicle_throw_passenger  )
private

◆ Register()

void spell_vehicle_throw_passenger::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

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

References SpellScript::AfterCast, HandleScript(), and SpellCastFn.


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