37 if (
me->Attack(who,
true))
39 me->AddThreat(who, 0.0f);
40 me->SetInCombatWith(who);
47 me->GetMotionMaster()->MoveChase(who);
68 if (
me->IsFriendlyTo(who))
83 me->AddThreat(who, 0.0f);
101 if (
me->IsHostileTo(who))
103 float fAttackRadius =
me->GetAttackDistance(who);
104 if (
me->IsWithinDistInMap(who, fAttackRadius) &&
me->IsWithinLOSInMap(who))
106 if (!
me->GetVictim())
111 else if (
me->GetMap()->IsInstance())
114 me->AddThreat(who, 0.0f);
129 if (
Group* group = player->GetGroup())
131 for (
GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->
next())
133 if (
Player* member = groupRef->GetSource())
155 if (
me->getFaction() !=
me->GetCreatureTemplate()->faction_A)
156 me->setFaction(
me->GetCreatureTemplate()->faction_A);
163 me->RemoveAllAuras();
164 me->DeleteThreatList();
165 me->CombatStop(
true);
166 me->SetLootRecipient(NULL);
170 SF_LOG_DEBUG(
"scripts",
"FollowerAI left combat, returning to CombatStartPosition.");
174 float fPosX, fPosY, fPosZ;
175 me->GetPosition(fPosX, fPosY, fPosZ);
182 me->GetMotionMaster()->MoveTargetedHome();
196 SF_LOG_DEBUG(
"scripts",
"FollowerAI is set completed, despawns.");
197 me->DespawnOrUnsummon();
201 bool bIsMaxRangeExceeded =
true;
207 SF_LOG_DEBUG(
"scripts",
"FollowerAI is returning to leader.");
214 if (
Group* group = player->GetGroup())
216 for (
GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->
next())
218 Player* member = groupRef->GetSource();
222 bIsMaxRangeExceeded =
false;
230 bIsMaxRangeExceeded =
false;
234 if (bIsMaxRangeExceeded)
236 SF_LOG_DEBUG(
"scripts",
"FollowerAI failed because player/group was to far away or not found");
237 me->DespawnOrUnsummon();
271 me->DespawnOrUnsummon();
279 SF_LOG_DEBUG(
"scripts",
"FollowerAI attempt to StartFollow while in combat.");
285 SF_LOG_ERROR(
"scripts",
"FollowerAI attempt to StartFollow while already following.");
292 if (factionForFollower)
293 me->setFaction(factionForFollower);
299 me->GetMotionMaster()->Clear();
300 me->GetMotionMaster()->MoveIdle();
301 SF_LOG_DEBUG(
"scripts",
"FollowerAI start with WAYPOINT_MOTION_TYPE, set to MoveIdle.");
317 if (player->IsAlive())
321 if (
Group* group = player->GetGroup())
323 for (
GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->
next())
325 Player* member = groupRef->GetSource();
329 SF_LOG_DEBUG(
"scripts",
"FollowerAI GetLeader changed and returned new leader.");
338 SF_LOG_DEBUG(
"scripts",
"FollowerAI GetLeader can not find suitable leader.");
349 me->GetMotionMaster()->Clear();
350 me->GetMotionMaster()->MoveIdle();
378 me->GetMotionMaster()->Clear();
379 me->GetMotionMaster()->MoveIdle();
#define CREATURE_Z_ATTACK_RANGE
#define SF_LOG_DEBUG(filterType__,...)
#define SF_LOG_ERROR(filterType__,...)
@ QUEST_STATUS_INCOMPLETE
const float MAX_PLAYER_DISTANCE
@ STATE_FOLLOW_INPROGRESS
@ CREATURE_TYPEFLAGS_AID_PLAYERS
void SetFollowPaused(bool bPaused)
uint32 m_uiUpdateFollowTimer
void MovementInform(uint32 motionType, uint32 pointId) OVERRIDE
void JustDied(Unit *) OVERRIDE
void JustRespawned() OVERRIDE
const Quest * m_pQuestForFollow
void MoveInLineOfSight(Unit *) OVERRIDE
virtual void UpdateFollowerAI(uint32)
void EnterEvadeMode() OVERRIDE
void UpdateAI(uint32) OVERRIDE
== Triggered Actions Requested ==================
void RemoveFollowState(uint32 uiFollowState)
void AttackStart(Unit *) OVERRIDE
Player * GetLeaderForFollower()
void SetFollowComplete(bool bWithEndEvent=false)
bool AssistPlayerInCombat(Unit *who)
FollowerAI(Creature *creature)
void StartFollow(Player *player, uint32 factionForFollower=0, const Quest *quest=NULL)
bool HasFollowState(uint32 uiFollowState) const
void AddFollowState(uint32 uiFollowState)
static Player * GetPlayer(WorldObject const &, uint64 guid)
void DoMeleeAttackIfReady()
bool isTargetableForAttack(bool checkFakeDeath=true) const
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
bool isInAccessiblePlaceFor(Creature const *c) const
void RemoveAurasByType(AuraType auraType, uint64 casterGUID=0, Aura *except=NULL, bool negative=true, bool positive=true)
void SetInCombatWith(Unit *enemy)
std::string const & GetName() const
void SetCombatMovement(bool allowMovement)
bool IsCombatMovementAllowed() const
ScriptedAI(Creature *creature)