mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Bug fixes to push, shouldn't get stuck anymore
This commit is contained in:
parent
339e921f17
commit
d62f2d41fc
@ -20,6 +20,7 @@
|
|||||||
#include "../common/features.h"
|
#include "../common/features.h"
|
||||||
#include "../common/rulesys.h"
|
#include "../common/rulesys.h"
|
||||||
#include "../common/string_util.h"
|
#include "../common/string_util.h"
|
||||||
|
#include "../common/misc_functions.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
@ -959,35 +960,39 @@ void Mob::ProcessForcedMovement()
|
|||||||
bool bPassed = true;
|
bool bPassed = true;
|
||||||
auto z_off = GetZOffset();
|
auto z_off = GetZOffset();
|
||||||
glm::vec3 normal;
|
glm::vec3 normal;
|
||||||
glm::vec3 new_pos = m_Position + m_Delta;
|
|
||||||
|
|
||||||
// no zone map = fucked
|
// no zone map = fucked
|
||||||
if (zone->HasMap()) {
|
if (zone->HasMap()) {
|
||||||
|
float angle = GetHeading();
|
||||||
// in front
|
// in front
|
||||||
m_CollisionBox[0].x = m_Position.x + 3.0f * g_Math.FastSin(0.0f);
|
m_CollisionBox[0].x = m_Position.x + 3.0f * g_Math.FastSin(angle);
|
||||||
m_CollisionBox[0].y = m_Position.y + 3.0f * g_Math.FastCos(0.0f);
|
m_CollisionBox[0].y = m_Position.y + 3.0f * g_Math.FastCos(angle);
|
||||||
m_CollisionBox[0].z = m_Position.z + z_off;
|
m_CollisionBox[0].z = m_Position.z + z_off;
|
||||||
|
|
||||||
// to right
|
// to right
|
||||||
m_CollisionBox[1].x = m_Position.x + 3.0f * g_Math.FastSin(128.0f);
|
angle = FixHeading(GetHeading() - 128.0f);
|
||||||
m_CollisionBox[1].y = m_Position.y + 3.0f * g_Math.FastCos(128.0f);
|
m_CollisionBox[1].x = m_Position.x + 3.0f * g_Math.FastSin(angle);
|
||||||
|
m_CollisionBox[1].y = m_Position.y + 3.0f * g_Math.FastCos(angle);
|
||||||
m_CollisionBox[1].z = m_Position.z + z_off;
|
m_CollisionBox[1].z = m_Position.z + z_off;
|
||||||
|
|
||||||
|
|
||||||
// behind
|
// behind
|
||||||
m_CollisionBox[2].x = m_Position.x + 3.0f * g_Math.FastSin(256.0f);
|
angle = FixHeading(GetHeading() - 256.0f);
|
||||||
m_CollisionBox[2].y = m_Position.y + 3.0f * g_Math.FastCos(256.0f);
|
m_CollisionBox[2].x = m_Position.x + 3.0f * g_Math.FastSin(angle);
|
||||||
|
m_CollisionBox[2].y = m_Position.y + 3.0f * g_Math.FastCos(angle);
|
||||||
m_CollisionBox[2].z = m_Position.z + z_off;
|
m_CollisionBox[2].z = m_Position.z + z_off;
|
||||||
|
|
||||||
// to left
|
// to left
|
||||||
m_CollisionBox[3].x = m_Position.x + 3.0f * g_Math.FastSin(384.0f);
|
angle = FixHeading(GetHeading() - 384.0f);
|
||||||
m_CollisionBox[3].y = m_Position.y + 3.0f * g_Math.FastCos(384.0f);
|
m_CollisionBox[3].x = m_Position.x + 3.0f * g_Math.FastSin(angle);
|
||||||
|
m_CollisionBox[3].y = m_Position.y + 3.0f * g_Math.FastCos(angle);
|
||||||
m_CollisionBox[3].z = m_Position.z + z_off;
|
m_CollisionBox[3].z = m_Position.z + z_off;
|
||||||
|
|
||||||
// collision happened, need to move along the wall
|
// collision happened, need to move along the wall
|
||||||
float distance = 0.0f, shortest = std::numeric_limits<float>::infinity();
|
float distance = 0.0f, shortest = std::numeric_limits<float>::infinity();
|
||||||
glm::vec3 tmp_nrm;
|
glm::vec3 tmp_nrm;
|
||||||
for (auto &vec : m_CollisionBox) {
|
for (auto &vec : m_CollisionBox) {
|
||||||
if (zone->zonemap->DoCollisionCheck(vec, new_pos, tmp_nrm, distance)) {
|
if (zone->zonemap->DoCollisionCheck(vec, vec + m_Delta, tmp_nrm, distance)) {
|
||||||
bPassed = false; // lets try with new projection next pass
|
bPassed = false; // lets try with new projection next pass
|
||||||
if (distance < shortest) {
|
if (distance < shortest) {
|
||||||
normal = tmp_nrm;
|
normal = tmp_nrm;
|
||||||
@ -999,8 +1004,8 @@ void Mob::ProcessForcedMovement()
|
|||||||
|
|
||||||
if (bPassed) {
|
if (bPassed) {
|
||||||
ForcedMovement = 0;
|
ForcedMovement = 0;
|
||||||
|
Teleport(m_Position + m_Delta);
|
||||||
m_Delta = glm::vec4();
|
m_Delta = glm::vec4();
|
||||||
Teleport(new_pos);
|
|
||||||
SendPositionUpdate();
|
SendPositionUpdate();
|
||||||
pLastChange = Timer::GetCurrentTime();
|
pLastChange = Timer::GetCurrentTime();
|
||||||
FixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc
|
FixZ(); // so we teleport to the ground locally, we want the client to interpolate falling etc
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user