Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
ScriptedEscortAI.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SC_ESCORTAI_H
7#define SC_ESCORTAI_H
8
9#include "ScriptedCreature.h"
10#include "ScriptSystem.h"
11
12#define DEFAULT_MAX_PLAYER_DISTANCE 50
13
15{
16 Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
17 {
18 id = _id;
19 x = _x;
20 y = _y;
21 z = _z;
22 WaitTimeMs = _w;
23 }
24
26 float x;
27 float y;
28 float z;
30};
31
33{
34 STATE_ESCORT_NONE = 0x000, //nothing in progress
35 STATE_ESCORT_ESCORTING = 0x001, //escort are in progress
36 STATE_ESCORT_RETURNING = 0x002, //escort is returning after being in combat
37 STATE_ESCORT_PAUSED = 0x004 //will not proceed with waypoints before state is removed
38};
39
40struct npc_escortAI : public ScriptedAI
41{
42public:
43 explicit npc_escortAI(Creature* creature);
45
46 // CreatureAI functions
47 void AttackStart(Unit* who) OVERRIDE;
48
50
51 void JustDied(Unit*) OVERRIDE;
52
54
55 void ReturnToLastPoint();
56
58
59 void UpdateAI(uint32 diff) OVERRIDE; //the "internal" update, calls UpdateEscortAI()
60 virtual void UpdateEscortAI(uint32 const diff); //used when it's needed to add code in update (abilities, scripted events, etc)
61
63
64 // EscortAI functions
65 void AddWaypoint(uint32 id, float x, float y, float z, uint32 waitTime = 0); // waitTime is in ms
66
67 //this will set the current position to x/y/z/o, and the current WP to pointId.
68 bool SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation);
69
70 //this will set the current position to WP start position (if setPosition == true),
71 //and the current WP to pointId
72 bool SetNextWaypoint(uint32 pointId, bool setPosition = true, bool resetWaypointsOnFail = true);
73
74 bool GetWaypointPosition(uint32 pointId, float& x, float& y, float& z);
75
76 virtual void WaypointReached(uint32 pointId) = 0;
77 virtual void WaypointStart(uint32 /*pointId*/) { }
78
79 void Start(bool isActiveAttacker = true, bool run = false, uint64 playerGUID = 0, Quest const* quest = NULL, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true);
80
81 void SetRun(bool on = true);
82 void SetEscortPaused(bool on);
83
84 bool HasEscortState(uint32 escortState) const { return (m_uiEscortState & escortState); }
86
87 void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
88 float GetMaxPlayerDistance() const { return MaxPlayerDistance; }
89
90 void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
91 void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
92 bool GetAttack() const { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
93 void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
95
96protected:
98
99private:
100 bool AssistPlayerInCombat(Unit* who);
103
104 void AddEscortState(uint32 escortState) { m_uiEscortState |= escortState; }
105 void RemoveEscortState(uint32 escortState) { m_uiEscortState &= ~escortState; }
106
112
113 Quest const* m_pQuestForEscort; //generally passed in Start() when regular escort script.
114
115 std::list<Escort_Waypoint> WaypointList;
116 std::list<Escort_Waypoint>::iterator CurrentWP;
117
118 bool m_bIsActiveAttacker; //obsolete, determined by faction.
119 bool m_bIsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK)
120 bool m_bCanInstantRespawn; //if creature should respawn instantly after escort over (if not, database respawntime are used)
121 bool m_bCanReturnToStart; //if creature can walk same path (loop) without despawn. Not for regular escort quests.
126};
127#endif
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
eEscortState
@ STATE_ESCORT_PAUSED
@ STATE_ESCORT_ESCORTING
@ STATE_ESCORT_NONE
@ STATE_ESCORT_RETURNING
static Player * GetPlayer(WorldObject const &, uint64 guid)
Definition Unit.h:1367
Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
Creature * me
ScriptedAI(Creature *creature)
void EnterEvadeMode() OVERRIDE
bool GetAttack() const
void SetDespawnAtFar(bool despawn)
void FillPointMovementListForCreature()
uint32 m_uiPlayerCheckTimer
std::list< Escort_Waypoint > WaypointList
std::list< Escort_Waypoint >::iterator CurrentWP
virtual bool IsEscorted() OVERRIDE
void AddEscortState(uint32 escortState)
virtual void UpdateEscortAI(uint32 const diff)
void JustDied(Unit *) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
virtual void WaypointReached(uint32 pointId)=0
bool IsPlayerOrGroupInRange()
Player * GetPlayerForEscort()
void SetRun(bool on=true)
bool HasEscortState(uint32 escortState) const
void SetCanAttack(bool attack)
npc_escortAI(Creature *creature)
void RemoveEscortState(uint32 escortState)
float GetMaxPlayerDistance() const
void SetDespawnAtEnd(bool despawn)
void SetEscortPaused(bool on)
void Start(bool isActiveAttacker=true, bool run=false, uint64 playerGUID=0, Quest const *quest=NULL, bool instantRespawn=false, bool canLoopPath=false, bool resetWaypoints=true)
void MovementInform(uint32, uint32) OVERRIDE
bool AssistPlayerInCombat(Unit *who)
uint64 GetEventStarterGUID() const
bool SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation)
void MoveInLineOfSight(Unit *who) OVERRIDE
void JustRespawned() OVERRIDE
virtual void WaypointStart(uint32)
void AddWaypoint(uint32 id, float x, float y, float z, uint32 waitTime=0)
Quest const * m_pQuestForEscort
bool GetWaypointPosition(uint32 pointId, float &x, float &y, float &z)
void SetMaxPlayerDistance(float newMax)
void AttackStart(Unit *who) OVERRIDE