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

◆ HandleScript()

void spell_vehicle_throw_passenger::HandleScript ( )
inlineprivate
1504 {
1505 Vehicle* vehicle = GetCaster()->GetVehicleKit();
1506 Unit* passenger = vehicle ? vehicle->GetPassenger(3) : nullptr;
1507 if (!vehicle || !passenger)
1508 return;
1509
1510 // Find nearest unoccupied Flame Leviathan seat near trajectory destination
1511 Position const* dst = GetExplTargetDest();
1512 if (!dst)
1513 return;
1514
1515 constexpr float SEARCH_RADIUS = 99.0f;
1516
1517 std::list<WorldObject*> targetList;
1519 Acore::WorldObjectListSearcher searcher(GetCaster(), targetList, check);
1520 Cell::VisitObjects(GetCaster(), searcher, SEARCH_RADIUS);
1521
1522 Unit* seatTarget = nullptr;
1523 float minDist = SEARCH_RADIUS * SEARCH_RADIUS;
1524
1525 for (WorldObject* obj : targetList)
1526 {
1527 Unit* unit = obj->ToUnit();
1528 if (!unit || unit->GetEntry() != NPC_SEAT) continue;
1529
1530 Vehicle* seat = unit->GetVehicleKit();
1531 Unit* device = seat ? seat->GetPassenger(SEAT_DEVICE) : nullptr;
1532 if (!seat || seat->GetPassenger(0) || !device || device->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) continue;
1533
1534 float dist = unit->GetExactDistSq(dst);
1535 if (dist < minDist)
1536 {
1537 minDist = dist;
1538 seatTarget = unit;
1539 }
1540 }
1541
1542 // Launch passenger toward destination
1543 float x, y, z;
1544 dst->GetPosition(x, y, z);
1545 passenger->ExitVehicle();
1546 passenger->GetMotionMaster()->MoveJump(x, y, z, GetSpell()->m_targets.GetSpeedXY(), GetSpell()->m_targets.GetSpeedZ());
1547
1548 if (seatTarget && seatTarget->IsWithinDist2d(dst, GetSpellInfo()->Effects[EFFECT_0].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct
1549 passenger->CastCustomSpell(SPELL_HOOKSHOT_AURA, SPELLVALUE_AURA_DURATION, 5000, passenger, true);
1550 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELLVALUE_AURA_DURATION
Definition SpellDefines.h:127
@ TARGET_CHECK_DEFAULT
Definition SpellInfo.h:115
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:558
@ SPELL_HOOKSHOT_AURA
Definition boss_flame_leviathan.cpp:92
@ SEAT_DEVICE
Definition boss_flame_leviathan.cpp:170
@ NPC_SEAT
Definition boss_flame_leviathan.cpp:99
void MoveJump(Position const &pos, float speedXY, float speedZ, uint32 id=0)
Definition MotionMaster.h:257
uint32 GetEntry() const
Definition Object.h:123
Unit * ToUnit()
Definition Object.h:216
WorldLocation const * GetExplTargetDest()
Definition SpellScript.cpp:421
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:416
Spell * GetSpell()
Definition SpellScript.h:443
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:665
MotionMaster * GetMotionMaster()
Definition Unit.h:1761
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:1429
Vehicle * GetVehicleKit() const
Definition Unit.h:1931
void ExitVehicle(Position const *exitPosition=nullptr)
Definition Unit.cpp:15315
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1581
Definition Vehicle.h:28
Unit * GetPassenger(int8 seatId) const
Definition Vehicle.cpp:253
Definition Object.h:482
bool IsWithinDist2d(float x, float y, float dist) const
Definition Object.cpp:1364
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.

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

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

◆ Validate()

bool spell_vehicle_throw_passenger::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

1499 {
1501 }
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: