TrinityCore
ScriptedFollowerAI.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_SCRIPTEDFOLLOWERAI_H
19#define TRINITY_SCRIPTEDFOLLOWERAI_H
20
21#include "ScriptedCreature.h"
22
23class Quest;
24
26{
28 STATE_FOLLOW_INPROGRESS = 0x001, // must always have this state for any follow
29 STATE_FOLLOW_PAUSED = 0x002, // disables following
30 STATE_FOLLOW_COMPLETE = 0x004, // follow is completed and may end
31 STATE_FOLLOW_PREEVENT = 0x008, // not implemented (allow pre event to run, before follow is initiated)
32 STATE_FOLLOW_POSTEVENT = 0x010 // can be set at complete and allow post event to run
33};
34
36{
37 public:
38 explicit FollowerAI(Creature* creature);
40
41 void MoveInLineOfSight(Unit*) override;
42 void JustDied(Unit*) override;
43 void JustReachedHome() override;
44 void OwnerAttackedBy(Unit* other) override;
45
46 // the "internal" update, calls UpdateFollowerAI()
47 void UpdateAI(uint32) override;
48 // used when it's needed to add code in update (abilities, scripted events, etc)
49 virtual void UpdateFollowerAI(uint32);
50
51 void StartFollow(Player* player, uint32 factionForFollower = 0, uint32 quest = 0);
52 // if special event require follow mode to hold/resume during the follow
53 void SetFollowPaused(bool paused);
54 void SetFollowComplete(bool withEndEvent = false);
55
56 bool IsEscorted() const override { return HasFollowState(STATE_FOLLOW_INPROGRESS); }
57 bool HasFollowState(uint32 uiFollowState) const { return (_followState & uiFollowState) != 0; }
58
59 protected:
60 Player* GetLeaderForFollower();
61
62 private:
63 void AddFollowState(uint32 followState) { _followState |= followState; }
64 void RemoveFollowState(uint32 followState) { _followState &= ~followState; }
65 bool ShouldAssistPlayerInCombatAgainst(Unit* who) const;
66
71};
72
73#endif
#define TC_GAME_API
Definition: Define.h:123
uint32_t uint32
Definition: Define.h:142
FollowerState
@ STATE_FOLLOW_PREEVENT
@ STATE_FOLLOW_COMPLETE
@ STATE_FOLLOW_POSTEVENT
@ STATE_FOLLOW_NONE
@ STATE_FOLLOW_INPROGRESS
@ STATE_FOLLOW_PAUSED
virtual void MoveInLineOfSight(Unit *)
Definition: CreatureAI.cpp:122
virtual void JustReachedHome()
Definition: CreatureAI.h:159
virtual void JustDied(Unit *)
Definition: CreatureAI.h:105
virtual void OwnerAttackedBy(Unit *attacker)
Definition: CreatureAI.h:168
bool IsEscorted() const override
void AddFollowState(uint32 followState)
ObjectGuid _leaderGUID
void RemoveFollowState(uint32 followState)
uint32 _updateFollowTimer
bool HasFollowState(uint32 uiFollowState) const
uint32 _questForFollow
Definition: Unit.h:627
virtual void UpdateAI(uint32 diff) override