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

#include <ScriptedFollowerAI.h>

Public Member Functions

 FollowerAI (Creature *creature)
 
 ~FollowerAI ()
 
void MovementInform (uint32 motionType, uint32 pointId) override
 
void AttackStart (Unit *) override
 
void MoveInLineOfSight (Unit *) override
 
void EnterEvadeMode (EvadeReason=EVADE_REASON_OTHER) override
 
void JustDied (Unit *) override
 
void JustRespawned () override
 
void UpdateAI (uint32) override
 
virtual void UpdateFollowerAI (uint32)
 
void StartFollow (Player *player, uint32 factionForFollower=0, const Quest *quest=NULL)
 
void SetFollowPaused (bool bPaused)
 
void SetFollowComplete (bool bWithEndEvent=false)
 
bool HasFollowState (uint32 uiFollowState)
 
- Public Member Functions inherited from ScriptedAI
 ScriptedAI (Creature *creature)
 
virtual ~ScriptedAI ()
 
void AttackStartNoMove (Unit *target)
 
void DamageTaken (Unit *, uint32 &) 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 OnPossess (bool)
 
void Reset () override
 
void EnterCombat (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 DoResetThreat ()
 
float DoGetThreat (Unit *unit)
 
void DoModifyThreatPercent (Unit *unit, int32 pct)
 
void DoTeleportTo (float x, float y, float z, uint32 time=0)
 
void DoTeleportTo (float const pos[4])
 
void DoTeleportPlayer (Unit *unit, float x, float y, float z, float o)
 
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 HealthBelowPct (uint32 pct) const
 
bool HealthAbovePct (uint32 pct) const
 
SpellInfo constSelectSpell (Unit *target, uint32 school, uint32 mechanic, SelectTargetType targets, 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)
 
void SetCombatMovement (bool allowMovement)
 
bool IsCombatMovementAllowed () 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
 
- Public Member Functions inherited from CreatureAI
void Talk (uint8 id, WorldObject const *whisperTarget=nullptr)
 
 CreatureAI (Creature *creature)
 
virtual ~CreatureAI ()
 
void MoveInLineOfSight_Safe (Unit *who)
 == Reactions At ================================= More...
 
void TriggerAlert (Unit const *who) const
 
virtual bool CanRespawn ()
 
virtual void IsSummonedBy (Unit *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void AttackedBy (Unit *)
 
virtual bool IsEscorted () const
 
void OnCharmed (bool apply) override
 
virtual void JustReachedHome ()
 
void DoZoneInCombat (Creature *creature=NULL, float maxRangeToNearestTarget=50.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 void OnSpellClick (Unit *, bool &)
 
virtual bool CanSeeAlways (WorldObject const *)
 
int32 VisualizeBoundary (uint32 duration, Unit *owner=nullptr, bool fill=false) const
 
virtual bool CheckInRoom ()
 
CreatureBoundary constGetBoundary () const
 
- Public Member Functions inherited from UnitAI
 UnitAI (Unit *unit)
 
virtual ~UnitAI ()
 
virtual bool CanAIAttack (Unit const *) const
 
virtual void InitializeAI ()
 
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 (SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
UnitSelectTarget (SelectAggroTarget targetType, uint32 position, PREDICATE const &predicate)
 
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectAggroTarget targetType, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
void SelectTargetList (std::list< Unit * > &targetList, PREDICATE const &predicate, uint32 maxTargets, SelectAggroTarget targetType)
 
virtual void DamageDealt (Unit *, uint32 &, DamageEffectType)
 
virtual void HealReceived (Unit *, uint32 &)
 
virtual void HealDone (Unit *, uint32 &)
 
virtual void SpellInterrupted (uint32, uint32)
 
void AttackStartCaster (Unit *victim, float dist)
 
void DoCast (uint32 spellId)
 
void DoCast (Unit *victim, uint32 spellId, bool triggered=false)
 
void DoCastVictim (uint32 spellId, bool triggered=false)
 
void DoCastAOE (uint32 spellId, bool triggered=false)
 
void DoMeleeAttackIfReady ()
 
bool DoSpellAttackIfReady (uint32 spellId)
 
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 sQuestReward (Player *, Quest const *, uint32)
 
virtual bool sOnDummyEffect (Unit *, uint32, SpellEffIndex)
 
virtual void sOnGameEvent (bool, uint16)
 

Protected Member Functions

PlayerGetLeaderForFollower ()
 
- 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)
 
bool CheckBoundary (Position const *who=nullptr) const
 
void SetBoundary (CreatureBoundary const *boundary)
 
bool _EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 

Private Member Functions

void AddFollowState (uint32 uiFollowState)
 
void RemoveFollowState (uint32 uiFollowState)
 
bool AssistPlayerInCombat (Unit *who)
 

Private Attributes

ObjectGuid m_uiLeaderGUID
 
uint32 m_uiUpdateFollowTimer
 
uint32 m_uiFollowState
 
const Questm_pQuestForFollow
 

Additional Inherited Members

- Public Types inherited from CreatureAI
enum  EvadeReason { EVADE_REASON_NO_HOSTILES, EVADE_REASON_BOUNDARY, EVADE_REASON_SEQUENCE_BREAK, EVADE_REASON_OTHER }
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- Public Attributes inherited from ScriptedAI
bool IsFleeing
 
- Static Public Attributes inherited from UnitAI
static AISpellInfoTypeAISpellInfo
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
CreatureBoundary const_boundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Constructor & Destructor Documentation

FollowerAI::FollowerAI ( Creature creature)
explicit
38  : ScriptedAI(creature),
42 { }
ScriptedAI(Creature *creature)
Definition: ScriptedCreature.cpp:100
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: ScriptedFollowerAI.h:26
uint32 m_uiUpdateFollowTimer
Definition: ScriptedFollowerAI.h:75
const Quest * m_pQuestForFollow
Definition: ScriptedFollowerAI.h:78
uint32 m_uiFollowState
Definition: ScriptedFollowerAI.h:76
FollowerAI::~FollowerAI ( )
inline
39 { }

Member Function Documentation

void FollowerAI::AddFollowState ( uint32  uiFollowState)
inlineprivate
69 { m_uiFollowState |= uiFollowState; }
uint32 m_uiFollowState
Definition: ScriptedFollowerAI.h:76

+ Here is the caller graph for this function:

bool FollowerAI::AssistPlayerInCombat ( Unit who)
private
67 {
68  if (!who || !who->GetVictim())
69  return false;
70 
71  //experimental (unknown) flag not present
73  return false;
74 
75  //not a player
77  return false;
78 
79  //never attack friendly
80  if (me->IsFriendlyTo(who))
81  return false;
82 
83  //too far away and no free sight?
85  {
86  //already fighting someone?
87  if (!me->GetVictim())
88  {
89  AttackStart(who);
90  return true;
91  }
92  else
93  {
94  who->SetInCombatWith(me);
95  me->AddThreat(who, 0.0f);
96  return true;
97  }
98  }
99 
100  return false;
101 }
Unit * EnsureVictim() const
Definition: Unit.h:1381
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: Unit.cpp:10691
bool IsWithinLOSInMap(WorldObject const *obj) const
Definition: Object.cpp:1584
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
Creature *const me
Definition: CreatureAI.h:71
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: SharedDefines.h:3668
Unit * GetVictim() const
Definition: Unit.h:1379
void AttackStart(Unit *) override
Definition: ScriptedFollowerAI.cpp:44
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
const float MAX_PLAYER_DISTANCE
Definition: ScriptedFollowerAI.cpp:31
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9840
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560
uint32 type_flags
Definition: Creature.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FollowerAI::AttackStart ( Unit who)
overridevirtual

Reimplemented from ScriptedAI.

45 {
46  if (!who)
47  return;
48 
49  if (me->Attack(who, true))
50  {
51  me->AddThreat(who, 0.0f);
52  me->SetInCombatWith(who);
53  who->SetInCombatWith(me);
54 
57 
59  me->GetMotionMaster()->MoveChase(who);
60  }
61 }
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: Unit.cpp:10691
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7222
void MoveChase(Unit *target, float dist=0.0f, float angle=0.0f)
Definition: MotionMaster.cpp:241
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsCombatMovementAllowed() const
Definition: ScriptedCreature.h:261
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
Creature *const me
Definition: CreatureAI.h:71
Definition: Unit.h:559
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9840

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FollowerAI::EnterEvadeMode ( EvadeReason  = EVADE_REASON_OTHER)
overridevirtual

Reimplemented from CreatureAI.

180 {
181  me->RemoveAllAuras();
182  me->DeleteThreatList();
183  me->CombatStop(true);
185 
187  {
188  TC_LOG_DEBUG("scripts", "FollowerAI left combat, returning to CombatStartPosition.");
189 
191  {
192  float fPosX, fPosY, fPosZ;
193  me->GetPosition(fPosX, fPosY, fPosZ);
194  me->GetMotionMaster()->MovePoint(POINT_COMBAT_START, fPosX, fPosY, fPosZ);
195  }
196  }
197  else
198  {
201  }
202 
203  Reset();
204 }
void RemoveAllAuras()
Definition: Unit.cpp:3920
Definition: ScriptedFollowerAI.h:27
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void MoveTargetedHome()
Definition: MotionMaster.cpp:201
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:663
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetLootRecipient(Unit *unit)
Definition: Creature.cpp:993
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
Creature *const me
Definition: CreatureAI.h:71
void MovePoint(uint32 id, Position const &pos, bool generatePath=true)
Definition: MotionMaster.h:172
void GetPosition(float &x, float &y) const
Definition: Position.h:109
void Reset() override
Definition: ScriptedCreature.h:192
void DeleteThreatList()
Definition: Unit.cpp:10700
Definition: MotionMaster.h:43
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
Definition: ScriptedFollowerAI.cpp:35

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * FollowerAI::GetLeaderForFollower ( )
protected
332 {
334  {
335  if (player->IsAlive())
336  return player;
337  else
338  {
339  if (Group* group = player->GetGroup())
340  {
341  for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
342  {
343  Player* member = groupRef->GetSource();
344 
345  if (member && member->IsAlive() && me->IsWithinDistInMap(member, MAX_PLAYER_DISTANCE))
346  {
347  TC_LOG_DEBUG("scripts", "FollowerAI GetLeader changed and returned new leader.");
348  m_uiLeaderGUID = member->GetGUID();
349  return member;
350  }
351  }
352  }
353  }
354  }
355 
356  TC_LOG_DEBUG("scripts", "FollowerAI GetLeader can not find suitable leader.");
357  return NULL;
358 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
Creature *const me
Definition: CreatureAI.h:71
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
const float MAX_PLAYER_DISTANCE
Definition: ScriptedFollowerAI.cpp:31
ObjectGuid m_uiLeaderGUID
Definition: ScriptedFollowerAI.h:74
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool FollowerAI::HasFollowState ( uint32  uiFollowState)
inline
63 { return (m_uiFollowState & uiFollowState) != 0; }
uint32 m_uiFollowState
Definition: ScriptedFollowerAI.h:76

+ Here is the caller graph for this function:

void FollowerAI::JustDied ( Unit )
overridevirtual
Todo:
need a better check for quests with time limit.

Reimplemented from ScriptedAI.

140 {
142  return;
143 
145  if (Player* player = GetLeaderForFollower())
146  {
147  if (Group* group = player->GetGroup())
148  {
149  for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
150  {
151  if (Player* member = groupRef->GetSource())
152  {
153  if (member->GetQuestStatus(m_pQuestForFollow->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
154  member->FailQuest(m_pQuestForFollow->GetQuestId());
155  }
156  }
157  }
158  else
159  {
160  if (player->GetQuestStatus(m_pQuestForFollow->GetQuestId()) == QUEST_STATUS_INCOMPLETE)
161  player->FailQuest(m_pQuestForFollow->GetQuestId());
162  }
163  }
164 }
Definition: ScriptedFollowerAI.h:27
arena_t NULL
Definition: jemalloc_internal.h:624
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
Player * GetLeaderForFollower()
Definition: ScriptedFollowerAI.cpp:331
uint32 GetQuestId() const
Definition: QuestDef.h:304
const Quest * m_pQuestForFollow
Definition: ScriptedFollowerAI.h:78
Definition: QuestDef.h:113
ObjectGuid m_uiLeaderGUID
Definition: ScriptedFollowerAI.h:74
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

void FollowerAI::JustRespawned ( )
overridevirtual

Reimplemented from CreatureAI.

167 {
169 
171  SetCombatMovement(true);
172 
175 
176  Reset();
177 }
uint32 getFaction() const
Definition: Unit.h:1466
Definition: ScriptedFollowerAI.h:26
bool IsCombatMovementAllowed() const
Definition: ScriptedCreature.h:261
uint32 faction
Definition: Creature.h:97
void setFaction(uint32 faction)
Definition: Unit.h:1467
Creature *const me
Definition: CreatureAI.h:71
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
void SetCombatMovement(bool allowMovement)
Definition: ScriptedCreature.cpp:382
void Reset() override
Definition: ScriptedCreature.h:192
uint32 m_uiFollowState
Definition: ScriptedFollowerAI.h:76

+ Here is the call graph for this function:

void FollowerAI::MoveInLineOfSight ( Unit who)
overridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_beryl_sorcerer::npc_beryl_sorcererAI, npc_nexus_drake_hatchling::npc_nexus_drake_hatchlingAI, npc_tooga::npc_toogaAI, and npc_mist::npc_mistAI.

104 {
106  {
108  return;
109 
110  if (!me->CanFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
111  return;
112 
113  if (me->IsHostileTo(who))
114  {
115  float fAttackRadius = me->GetAttackDistance(who);
116  if (me->IsWithinDistInMap(who, fAttackRadius) && me->IsWithinLOSInMap(who))
117  {
118  if (!me->GetVictim())
119  {
120  // Clear distracted state on combat
122  {
124  me->GetMotionMaster()->Clear();
125  }
126 
127  AttackStart(who);
128  }
129  else if (me->GetMap()->IsDungeon())
130  {
131  who->SetInCombatWith(me);
132  me->AddThreat(who, 0.0f);
133  }
134  }
135  }
136  }
137 }
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: Unit.cpp:10691
Definition: ScriptedFollowerAI.h:27
Definition: Unit.h:562
Map * GetMap() const
Definition: Object.h:543
void Clear(bool reset=true)
Definition: MotionMaster.h:138
bool IsWithinLOSInMap(WorldObject const *obj) const
Definition: Object.cpp:1584
#define CREATURE_Z_ATTACK_RANGE
Definition: Creature.h:459
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
bool IsDungeon() const
Definition: Map.h:395
float GetDistanceZ(WorldObject const *obj) const
Definition: Object.cpp:1546
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
Creature *const me
Definition: CreatureAI.h:71
bool AssistPlayerInCombat(Unit *who)
Definition: ScriptedFollowerAI.cpp:66
Definition: Unit.h:553
float GetAttackDistance(Unit const *player) const
Definition: Creature.cpp:1586
Unit * GetVictim() const
Definition: Unit.h:1379
void AttackStart(Unit *) override
Definition: ScriptedFollowerAI.cpp:44
bool isInAccessiblePlaceFor(Creature const *c) const
Definition: Unit.cpp:2956
bool CanFly() const override
Definition: Creature.h:500
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
bool isTargetableForAttack(bool checkFakeDeath=true) const
Definition: Unit.cpp:9987
void SetInCombatWith(Unit *enemy)
Definition: Unit.cpp:9840

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FollowerAI::MovementInform ( uint32  motionType,
uint32  pointId 
)
overridevirtual

Reimplemented from CreatureAI.

Reimplemented in npc_tooga::npc_toogaAI.

277 {
279  return;
280 
281  if (pointId == POINT_COMBAT_START)
282  {
283  if (GetLeaderForFollower())
284  {
287  }
288  else
290  }
291 }
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
Definition: ScriptedFollowerAI.h:27
void AddFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:69
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
Creature *const me
Definition: CreatureAI.h:71
Player * GetLeaderForFollower()
Definition: ScriptedFollowerAI.cpp:331
Definition: ScriptedFollowerAI.h:28
Definition: MotionMaster.h:46
Definition: ScriptedFollowerAI.cpp:35
Definition: ScriptedFollowerAI.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FollowerAI::RemoveFollowState ( uint32  uiFollowState)
inlineprivate
70 { m_uiFollowState &= ~uiFollowState; }
uint32 m_uiFollowState
Definition: ScriptedFollowerAI.h:76

+ Here is the caller graph for this function:

void FollowerAI::SetFollowComplete ( bool  bWithEndEvent = false)
361 {
363  {
365 
366  me->StopMoving();
367  me->GetMotionMaster()->Clear();
369  }
370 
371  if (bWithEndEvent)
373  else
374  {
377  }
378 
380 }
void MoveIdle()
Definition: MotionMaster.cpp:185
Definition: ScriptedFollowerAI.h:32
void Clear(bool reset=true)
Definition: MotionMaster.h:138
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void AddFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:69
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
Creature *const me
Definition: CreatureAI.h:71
Definition: Unit.h:559
void RemoveFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:70
Definition: ScriptedFollowerAI.h:30
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FollowerAI::SetFollowPaused ( bool  bPaused)
383 {
385  return;
386 
387  if (paused)
388  {
390 
392  {
394 
395  me->StopMoving();
396  me->GetMotionMaster()->Clear();
398  }
399  }
400  else
401  {
403 
404  if (Player* leader = GetLeaderForFollower())
406  }
407 }
#define PET_FOLLOW_ANGLE
Definition: PetDefines.h:78
Definition: ScriptedFollowerAI.h:27
void MoveIdle()
Definition: MotionMaster.cpp:185
void Clear(bool reset=true)
Definition: MotionMaster.h:138
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void AddFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:69
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
Creature *const me
Definition: CreatureAI.h:71
Player * GetLeaderForFollower()
Definition: ScriptedFollowerAI.cpp:331
Definition: Unit.h:559
void RemoveFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:70
Definition: ScriptedFollowerAI.h:30
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:265
Definition: ScriptedFollowerAI.h:29

+ Here is the call graph for this function:

void FollowerAI::StartFollow ( Player player,
uint32  factionForFollower = 0,
const Quest quest = NULL 
)
294 {
295  if (me->GetVictim())
296  {
297  TC_LOG_DEBUG("scripts", "FollowerAI attempt to StartFollow while in combat.");
298  return;
299  }
300 
302  {
303  TC_LOG_ERROR("scripts", "FollowerAI attempt to StartFollow while already following.");
304  return;
305  }
306 
307  //set variables
308  m_uiLeaderGUID = player->GetGUID();
309 
310  if (factionForFollower)
311  me->setFaction(factionForFollower);
312 
313  m_pQuestForFollow = quest;
314 
316  {
317  me->GetMotionMaster()->Clear();
319  TC_LOG_DEBUG("scripts", "FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle.");
320  }
321 
323 
325 
327 
328  TC_LOG_DEBUG("scripts", "FollowerAI start follow %s (%s)", player->GetName().c_str(), m_uiLeaderGUID.ToString().c_str());
329 }
#define PET_FOLLOW_ANGLE
Definition: PetDefines.h:78
Definition: ScriptedFollowerAI.h:27
void MoveIdle()
Definition: MotionMaster.cpp:185
void Clear(bool reset=true)
Definition: MotionMaster.h:138
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void AddFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:69
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:663
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
void setFaction(uint32 faction)
Definition: Unit.h:1467
Creature *const me
Definition: CreatureAI.h:71
Unit * GetVictim() const
Definition: Unit.h:1379
Definition: Unit.h:734
const Quest * m_pQuestForFollow
Definition: ScriptedFollowerAI.h:78
ObjectGuid m_uiLeaderGUID
Definition: ScriptedFollowerAI.h:74
Definition: UpdateFields.h:135
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetUInt64Value(uint16 index, uint64 value)
Definition: Object.cpp:1017
Definition: MotionMaster.h:39
std::string ToString() const
Definition: ObjectGuid.cpp:99
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FollowerAI::UpdateAI ( uint32  uiDiff)
overridevirtual

Reimplemented from ScriptedAI.

Reimplemented in npc_beryl_sorcerer::npc_beryl_sorcererAI, and npc_nexus_drake_hatchling::npc_nexus_drake_hatchlingAI.

207 {
209  {
210  if (m_uiUpdateFollowTimer <= uiDiff)
211  {
213  {
214  TC_LOG_DEBUG("scripts", "FollowerAI is set completed, despawns.");
216  return;
217  }
218 
219  bool bIsMaxRangeExceeded = true;
220 
221  if (Player* player = GetLeaderForFollower())
222  {
224  {
225  TC_LOG_DEBUG("scripts", "FollowerAI is returning to leader.");
226 
229  return;
230  }
231 
232  if (Group* group = player->GetGroup())
233  {
234  for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next())
235  {
236  Player* member = groupRef->GetSource();
237 
238  if (member && me->IsWithinDistInMap(member, MAX_PLAYER_DISTANCE))
239  {
240  bIsMaxRangeExceeded = false;
241  break;
242  }
243  }
244  }
245  else
246  {
248  bIsMaxRangeExceeded = false;
249  }
250  }
251 
252  if (bIsMaxRangeExceeded)
253  {
254  TC_LOG_DEBUG("scripts", "FollowerAI failed because player/group was to far away or not found");
256  return;
257  }
258 
259  m_uiUpdateFollowTimer = 1000;
260  }
261  else
262  m_uiUpdateFollowTimer -= uiDiff;
263  }
264 
265  UpdateFollowerAI(uiDiff);
266 }
#define PET_FOLLOW_ANGLE
Definition: PetDefines.h:78
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
Definition: ScriptedFollowerAI.h:27
Definition: ScriptedFollowerAI.h:32
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
uint32 m_uiUpdateFollowTimer
Definition: ScriptedFollowerAI.h:75
Creature *const me
Definition: CreatureAI.h:71
Player * GetLeaderForFollower()
Definition: ScriptedFollowerAI.cpp:331
Unit * GetVictim() const
Definition: Unit.h:1379
virtual void UpdateFollowerAI(uint32)
Definition: ScriptedFollowerAI.cpp:268
Definition: ScriptedFollowerAI.h:28
void RemoveFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:70
const float MAX_PLAYER_DISTANCE
Definition: ScriptedFollowerAI.cpp:31
Definition: ScriptedFollowerAI.h:30
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
Definition: Group.h:191
Definition: GroupReference.h:27
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:265

+ Here is the call graph for this function:

void FollowerAI::UpdateFollowerAI ( uint32  )
virtual

Reimplemented in npc_tooga::npc_toogaAI.

269 {
270  if (!UpdateVictim())
271  return;
272 
274 }
bool UpdateVictim()
Definition: CreatureAI.cpp:233
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

const Quest* FollowerAI::m_pQuestForFollow
private
uint32 FollowerAI::m_uiFollowState
private
ObjectGuid FollowerAI::m_uiLeaderGUID
private
uint32 FollowerAI::m_uiUpdateFollowTimer
private

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