*added new escortAI functions (does not effect already coded escort scripts)
--HG-- branch : trunk
This commit is contained in:
@@ -13,7 +13,6 @@ EndScriptData */
|
|||||||
#include "npc_escortAI.h"
|
#include "npc_escortAI.h"
|
||||||
|
|
||||||
#define WP_LAST_POINT -1
|
#define WP_LAST_POINT -1
|
||||||
#define MAX_PLAYER_DISTANCE 50
|
|
||||||
|
|
||||||
bool npc_escortAI::IsVisible(Unit* who) const
|
bool npc_escortAI::IsVisible(Unit* who) const
|
||||||
{
|
{
|
||||||
@@ -131,6 +130,8 @@ void npc_escortAI::UpdateAI(const uint32 diff)
|
|||||||
|
|
||||||
//End of the line, Despawn self then immediatly respawn
|
//End of the line, Despawn self then immediatly respawn
|
||||||
if (CurrentWP == WaypointList.end())
|
if (CurrentWP == WaypointList.end())
|
||||||
|
{
|
||||||
|
if(DespawnAtEnd)
|
||||||
{
|
{
|
||||||
debug_log("SD2: EscortAI reached end of waypoints");
|
debug_log("SD2: EscortAI reached end of waypoints");
|
||||||
|
|
||||||
@@ -147,6 +148,12 @@ void npc_escortAI::UpdateAI(const uint32 diff)
|
|||||||
IsBeingEscorted = false;
|
IsBeingEscorted = false;
|
||||||
WaitTimer = 0;
|
WaitTimer = 0;
|
||||||
return;
|
return;
|
||||||
|
}else{
|
||||||
|
debug_log("SD2: EscortAI reached end of waypoints with Despawn off");
|
||||||
|
IsBeingEscorted = false;
|
||||||
|
WaitTimer = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !IsOnHold )
|
if( !IsOnHold )
|
||||||
@@ -165,7 +172,7 @@ void npc_escortAI::UpdateAI(const uint32 diff)
|
|||||||
{
|
{
|
||||||
Unit* p = Unit::GetUnit(*m_creature, PlayerGUID);
|
Unit* p = Unit::GetUnit(*m_creature, PlayerGUID);
|
||||||
|
|
||||||
if (!p || m_creature->GetDistance(p) > MAX_PLAYER_DISTANCE)
|
if (DespawnAtFar && (!p || m_creature->GetDistance(p) > GetMaxPlayerDistance()))
|
||||||
{
|
{
|
||||||
JustDied(m_creature);
|
JustDied(m_creature);
|
||||||
IsBeingEscorted = false;
|
IsBeingEscorted = false;
|
||||||
@@ -187,6 +194,8 @@ void npc_escortAI::UpdateAI(const uint32 diff)
|
|||||||
}else PlayerTimer -= diff;
|
}else PlayerTimer -= diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(CanMelee)
|
||||||
|
{
|
||||||
//Check if we have a current target
|
//Check if we have a current target
|
||||||
if( m_creature->isAlive() && UpdateVictim())
|
if( m_creature->isAlive() && UpdateVictim())
|
||||||
{
|
{
|
||||||
@@ -201,6 +210,7 @@ void npc_escortAI::UpdateAI(const uint32 diff)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void npc_escortAI::MovementInform(uint32 type, uint32 id)
|
void npc_escortAI::MovementInform(uint32 type, uint32 id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef SC_ESCORTAI_H
|
#ifndef SC_ESCORTAI_H
|
||||||
#define SC_ESCORTAI_H
|
#define SC_ESCORTAI_H
|
||||||
|
|
||||||
|
#define DEFAULT_MAX_PLAYER_DISTANCE 50
|
||||||
|
|
||||||
struct Escort_Waypoint
|
struct Escort_Waypoint
|
||||||
{
|
{
|
||||||
Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
|
Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w)
|
||||||
@@ -35,7 +37,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
virtual void Reset() = 0;
|
virtual void Reset() = 0;
|
||||||
|
|
||||||
// CreatureAI functions
|
// CreatureAI functions
|
||||||
npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000) {m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);}
|
npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000), MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE), CanMelee(true), DespawnAtEnd(true), DespawnAtFar(true) {m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);}
|
||||||
|
|
||||||
bool IsVisible(Unit*) const;
|
bool IsVisible(Unit*) const;
|
||||||
|
|
||||||
@@ -58,6 +60,13 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
|
|
||||||
void Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID = 0);
|
void Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID = 0);
|
||||||
|
|
||||||
|
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
|
||||||
|
float GetMaxPlayerDistance() { return MaxPlayerDistance; }
|
||||||
|
|
||||||
|
void SetCanMelee(bool usemelee) { CanMelee = usemelee; }
|
||||||
|
void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
|
||||||
|
void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
|
||||||
|
|
||||||
// EscortAI variables
|
// EscortAI variables
|
||||||
protected:
|
protected:
|
||||||
uint64 PlayerGUID;
|
uint64 PlayerGUID;
|
||||||
@@ -67,6 +76,7 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
private:
|
private:
|
||||||
uint32 WaitTimer;
|
uint32 WaitTimer;
|
||||||
uint32 PlayerTimer;
|
uint32 PlayerTimer;
|
||||||
|
float MaxPlayerDistance;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@@ -83,6 +93,9 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
bool Returning;
|
bool Returning;
|
||||||
bool ReconnectWP;
|
bool ReconnectWP;
|
||||||
bool Run;
|
bool Run;
|
||||||
|
bool CanMelee;
|
||||||
|
bool DespawnAtEnd;
|
||||||
|
bool DespawnAtFar;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user