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)
 
bool Validate (SpellInfo const *) override
 
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 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
1390 {
1391 Vehicle* vehicle = GetCaster()->GetVehicleKit();
1392 Unit* passenger = vehicle ? vehicle->GetPassenger(3) : nullptr;
1393 if (!vehicle || !passenger)
1394 return;
1395
1396 // Find nearest unoccupied Flame Leviathan seat near trajectory destination
1397 Position const* dst = GetExplTargetDest();
1398 if (!dst)
1399 return;
1400
1401 constexpr float SEARCH_RADIUS = 99.0f;
1402
1403 std::list<WorldObject*> targetList;
1405 Acore::WorldObjectListSearcher searcher(GetCaster(), targetList, check);
1406 Cell::VisitObjects(GetCaster(), searcher, SEARCH_RADIUS);
1407
1408 Unit* seatTarget = nullptr;
1409 float minDist = SEARCH_RADIUS * SEARCH_RADIUS;
1410
1411 for (WorldObject* obj : targetList)
1412 {
1413 Unit* unit = obj->ToUnit();
1414 if (!unit || unit->GetEntry() != NPC_SEAT) continue;
1415
1416 Vehicle* seat = unit->GetVehicleKit();
1417 Unit* device = seat ? seat->GetPassenger(SEAT_DEVICE) : nullptr;
1418 if (!seat || seat->GetPassenger(0) || !device || device->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) continue;
1419
1420 float dist = unit->GetExactDistSq(dst);
1421 if (dist < minDist)
1422 {
1423 minDist = dist;
1424 seatTarget = unit;
1425 }
1426 }
1427
1428 // Launch passenger toward destination
1429 float x, y, z;
1430 dst->GetPosition(x, y, z);
1431 passenger->ExitVehicle();
1432 passenger->GetMotionMaster()->MoveJump(x, y, z, GetSpell()->m_targets.GetSpeedXY(), GetSpell()->m_targets.GetSpeedZ());
1433
1434 if (seatTarget && seatTarget->IsWithinDist2d(dst, GetSpellInfo()->Effects[EFFECT_0].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct
1435 passenger->CastCustomSpell(SPELL_HOOKSHOT_AURA, SPELLVALUE_AURA_DURATION, 5000, passenger, true);
1436 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELLVALUE_AURA_DURATION
Definition SpellDefines.h:119
@ TARGET_CHECK_DEFAULT
Definition SpellInfo.h:115
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:558
@ SPELL_HOOKSHOT_AURA
Definition boss_flame_leviathan.cpp:90
@ SEAT_DEVICE
Definition boss_flame_leviathan.cpp:168
@ NPC_SEAT
Definition boss_flame_leviathan.cpp:97
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=0)
Definition MotionMaster.h:256
uint32 GetEntry() const
Definition Object.h:117
Unit * ToUnit()
Definition Object.h:210
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 Unit.h:665
MotionMaster * GetMotionMaster()
Definition Unit.h:1758
SpellCastResult CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1418
Vehicle * GetVehicleKit() const
Definition Unit.h:1925
void ExitVehicle(Position const *exitPosition=nullptr)
Definition Unit.cpp:15705
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1577
Definition Vehicle.h:28
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:239
Definition Object.h:476
bool IsWithinDist2d(float x, float y, float dist) const
Definition Object.cpp:1359
Definition GridNotifiers.h:262
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165
Definition Position.h:27
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 Unit::CastCustomSpell(), CURRENT_CHANNELED_SPELL, EFFECT_0, Unit::ExitVehicle(), SpellScript::GetCaster(), Unit::GetCurrentSpell(), Object::GetEntry(), Position::GetExactDistSq(), SpellScript::GetExplTargetDest(), Unit::GetMotionMaster(), Vehicle::GetPassenger(), Position::GetPosition(), SpellCastTargets::GetSpeedXY(), SpellCastTargets::GetSpeedZ(), SpellScript::GetSpell(), SpellScript::GetSpellInfo(), Unit::GetVehicleKit(), WorldObject::IsWithinDist2d(), Spell::m_targets, MotionMaster::MoveJump(), NPC_SEAT, SEAT_DEVICE, SPELL_HOOKSHOT_AURA, SPELLVALUE_AURA_DURATION, 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.

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

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

◆ Validate()

bool spell_vehicle_throw_passenger::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

1385 {
1387 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition SpellScript.h:125

References SPELL_HOOKSHOT_AURA, and _SpellScript::ValidateSpellInfo().


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