TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ScriptedFollowerAI.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef SC_FOLLOWERAI_H
20 #define SC_FOLLOWERAI_H
21 
22 #include "ScriptSystem.h"
23 
25 {
27  STATE_FOLLOW_INPROGRESS = 0x001, //must always have this state for any follow
28  STATE_FOLLOW_RETURNING = 0x002, //when returning to combat start after being in combat
29  STATE_FOLLOW_PAUSED = 0x004, //disables following
30  STATE_FOLLOW_COMPLETE = 0x008, //follow is completed and may end
31  STATE_FOLLOW_PREEVENT = 0x010, //not implemented (allow pre event to run, before follow is initiated)
32  STATE_FOLLOW_POSTEVENT = 0x020 //can be set at complete and allow post event to run
33 };
34 
36 {
37  public:
38  explicit FollowerAI(Creature* creature);
40 
41  //virtual void WaypointReached(uint32 uiPointId) = 0;
42 
43  void MovementInform(uint32 motionType, uint32 pointId) override;
44 
45  void AttackStart(Unit*) override;
46 
47  void MoveInLineOfSight(Unit*) override;
48 
49  void EnterEvadeMode(EvadeReason /*why*/ = EVADE_REASON_OTHER) override;
50 
51  void JustDied(Unit*) override;
52 
53  void JustRespawned() override;
54 
55  void UpdateAI(uint32) override; //the "internal" update, calls UpdateFollowerAI()
56  virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc)
57 
58  void StartFollow(Player* player, uint32 factionForFollower = 0, const Quest* quest = NULL);
59 
60  void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow
61  void SetFollowComplete(bool bWithEndEvent = false);
62 
63  bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState) != 0; }
64 
65  protected:
66  Player* GetLeaderForFollower();
67 
68  private:
69  void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; }
70  void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; }
71 
72  bool AssistPlayerInCombat(Unit* who);
73 
77 
78  const Quest* m_pQuestForFollow; //normally we have a quest
79 };
80 
81 #endif
Definition: ScriptedFollowerAI.h:27
Definition: QuestDef.h:279
Definition: ScriptedFollowerAI.h:32
~FollowerAI()
Definition: ScriptedFollowerAI.h:39
Definition: ScriptedFollowerAI.h:35
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
Definition: CreatureAI.cpp:168
void AddFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:69
virtual void UpdateAI(uint32 diff) override
Definition: ScriptedCreature.cpp:125
arena_t NULL
Definition: jemalloc_internal.h:624
virtual void JustRespawned()
Definition: CreatureAI.h:140
Definition: ScriptedFollowerAI.h:26
void JustDied(Unit *) override
Definition: ScriptedCreature.h:160
Definition: Creature.h:467
bool HasFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:63
uint32 m_uiUpdateFollowTimer
Definition: ScriptedFollowerAI.h:75
Definition: ScriptedCreature.h:142
eFollowState
Definition: ScriptedFollowerAI.h:24
uint32_t uint32
Definition: Define.h:150
Definition: ScriptedFollowerAI.h:28
void RemoveFollowState(uint32 uiFollowState)
Definition: ScriptedFollowerAI.h:70
const Quest * m_pQuestForFollow
Definition: ScriptedFollowerAI.h:78
uint32 m_uiFollowState
Definition: ScriptedFollowerAI.h:76
void AttackStart(Unit *) override
Definition: ScriptedCreature.cpp:117
Definition: ScriptedFollowerAI.h:30
#define TC_GAME_API
Definition: Define.h:134
Definition: ScriptedFollowerAI.h:31
virtual void MoveInLineOfSight(Unit *)
Definition: CreatureAI.cpp:128
ObjectGuid m_uiLeaderGUID
Definition: ScriptedFollowerAI.h:74
Definition: ObjectGuid.h:189
Definition: Unit.h:1305
virtual void MovementInform(uint32, uint32)
Definition: CreatureAI.h:143
Definition: ScriptedFollowerAI.h:29