*Fix broken escort AI.
--HG-- branch : trunk
This commit is contained in:
@@ -15,14 +15,6 @@ EndScriptData */
|
|||||||
#define WP_LAST_POINT -1
|
#define WP_LAST_POINT -1
|
||||||
extern std::list<PointMovement> PointMovementList;
|
extern std::list<PointMovement> PointMovementList;
|
||||||
|
|
||||||
bool npc_escortAI::IsVisible(Unit* who) const
|
|
||||||
{
|
|
||||||
if (!who)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return (m_creature->GetDistance(who) < VISIBLE_RANGE) && who->isVisibleForOrDetect(m_creature,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void npc_escortAI::AttackStart(Unit *who)
|
void npc_escortAI::AttackStart(Unit *who)
|
||||||
{
|
{
|
||||||
if (!who)
|
if (!who)
|
||||||
@@ -33,10 +25,6 @@ void npc_escortAI::AttackStart(Unit *who)
|
|||||||
|
|
||||||
if(m_creature->Attack(who, true) )
|
if(m_creature->Attack(who, true) )
|
||||||
{
|
{
|
||||||
m_creature->AddThreat(who, 0.0f);
|
|
||||||
m_creature->SetInCombatWith(who);
|
|
||||||
who->SetInCombatWith(m_creature);
|
|
||||||
|
|
||||||
if(CombatMovement)
|
if(CombatMovement)
|
||||||
{
|
{
|
||||||
m_creature->GetMotionMaster()->MovementExpired();
|
m_creature->GetMotionMaster()->MovementExpired();
|
||||||
@@ -45,26 +33,12 @@ void npc_escortAI::AttackStart(Unit *who)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void npc_escortAI::EnterCombat(Unit *who)
|
|
||||||
{
|
|
||||||
if (IsBeingEscorted)
|
|
||||||
{
|
|
||||||
//Store last position
|
|
||||||
m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);
|
|
||||||
|
|
||||||
debug_log("TSCR: EscortAI has entered combat and stored last location.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void npc_escortAI::MoveInLineOfSight(Unit *who)
|
void npc_escortAI::MoveInLineOfSight(Unit *who)
|
||||||
{
|
{
|
||||||
if (IsBeingEscorted && !Attack)
|
if (IsBeingEscorted && !Attack)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_creature->getVictim() || !m_creature->canStartAttack(who))
|
ScriptedAI::MoveInLineOfSight(who);
|
||||||
return;
|
|
||||||
|
|
||||||
AttackStart(who);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void npc_escortAI::JustRespawned()
|
void npc_escortAI::JustRespawned()
|
||||||
@@ -83,26 +57,19 @@ void npc_escortAI::EnterEvadeMode()
|
|||||||
{
|
{
|
||||||
m_creature->RemoveAllAuras();
|
m_creature->RemoveAllAuras();
|
||||||
m_creature->DeleteThreatList();
|
m_creature->DeleteThreatList();
|
||||||
m_creature->CombatStop();
|
m_creature->CombatStop(true);
|
||||||
m_creature->SetLootRecipient(NULL);
|
m_creature->SetLootRecipient(NULL);
|
||||||
|
|
||||||
if (IsBeingEscorted)
|
if (IsBeingEscorted)
|
||||||
{
|
{
|
||||||
debug_log("TSCR: EscortAI has left combat and is now returning to last point.");
|
|
||||||
Returning = true;
|
Returning = true;
|
||||||
m_creature->GetMotionMaster()->MovementExpired();
|
float x, y, z, o;
|
||||||
|
m_creature->GetHomePosition(x, y, z, o);
|
||||||
//if default is WAYPOINT_MOTION_TYPE, must MoveIdle to prevent from using
|
m_creature->GetMotionMaster()->MovePoint(WP_LAST_POINT, x, y, z);
|
||||||
if(m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
|
debug_log("TSCR: EscortAI has left combat and is now returning to last point %f %f %f.", x, y, z);
|
||||||
m_creature->GetMotionMaster()->MoveIdle();
|
|
||||||
|
|
||||||
m_creature->GetMotionMaster()->MovePoint(WP_LAST_POINT, LastPos.x, LastPos.y, LastPos.z);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_creature->GetMotionMaster()->MovementExpired();
|
|
||||||
m_creature->GetMotionMaster()->MoveTargetedHome();
|
m_creature->GetMotionMaster()->MoveTargetedHome();
|
||||||
}
|
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
@@ -208,22 +175,8 @@ void npc_escortAI::UpdateAI(const uint32 diff)
|
|||||||
}else PlayerTimer -= diff;
|
}else PlayerTimer -= diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CanMelee)
|
if(CanMelee && UpdateVictim())
|
||||||
{
|
DoMeleeAttackIfReady();
|
||||||
//Check if we have a current target
|
|
||||||
if( m_creature->isAlive() && UpdateVictim())
|
|
||||||
{
|
|
||||||
//If we are within range melee the target
|
|
||||||
if( m_creature->IsWithinMeleeRange(m_creature->getVictim()))
|
|
||||||
{
|
|
||||||
if( m_creature->isAttackReady() )
|
|
||||||
{
|
|
||||||
m_creature->AttackerStateUpdate(m_creature->getVictim());
|
|
||||||
m_creature->resetAttackTimer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void npc_escortAI::MovementInform(uint32 type, uint32 id)
|
void npc_escortAI::MovementInform(uint32 type, uint32 id)
|
||||||
@@ -261,6 +214,7 @@ void npc_escortAI::MovementInform(uint32 type, uint32 id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void npc_escortAI::OnPossess(bool apply)
|
void npc_escortAI::OnPossess(bool apply)
|
||||||
{
|
{
|
||||||
// We got possessed in the middle of being escorted, store the point
|
// We got possessed in the middle of being escorted, store the point
|
||||||
@@ -277,8 +231,7 @@ void npc_escortAI::OnPossess(bool apply)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
void npc_escortAI::AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs)
|
void npc_escortAI::AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs)
|
||||||
{
|
{
|
||||||
@@ -380,4 +333,3 @@ void npc_escortAI::Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID)
|
|||||||
IsOnHold = false;
|
IsOnHold = false;
|
||||||
CombatMovement = true;
|
CombatMovement = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,8 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
virtual void WaypointReached(uint32) = 0;
|
virtual void WaypointReached(uint32) = 0;
|
||||||
|
|
||||||
// CreatureAI functions
|
// CreatureAI functions
|
||||||
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);}
|
npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000), MaxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE), CanMelee(true), DespawnAtEnd(true), DespawnAtFar(true)
|
||||||
|
{}
|
||||||
bool IsVisible(Unit*) const;
|
|
||||||
|
|
||||||
void EnterCombat(Unit *);
|
|
||||||
|
|
||||||
void AttackStart(Unit*);
|
void AttackStart(Unit*);
|
||||||
|
|
||||||
@@ -53,8 +50,6 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
|
|
||||||
void MovementInform(uint32, uint32);
|
void MovementInform(uint32, uint32);
|
||||||
|
|
||||||
void OnPossess(bool apply);
|
|
||||||
|
|
||||||
// EscortAI functions
|
// EscortAI functions
|
||||||
void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0);
|
void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0);
|
||||||
|
|
||||||
@@ -83,13 +78,6 @@ struct TRINITY_DLL_DECL npc_escortAI : public ScriptedAI
|
|||||||
uint32 m_uiNpcFlags;
|
uint32 m_uiNpcFlags;
|
||||||
float MaxPlayerDistance;
|
float MaxPlayerDistance;
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
}LastPos;
|
|
||||||
|
|
||||||
std::list<Escort_Waypoint> WaypointList;
|
std::list<Escort_Waypoint> WaypointList;
|
||||||
std::list<Escort_Waypoint>::iterator CurrentWP;
|
std::list<Escort_Waypoint>::iterator CurrentWP;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -10081,7 +10081,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
|
|||||||
|
|
||||||
if(GetTypeId() != TYPEID_PLAYER)
|
if(GetTypeId() != TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
if(GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_IDLE) != IDLE_MOTION_TYPE)
|
//if(GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_IDLE) != IDLE_MOTION_TYPE)
|
||||||
((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||||
if(enemy)
|
if(enemy)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user