2009-02-17 18:08:26 +01:00
|
|
|
/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
|
2008-10-21 13:19:26 -05:00
|
|
|
* This program is free software licensed under GPL version 2
|
|
|
|
|
* Please see the included DOCS/LICENSE.TXT for more information */
|
|
|
|
|
|
|
|
|
|
#ifndef SC_ESCORTAI_H
|
|
|
|
|
#define SC_ESCORTAI_H
|
|
|
|
|
|
2009-04-03 17:57:57 +02:00
|
|
|
#define DEFAULT_MAX_PLAYER_DISTANCE 50
|
2009-03-22 23:11:55 +01:00
|
|
|
|
2009-04-09 23:07:32 +02:00
|
|
|
extern UNORDERED_MAP<uint32, std::vector<PointMovement> > PointMovementMap;
|
|
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
struct Escort_Waypoint
|
|
|
|
|
{
|
|
|
|
|
Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
|
|
|
|
|
{
|
|
|
|
|
id = _id;
|
|
|
|
|
x = _x;
|
|
|
|
|
y = _y;
|
|
|
|
|
z = _z;
|
|
|
|
|
WaitTimeMs = _w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32 id;
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float z;
|
|
|
|
|
uint32 WaitTimeMs;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|
|
|
|
{
|
|
|
|
|
public:
|
2009-08-11 00:43:06 +02:00
|
|
|
explicit npc_escortAI(Creature* pCreature) : ScriptedAI(pCreature),
|
2009-08-14 05:32:39 +02:00
|
|
|
IsBeingEscorted(false), IsOnHold(false), PlayerGUID(0), MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE), CanMelee(true), m_uiPlayerCheckTimer(1000), m_uiWPWaitTimer(2500), m_bIsReturning(false), m_bIsActiveAttacker(true), m_bIsRunning(false), DespawnAtEnd(true), DespawnAtFar(true), m_pQuestForEscort(NULL), m_bCanInstantRespawn(false), m_bCanReturnToStart(false) {}
|
2009-08-11 00:43:06 +02:00
|
|
|
~npc_escortAI() {}
|
2008-10-21 13:19:26 -05:00
|
|
|
|
|
|
|
|
// Pure Virtual Functions
|
|
|
|
|
virtual void WaypointReached(uint32) = 0;
|
|
|
|
|
|
|
|
|
|
// CreatureAI functions
|
2009-06-04 17:42:48 -05:00
|
|
|
void AttackStart(Unit* who);
|
2008-10-21 13:19:26 -05:00
|
|
|
|
2009-06-04 17:42:48 -05:00
|
|
|
void MoveInLineOfSight(Unit* who);
|
2008-10-21 13:19:26 -05:00
|
|
|
|
2009-08-14 05:32:39 +02:00
|
|
|
void JustDied(Unit*);
|
|
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
void JustRespawned();
|
|
|
|
|
|
2009-08-10 15:27:42 +02:00
|
|
|
void ReturnToLastPoint();
|
|
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
void EnterEvadeMode();
|
|
|
|
|
|
|
|
|
|
void UpdateAI(const uint32);
|
|
|
|
|
|
|
|
|
|
void MovementInform(uint32, uint32);
|
|
|
|
|
|
|
|
|
|
// EscortAI functions
|
|
|
|
|
void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0);
|
2009-04-06 21:14:51 +02:00
|
|
|
|
2009-03-22 23:11:55 +01:00
|
|
|
void FillPointMovementListForCreature();
|
2008-10-21 13:19:26 -05:00
|
|
|
|
2009-08-13 05:47:23 +02:00
|
|
|
void Start(bool bIsActiveAttacker = true, bool bRun = false, uint64 uiPlayerGUID = 0, const Quest* pQuest = NULL, bool bInstantRespawn = false, bool bCanLoopPath = false);
|
|
|
|
|
|
2009-04-19 21:16:11 +02:00
|
|
|
void SetRun(bool bRun = true);
|
2008-10-21 13:19:26 -05:00
|
|
|
|
2009-04-03 17:57:57 +02:00
|
|
|
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
|
|
|
|
|
float GetMaxPlayerDistance() { return MaxPlayerDistance; }
|
|
|
|
|
|
2009-07-14 20:15:47 +02:00
|
|
|
bool IsEscorted() {return IsBeingEscorted;}
|
|
|
|
|
|
2009-04-03 17:57:57 +02:00
|
|
|
void SetCanMelee(bool usemelee) { CanMelee = usemelee; }
|
|
|
|
|
void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
|
|
|
|
|
void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
|
2009-08-11 00:43:06 +02:00
|
|
|
bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
|
2009-08-10 15:27:42 +02:00
|
|
|
bool GetIsBeingEscorted() { return IsBeingEscorted; }//used in EnterEvadeMode override
|
2009-08-11 00:43:06 +02:00
|
|
|
void SetReturning(bool returning) { m_bIsReturning = returning; }//used in EnterEvadeMode override
|
|
|
|
|
void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
|
2009-08-10 15:27:42 +02:00
|
|
|
uint64 GetEventStarterGUID() { return PlayerGUID; }
|
2009-04-03 17:57:57 +02:00
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
// EscortAI variables
|
|
|
|
|
protected:
|
|
|
|
|
uint64 PlayerGUID;
|
|
|
|
|
bool IsBeingEscorted;
|
|
|
|
|
bool IsOnHold;
|
|
|
|
|
|
|
|
|
|
private:
|
2009-08-11 00:43:06 +02:00
|
|
|
uint32 m_uiWPWaitTimer;
|
|
|
|
|
uint32 m_uiPlayerCheckTimer;
|
2009-04-03 17:57:57 +02:00
|
|
|
float MaxPlayerDistance;
|
2008-10-21 13:19:26 -05:00
|
|
|
|
2009-08-13 05:47:23 +02:00
|
|
|
const Quest* m_pQuestForEscort; //generally passed in Start() when regular escort script.
|
|
|
|
|
|
2008-10-21 13:19:26 -05:00
|
|
|
std::list<Escort_Waypoint> WaypointList;
|
|
|
|
|
std::list<Escort_Waypoint>::iterator CurrentWP;
|
|
|
|
|
|
2009-08-11 00:43:06 +02:00
|
|
|
bool m_bIsActiveAttacker; //possible obsolete, and should be determined with db only (civilian)
|
|
|
|
|
bool m_bIsReturning; //in use when creature leave combat, and are returning to combat start position
|
|
|
|
|
bool m_bIsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK)
|
2009-08-13 05:47:23 +02:00
|
|
|
bool m_bCanInstantRespawn; //if creature should respawn instantly after escort over (if not, database respawntime are used)
|
|
|
|
|
bool m_bCanReturnToStart; //if creature can walk same path (loop) without despawn. Not for regular escort quests.
|
2009-04-03 17:57:57 +02:00
|
|
|
bool CanMelee;
|
|
|
|
|
bool DespawnAtEnd;
|
|
|
|
|
bool DespawnAtFar;
|
2008-10-21 13:19:26 -05:00
|
|
|
};
|
|
|
|
|
#endif
|
2009-02-17 20:07:49 -06:00
|
|
|
|