smoother NPC pathing. (credit to Haynar from EQMacEmu)

This commit is contained in:
regneq
2015-05-11 21:42:48 -07:00
parent cc2a60feb2
commit 052f343e4d
7 changed files with 133 additions and 73 deletions
+14 -3
View File
@@ -394,6 +394,7 @@ void NPC::SetWaypointPause()
if (cur_wp_pause == 0) {
AIwalking_timer->Start(100);
AIwalking_timer->Trigger();
}
else
{
@@ -514,7 +515,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
return true;
}
bool send_update = false;
int compare_steps = IsBoat() ? 1 : 20;
if(tar_ndx < compare_steps && m_TargetLocation.x==x && m_TargetLocation.y==y) {
float new_x = m_Position.x + m_TargetV.x*tar_vector;
@@ -637,13 +640,14 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
m_Position.y = y;
m_Position.z = z;
tar_ndx = 20;
Log.Out(Logs::Detail, Logs::AI, "Only a single step to get there... jumping.");
}
}
else {
tar_vector/=20;
tar_vector/=20.0f;
float new_x = m_Position.x + m_TargetV.x*tar_vector;
float new_y = m_Position.y + m_TargetV.y*tar_vector;
@@ -699,12 +703,19 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
m_Delta = glm::vec4(m_Position.x - nx, m_Position.y - ny, m_Position.z - nz, 0.0f);
if (IsClient())
{
SendPosUpdate(1);
CastToClient()->ResetPositionTimer();
}
else
{
// force an update now
move_tic_count = RuleI(Zone, NPCPositonUpdateTicCount);
SendPosUpdate();
SetAppearance(eaStanding, false);
SetAppearance(eaStanding, false);
}
pLastChange = Timer::GetCurrentTime();
return true;
}