mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 12:18:27 +00:00
MoveTo while saving guard position no longer hops.
This commit is contained in:
+52
-34
@@ -176,9 +176,15 @@ void NPC::MoveTo(const glm::vec4& position, bool saveguardspot)
|
||||
cur_wp = -2; // flag as quest controlled w/no grid
|
||||
Log(Logs::Detail, Logs::AI, "MoveTo %s without a grid.", to_string(static_cast<glm::vec3>(position)).c_str());
|
||||
}
|
||||
|
||||
glm::vec3 dest(position);
|
||||
|
||||
m_CurrentWayPoint = position;
|
||||
m_CurrentWayPoint.z = GetFixedZ(dest);
|
||||
|
||||
if (saveguardspot)
|
||||
{
|
||||
m_GuardPoint = position;
|
||||
m_GuardPoint = m_CurrentWayPoint;
|
||||
|
||||
if (m_GuardPoint.w == 0)
|
||||
m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler
|
||||
@@ -189,7 +195,6 @@ void NPC::MoveTo(const glm::vec4& position, bool saveguardspot)
|
||||
Log(Logs::Detail, Logs::AI, "Setting guard position to %s", to_string(static_cast<glm::vec3>(m_GuardPoint)).c_str());
|
||||
}
|
||||
|
||||
m_CurrentWayPoint = position;
|
||||
cur_wp_pause = 0;
|
||||
pLastFightingDelayMoving = 0;
|
||||
if (AI_walking_timer->Enabled())
|
||||
@@ -838,49 +843,62 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
|
||||
}
|
||||
}
|
||||
|
||||
void Mob::FixZ(int32 z_find_offset /*= 5*/)
|
||||
float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset)
|
||||
{
|
||||
|
||||
BenchTimer timer;
|
||||
timer.reset();
|
||||
float new_z = dest.z;
|
||||
|
||||
if (zone->HasMap() && RuleB(Map, FixZWhenMoving) && (flymode != 1 && flymode != 2))
|
||||
if (zone->HasMap() && RuleB(Map, FixZWhenMoving) &&
|
||||
(flymode != 1 && flymode != 2))
|
||||
{
|
||||
if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
|
||||
(zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position))))
|
||||
if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap()
|
||||
|| (zone->HasWaterMap() &&
|
||||
!zone->watermap->InWater(glm::vec3(m_Position))))
|
||||
{
|
||||
/* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors */
|
||||
float new_z = this->FindGroundZ(m_Position.x, m_Position.y, z_find_offset);
|
||||
new_z += this->GetZOffset();
|
||||
new_z = this->FindDestGroundZ(dest,z_find_offset);
|
||||
if (new_z != BEST_Z_INVALID)
|
||||
{
|
||||
new_z += this->GetZOffset();
|
||||
|
||||
auto duration = timer.elapsed();
|
||||
|
||||
Log(
|
||||
Logs::Moderate,
|
||||
Logs::FixZ,
|
||||
"Mob::FixZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf",
|
||||
this->GetCleanName(),
|
||||
new_z,
|
||||
m_Position.x,
|
||||
m_Position.y,
|
||||
m_Position.z,
|
||||
duration
|
||||
);
|
||||
|
||||
if ((new_z > -2000) && new_z != BEST_Z_INVALID) {
|
||||
if (RuleB(Map, MobZVisualDebug))
|
||||
this->SendAppearanceEffect(78, 0, 0, 0, 0);
|
||||
|
||||
m_Position.z = new_z;
|
||||
// If bad new Z restore old one
|
||||
if (new_z < -2000) {
|
||||
new_z = m_Position.z;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (RuleB(Map, MobZVisualDebug))
|
||||
this->SendAppearanceEffect(103, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f", this->GetCleanName(), std::abs(m_Position.z - new_z));
|
||||
}
|
||||
auto duration = timer.elapsed();
|
||||
|
||||
last_z = m_Position.z;
|
||||
Log(Logs::Moderate, Logs::FixZ,
|
||||
"Mob::FixZ() (%s) returned %4.3f at %4.3f, %4.3f, %4.3f - Took %lf",
|
||||
this->GetCleanName(), new_z, m_Position.x, m_Position.y,
|
||||
m_Position.z, duration);
|
||||
}
|
||||
|
||||
return new_z;
|
||||
}
|
||||
|
||||
void Mob::FixZ(int32 z_find_offset /*= 5*/)
|
||||
{
|
||||
glm::vec3 current_loc(m_Position);
|
||||
float new_z=GetFixedZ(current_loc, z_find_offset);
|
||||
|
||||
if (new_z != m_Position.z)
|
||||
{
|
||||
if ((new_z > -2000) && new_z != BEST_Z_INVALID) {
|
||||
if (RuleB(Map, MobZVisualDebug))
|
||||
this->SendAppearanceEffect(78, 0, 0, 0, 0);
|
||||
|
||||
m_Position.z = new_z;
|
||||
}
|
||||
else {
|
||||
if (RuleB(Map, MobZVisualDebug))
|
||||
this->SendAppearanceEffect(103, 0, 0, 0, 0);
|
||||
|
||||
Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f",
|
||||
this->GetCleanName(), std::abs(m_Position.z - new_z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user