mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 13:28:25 +00:00
A bunch of send position changes, rename navigateto
This commit is contained in:
+83
-88
@@ -555,7 +555,7 @@ void NPC::AI_Start(uint32 iMoveDelay) {
|
||||
}
|
||||
|
||||
SendTo(GetX(), GetY(), GetZ());
|
||||
SaveGuardSpot();
|
||||
SaveGuardSpot(GetPosition());
|
||||
}
|
||||
|
||||
void Mob::AI_Stop() {
|
||||
@@ -910,7 +910,6 @@ void Client::AI_Process()
|
||||
float dist = DistanceSquared(m_Position, owner->GetPosition());
|
||||
if (dist >= 202500) { // >= 450 distance
|
||||
Teleport(owner->GetPosition());
|
||||
SendPositionUpdate(); // this shouldn't happen a lot (and hard to make it) so lets not rate limit
|
||||
} else if (dist >= 400) { // >=20
|
||||
if (AI_movement_timer->Check()) {
|
||||
if (dist >= 1225) {
|
||||
@@ -929,86 +928,86 @@ void Client::AI_Process()
|
||||
|
||||
void Mob::ProcessForcedMovement()
|
||||
{
|
||||
//// we are being pushed, we will hijack this movement timer
|
||||
//// this also needs to be done before casting to have a chance to interrupt
|
||||
//// this flag won't be set if the mob can't be pushed (rooted etc)
|
||||
//if (AI_movement_timer->Check()) {
|
||||
// bool bPassed = true;
|
||||
// glm::vec3 normal;
|
||||
//
|
||||
// // no zone map = fucked
|
||||
// if (zone->HasMap()) {
|
||||
// // in front
|
||||
// m_CollisionBox[0].x = m_Position.x + 3.0f * g_Math.FastSin(0.0f);
|
||||
// m_CollisionBox[0].y = m_Position.y + 3.0f * g_Math.FastCos(0.0f);
|
||||
// m_CollisionBox[0].z = m_Position.z;
|
||||
//
|
||||
// // 45 right front
|
||||
// m_CollisionBox[1].x = m_Position.x + 3.0f * g_Math.FastSin(64.0f);
|
||||
// m_CollisionBox[1].y = m_Position.y + 3.0f * g_Math.FastCos(64.0f);
|
||||
// m_CollisionBox[1].z = m_Position.z;
|
||||
//
|
||||
// // to right
|
||||
// m_CollisionBox[2].x = m_Position.x + 3.0f * g_Math.FastSin(128.0f);
|
||||
// m_CollisionBox[2].y = m_Position.y + 3.0f * g_Math.FastCos(128.0f);
|
||||
// m_CollisionBox[2].z = m_Position.z;
|
||||
//
|
||||
// // 45 right back
|
||||
// m_CollisionBox[3].x = m_Position.x + 3.0f * g_Math.FastSin(192.0f);
|
||||
// m_CollisionBox[3].y = m_Position.y + 3.0f * g_Math.FastCos(192.0f);
|
||||
// m_CollisionBox[3].z = m_Position.z;
|
||||
//
|
||||
// // behind
|
||||
// m_CollisionBox[4].x = m_Position.x + 3.0f * g_Math.FastSin(256.0f);
|
||||
// m_CollisionBox[4].y = m_Position.y + 3.0f * g_Math.FastCos(256.0f);
|
||||
// m_CollisionBox[4].z = m_Position.z;
|
||||
//
|
||||
// // 45 left back
|
||||
// m_CollisionBox[5].x = m_Position.x + 3.0f * g_Math.FastSin(320.0f);
|
||||
// m_CollisionBox[5].y = m_Position.y + 3.0f * g_Math.FastCos(320.0f);
|
||||
// m_CollisionBox[5].z = m_Position.z;
|
||||
//
|
||||
// // to left
|
||||
// m_CollisionBox[6].x = m_Position.x + 3.0f * g_Math.FastSin(384.0f);
|
||||
// m_CollisionBox[6].y = m_Position.y + 3.0f * g_Math.FastCos(384.0f);
|
||||
// m_CollisionBox[6].z = m_Position.z;
|
||||
//
|
||||
// // 45 left front
|
||||
// m_CollisionBox[7].x = m_Position.x + 3.0f * g_Math.FastSin(448.0f);
|
||||
// m_CollisionBox[7].y = m_Position.y + 3.0f * g_Math.FastCos(448.0f);
|
||||
// m_CollisionBox[7].z = m_Position.z;
|
||||
//
|
||||
// // collision happened, need to move along the wall
|
||||
// float distance = 0.0f, shortest = std::numeric_limits<float>::infinity();
|
||||
// glm::vec3 tmp_nrm;
|
||||
// for (auto &vec : m_CollisionBox) {
|
||||
// if (zone->zonemap->DoCollisionCheck(vec, vec + m_Delta, tmp_nrm, distance)) {
|
||||
// bPassed = false; // lets try with new projection next pass
|
||||
// if (distance < shortest) {
|
||||
// normal = tmp_nrm;
|
||||
// shortest = distance;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (bPassed) {
|
||||
// ForcedMovement = 0;
|
||||
// Teleport(m_Position + m_Delta);
|
||||
// m_Delta = glm::vec4();
|
||||
// SendPositionUpdate();
|
||||
// FixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc
|
||||
// } else if (--ForcedMovement) {
|
||||
// if (normal.z < -0.15f) // prevent too much wall climbing. ex. OMM's room in anguish
|
||||
// normal.z = 0.0f;
|
||||
// auto proj = glm::proj(static_cast<glm::vec3>(m_Delta), normal);
|
||||
// m_Delta.x -= proj.x;
|
||||
// m_Delta.y -= proj.y;
|
||||
// m_Delta.z -= proj.z;
|
||||
// } else {
|
||||
// m_Delta = glm::vec4(); // well, we failed to find a spot to be forced to, lets give up
|
||||
// }
|
||||
//}
|
||||
// we are being pushed, we will hijack this movement timer
|
||||
// this also needs to be done before casting to have a chance to interrupt
|
||||
// this flag won't be set if the mob can't be pushed (rooted etc)
|
||||
if (AI_movement_timer->Check()) {
|
||||
bool bPassed = true;
|
||||
glm::vec3 normal;
|
||||
|
||||
// no zone map = fucked
|
||||
if (zone->HasMap()) {
|
||||
// in front
|
||||
m_CollisionBox[0].x = m_Position.x + 3.0f * g_Math.FastSin(0.0f);
|
||||
m_CollisionBox[0].y = m_Position.y + 3.0f * g_Math.FastCos(0.0f);
|
||||
m_CollisionBox[0].z = m_Position.z;
|
||||
|
||||
// 45 right front
|
||||
m_CollisionBox[1].x = m_Position.x + 3.0f * g_Math.FastSin(64.0f);
|
||||
m_CollisionBox[1].y = m_Position.y + 3.0f * g_Math.FastCos(64.0f);
|
||||
m_CollisionBox[1].z = m_Position.z;
|
||||
|
||||
// to right
|
||||
m_CollisionBox[2].x = m_Position.x + 3.0f * g_Math.FastSin(128.0f);
|
||||
m_CollisionBox[2].y = m_Position.y + 3.0f * g_Math.FastCos(128.0f);
|
||||
m_CollisionBox[2].z = m_Position.z;
|
||||
|
||||
// 45 right back
|
||||
m_CollisionBox[3].x = m_Position.x + 3.0f * g_Math.FastSin(192.0f);
|
||||
m_CollisionBox[3].y = m_Position.y + 3.0f * g_Math.FastCos(192.0f);
|
||||
m_CollisionBox[3].z = m_Position.z;
|
||||
|
||||
// behind
|
||||
m_CollisionBox[4].x = m_Position.x + 3.0f * g_Math.FastSin(256.0f);
|
||||
m_CollisionBox[4].y = m_Position.y + 3.0f * g_Math.FastCos(256.0f);
|
||||
m_CollisionBox[4].z = m_Position.z;
|
||||
|
||||
// 45 left back
|
||||
m_CollisionBox[5].x = m_Position.x + 3.0f * g_Math.FastSin(320.0f);
|
||||
m_CollisionBox[5].y = m_Position.y + 3.0f * g_Math.FastCos(320.0f);
|
||||
m_CollisionBox[5].z = m_Position.z;
|
||||
|
||||
// to left
|
||||
m_CollisionBox[6].x = m_Position.x + 3.0f * g_Math.FastSin(384.0f);
|
||||
m_CollisionBox[6].y = m_Position.y + 3.0f * g_Math.FastCos(384.0f);
|
||||
m_CollisionBox[6].z = m_Position.z;
|
||||
|
||||
// 45 left front
|
||||
m_CollisionBox[7].x = m_Position.x + 3.0f * g_Math.FastSin(448.0f);
|
||||
m_CollisionBox[7].y = m_Position.y + 3.0f * g_Math.FastCos(448.0f);
|
||||
m_CollisionBox[7].z = m_Position.z;
|
||||
|
||||
// collision happened, need to move along the wall
|
||||
float distance = 0.0f, shortest = std::numeric_limits<float>::infinity();
|
||||
glm::vec3 tmp_nrm;
|
||||
for (auto &vec : m_CollisionBox) {
|
||||
if (zone->zonemap->DoCollisionCheck(vec, vec + m_Delta, tmp_nrm, distance)) {
|
||||
bPassed = false; // lets try with new projection next pass
|
||||
if (distance < shortest) {
|
||||
normal = tmp_nrm;
|
||||
shortest = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bPassed) {
|
||||
ForcedMovement = 0;
|
||||
Teleport(m_Position + m_Delta);
|
||||
m_Delta = glm::vec4();
|
||||
SentPositionPacket(0.0f, 0.0f, 0.0f, 0.0f, 0, true);
|
||||
FixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc
|
||||
} else if (--ForcedMovement) {
|
||||
if (normal.z < -0.15f) // prevent too much wall climbing. ex. OMM's room in anguish
|
||||
normal.z = 0.0f;
|
||||
auto proj = glm::proj(static_cast<glm::vec3>(m_Delta), normal);
|
||||
m_Delta.x -= proj.x;
|
||||
m_Delta.y -= proj.y;
|
||||
m_Delta.z -= proj.z;
|
||||
} else {
|
||||
m_Delta = glm::vec4(); // well, we failed to find a spot to be forced to, lets give up
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Mob::AI_Process() {
|
||||
@@ -1108,16 +1107,12 @@ void Mob::AI_Process() {
|
||||
if (this->GetTarget()) {
|
||||
/* If we are engaged, moving and following client, let's look for best Z more often */
|
||||
float target_distance = DistanceNoZ(this->GetPosition(), this->GetTarget()->GetPosition());
|
||||
this->FixZ();
|
||||
FixZ();
|
||||
|
||||
if (target_distance <= 15 && !this->CheckLosFN(this->GetTarget())) {
|
||||
Mob *target = this->GetTarget();
|
||||
|
||||
m_Position.x = target->GetX();
|
||||
m_Position.y = target->GetY();
|
||||
m_Position.z = target->GetZ();
|
||||
m_Position.w = target->GetHeading();
|
||||
SendPosition();
|
||||
Teleport(target->GetPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user