TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
spell_vehicle_throw_passenger::spell_vehicle_throw_passenger_SpellScript Class Reference

Private Member Functions

 PrepareSpellScript (spell_vehicle_throw_passenger_SpellScript)
 
void HandleScript (SpellEffIndex effIndex)
 
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 constGetSpellInfo ()
 
SpellValue constGetSpellValue ()
 
SpellEffectInfo constGetEffectInfo (SpellEffIndex) const
 
WorldLocation constGetExplTargetDest ()
 
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)
 
SpellEffectInfo constGetEffectInfo () const
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
ItemGetCastItem ()
 
void CreateItem (uint32 effIndex, uint32 itemId)
 
SpellInfo constGetTriggeringSpell ()
 
void FinishCast (SpellCastResult result)
 
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 ()
 
- Public Attributes inherited from SpellScript
HookList< CastHandlerBeforeCast
 
HookList< CastHandlerOnCast
 
HookList< CastHandlerAfterCast
 
HookList< CheckCastHandlerOnCheckCast
 
HookList< EffectHandlerOnEffectLaunch
 
HookList< EffectHandlerOnEffectLaunchTarget
 
HookList< EffectHandlerOnEffectHit
 
HookList< EffectHandlerOnEffectHitTarget
 
HookList< EffectHandlerOnEffectSuccessfulDispel
 
HookList< HitHandlerBeforeHit
 
HookList< HitHandlerOnHit
 
HookList< HitHandlerAfterHit
 
HookList
< ObjectAreaTargetSelectHandler
OnObjectAreaTargetSelect
 
HookList
< ObjectTargetSelectHandler
OnObjectTargetSelect
 
HookList
< DestinationTargetSelectHandler
OnDestinationTargetSelect
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string constm_scriptName
 
uint32 m_scriptSpellId
 

Member Function Documentation

void spell_vehicle_throw_passenger::spell_vehicle_throw_passenger_SpellScript::HandleScript ( SpellEffIndex  effIndex)
inlineprivate
1734  {
1735  Spell* baseSpell = GetSpell();
1736  SpellCastTargets targets = baseSpell->m_targets;
1737  int32 damage = GetEffectValue();
1738  if (targets.HasTraj())
1739  if (Vehicle* vehicle = GetCaster()->GetVehicleKit())
1740  if (Unit* passenger = vehicle->GetPassenger(damage - 1))
1741  {
1742  // use 99 because it is 3d search
1743  std::list<WorldObject*> targetList;
1746  GetCaster()->GetMap()->VisitAll(GetCaster()->m_positionX, GetCaster()->m_positionY, 99, searcher);
1747  float minDist = 99 * 99;
1748  Unit* target = NULL;
1749  for (std::list<WorldObject*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
1750  {
1751  if (Unit* unit = (*itr)->ToUnit())
1752  if (unit->GetEntry() == NPC_SEAT)
1753  if (Vehicle* seat = unit->GetVehicleKit())
1754  if (!seat->GetPassenger(0))
1755  if (Unit* device = seat->GetPassenger(2))
1756  if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
1757  {
1758  float dist = unit->GetExactDistSq(targets.GetDstPos());
1759  if (dist < minDist)
1760  {
1761  minDist = dist;
1762  target = unit;
1763  }
1764  }
1765  }
1766  if (target && target->IsWithinDist2d(targets.GetDstPos(), GetSpellInfo()->GetEffect(effIndex)->CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct
1767  passenger->EnterVehicle(target, 0);
1768  else
1769  {
1770  passenger->ExitVehicle();
1771  passenger->GetMotionMaster()->MoveJump(*targets.GetDstPos(), targets.GetSpeedXY(), targets.GetSpeedZ());
1772  }
1773  }
1774  }
Definition: Vehicle.h:32
Map * GetMap() const
Definition: Object.h:543
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: boss_flame_leviathan.cpp:88
Definition: Unit.h:1110
arena_t NULL
Definition: jemalloc_internal.h:624
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
bool IsWithinDist2d(float x, float y, float dist) const
Definition: Object.cpp:1648
Definition: SpellInfo.h:120
WorldLocation const * GetExplTargetDest()
Definition: SpellScript.cpp:409
bool HasTraj() const
Definition: Spell.h:230
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
Definition: SpellInfo.cpp:655
Spell * GetSpell()
Definition: SpellScript.h:403
int32_t int32
Definition: Define.h:146
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:404
void VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
Definition: Map.h:826
Definition: Spell.h:170
SpellEffectInfo const * GetEffect(uint32 difficulty, uint32 index) const
Definition: SpellInfo.cpp:3348
Unit * GetCaster()
Definition: SpellScript.cpp:394
float GetSpeedZ() const
Definition: Spell.h:239
int32 GetEffectValue() const
Definition: SpellScript.cpp:600
float GetSpeedXY() const
Definition: Spell.h:238
T check(T value)
Definition: format.h:305
Definition: Unit.h:1305
Definition: GridNotifiers.h:218
Unit * ToUnit()
Definition: Object.h:197
void EnterVehicle(Unit *base, int8 seatId=-1)
Definition: Unit.cpp:15249
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

spell_vehicle_throw_passenger::spell_vehicle_throw_passenger_SpellScript::PrepareSpellScript ( spell_vehicle_throw_passenger_SpellScript  )
private
void spell_vehicle_throw_passenger::spell_vehicle_throw_passenger_SpellScript::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

1777  {
1779  }
Definition: SharedDefines.h:28
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:297
void HandleScript(SpellEffIndex effIndex)
Definition: boss_flame_leviathan.cpp:1733
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:295
Definition: SharedDefines.h:1013

+ Here is the call graph for this function:


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