AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
npc_escortAI Struct Referenceabstract

#include "ScriptedEscortAI.h"

Inheritance diagram for npc_escortAI:
ScriptedAI CreatureAI UnitAI boss_bjarngrim::boss_bjarngrimAI boss_grand_champion::boss_grand_championAI boss_thorim_lightning_orb::boss_thorim_lightning_orbAI boss_thorim_sif_blizzard::boss_thorim_sif_blizzardAI boss_yoggsaron_cloud::boss_yoggsaron_cloudAI brann_bronzebeard::brann_bronzebeardAI npc_ame::npc_ameAI npc_ancestral_wolf::npc_ancestral_wolfAI npc_apothecary_hanes::npc_Apothecary_HanesAI npc_argent_soldier::npc_argent_soldierAI npc_arthas::npc_arthasAI npc_azure_saboteur::npc_azure_saboteurAI npc_barnes::npc_barnesAI npc_bessy::npc_bessyAI npc_black_knight_skeletal_gryphon::npc_black_knight_skeletal_gryphonAI npc_bonker_togglevolt::npc_bonker_togglevoltAI npc_captain_saeed::npc_captain_saeedAI npc_clintar_spirit::npc_clintar_spiritAI npc_cork_gizelton::npc_cork_gizeltonAI npc_corporal_keeshan::npc_corporal_keeshanAI npc_crok_scourgebane::npc_crok_scourgebaneAI npc_custodian_of_time::npc_custodian_of_timeAI npc_daphne_stilwell::npc_daphne_stilwellAI npc_deathstalker_erland::npc_deathstalker_erlandAI npc_emily::npc_emilyAI npc_engineer_helice::npc_engineer_heliceAI npc_frosthound::npc_frosthoundAI npc_garments_of_quests::npc_garments_of_questsAI npc_general_andorov npc_gilthares::npc_giltharesAI npc_grimstone::npc_grimstoneAI npc_icefang::npc_icefangAI npc_isla_starmane::npc_isla_starmaneAI npc_kaya_flathoof::npc_kaya_flathoofAI npc_koltira_deathweaver::npc_koltira_deathweaverAI npc_kservant::npc_kservantAI npc_kurenai_captive::npc_kurenai_captiveAI npc_lakota_windsong::npc_lakota_windsongAI npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI npc_lurgglbr::npc_lurgglbrAI npc_maghar_captive::npc_maghar_captiveAI npc_magwin::npc_magwinAI npc_maxx_a_million_escort::npc_maxx_a_million_escortAI npc_mimirons_inferno::npc_mimirons_infernoAI npc_mootoo_the_younger::npc_mootoo_the_youngerAI npc_muglash::npc_muglashAI npc_onyx_flamecaller::npc_onyx_flamecallerAI npc_paoka_swiftmountain::npc_paoka_swiftmountainAI npc_plaguehound_tracker::npc_plaguehound_trackerAI npc_professor_phizzlethorpe::npc_professor_phizzlethorpeAI npc_prospector_remtravel::npc_prospector_remtravelAI npc_ranger_lilatha npc_ranshalla::npc_ranshallaAI npc_rinji::npc_rinjiAI npc_rocknot::npc_rocknotAI npc_scarlet_miner::npc_scarlet_minerAI npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI npc_taretha::npc_tarethaAI npc_thrall_bfu::npc_thrall_bfuAI npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI npc_time_lost_proto_drake::npc_time_lost_proto_drakeAI npc_tirions_gambit_tirion::npc_tirions_gambit_tirionAI npc_tyrion_spybot::npc_tyrion_spybotAI npc_varian_wrynn::npc_varian_wrynnAI npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI npc_wounded_blood_elf::npc_wounded_blood_elfAI violet_hold_trashAI

Public Member Functions

 npc_escortAI (Creature *creature)
 
 ~npc_escortAI () override
 
void AttackStart (Unit *who) override
 
void MoveInLineOfSight (Unit *who) override
 
void JustDied (Unit *) override
 
void JustRespawned () override
 
void ReturnToLastPoint ()
 
void EnterEvadeMode (EvadeReason=EVADE_REASON_OTHER) override
 
void UpdateAI (uint32 diff) override
 Use to start attacking a target. Called just before JustEngagedWith() More...
 
virtual void UpdateEscortAI (uint32 diff)
 
void MovementInform (uint32, uint32) override
 
void AddWaypoint (uint32 id, float x, float y, float z, uint32 waitTime=0)
 
bool SetNextWaypoint (uint32 pointId, float x, float y, float z, float orientation)
 
bool SetNextWaypoint (uint32 pointId, bool setPosition=true)
 
bool GetWaypointPosition (uint32 pointId, float &x, float &y, float &z)
 
void GenerateWaypointArray (Movement::PointsArray *points)
 
virtual void WaypointReached (uint32 pointId)=0
 
virtual void WaypointStart (uint32)
 
void Start (bool isActiveAttacker=true, bool run=false, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false, bool resetWaypoints=true)
 
void SetRun (bool on=true)
 
void SetEscortPaused (bool on)
 
bool HasEscortState (uint32 escortState)
 
bool IsEscorted () override
 
void SetMaxPlayerDistance (float newMax)
 
float GetMaxPlayerDistance ()
 
void SetDespawnAtEnd (bool despawn)
 
void SetDespawnAtFar (bool despawn)
 
bool GetAttack ()
 
void SetCanAttack (bool attack)
 
ObjectGuid GetEventStarterGUID ()
 
void AddEscortState (uint32 escortState)
 
void RemoveEscortState (uint32 escortState)
 
- Public Member Functions inherited from ScriptedAI
 ScriptedAI (Creature *creature)
 
 ~ScriptedAI () override
 
void AttackStartNoMove (Unit *target)
 
void DamageTaken (Unit *, uint32 &, DamageEffectType, SpellSchoolMask) override
 Called at any Damage from any attacker (before damage apply) More...
 
void UpdateAI (uint32 diff) override
 Use to start attacking a target. Called just before JustEngagedWith() More...
 
void JustDied (Unit *) override
 
void KilledUnit (Unit *) override
 
void JustSummoned (Creature *) override
 
void SummonedCreatureDespawn (Creature *) override
 
void SpellHit (Unit *, SpellInfo const *) override
 
void SpellHitTarget (Unit *, SpellInfo const *) override
 
void MovementInform (uint32, uint32) override
 
void OnPossess (bool)
 
bool IsInRoom (const Position *pos, Axis axis, bool above)
 
void Reset () override
 
void JustEngagedWith (Unit *) override
 Called for reaction when initially engaged. More...
 
void AttackStart (Unit *) override
 
void DoStartMovement (Unit *target, float distance=0.0f, float angle=0.0f)
 
void DoStartNoMovement (Unit *target)
 
void DoStopAttack ()
 
void DoCastSpell (Unit *target, SpellInfo const *spellInfo, bool triggered=false)
 
void DoPlaySoundToSet (WorldObject *source, uint32 soundId)
 
void DoPlayMusic (uint32 soundId, bool zone)
 
void DoAddThreat (Unit *unit, float amount)
 
void DoModifyThreatByPercent (Unit *unit, int32 pct)
 
void DoResetThreat (Unit *unit)
 
void DoResetThreatList ()
 
float DoGetThreat (Unit *unit)
 
void DoTeleportPlayer (Unit *unit, float x, float y, float z, float o)
 
void DoTeleportPlayer (Unit *unit, Position pos)
 
void DoTeleportAll (float x, float y, float z, float o)
 
UnitDoSelectLowestHpFriendly (float range, uint32 minHPDiff=1)
 
std::list< Creature * > DoFindFriendlyCC (float range)
 
std::list< Creature * > DoFindFriendlyMissingBuff (float range, uint32 spellId)
 
PlayerGetPlayerAtMinimumRange (float minRange)
 
CreatureDoSpawnCreature (uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
 
bool IsUniqueTimedEventDone (uint32 id) const
 
void SetUniqueTimedEventDone (uint32 id)
 
void ResetUniqueTimedEvent (uint32 id)
 
void ClearUniqueTimedEventsDone ()
 
void ScheduleTimedEvent (Milliseconds timerMin, Milliseconds timerMax, std::function< void()> exec, Milliseconds repeatMin, Milliseconds repeatMax=0s, uint32 uniqueId=0)
 
void ScheduleTimedEvent (Milliseconds timerMax, std::function< void()> exec, Milliseconds repeatMin, Milliseconds repeatMax=0s, uint32 uniqueId=0)
 
void ScheduleUniqueTimedEvent (Milliseconds timer, std::function< void()> exec, uint32 uniqueId)
 
bool HealthBelowPct (uint32 pct) const
 
bool HealthAbovePct (uint32 pct) const
 
SpellInfo const * SelectSpell (Unit *target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effect)
 
void SetEquipmentSlots (bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
 
virtual bool CheckEvadeIfOutOfCombatArea () const
 
bool IsHeroic () const
 
Difficulty GetDifficulty () const
 
bool Is25ManRaid () const
 
template<class T >
const T & DUNGEON_MODE (const T &normal5, const T &heroic10) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25, const T &heroic10, const T &heroic25) const
 
PlayerSelectTargetFromPlayerList (float maxdist, uint32 excludeAura=0, bool mustBeInLOS=false) const
 
- Public Member Functions inherited from CreatureAI
void Talk (uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0s)
 Causes the creature to talk/say the text assigned to their entry in the creature_text database table. More...
 
void Talk (uint8 id, Milliseconds delay)
 
 CreatureAI (Creature *creature)
 
 ~CreatureAI () override
 
void MoveCircleChecks ()
 
void MoveBackwardsChecks ()
 
void MoveInLineOfSight_Safe (Unit *who)
 == Reactions At ================================= More...
 
void TriggerAlert (Unit const *who) const
 
virtual bool CanRespawn ()
 
virtual void EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
virtual void JustEngagedWith (Unit *)
 Called for reaction when initially engaged. More...
 
virtual void JustDied (Unit *)
 
virtual void KilledUnit (Unit *)
 
virtual void JustSummoned (Creature *)
 
virtual void IsSummonedBy (WorldObject *)
 
virtual void SummonedCreatureDespawn (Creature *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void SummonedCreatureDespawnAll ()
 
virtual void SummonedCreatureEvade (Creature *)
 
virtual void SpellHit (Unit *, SpellInfo const *)
 
virtual void SpellHitTarget (Unit *, SpellInfo const *)
 
virtual void AttackedBy (Unit *)
 
virtual bool IsEscorted ()
 
virtual void JustRespawned ()
 
virtual void MovementInform (uint32, uint32)
 
virtual void PathEndReached (uint32)
 
void OnCharmed (bool apply) override
 Called when unit is charmed. More...
 
virtual void JustReachedHome ()
 
void DoZoneInCombat (Creature *creature=nullptr, float maxRangeToNearestTarget=250.0f)
 
virtual void ReceiveEmote (Player *, uint32)
 
virtual void OwnerAttackedBy (Unit *)
 
virtual void OwnerAttacked (Unit *)
 
virtual void CorpseRemoved (uint32 &)
 == Triggered Actions Requested ================== More...
 
virtual void PassengerBoarded (Unit *, int8, bool)
 == Fields ======================================= More...
 
virtual bool BeforeSpellClick (Unit *)
 
virtual void OnSpellClick (Unit *, bool &)
 
virtual bool CanSeeAlways (WorldObject const *)
 
virtual bool CanBeSeen (Player const *)
 
virtual bool CanAlwaysBeDetectable (WorldObject const *)
 
virtual void PetStopAttack ()
 
virtual bool CheckInRoom ()
 
CreatureBoundary const * GetBoundary () const
 
void SetBoundary (CreatureBoundary const *boundary, bool negativeBoundaries=false)
 
bool IsInBoundary (Position const *who=nullptr) const
 
virtual void CalculateThreat (Unit *, float &, SpellInfo const *)
 
virtual bool OnTeleportUnreacheablePlayer (Player *)
 
virtual void OnAuraRemove (AuraApplication *, AuraRemoveMode)
 
- Public Member Functions inherited from UnitAI
 UnitAI (Unit *unit)
 
virtual ~UnitAI ()
 
virtual bool CanAIAttack (Unit const *) const
 
virtual void AttackStart (Unit *)
 
virtual void UpdateAI (uint32)=0
 Use to start attacking a target. Called just before JustEngagedWith() More...
 
virtual void InitializeAI ()
 
virtual void Reset ()
 
virtual void OnCharmed (bool apply)=0
 Called when unit is charmed. More...
 
virtual void DoAction (int32)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void SetGUID (ObjectGuid, int32=0)
 
virtual ObjectGuid GetGUID (int32=0) const
 
UnitSelectTarget (SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
 
template<class PREDICATE >
UnitSelectTarget (SelectTargetMethod targetType, uint32 position, PREDICATE const &predicate)
 
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
 Select the best (up to) <num> targets (in <targetType> order) from the threat list that fulfill the following: More...
 
template<class PREDICATE >
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 position, PREDICATE const &predicate)
 
virtual void JustEnteredCombat (Unit *)
 Called when the unit enters combat. More...
 
virtual void JustExitedCombat ()
 Called when the unit leaves combat. More...
 
virtual void DamageDealt (Unit *, uint32 &, DamageEffectType)
 Called at any Damage to any victim (before damage apply) More...
 
virtual void DamageTaken (Unit *, uint32 &, DamageEffectType, SpellSchoolMask)
 Called at any Damage from any attacker (before damage apply) More...
 
virtual void HealReceived (Unit *, uint32 &)
 Called when the creature receives heal. More...
 
virtual void OnPowerUpdate (Powers, int32, int32, uint32)
 Called when the creature power updates. More...
 
virtual void HealDone (Unit *, uint32 &)
 Called when the unit heals. More...
 
virtual void OnCalculateMeleeDamageReceived (uint32 &, Unit *)
 Called during damage calculations. More...
 
virtual void OnCalculateSpellDamageReceived (int32 &, Unit *)
 
virtual void OnCalculatePeriodicTickReceived (uint32 &, Unit *)
 Called during calculation when receiving periodic healing or damage (DoT or HoT) More...
 
void AttackStartCaster (Unit *victim, float dist)
 
SpellCastResult DoAddAuraToAllHostilePlayers (uint32 spellid)
 
SpellCastResult DoCast (uint32 spellId)
 
SpellCastResult DoCast (Unit *victim, uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastSelf (uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastToAllHostilePlayers (uint32 spellid, bool triggered=false)
 To specify the caster as target if the spell is self-cast. More...
 
SpellCastResult DoCastVictim (uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastAOE (uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastRandomTarget (uint32 spellId, uint32 threatTablePosition=0, float dist=0.0f, bool playerOnly=true, bool triggered=false, bool withTank=true)
 Cast the spell on a random unit from the threat list. More...
 
SpellCastResult DoCastMaxThreat (uint32 spellId, uint32 threatTablePosition=0, float dist=0.0f, bool playerOnly=true, bool triggered=false)
 Cast spell on the top threat target, which may not be the current victim. More...
 
float DoGetSpellMaxRange (uint32 spellId, bool positive=false)
 
void DoMeleeAttackIfReady ()
 
bool DoSpellAttackIfReady (uint32 spell)
 
void DoSpellAttackToRandomTargetIfReady (uint32 spell, uint32 threatTablePosition=0, float dist=0.f, bool playerOnly=true)
 
virtual void SummonMovementInform (Creature *, uint32, uint32)
 Called when a summon reaches a waypoint or point movement finished. More...
 
virtual void sGossipHello (Player *)
 
virtual void sGossipSelect (Player *, uint32, uint32)
 
virtual void sGossipSelectCode (Player *, uint32, uint32, char const *)
 
virtual void sQuestAccept (Player *, Quest const *)
 
virtual void sQuestSelect (Player *, Quest const *)
 
virtual void sQuestComplete (Player *, Quest const *)
 
virtual void sQuestReward (Player *, Quest const *, uint32)
 
virtual void sOnGameEvent (bool, uint16)
 
virtual std::string GetDebugInfo () const
 

Protected Member Functions

PlayerGetPlayerForEscort ()
 
- Protected Member Functions inherited from CreatureAI
bool UpdateVictim ()
 
bool UpdateVictimWithGaze ()
 
void SetGazeOn (Unit *target)
 
CreatureDoSummon (uint32 entry, Position const &pos, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummon (uint32 entry, WorldObject *obj, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummonFlyer (uint32 entry, WorldObject *obj, float flightZ, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
virtual void MoveInLineOfSight (Unit *)
 
bool _EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 

Private Member Functions

bool AssistPlayerInCombatAgainst (Unit *who)
 
bool IsPlayerOrGroupInRange ()
 
void FillPointMovementListForCreature ()
 

Private Attributes

ObjectGuid m_uiPlayerGUID
 
uint32 m_uiWPWaitTimer
 
uint32 m_uiPlayerCheckTimer
 
uint32 m_uiEscortState
 
float MaxPlayerDistance
 
Quest const * m_pQuestForEscort
 
std::list< Escort_WaypointWaypointList
 
std::list< Escort_Waypoint >::iterator CurrentWP
 
bool m_bIsActiveAttacker
 
bool m_bIsRunning
 
bool m_bCanInstantRespawn
 
bool m_bCanReturnToStart
 
bool DespawnAtEnd
 
bool DespawnAtFar
 
bool ScriptWP
 
bool HasImmuneToNPCFlags
 

Additional Inherited Members

- Public Types inherited from ScriptedAI
enum class  Axis {
  AXIS_X ,
  AXIS_Y
}
 
- Public Types inherited from CreatureAI
enum  EvadeReason {
  EVADE_REASON_NO_HOSTILES ,
  EVADE_REASON_BOUNDARY ,
  EVADE_REASON_SEQUENCE_BREAK ,
  EVADE_REASON_NO_PATH ,
  EVADE_REASON_OTHER
}
 
- Static Public Member Functions inherited from CreatureAI
static bool IsInBounds (CreatureBoundary const &boundary, Position const *who)
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- Public Attributes inherited from ScriptedAI
Creatureme
 
- Static Public Attributes inherited from UnitAI
static AISpellInfoTypeAISpellInfo
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
EventMap events
 
TaskScheduler scheduler
 
CreatureBoundary const * _boundary
 
bool _negateBoundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Detailed Description

Constructor & Destructor Documentation

◆ npc_escortAI()

npc_escortAI::npc_escortAI ( Creature creature)
explicit
36 : ScriptedAI(creature),
37 m_uiWPWaitTimer(1000),
41 m_pQuestForEscort(nullptr),
43 m_bIsRunning(false),
46 DespawnAtEnd(true),
47 DespawnAtFar(true),
48 ScriptWP(false),
50{}
#define DEFAULT_MAX_PLAYER_DISTANCE
Definition: ScriptedEscortAI.h:24
@ STATE_ESCORT_NONE
Definition: ScriptedEscortAI.h:46
Definition: ScriptedCreature.h:190
float MaxPlayerDistance
Definition: ScriptedEscortAI.h:125
bool m_bCanReturnToStart
Definition: ScriptedEscortAI.h:135
uint32 m_uiPlayerCheckTimer
Definition: ScriptedEscortAI.h:123
uint32 m_uiEscortState
Definition: ScriptedEscortAI.h:124
bool DespawnAtFar
Definition: ScriptedEscortAI.h:137
bool m_bIsActiveAttacker
Definition: ScriptedEscortAI.h:132
uint32 m_uiWPWaitTimer
Definition: ScriptedEscortAI.h:122
bool ScriptWP
Definition: ScriptedEscortAI.h:138
bool m_bCanInstantRespawn
Definition: ScriptedEscortAI.h:134
bool m_bIsRunning
Definition: ScriptedEscortAI.h:133
bool DespawnAtEnd
Definition: ScriptedEscortAI.h:136
bool HasImmuneToNPCFlags
Definition: ScriptedEscortAI.h:139
Quest const * m_pQuestForEscort
Definition: ScriptedEscortAI.h:127

◆ ~npc_escortAI()

npc_escortAI::~npc_escortAI ( )
inlineoverride
56{}

Member Function Documentation

◆ AddEscortState()

◆ AddWaypoint()

void npc_escortAI::AddWaypoint ( uint32  id,
float  x,
float  y,
float  z,
uint32  waitTime = 0 
)
397{
398 Escort_Waypoint t(id, x, y, z, waitTime);
399
400 WaypointList.push_back(t);
401
402 // i think SD2 no longer uses this function
403 ScriptWP = true;
404 /*PointMovement wp;
405 wp.m_uiCreatureEntry = me->GetEntry();
406 wp.m_uiPointId = id;
407 wp.m_fX = x;
408 wp.m_fY = y;
409 wp.m_fZ = z;
410 wp.m_uiWaitTime = WaitTimeMs;
411 PointMovementMap[wp.m_uiCreatureEntry].push_back(wp);*/
412}
Definition: ScriptedEscortAI.h:27
std::list< Escort_Waypoint > WaypointList
Definition: ScriptedEscortAI.h:129

References ScriptWP, and WaypointList.

Referenced by npc_onyx_flamecaller::npc_onyx_flamecallerAI::AddWaypoints(), boss_bjarngrim::boss_bjarngrimAI::boss_bjarngrimAI(), npc_scarlet_miner::npc_scarlet_minerAI::InitWaypoint(), boss_thorim_lightning_orb::boss_thorim_lightning_orbAI::InitWaypoint(), boss_thorim_sif_blizzard::boss_thorim_sif_blizzardAI::InitWaypoint(), boss_yoggsaron_cloud::boss_yoggsaron_cloudAI::InitWaypoint(), boss_grand_champion::boss_grand_championAI::SetData(), npc_argent_soldier::npc_argent_soldierAI::SetData(), npc_clintar_spirit::npc_clintar_spiritAI::StartEvent(), violet_hold_trashAI::UpdateAI(), and npc_azure_saboteur::npc_azure_saboteurAI::UpdateAI().

◆ AssistPlayerInCombatAgainst()

bool npc_escortAI::AssistPlayerInCombatAgainst ( Unit who)
private
74{
75 if (!who || !who->GetVictim())
76 {
77 return false;
78 }
79
81 {
82 return false;
83 }
84
85 //experimental (unknown) flag not present
87 {
88 return false;
89 }
90
91 //not a player
93 {
94 return false;
95 }
96
97 if (!who->isInAccessiblePlaceFor(me))
98 {
99 return false;
100 }
101
102 if (!CanAIAttack(who))
103 {
104 return false;
105 }
106
107 // we cannot attack in evade mode
108 if (me->IsInEvadeMode())
109 {
110 return false;
111 }
112
113 // or if enemy is in evade mode
114 if (who->IsCreature() && who->ToCreature()->IsInEvadeMode())
115 {
116 return false;
117 }
118
119 //never attack friendly
120 if (!me->IsValidAttackTarget(who))
121 {
122 return false;
123 }
124
125 //too far away and no free sight?
127 {
128 AttackStart(who);
129 return true;
130 }
131
132 return false;
133}
@ REACT_PASSIVE
Definition: Unit.h:548
@ CREATURE_TYPE_FLAG_CAN_ASSIST
Definition: SharedDefines.h:2707
virtual bool CanAIAttack(Unit const *) const
Definition: UnitAI.h:200
Creature * me
Definition: ScriptedCreature.h:280
float GetMaxPlayerDistance()
Definition: ScriptedEscortAI.h:102
void AttackStart(Unit *who) override
Definition: ScriptedEscortAI.cpp:52
bool HasReactState(ReactStates state) const
Definition: Creature.h:99
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:206
bool IsInEvadeMode() const
Definition: Creature.h:137
uint32 type_flags
Definition: CreatureData.h:226
bool IsCreature() const
Definition: Object.h:201
Creature * ToCreature()
Definition: Object.h:202
bool IsWithinLOSInMap(WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
Definition: Object.cpp:1347
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1321
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:10578
bool isInAccessiblePlaceFor(Creature const *c) const
Definition: Unit.cpp:4175
Unit * GetVictim() const
Definition: Unit.h:789
bool IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell=nullptr) const
Definition: Unit.cpp:13828

References AttackStart(), UnitAI::CanAIAttack(), CREATURE_TYPE_FLAG_CAN_ASSIST, Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), Creature::GetCreatureTemplate(), GetMaxPlayerDistance(), Unit::GetVictim(), Creature::HasReactState(), Object::IsCreature(), Unit::isInAccessiblePlaceFor(), Creature::IsInEvadeMode(), Unit::IsValidAttackTarget(), WorldObject::IsWithinDistInMap(), WorldObject::IsWithinLOSInMap(), ScriptedAI::me, REACT_PASSIVE, Object::ToCreature(), and CreatureTemplate::type_flags.

Referenced by MoveInLineOfSight().

◆ AttackStart()

void npc_escortAI::AttackStart ( Unit who)
overridevirtual

Reimplemented from ScriptedAI.

Reimplemented in npc_taretha::npc_tarethaAI, npc_mimirons_inferno::npc_mimirons_infernoAI, boss_thorim_lightning_orb::boss_thorim_lightning_orbAI, boss_thorim_sif_blizzard::boss_thorim_sif_blizzardAI, boss_yoggsaron_cloud::boss_yoggsaron_cloudAI, npc_frosthound::npc_frosthoundAI, npc_icefang::npc_icefangAI, npc_koltira_deathweaver::npc_koltira_deathweaverAI, npc_daphne_stilwell::npc_daphne_stilwellAI, and violet_hold_trashAI.

53{
54 if (!who)
55 return;
56
57 if (me->Attack(who, true))
58 {
60 if (type == ESCORT_MOTION_TYPE || type == POINT_MOTION_TYPE)
61 {
63 //me->DisableSpline();
64 me->StopMoving();
65 }
66
69 }
70}
@ MOTION_SLOT_ACTIVE
Definition: MotionMaster.h:62
MovementGeneratorType
Definition: MotionMaster.h:36
@ ESCORT_MOTION_TYPE
Definition: MotionMaster.h:55
@ POINT_MOTION_TYPE
Definition: MotionMaster.h:46
bool IsCombatMovementAllowed() const
Definition: Creature.h:427
MotionMaster * GetMotionMaster()
Definition: Unit.h:1601
void StopMoving()
Definition: Unit.cpp:16606
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:10234
MovementGeneratorType GetMotionSlotType(int slot) const
Definition: MotionMaster.cpp:918
void MoveChase(Unit *target, std::optional< ChaseRange > dist={}, std::optional< ChaseAngle > angle={})
Force the unit to chase this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition: MotionMaster.cpp:313
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178

References Unit::Attack(), ESCORT_MOTION_TYPE, Unit::GetMotionMaster(), MotionMaster::GetMotionSlotType(), Creature::IsCombatMovementAllowed(), ScriptedAI::me, MOTION_SLOT_ACTIVE, MotionMaster::MoveChase(), MotionMaster::MovementExpired(), POINT_MOTION_TYPE, and Unit::StopMoving().

Referenced by AssistPlayerInCombatAgainst(), npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::AttackedBy(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::AttackStart(), npc_clintar_spirit::npc_clintar_spiritAI::EnterEvadeMode(), MoveInLineOfSight(), npc_general_andorov::MoveInLineOfSight(), npc_captain_saeed::npc_captain_saeedAI::MoveInLineOfSight(), boss_grand_champion::boss_grand_championAI::MovementInform(), npc_arthas::npc_arthasAI::UpdateAI(), npc_clintar_spirit::npc_clintar_spiritAI::UpdateAI(), boss_grand_champion::boss_grand_championAI::UpdateAI(), npc_captain_saeed::npc_captain_saeedAI::UpdateAI(), npc_ranger_lilatha::WaypointReached(), and npc_cork_gizelton::npc_cork_gizeltonAI::WaypointReached().

◆ EnterEvadeMode()

void npc_escortAI::EnterEvadeMode ( EvadeReason  = EVADE_REASON_OTHER)
overridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_cork_gizelton::npc_cork_gizeltonAI, npc_clintar_spirit::npc_clintar_spiritAI, npc_captain_saeed::npc_captain_saeedAI, npc_koltira_deathweaver::npc_koltira_deathweaverAI, npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI, npc_varian_wrynn::npc_varian_wrynnAI, npc_thrall_bfu::npc_thrall_bfuAI, npc_onyx_flamecaller::npc_onyx_flamecallerAI, boss_grand_champion::boss_grand_championAI, boss_thorim_lightning_orb::boss_thorim_lightning_orbAI, violet_hold_trashAI, npc_frosthound::npc_frosthoundAI, and npc_icefang::npc_icefangAI.

202{
204 me->CombatStop(true);
205 me->SetLootRecipient(nullptr);
206
208 {
211 LOG_DEBUG("scripts.ai", "EscortAI has left combat and is now returning to last point");
212 }
213 else
214 {
217 me->SetImmuneToNPC(true);
218 Reset();
219 }
220}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
@ STATE_ESCORT_ESCORTING
Definition: ScriptedEscortAI.h:47
@ STATE_ESCORT_RETURNING
Definition: ScriptedEscortAI.h:48
void Reset() override
Definition: ScriptedCreature.h:287
bool HasEscortState(uint32 escortState)
Definition: ScriptedEscortAI.h:98
void AddEscortState(uint32 escortState)
Definition: ScriptedEscortAI.h:110
void ReturnToLastPoint()
Definition: ScriptedEscortAI.cpp:193
void ClearAllThreat()
Definition: ThreatMgr.cpp:417
void SetLootRecipient(Unit *unit, bool withGroup=true)
Definition: Creature.cpp:1315
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10398
void SetImmuneToNPC(bool apply, bool keepCombat=false)
Definition: Unit.cpp:13577
ThreatMgr & GetThreatMgr()
Definition: Unit.h:839
void MoveTargetedHome(bool walk=false)
The unit will return this initial position (owner for pets and summoned creatures)....
Definition: MotionMaster.cpp:259

References AddEscortState(), ThreatMgr::ClearAllThreat(), Unit::CombatStop(), Unit::GetMotionMaster(), Unit::GetThreatMgr(), HasEscortState(), HasImmuneToNPCFlags, LOG_DEBUG, ScriptedAI::me, MotionMaster::MoveTargetedHome(), ScriptedAI::Reset(), ReturnToLastPoint(), Unit::SetImmuneToNPC(), Creature::SetLootRecipient(), STATE_ESCORT_ESCORTING, and STATE_ESCORT_RETURNING.

Referenced by npc_arthas::npc_arthasAI::DoAction(), npc_cork_gizelton::npc_cork_gizeltonAI::EnterEvadeMode(), npc_clintar_spirit::npc_clintar_spiritAI::EnterEvadeMode(), and npc_captain_saeed::npc_captain_saeedAI::EnterEvadeMode().

◆ FillPointMovementListForCreature()

void npc_escortAI::FillPointMovementListForCreature ( )
private
415{
416 ScriptPointVector const& movePoints = sScriptSystemMgr->GetPointMoveList(me->GetEntry());
417 if (movePoints.empty())
418 return;
419
420 ScriptPointVector::const_iterator itrEnd = movePoints.end();
421 for (ScriptPointVector::const_iterator itr = movePoints.begin(); itr != itrEnd; ++itr)
422 {
423 Escort_Waypoint point(itr->uiPointId, itr->fX, itr->fY, itr->fZ, itr->uiWaitTime);
424 WaypointList.push_back(point);
425 }
426}
#define sScriptSystemMgr
Definition: ScriptSystem.h:91
std::vector< ScriptPointMove > ScriptPointVector
Definition: ScriptSystem.h:59
uint32 GetEntry() const
Definition: Object.h:112

References Object::GetEntry(), ScriptedAI::me, sScriptSystemMgr, and WaypointList.

Referenced by SetNextWaypoint(), and Start().

◆ GenerateWaypointArray()

void npc_escortAI::GenerateWaypointArray ( Movement::PointsArray points)
585{
586 if (WaypointList.empty())
587 return;
588
589 uint32 startingWaypointId = CurrentWP->id;
590
591 // Flying unit, just fill array
593 {
594 // xinef: first point in vector is unit real position
595 points->clear();
596 points->push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
597 for (std::list<Escort_Waypoint>::const_iterator itr = CurrentWP; itr != WaypointList.end(); ++itr)
598 points->push_back(G3D::Vector3(itr->x, itr->y, itr->z));
599 }
600 else
601 {
602 for (float size = 1.0f; size; size *= 0.5f)
603 {
604 std::vector<G3D::Vector3> pVector;
605 // xinef: first point in vector is unit real position
606 pVector.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
607 uint32 length = (WaypointList.size() - startingWaypointId) * size;
608
609 uint32 cnt = 0;
610 for (std::list<Escort_Waypoint>::const_iterator itr = CurrentWP; itr != WaypointList.end() && cnt <= length; ++itr, ++cnt)
611 pVector.push_back(G3D::Vector3(itr->x, itr->y, itr->z));
612
613 if (pVector.size() > 2) // more than source + dest
614 {
615 G3D::Vector3 middle = (pVector[0] + pVector[pVector.size() - 1]) / 2.f;
616 G3D::Vector3 offset;
617
618 bool continueLoop = false;
619 for (uint32 i = 1; i < pVector.size() - 1; ++i)
620 {
621 offset = middle - pVector[i];
622 if (std::fabs(offset.x) >= 0xFF || std::fabs(offset.y) >= 0xFF || std::fabs(offset.z) >= 0x7F)
623 {
624 // offset is too big, split points
625 continueLoop = true;
626 break;
627 }
628 }
629 if (continueLoop)
630 continue;
631 }
632 // everything ok
633 *points = pVector;
634 break;
635 }
636 }
637}
std::uint32_t uint32
Definition: Define.h:107
MovementFlags
Definition: UnitDefines.h:342
@ MOVEMENTFLAG_DISABLE_GRAVITY
Definition: UnitDefines.h:354
@ MOVEMENTFLAG_CAN_FLY
Definition: UnitDefines.h:368
std::list< Escort_Waypoint >::iterator CurrentWP
Definition: ScriptedEscortAI.h:130
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:334
MovementInfo m_movementInfo
Definition: Object.h:609
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118

References CurrentWP, Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), MovementInfo::HasMovementFlag(), WorldObject::m_movementInfo, ScriptedAI::me, MOVEMENTFLAG_CAN_FLY, MOVEMENTFLAG_DISABLE_GRAVITY, and WaypointList.

Referenced by UpdateAI().

◆ GetAttack()

bool npc_escortAI::GetAttack ( )
inline

◆ GetEventStarterGUID()

ObjectGuid npc_escortAI::GetEventStarterGUID ( )
inline
108{ return m_uiPlayerGUID; }
ObjectGuid m_uiPlayerGUID
Definition: ScriptedEscortAI.h:121

References m_uiPlayerGUID.

◆ GetMaxPlayerDistance()

float npc_escortAI::GetMaxPlayerDistance ( )
inline

◆ GetPlayerForEscort()

Player * npc_escortAI::GetPlayerForEscort ( )
inlineprotected
Player * GetPlayer(Map const *, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:223

References ObjectAccessor::GetPlayer(), m_uiPlayerGUID, and ScriptedAI::me.

Referenced by npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::DamageTaken(), IsPlayerOrGroupInRange(), npc_ranshalla::npc_ranshallaAI::JustDidDialogueStep(), JustDied(), npc_muglash::npc_muglashAI::JustDied(), npc_ame::npc_ameAI::JustDied(), npc_mootoo_the_younger::npc_mootoo_the_youngerAI::JustDied(), npc_bonker_togglevolt::npc_bonker_togglevoltAI::JustDied(), npc_apothecary_hanes::npc_Apothecary_HanesAI::JustDied(), npc_engineer_helice::npc_engineer_heliceAI::JustDied(), npc_maghar_captive::npc_maghar_captiveAI::JustDied(), npc_kurenai_captive::npc_kurenai_captiveAI::JustDied(), npc_captain_saeed::npc_captain_saeedAI::JustDied(), npc_bessy::npc_bessyAI::JustDied(), npc_maxx_a_million_escort::npc_maxx_a_million_escortAI::JustDied(), npc_isla_starmane::npc_isla_starmaneAI::JustDied(), npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::JustEngagedWith(), npc_muglash::npc_muglashAI::JustEngagedWith(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::JustSummoned(), npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::JustSummoned(), npc_captain_saeed::npc_captain_saeedAI::MoveInLineOfSight(), npc_daphne_stilwell::npc_daphne_stilwellAI::SummonedCreatureDies(), npc_varian_wrynn::npc_varian_wrynnAI::UpdateAI(), npc_lurgglbr::npc_lurgglbrAI::UpdateAI(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::UpdateAI(), npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI::UpdateAI(), npc_tyrion_spybot::npc_tyrion_spybotAI::UpdateAI(), npc_rinji::npc_rinjiAI::UpdateEscortAI(), npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI::UpdateEscortAI(), npc_captain_saeed::npc_captain_saeedAI::WaypointReached(), npc_professor_phizzlethorpe::npc_professor_phizzlethorpeAI::WaypointReached(), npc_ranger_lilatha::WaypointReached(), npc_rinji::npc_rinjiAI::WaypointReached(), npc_corporal_keeshan::npc_corporal_keeshanAI::WaypointReached(), npc_deathstalker_erland::npc_deathstalker_erlandAI::WaypointReached(), npc_varian_wrynn::npc_varian_wrynnAI::WaypointReached(), npc_daphne_stilwell::npc_daphne_stilwellAI::WaypointReached(), npc_muglash::npc_muglashAI::WaypointReached(), npc_magwin::npc_magwinAI::WaypointReached(), npc_prospector_remtravel::npc_prospector_remtravelAI::WaypointReached(), npc_kaya_flathoof::npc_kaya_flathoofAI::WaypointReached(), npc_custodian_of_time::npc_custodian_of_timeAI::WaypointReached(), npc_gilthares::npc_giltharesAI::WaypointReached(), npc_lakota_windsong::npc_lakota_windsongAI::WaypointReached(), npc_paoka_swiftmountain::npc_paoka_swiftmountainAI::WaypointReached(), npc_ame::npc_ameAI::WaypointReached(), npc_mootoo_the_younger::npc_mootoo_the_youngerAI::WaypointReached(), npc_bonker_togglevolt::npc_bonker_togglevoltAI::WaypointReached(), npc_emily::npc_emilyAI::WaypointReached(), npc_apothecary_hanes::npc_Apothecary_HanesAI::WaypointReached(), npc_engineer_helice::npc_engineer_heliceAI::WaypointReached(), npc_frosthound::npc_frosthoundAI::WaypointReached(), npc_wounded_blood_elf::npc_wounded_blood_elfAI::WaypointReached(), npc_maghar_captive::npc_maghar_captiveAI::WaypointReached(), npc_kurenai_captive::npc_kurenai_captiveAI::WaypointReached(), npc_bessy::npc_bessyAI::WaypointReached(), npc_maxx_a_million_escort::npc_maxx_a_million_escortAI::WaypointReached(), npc_kservant::npc_kservantAI::WaypointReached(), npc_isla_starmane::npc_isla_starmaneAI::WaypointReached(), and npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI::WaypointStart().

◆ GetWaypointPosition()

bool npc_escortAI::GetWaypointPosition ( uint32  pointId,
float &  x,
float &  y,
float &  z 
)
565{
566 ScriptPointVector const& waypoints = sScriptSystemMgr->GetPointMoveList(me->GetEntry());
567 if (waypoints.empty())
568 return false;
569
570 for (ScriptPointVector::const_iterator itr = waypoints.begin(); itr != waypoints.end(); ++itr)
571 {
572 if (itr->uiPointId == pointId)
573 {
574 x = itr->fX;
575 y = itr->fY;
576 z = itr->fZ;
577 return true;
578 }
579 }
580
581 return false;
582}

References Object::GetEntry(), ScriptedAI::me, and sScriptSystemMgr.

◆ HasEscortState()

bool npc_escortAI::HasEscortState ( uint32  escortState)
inline
98{ return (m_uiEscortState & escortState); }

References m_uiEscortState.

Referenced by npc_koltira_deathweaver::npc_koltira_deathweaverAI::AttackStart(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::EnterEvadeMode(), npc_varian_wrynn::npc_varian_wrynnAI::EnterEvadeMode(), npc_thrall_bfu::npc_thrall_bfuAI::EnterEvadeMode(), violet_hold_trashAI::EnterEvadeMode(), EnterEvadeMode(), JustDied(), npc_muglash::npc_muglashAI::JustDied(), npc_engineer_helice::npc_engineer_heliceAI::JustDied(), npc_maghar_captive::npc_maghar_captiveAI::JustDied(), npc_kurenai_captive::npc_kurenai_captiveAI::JustDied(), npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::JustEngagedWith(), npc_muglash::npc_muglashAI::JustEngagedWith(), npc_wounded_blood_elf::npc_wounded_blood_elfAI::JustEngagedWith(), npc_rinji::npc_rinjiAI::JustEngagedWith(), MoveInLineOfSight(), npc_custodian_of_time::npc_custodian_of_timeAI::MoveInLineOfSight(), MovementInform(), npc_rocknot::npc_rocknotAI::Reset(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::Reset(), npc_varian_wrynn::npc_varian_wrynnAI::Reset(), npc_thrall_bfu::npc_thrall_bfuAI::Reset(), npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::Reset(), npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI::Reset(), npc_lurgglbr::npc_lurgglbrAI::Reset(), SetEscortPaused(), Start(), UpdateAI(), npc_barnes::npc_barnesAI::UpdateAI(), npc_corporal_keeshan::npc_corporal_keeshanAI::UpdateAI(), npc_muglash::npc_muglashAI::UpdateAI(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::UpdateAI(), npc_engineer_helice::npc_engineer_heliceAI::UpdateAI(), and npc_rinji::npc_rinjiAI::UpdateEscortAI().

◆ IsEscorted()

bool npc_escortAI::IsEscorted ( )
inlineoverridevirtual

Reimplemented from CreatureAI.

References m_uiEscortState, and STATE_ESCORT_ESCORTING.

◆ IsPlayerOrGroupInRange()

bool npc_escortAI::IsPlayerOrGroupInRange ( )
private
223{
224 if (Player* player = GetPlayerForEscort())
225 {
226 if (Group* group = player->GetGroup())
227 {
228 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
229 if (Player* member = groupRef->GetSource())
230 if (me->IsWithinDistInMap(member, GetMaxPlayerDistance(), true, false))
231 return true;
232 }
233 else if (me->IsWithinDistInMap(player, GetMaxPlayerDistance(), true, false))
234 return true;
235 }
236
237 return false;
238}
Player * GetPlayerForEscort()
Definition: ScriptedEscortAI.h:114
Definition: Player.h:1064
Definition: Group.h:169
Definition: GroupReference.h:27
GroupReference * next()
Definition: GroupReference.h:36

References GetMaxPlayerDistance(), GetPlayerForEscort(), WorldObject::IsWithinDistInMap(), ScriptedAI::me, and GroupReference::next().

Referenced by UpdateAI().

◆ JustDied()

void npc_escortAI::JustDied ( Unit )
overridevirtual

Reimplemented from ScriptedAI.

Reimplemented in npc_arthas::npc_arthasAI, npc_muglash::npc_muglashAI, npc_clintar_spirit::npc_clintar_spiritAI, npc_ame::npc_ameAI, npc_argent_soldier::npc_argent_soldierAI, boss_bjarngrim::boss_bjarngrimAI, brann_bronzebeard::brann_bronzebeardAI, violet_hold_trashAI, npc_mootoo_the_younger::npc_mootoo_the_youngerAI, npc_bonker_togglevolt::npc_bonker_togglevoltAI, npc_apothecary_hanes::npc_Apothecary_HanesAI, npc_engineer_helice::npc_engineer_heliceAI, npc_frosthound::npc_frosthoundAI, npc_icefang::npc_icefangAI, npc_maghar_captive::npc_maghar_captiveAI, npc_kurenai_captive::npc_kurenai_captiveAI, npc_captain_saeed::npc_captain_saeedAI, npc_bessy::npc_bessyAI, npc_maxx_a_million_escort::npc_maxx_a_million_escortAI, npc_isla_starmane::npc_isla_starmaneAI, npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI, npc_general_andorov, and npc_cork_gizelton::npc_cork_gizeltonAI.

156{
158 return;
159
160 if (Player* player = GetPlayerForEscort())
161 {
162 if (Group* group = player->GetGroup())
163 {
164 for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
165 if (Player* member = groupRef->GetSource())
166 if (member->IsInMap(player) && member->GetQuestStatus(m_pQuestForEscort->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
167 member->FailQuest(m_pQuestForEscort->GetQuestId());
168 }
169 else
170 {
171 if (player->GetQuestStatus(m_pQuestForEscort->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
172 player->FailQuest(m_pQuestForEscort->GetQuestId());
173 }
174 }
175}
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:103
uint32 GetQuestId() const
Definition: QuestDef.h:228

References GetPlayerForEscort(), Quest::GetQuestId(), HasEscortState(), m_pQuestForEscort, m_uiPlayerGUID, GroupReference::next(), QUEST_STATUS_INCOMPLETE, and STATE_ESCORT_ESCORTING.

Referenced by npc_cork_gizelton::npc_cork_gizeltonAI::JustDied().

◆ JustRespawned()

void npc_escortAI::JustRespawned ( )
overridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_rinji::npc_rinjiAI, npc_cork_gizelton::npc_cork_gizeltonAI, and npc_isla_starmane::npc_isla_starmaneAI.

178{
180
182 me->SetCombatMovement(true);
183
184 //add a small delay before going to first waypoint, normal in near all cases
185 m_uiWPWaitTimer = 1000;
186
189
190 Reset();
191}
@ STATE_ESCORT_PAUSED
Definition: ScriptedEscortAI.h:49
void RemoveEscortState(uint32 escortState)
Definition: ScriptedEscortAI.h:111
void SetCombatMovement(bool allowMovement)
Definition: Creature.cpp:3833
uint32 faction
Definition: CreatureData.h:201
void RestoreFaction()
Definition: Unit.cpp:18651
uint32 GetFaction() const
Definition: Unit.h:755

References CreatureTemplate::faction, Creature::GetCreatureTemplate(), Unit::GetFaction(), Creature::IsCombatMovementAllowed(), m_uiWPWaitTimer, ScriptedAI::me, RemoveEscortState(), ScriptedAI::Reset(), Unit::RestoreFaction(), Creature::SetCombatMovement(), STATE_ESCORT_ESCORTING, STATE_ESCORT_PAUSED, and STATE_ESCORT_RETURNING.

Referenced by npc_rinji::npc_rinjiAI::JustRespawned(), npc_cork_gizelton::npc_cork_gizeltonAI::JustRespawned(), and npc_isla_starmane::npc_isla_starmaneAI::JustRespawned().

◆ MoveInLineOfSight()

void npc_escortAI::MoveInLineOfSight ( Unit who)
overridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_taretha::npc_tarethaAI, brann_bronzebeard::brann_bronzebeardAI, npc_mimirons_inferno::npc_mimirons_infernoAI, boss_thorim_lightning_orb::boss_thorim_lightning_orbAI, boss_thorim_sif_blizzard::boss_thorim_sif_blizzardAI, boss_yoggsaron_cloud::boss_yoggsaron_cloudAI, npc_azure_saboteur::npc_azure_saboteurAI, npc_general_andorov, npc_custodian_of_time::npc_custodian_of_timeAI, violet_hold_trashAI, npc_ancestral_wolf::npc_ancestral_wolfAI, and npc_captain_saeed::npc_captain_saeedAI.

136{
137 if (me->GetVictim())
138 return;
139
142 return;
143
145 {
147 {
150 }
151 AttackStart(who);
152 }
153}
@ REACT_AGGRESSIVE
Definition: Unit.h:550
@ UNIT_STATE_DISTRACTED
Definition: UnitDefines.h:161
@ UNIT_STATE_STUNNED
Definition: UnitDefines.h:152
bool AssistPlayerInCombatAgainst(Unit *who)
Definition: ScriptedEscortAI.cpp:73
bool CanStartAttack(Unit const *u) const
Definition: Creature.cpp:1903
void ClearUnitState(uint32 f)
Definition: Unit.h:674
bool HasUnitState(const uint32 f) const
Definition: Unit.h:673
bool isTargetableForAttack(bool checkFakeDeath=true, Unit const *byWho=nullptr) const
Definition: Unit.cpp:13811
void Clear(bool reset=true)
Definition: MotionMaster.h:165

References AssistPlayerInCombatAgainst(), AttackStart(), Creature::CanStartAttack(), MotionMaster::Clear(), Unit::ClearUnitState(), Unit::GetMotionMaster(), Unit::GetVictim(), HasEscortState(), Creature::HasReactState(), Unit::HasUnitState(), Unit::isInAccessiblePlaceFor(), Unit::isTargetableForAttack(), ScriptedAI::me, REACT_AGGRESSIVE, STATE_ESCORT_ESCORTING, UNIT_STATE_DISTRACTED, and UNIT_STATE_STUNNED.

Referenced by npc_ancestral_wolf::npc_ancestral_wolfAI::MoveInLineOfSight(), and npc_captain_saeed::npc_captain_saeedAI::MoveInLineOfSight().

◆ MovementInform()

void npc_escortAI::MovementInform ( uint32  moveType,
uint32  pointId 
)
overridevirtual

Reimplemented from ScriptedAI.

Reimplemented in boss_grand_champion::boss_grand_championAI, and npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI.

327{
328 // xinef: no action allowed if there is no escort
330 return;
331
332 if (moveType == POINT_MOTION_TYPE)
333 {
334 //Combat start position reached, continue waypoint movement
335 if (pointId == POINT_LAST_POINT)
336 {
337 LOG_DEBUG("scripts.ai", "EscortAI has returned to original position before combat");
338
341
342 if (!m_uiWPWaitTimer)
343 m_uiWPWaitTimer = 1;
344 }
345 else if (pointId == POINT_HOME)
346 {
347 LOG_DEBUG("scripts.ai", "EscortAI has returned to original home location and will continue from beginning of waypoint list.");
348
349 CurrentWP = WaypointList.begin();
350 m_uiWPWaitTimer = 1;
351 }
352 }
353 else if (moveType == ESCORT_MOTION_TYPE)
354 {
356 {
357 //Call WP function
361
362 m_uiWPWaitTimer = CurrentWP->WaitTimeMs + 1;
363
364 ++CurrentWP;
365
367 {
372 }
373 }
374 }
375}
@ POINT_HOME
Definition: ScriptedEscortAI.cpp:33
@ POINT_LAST_POINT
Definition: ScriptedEscortAI.cpp:32
virtual void WaypointReached(uint32 pointId)=0
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:337
void SetPosition(float x, float y, float z, float o)
Definition: Creature.cpp:3149
bool SetWalk(bool enable) override
Enable or disable the creature's walk mode by removing: MOVEMENTFLAG_WALKING. Infom also the client.
Definition: Creature.cpp:3178
float GetOrientation() const
Definition: Position.h:120
void StopMovingOnCurrentPos()
Definition: Unit.cpp:16645
void MoveIdle()
Definition: MotionMaster.cpp:232

References CurrentWP, ESCORT_MOTION_TYPE, Unit::GetMotionMaster(), MotionMaster::GetMotionSlotType(), Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), HasEscortState(), LOG_DEBUG, m_bIsRunning, m_uiWPWaitTimer, ScriptedAI::me, MOTION_SLOT_ACTIVE, MotionMaster::MoveIdle(), MotionMaster::MovementExpired(), POINT_HOME, POINT_LAST_POINT, POINT_MOTION_TYPE, RemoveEscortState(), Creature::SetHomePosition(), Creature::SetPosition(), Creature::SetWalk(), STATE_ESCORT_ESCORTING, STATE_ESCORT_PAUSED, STATE_ESCORT_RETURNING, Unit::StopMovingOnCurrentPos(), WaypointList, and WaypointReached().

Referenced by boss_grand_champion::boss_grand_championAI::MovementInform(), and npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::MovementInform().

◆ RemoveEscortState()

◆ ReturnToLastPoint()

void npc_escortAI::ReturnToLastPoint ( )
194{
195 float x, y, z, o;
196 me->SetWalk(false);
197 me->GetHomePosition(x, y, z, o);
199}
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:339
void MovePoint(uint32 id, const Position &pos, bool generatePath=true, bool forceDestination=true)
Definition: MotionMaster.h:211

References Creature::GetHomePosition(), Unit::GetMotionMaster(), ScriptedAI::me, MotionMaster::MovePoint(), POINT_LAST_POINT, and Creature::SetWalk().

Referenced by npc_koltira_deathweaver::npc_koltira_deathweaverAI::EnterEvadeMode(), npc_varian_wrynn::npc_varian_wrynnAI::EnterEvadeMode(), npc_thrall_bfu::npc_thrall_bfuAI::EnterEvadeMode(), violet_hold_trashAI::EnterEvadeMode(), and EnterEvadeMode().

◆ SetCanAttack()

void npc_escortAI::SetCanAttack ( bool  attack)
inline
107{ m_bIsActiveAttacker = attack; }

References m_bIsActiveAttacker.

◆ SetDespawnAtEnd()

◆ SetDespawnAtFar()

◆ SetEscortPaused()

void npc_escortAI::SetEscortPaused ( bool  on)
524{
526 return;
527
528 if (on)
530 else
532}

References AddEscortState(), HasEscortState(), RemoveEscortState(), STATE_ESCORT_ESCORTING, and STATE_ESCORT_PAUSED.

Referenced by brann_bronzebeard::brann_bronzebeardAI::DoAction(), npc_arthas::npc_arthasAI::DoAction(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::DoAction(), npc_black_knight_skeletal_gryphon::npc_black_knight_skeletal_gryphonAI::DoAction(), npc_ranshalla::npc_ranshallaAI::DoChannelTorchSpell(), npc_muglash::npc_muglashAI::DoWaveSummon(), npc_captain_saeed::npc_captain_saeedAI::EnterEvadeMode(), npc_ranshalla::npc_ranshallaAI::JustDidDialogueStep(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::ReorderInstance(), npc_crok_scourgebane::npc_crok_scourgebaneAI::SetGUID(), npc_cork_gizelton::npc_cork_gizeltonAI::SetGUID(), npc_captain_saeed::npc_captain_saeedAI::SetGUID(), npc_varian_wrynn::npc_varian_wrynnAI::SetHoldState(), npc_thrall_bfu::npc_thrall_bfuAI::SetHoldState(), npc_general_andorov::sGossipSelect(), npc_thrall_bfu::npc_thrall_bfuAI::SummonedCreatureDies(), npc_barnes::npc_barnesAI::UpdateAI(), npc_corporal_keeshan::npc_corporal_keeshanAI::UpdateAI(), npc_varian_wrynn::npc_varian_wrynnAI::UpdateAI(), npc_thrall_bfu::npc_thrall_bfuAI::UpdateAI(), npc_arthas::npc_arthasAI::UpdateAI(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::UpdateAI(), npc_captain_saeed::npc_captain_saeedAI::UpdateAI(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::UpdateAI(), npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI::UpdateAI(), npc_tyrion_spybot::npc_tyrion_spybotAI::UpdateAI(), npc_maxx_a_million_escort::npc_maxx_a_million_escortAI::UpdateAI(), npc_grimstone::npc_grimstoneAI::UpdateEscortAI(), npc_cork_gizelton::npc_cork_gizeltonAI::UpdateEscortAI(), npc_ranshalla::npc_ranshallaAI::UpdateEscortAI(), brann_bronzebeard::brann_bronzebeardAI::UpdateEscortAI(), npc_tirions_gambit_tirion::npc_tirions_gambit_tirionAI::UpdateEscortAI(), npc_black_knight_skeletal_gryphon::npc_black_knight_skeletal_gryphonAI::WaypointReached(), npc_captain_saeed::npc_captain_saeedAI::WaypointReached(), npc_ranshalla::npc_ranshallaAI::WaypointReached(), npc_tirions_gambit_tirion::npc_tirions_gambit_tirionAI::WaypointReached(), npc_arthas::npc_arthasAI::WaypointReached(), npc_grimstone::npc_grimstoneAI::WaypointReached(), npc_barnes::npc_barnesAI::WaypointReached(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::WaypointReached(), npc_corporal_keeshan::npc_corporal_keeshanAI::WaypointReached(), npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI::WaypointReached(), npc_tyrion_spybot::npc_tyrion_spybotAI::WaypointReached(), npc_daphne_stilwell::npc_daphne_stilwellAI::WaypointReached(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::WaypointReached(), npc_general_andorov::WaypointReached(), npc_muglash::npc_muglashAI::WaypointReached(), npc_cork_gizelton::npc_cork_gizeltonAI::WaypointReached(), npc_crok_scourgebane::npc_crok_scourgebaneAI::WaypointReached(), and npc_maxx_a_million_escort::npc_maxx_a_million_escortAI::WaypointReached().

◆ SetMaxPlayerDistance()

void npc_escortAI::SetMaxPlayerDistance ( float  newMax)
inline
101{ MaxPlayerDistance = newMax; }

References MaxPlayerDistance.

◆ SetNextWaypoint() [1/2]

bool npc_escortAI::SetNextWaypoint ( uint32  pointId,
bool  setPosition = true 
)
541{
542 if (!WaypointList.empty())
543 WaypointList.clear();
544
546
547 if (WaypointList.empty())
548 return false;
549
550 Escort_Waypoint waypoint(0, 0, 0, 0, 0);
551 for (CurrentWP = WaypointList.begin(); CurrentWP != WaypointList.end(); ++CurrentWP)
552 {
553 if (CurrentWP->id == pointId)
554 {
555 if (setPosition)
557 return true;
558 }
559 }
560
561 return false;
562}
void FillPointMovementListForCreature()
Definition: ScriptedEscortAI.cpp:414
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition: Unit.cpp:19983

References CurrentWP, FillPointMovementListForCreature(), Position::GetOrientation(), ScriptedAI::me, Unit::UpdatePosition(), and WaypointList.

◆ SetNextWaypoint() [2/2]

bool npc_escortAI::SetNextWaypoint ( uint32  pointId,
float  x,
float  y,
float  z,
float  orientation 
)
535{
536 me->UpdatePosition(x, y, z, orientation);
537 return SetNextWaypoint(pointId, false);
538}
bool SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation)
Definition: ScriptedEscortAI.cpp:534

References ScriptedAI::me, SetNextWaypoint(), and Unit::UpdatePosition().

Referenced by brann_bronzebeard::brann_bronzebeardAI::DoAction(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::ReorderInstance(), npc_time_lost_proto_drake::npc_time_lost_proto_drakeAI::RollPath(), and SetNextWaypoint().

◆ SetRun()

void npc_escortAI::SetRun ( bool  on = true)
429{
430 if (on)
431 {
432 if (!m_bIsRunning)
433 me->SetWalk(false);
434 else
435 LOG_DEBUG("scripts.ai", "EscortAI attempt to set run mode, but is already running.");
436 }
437 else
438 {
439 if (m_bIsRunning)
440 me->SetWalk(true);
441 else
442 LOG_DEBUG("scripts.ai", "EscortAI attempt to set walk mode, but is already walking.");
443 }
444
445 m_bIsRunning = on;
446}

References LOG_DEBUG, m_bIsRunning, ScriptedAI::me, and Creature::SetWalk().

Referenced by npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::DamageTaken(), npc_arthas::npc_arthasAI::DoAction(), npc_thrall_bfu::npc_thrall_bfuAI::SummonedCreatureDies(), npc_varian_wrynn::npc_varian_wrynnAI::UpdateAI(), npc_thrall_bfu::npc_thrall_bfuAI::UpdateAI(), npc_arthas::npc_arthasAI::UpdateAI(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::UpdateAI(), npc_arthas::npc_arthasAI::WaypointReached(), npc_scarlet_miner::npc_scarlet_minerAI::WaypointReached(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::WaypointReached(), npc_professor_phizzlethorpe::npc_professor_phizzlethorpeAI::WaypointReached(), npc_rinji::npc_rinjiAI::WaypointReached(), npc_daphne_stilwell::npc_daphne_stilwellAI::WaypointReached(), npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::WaypointReached(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::WaypointReached(), npc_taretha::npc_tarethaAI::WaypointReached(), npc_magwin::npc_magwinAI::WaypointReached(), npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI::WaypointReached(), npc_mootoo_the_younger::npc_mootoo_the_youngerAI::WaypointReached(), npc_apothecary_hanes::npc_Apothecary_HanesAI::WaypointReached(), npc_maghar_captive::npc_maghar_captiveAI::WaypointReached(), npc_kurenai_captive::npc_kurenai_captiveAI::WaypointReached(), and npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI::WaypointStart().

◆ Start()

void npc_escortAI::Start ( bool  isActiveAttacker = true,
bool  run = false,
ObjectGuid  playerGUID = ObjectGuid::Empty,
Quest const *  quest = nullptr,
bool  instantRespawn = false,
bool  canLoopPath = false,
bool  resetWaypoints = true 
)
450{
451 if (me->GetVictim())
452 {
453 LOG_ERROR("entities.unit.ai", "ERROR: EscortAI (script: {}, creature entry: {}) attempts to Start while in combat", me->GetScriptName(), me->GetEntry());
454 return;
455 }
456
458 {
459 LOG_ERROR("entities.unit.ai", "EscortAI (script: {}, creature entry: {}) attempts to Start while already escorting", me->GetScriptName(), me->GetEntry());
460 return;
461 }
462
463 if (!ScriptWP && resetWaypoints) // sd2 never adds wp in script, but tc does
464 {
465 if (!WaypointList.empty())
466 WaypointList.clear();
468 }
469
470 if (WaypointList.empty())
471 {
472 LOG_ERROR("sql.sql", "EscortAI (script: {}, creature entry: {}) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: {}).",
473 me->GetScriptName(), me->GetEntry(), quest ? quest->GetQuestId() : 0);
474 return;
475 }
476
477 //set variables
478 m_bIsActiveAttacker = isActiveAttacker;
479 m_bIsRunning = run;
480
481 m_uiPlayerGUID = playerGUID;
482 m_pQuestForEscort = quest;
483
484 m_bCanInstantRespawn = instantRespawn;
485 m_bCanReturnToStart = canLoopPath;
486
488 LOG_DEBUG("scripts.ai", "EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn.");
489
491 {
494 LOG_DEBUG("scripts.ai", "EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle.");
495 }
496
497 //disable npcflags
499 if (me->IsImmuneToNPC())
500 {
501 HasImmuneToNPCFlags = true;
502 me->SetImmuneToNPC(false);
503 }
504
505 LOG_DEBUG("scripts.ai", "EscortAI started with {} waypoints. ActiveAttacker = {}, Run = {}, PlayerGUID = {}",
507
508 CurrentWP = WaypointList.begin();
509
510 //Set initial speed
511 if (m_bIsRunning)
512 me->SetWalk(false);
513 else
514 me->SetWalk(true);
515
519 me->DisableSpline();
521}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint64_t uint64
Definition: Define.h:106
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:39
@ UNIT_NPC_FLAG_NONE
Definition: UnitDefines.h:293
std::string GetScriptName() const
Definition: Creature.cpp:3033
std::string ToString() const
Definition: ObjectGuid.cpp:47
void DisableSpline()
Definition: Unit.cpp:637
bool IsImmuneToNPC() const
Definition: Unit.h:815
void ReplaceAllNpcFlags(NPCFlags flags)
Definition: Unit.h:697
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:910

References AddEscortState(), CurrentWP, Unit::DisableSpline(), ESCORT_MOTION_TYPE, FillPointMovementListForCreature(), MotionMaster::GetCurrentMovementGeneratorType(), Object::GetEntry(), Unit::GetMotionMaster(), MotionMaster::GetMotionSlotType(), Quest::GetQuestId(), Creature::GetScriptName(), Unit::GetVictim(), HasEscortState(), HasImmuneToNPCFlags, Unit::IsImmuneToNPC(), LOG_DEBUG, LOG_ERROR, m_bCanInstantRespawn, m_bCanReturnToStart, m_bIsActiveAttacker, m_bIsRunning, m_pQuestForEscort, m_uiPlayerGUID, ScriptedAI::me, MOTION_SLOT_ACTIVE, MotionMaster::MoveIdle(), MotionMaster::MovementExpired(), Unit::ReplaceAllNpcFlags(), ScriptWP, Unit::SetImmuneToNPC(), Creature::SetWalk(), STATE_ESCORT_ESCORTING, ObjectGuid::ToString(), UNIT_NPC_FLAG_NONE, WAYPOINT_MOTION_TYPE, and WaypointList.

Referenced by boss_bjarngrim::boss_bjarngrimAI::boss_bjarngrimAI(), boss_thorim_lightning_orb::boss_thorim_lightning_orbAI::boss_thorim_lightning_orbAI(), boss_thorim_sif_blizzard::boss_thorim_sif_blizzardAI::boss_thorim_sif_blizzardAI(), boss_yoggsaron_cloud::boss_yoggsaron_cloudAI::boss_yoggsaron_cloudAI(), brann_bronzebeard::brann_bronzebeardAI::DoAction(), npc_tirions_gambit_tirion::npc_tirions_gambit_tirionAI::DoAction(), npc_taretha::npc_tarethaAI::DoAction(), npc_scarlet_miner::npc_scarlet_minerAI::InitCartQuest(), npc_general_andorov::InitializeAI(), npc_kservant::npc_kservantAI::IsSummonedBy(), npc_custodian_of_time::npc_custodian_of_timeAI::MoveInLineOfSight(), npc_ancestral_wolf::npc_ancestral_wolfAI::npc_ancestral_wolfAI(), npc_frosthound::npc_frosthoundAI::PassengerBoarded(), npc_icefang::npc_icefangAI::PassengerBoarded(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::ReorderInstance(), npc_onyx_flamecaller::npc_onyx_flamecallerAI::Reset(), npc_black_knight_skeletal_gryphon::npc_black_knight_skeletal_gryphonAI::Reset(), npc_plaguehound_tracker::npc_plaguehound_trackerAI::Reset(), npc_time_lost_proto_drake::npc_time_lost_proto_drakeAI::RollPath(), boss_grand_champion::boss_grand_championAI::SetData(), npc_argent_soldier::npc_argent_soldierAI::SetData(), npc_kurenai_captive::npc_kurenai_captiveAI::SetGUID(), npc_captain_saeed::npc_captain_saeedAI::SetGUID(), npc_professor_phizzlethorpe::npc_professor_phizzlethorpeAI::sQuestAccept(), npc_ranger_lilatha::sQuestAccept(), npc_rinji::npc_rinjiAI::sQuestAccept(), npc_corporal_keeshan::npc_corporal_keeshanAI::sQuestAccept(), npc_muglash::npc_muglashAI::sQuestAccept(), npc_wounded_blood_elf::npc_wounded_blood_elfAI::sQuestAccept(), npc_barnes::npc_barnesAI::StartEvent(), npc_clintar_spirit::npc_clintar_spiritAI::StartEvent(), npc_arthas::npc_arthasAI::UpdateAI(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::UpdateAI(), npc_crok_scourgebane::npc_crok_scourgebaneAI::UpdateAI(), violet_hold_trashAI::UpdateAI(), npc_azure_saboteur::npc_azure_saboteurAI::UpdateAI(), npc_grimstone::npc_grimstoneAI::UpdateEscortAI(), npc_magwin::npc_magwinAI::UpdateEscortAI(), and npc_cork_gizelton::npc_cork_gizeltonAI::UpdateEscortAI().

◆ UpdateAI()

void npc_escortAI::UpdateAI ( uint32  )
overridevirtual

Use to start attacking a target. Called just before JustEngagedWith()

Reimplemented from ScriptedAI.

Reimplemented in npc_rocknot::npc_rocknotAI, npc_barnes::npc_barnesAI, npc_scarlet_miner::npc_scarlet_minerAI, npc_professor_phizzlethorpe::npc_professor_phizzlethorpeAI, npc_corporal_keeshan::npc_corporal_keeshanAI, npc_varian_wrynn::npc_varian_wrynnAI, npc_thrall_bfu::npc_thrall_bfuAI, npc_arthas::npc_arthasAI, npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI, npc_muglash::npc_muglashAI, npc_clintar_spirit::npc_clintar_spiritAI, npc_custodian_of_time::npc_custodian_of_timeAI, npc_ame::npc_ameAI, npc_argent_soldier::npc_argent_soldierAI, boss_grand_champion::boss_grand_championAI, npc_crok_scourgebane::npc_crok_scourgebaneAI, npc_mimirons_inferno::npc_mimirons_infernoAI, violet_hold_trashAI, npc_azure_invader::npc_azure_invaderAI, npc_azure_binder::npc_azure_binderAI, npc_azure_mage_slayer::npc_azure_mage_slayerAI, npc_azure_raider::npc_azure_raiderAI, npc_azure_stalker::npc_azure_stalkerAI, npc_azure_spellbreaker::npc_azure_spellbreakerAI, npc_azure_captain::npc_azure_captainAI, npc_azure_sorceror::npc_azure_sorcerorAI, npc_azure_saboteur::npc_azure_saboteurAI, npc_lurgglbr::npc_lurgglbrAI, npc_frosthound::npc_frosthoundAI, npc_icefang::npc_icefangAI, npc_maghar_captive::npc_maghar_captiveAI, npc_captain_saeed::npc_captain_saeedAI, npc_garments_of_quests::npc_garments_of_questsAI, npc_koltira_deathweaver::npc_koltira_deathweaverAI, npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI, npc_tyrion_spybot::npc_tyrion_spybotAI, npc_black_knight_skeletal_gryphon::npc_black_knight_skeletal_gryphonAI, npc_engineer_helice::npc_engineer_heliceAI, and npc_maxx_a_million_escort::npc_maxx_a_million_escortAI.

241{
243 {
244 if (m_uiWPWaitTimer <= diff)
245 {
246 if (CurrentWP == WaypointList.end())
247 {
248 if (DespawnAtEnd)
249 {
251 {
252 float fRetX, fRetY, fRetZ;
253 me->GetRespawnPosition(fRetX, fRetY, fRetZ);
254 me->GetMotionMaster()->MovePoint(POINT_HOME, fRetX, fRetY, fRetZ);
255
256 m_uiWPWaitTimer = 0;
257 return;
258 }
259
261 {
262 me->setDeathState(DeathState::JustDied);
263 me->Respawn();
264 }
265 else
267 }
268
269 // xinef: remove escort state, escort was finished (lack of this line resulted in skipping UpdateEscortAI calls after finished escort)
271 return;
272 }
273
275 {
276 // xinef, start escort if there is no spline active
277 if (me->movespline->Finalized())
278 {
279 Movement::PointsArray pathPoints;
280 GenerateWaypointArray(&pathPoints);
281 me->GetMotionMaster()->MoveSplinePath(&pathPoints);
282 }
283
285 m_uiWPWaitTimer = 0;
286 }
287 }
288 else
289 m_uiWPWaitTimer -= diff;
290 }
291
292 //Check if player or any member of his group is within range
294 {
295 m_uiPlayerCheckTimer += diff;
296 if (m_uiPlayerCheckTimer > 1000)
297 {
299 {
301 {
302 me->setDeathState(DeathState::JustDied);
303 me->Respawn();
304 }
305 else
307
308 return;
309 }
310
312 }
313 }
314
315 UpdateEscortAI(diff);
316}
std::vector< Vector3 > PointsArray
Definition: MoveSplineInitArgs.h:28
bool IsPlayerOrGroupInRange()
Definition: ScriptedEscortAI.cpp:222
void GenerateWaypointArray(Movement::PointsArray *points)
Definition: ScriptedEscortAI.cpp:584
virtual void WaypointStart(uint32)
Definition: ScriptedEscortAI.h:91
virtual void UpdateEscortAI(uint32 diff)
Definition: ScriptedEscortAI.cpp:318
void setDeathState(DeathState s, bool despawn=false) override
A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned....
Definition: Creature.cpp:1960
void Respawn(bool force=false)
Definition: Creature.cpp:2030
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition: Creature.cpp:2935
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2173
Movement::MoveSpline * movespline
Definition: Unit.h:1818
void MoveSplinePath(Movement::PointsArray *path)
Definition: MotionMaster.cpp:454
bool Finalized() const
Definition: MoveSpline.h:116

References CurrentWP, DespawnAtEnd, DespawnAtFar, Creature::DespawnOrUnsummon(), Movement::MoveSpline::Finalized(), GenerateWaypointArray(), Unit::GetMotionMaster(), Creature::GetRespawnPosition(), Unit::GetVictim(), HasEscortState(), IsPlayerOrGroupInRange(), m_bCanInstantRespawn, m_bCanReturnToStart, m_uiPlayerCheckTimer, m_uiPlayerGUID, m_uiWPWaitTimer, ScriptedAI::me, MotionMaster::MovePoint(), Unit::movespline, MotionMaster::MoveSplinePath(), POINT_HOME, RemoveEscortState(), Creature::Respawn(), Creature::setDeathState(), STATE_ESCORT_ESCORTING, STATE_ESCORT_PAUSED, STATE_ESCORT_RETURNING, UpdateEscortAI(), WaypointList, and WaypointStart().

Referenced by npc_daphne_stilwell::npc_daphne_stilwellAI::Update(), npc_rocknot::npc_rocknotAI::UpdateAI(), npc_barnes::npc_barnesAI::UpdateAI(), npc_scarlet_miner::npc_scarlet_minerAI::UpdateAI(), npc_professor_phizzlethorpe::npc_professor_phizzlethorpeAI::UpdateAI(), npc_corporal_keeshan::npc_corporal_keeshanAI::UpdateAI(), npc_varian_wrynn::npc_varian_wrynnAI::UpdateAI(), npc_thrall_bfu::npc_thrall_bfuAI::UpdateAI(), npc_arthas::npc_arthasAI::UpdateAI(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::UpdateAI(), npc_muglash::npc_muglashAI::UpdateAI(), npc_clintar_spirit::npc_clintar_spiritAI::UpdateAI(), npc_custodian_of_time::npc_custodian_of_timeAI::UpdateAI(), npc_ame::npc_ameAI::UpdateAI(), npc_argent_soldier::npc_argent_soldierAI::UpdateAI(), boss_grand_champion::boss_grand_championAI::UpdateAI(), npc_crok_scourgebane::npc_crok_scourgebaneAI::UpdateAI(), npc_mimirons_inferno::npc_mimirons_infernoAI::UpdateAI(), violet_hold_trashAI::UpdateAI(), npc_azure_saboteur::npc_azure_saboteurAI::UpdateAI(), npc_lurgglbr::npc_lurgglbrAI::UpdateAI(), npc_frosthound::npc_frosthoundAI::UpdateAI(), npc_icefang::npc_icefangAI::UpdateAI(), npc_maghar_captive::npc_maghar_captiveAI::UpdateAI(), npc_captain_saeed::npc_captain_saeedAI::UpdateAI(), npc_garments_of_quests::npc_garments_of_questsAI::UpdateAI(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::UpdateAI(), npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI::UpdateAI(), npc_tyrion_spybot::npc_tyrion_spybotAI::UpdateAI(), npc_black_knight_skeletal_gryphon::npc_black_knight_skeletal_gryphonAI::UpdateAI(), npc_engineer_helice::npc_engineer_heliceAI::UpdateAI(), and npc_maxx_a_million_escort::npc_maxx_a_million_escortAI::UpdateAI().

◆ UpdateEscortAI()

◆ WaypointReached()

virtual void npc_escortAI::WaypointReached ( uint32  pointId)
pure virtual

Implemented in npc_black_knight_skeletal_gryphon::npc_black_knight_skeletal_gryphonAI, boss_grand_champion::boss_grand_championAI, npc_captain_saeed::npc_captain_saeedAI, brann_bronzebeard::brann_bronzebeardAI, violet_hold_trashAI, boss_bjarngrim::boss_bjarngrimAI, npc_ranshalla::npc_ranshallaAI, npc_tirions_gambit_tirion::npc_tirions_gambit_tirionAI, npc_argent_soldier::npc_argent_soldierAI, npc_arthas::npc_arthasAI, npc_azure_saboteur::npc_azure_saboteurAI, npc_grimstone::npc_grimstoneAI, npc_rocknot::npc_rocknotAI, npc_barnes::npc_barnesAI, npc_scarlet_miner::npc_scarlet_minerAI, npc_koltira_deathweaver::npc_koltira_deathweaverAI, npc_professor_phizzlethorpe::npc_professor_phizzlethorpeAI, npc_ranger_lilatha, npc_rinji::npc_rinjiAI, npc_corporal_keeshan::npc_corporal_keeshanAI, npc_deathstalker_erland::npc_deathstalker_erlandAI, npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI, npc_tyrion_spybot::npc_tyrion_spybotAI, npc_varian_wrynn::npc_varian_wrynnAI, npc_thrall_bfu::npc_thrall_bfuAI, npc_daphne_stilwell::npc_daphne_stilwellAI, npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI, npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI, npc_taretha::npc_tarethaAI, npc_general_andorov, npc_muglash::npc_muglashAI, npc_magwin::npc_magwinAI, npc_prospector_remtravel::npc_prospector_remtravelAI, npc_cork_gizelton::npc_cork_gizeltonAI, npc_clintar_spirit::npc_clintar_spiritAI, npc_kaya_flathoof::npc_kaya_flathoofAI, npc_custodian_of_time::npc_custodian_of_timeAI, npc_gilthares::npc_giltharesAI, npc_wizzlecrank_shredder::npc_wizzlecrank_shredderAI, npc_lakota_windsong::npc_lakota_windsongAI, npc_paoka_swiftmountain::npc_paoka_swiftmountainAI, npc_ame::npc_ameAI, npc_onyx_flamecaller::npc_onyx_flamecallerAI, npc_crok_scourgebane::npc_crok_scourgebaneAI, npc_lurgglbr::npc_lurgglbrAI, npc_mootoo_the_younger::npc_mootoo_the_youngerAI, npc_bonker_togglevolt::npc_bonker_togglevoltAI, npc_emily::npc_emilyAI, npc_apothecary_hanes::npc_Apothecary_HanesAI, npc_plaguehound_tracker::npc_plaguehound_trackerAI, npc_engineer_helice::npc_engineer_heliceAI, npc_frosthound::npc_frosthoundAI, npc_ancestral_wolf::npc_ancestral_wolfAI, npc_wounded_blood_elf::npc_wounded_blood_elfAI, npc_maghar_captive::npc_maghar_captiveAI, npc_kurenai_captive::npc_kurenai_captiveAI, npc_bessy::npc_bessyAI, npc_maxx_a_million_escort::npc_maxx_a_million_escortAI, npc_kservant::npc_kservantAI, npc_isla_starmane::npc_isla_starmaneAI, npc_mimirons_inferno::npc_mimirons_infernoAI, boss_thorim_lightning_orb::boss_thorim_lightning_orbAI, boss_thorim_sif_blizzard::boss_thorim_sif_blizzardAI, boss_yoggsaron_cloud::boss_yoggsaron_cloudAI, npc_time_lost_proto_drake::npc_time_lost_proto_drakeAI, npc_icefang::npc_icefangAI, and npc_garments_of_quests::npc_garments_of_questsAI.

Referenced by MovementInform().

◆ WaypointStart()

virtual void npc_escortAI::WaypointStart ( uint32  )
inlinevirtual

Member Data Documentation

◆ CurrentWP

std::list<Escort_Waypoint>::iterator npc_escortAI::CurrentWP
private

◆ DespawnAtEnd

bool npc_escortAI::DespawnAtEnd
private

Referenced by SetDespawnAtEnd(), and UpdateAI().

◆ DespawnAtFar

bool npc_escortAI::DespawnAtFar
private

Referenced by SetDespawnAtFar(), and UpdateAI().

◆ HasImmuneToNPCFlags

bool npc_escortAI::HasImmuneToNPCFlags
private

Referenced by EnterEvadeMode(), and Start().

◆ m_bCanInstantRespawn

bool npc_escortAI::m_bCanInstantRespawn
private

Referenced by Start(), and UpdateAI().

◆ m_bCanReturnToStart

bool npc_escortAI::m_bCanReturnToStart
private

Referenced by Start(), and UpdateAI().

◆ m_bIsActiveAttacker

bool npc_escortAI::m_bIsActiveAttacker
private

Referenced by GetAttack(), SetCanAttack(), and Start().

◆ m_bIsRunning

bool npc_escortAI::m_bIsRunning
private

Referenced by MovementInform(), SetRun(), and Start().

◆ m_pQuestForEscort

Quest const* npc_escortAI::m_pQuestForEscort
private

Referenced by JustDied(), and Start().

◆ m_uiEscortState

uint32 npc_escortAI::m_uiEscortState
private

◆ m_uiPlayerCheckTimer

uint32 npc_escortAI::m_uiPlayerCheckTimer
private

Referenced by UpdateAI().

◆ m_uiPlayerGUID

ObjectGuid npc_escortAI::m_uiPlayerGUID
private

◆ m_uiWPWaitTimer

uint32 npc_escortAI::m_uiWPWaitTimer
private

◆ MaxPlayerDistance

float npc_escortAI::MaxPlayerDistance
private

◆ ScriptWP

bool npc_escortAI::ScriptWP
private

Referenced by AddWaypoint(), and Start().

◆ WaypointList