Small cleanup in boss Ouro script.
[scriptdev2-git.git] / base / escort_ai.h
blobd432058bd46f6b661495e58a1addb0008e55cea4
1 /* Copyright (C) 2006 - 2010 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
2 * This program is free software licensed under GPL version 2
3 * Please see the included DOCS/LICENSE.TXT for more information */
5 #ifndef SC_ESCORTAI_H
6 #define SC_ESCORTAI_H
8 #include "../system/system.h"
10 struct Escort_Waypoint
12 Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
14 id = _id;
15 x = _x;
16 y = _y;
17 z = _z;
18 WaitTimeMs = _w;
21 uint32 id;
22 float x;
23 float y;
24 float z;
25 uint32 WaitTimeMs;
28 enum eEscortState
30 STATE_ESCORT_NONE = 0x000, //nothing in progress
31 STATE_ESCORT_ESCORTING = 0x001, //escort are in progress
32 STATE_ESCORT_RETURNING = 0x002, //escort is returning after being in combat
33 STATE_ESCORT_PAUSED = 0x004 //will not proceed with waypoints before state is removed
36 struct MANGOS_DLL_DECL npc_escortAI : public ScriptedAI
38 public:
39 explicit npc_escortAI(Creature* pCreature);
40 ~npc_escortAI() {}
42 virtual void Aggro(Unit*);
44 virtual void Reset() = 0;
46 // CreatureAI functions
47 bool IsVisible(Unit*) const;
49 void AttackStart(Unit*);
51 void EnterCombat(Unit*);
53 void MoveInLineOfSight(Unit*);
55 void JustDied(Unit*);
57 void JustRespawned();
59 void EnterEvadeMode();
61 void UpdateAI(const uint32); //the "internal" update, calls UpdateEscortAI()
62 virtual void UpdateEscortAI(const uint32); //used when it's needed to add code in update (abilities, scripted events, etc)
64 void MovementInform(uint32, uint32);
66 // EscortAI functions
67 //void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0);
69 virtual void WaypointReached(uint32 uiPointId) = 0;
70 virtual void WaypointStart(uint32 uiPointId) {}
72 void Start(bool bIsActiveAttacker = true, bool bRun = false, uint64 uiPlayerGUID = 0, const Quest* pQuest = NULL, bool bInstantRespawn = false, bool bCanLoopPath = false);
74 void SetRun(bool bRun = true);
75 void SetEscortPaused(bool uPaused);
77 bool HasEscortState(uint32 uiEscortState) { return (m_uiEscortState & uiEscortState); }
79 protected:
80 Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*m_creature, m_uiPlayerGUID); }
81 virtual void JustStartedEscort() {}
83 private:
84 bool AssistPlayerInCombat(Unit* pWho);
85 bool IsPlayerOrGroupInRange();
86 void FillPointMovementListForCreature();
88 void AddEscortState(uint32 uiEscortState) { m_uiEscortState |= uiEscortState; }
89 void RemoveEscortState(uint32 uiEscortState) { m_uiEscortState &= ~uiEscortState; }
91 uint64 m_uiPlayerGUID;
92 uint32 m_uiWPWaitTimer;
93 uint32 m_uiPlayerCheckTimer;
94 uint32 m_uiEscortState;
96 const Quest* m_pQuestForEscort; //generally passed in Start() when regular escort script.
98 std::list<Escort_Waypoint> WaypointList;
99 std::list<Escort_Waypoint>::iterator CurrentWP;
101 bool m_bIsActiveAttacker; //obsolete, determined by faction.
102 bool m_bIsRunning; //all creatures are walking by default (has flag SPLINEFLAG_WALKMODE)
103 bool m_bCanInstantRespawn; //if creature should respawn instantly after escort over (if not, database respawntime are used)
104 bool m_bCanReturnToStart; //if creature can walk same path (loop) without despawn. Not for regular escort quests.
106 #endif