mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-14 20:12:26 +00:00
Work on making the paths work well when being z corrected esp for nav meshes
This commit is contained in:
parent
832c31a41a
commit
3afee1f841
@ -446,6 +446,7 @@ Mob::Mob(const char* in_name,
|
|||||||
npc_assist_cap = 0;
|
npc_assist_cap = 0;
|
||||||
|
|
||||||
PathRecalcTimer.reset(new Timer(2000));
|
PathRecalcTimer.reset(new Timer(2000));
|
||||||
|
PathingLoopCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mob::~Mob()
|
Mob::~Mob()
|
||||||
|
|||||||
@ -1227,7 +1227,6 @@ protected:
|
|||||||
void CalculateNewFearpoint();
|
void CalculateNewFearpoint();
|
||||||
float FindGroundZ(float new_x, float new_y, float z_offset=0.0);
|
float FindGroundZ(float new_x, float new_y, float z_offset=0.0);
|
||||||
glm::vec3 UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChange, bool &NodeReached);
|
glm::vec3 UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChange, bool &NodeReached);
|
||||||
void PrintRoute();
|
|
||||||
|
|
||||||
virtual float GetSympatheticProcChances(uint16 spell_id, int16 ProcRateMod, int32 ItemProcRate = 0);
|
virtual float GetSympatheticProcChances(uint16 spell_id, int16 ProcRateMod, int32 ItemProcRate = 0);
|
||||||
int16 GetSympatheticSpellProcRate(uint16 spell_id);
|
int16 GetSympatheticSpellProcRate(uint16 spell_id);
|
||||||
@ -1373,8 +1372,6 @@ protected:
|
|||||||
int32 GetItemFactionBonus(uint32 pFactionID);
|
int32 GetItemFactionBonus(uint32 pFactionID);
|
||||||
void ClearItemFactionBonuses();
|
void ClearItemFactionBonuses();
|
||||||
|
|
||||||
void CalculateFearPosition();
|
|
||||||
|
|
||||||
bool flee_mode;
|
bool flee_mode;
|
||||||
Timer flee_timer;
|
Timer flee_timer;
|
||||||
Timer fix_z_timer;
|
Timer fix_z_timer;
|
||||||
@ -1401,7 +1398,6 @@ protected:
|
|||||||
int npc_assist_cap;
|
int npc_assist_cap;
|
||||||
Timer assist_cap_timer; // clear assist cap so more nearby mobs can be called for help
|
Timer assist_cap_timer; // clear assist cap so more nearby mobs can be called for help
|
||||||
|
|
||||||
|
|
||||||
int patrol;
|
int patrol;
|
||||||
glm::vec3 m_FearWalkTarget;
|
glm::vec3 m_FearWalkTarget;
|
||||||
bool currently_fleeing;
|
bool currently_fleeing;
|
||||||
@ -1412,6 +1408,8 @@ protected:
|
|||||||
IPathfinder::IPath Route;
|
IPathfinder::IPath Route;
|
||||||
std::unique_ptr<Timer> PathRecalcTimer;
|
std::unique_ptr<Timer> PathRecalcTimer;
|
||||||
bool DistractedFromGrid;
|
bool DistractedFromGrid;
|
||||||
|
glm::vec3 PathingLastPosition;
|
||||||
|
int PathingLoopCount;
|
||||||
|
|
||||||
uint32 pDontHealMeBefore;
|
uint32 pDontHealMeBefore;
|
||||||
uint32 pDontBuffMeBefore;
|
uint32 pDontBuffMeBefore;
|
||||||
|
|||||||
@ -9,6 +9,8 @@
|
|||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "../common/compression.h"
|
#include "../common/compression.h"
|
||||||
|
|
||||||
|
extern Zone *zone;
|
||||||
|
|
||||||
struct PathfinderNavmesh::Implementation
|
struct PathfinderNavmesh::Implementation
|
||||||
{
|
{
|
||||||
dtNavMesh *nav_mesh;
|
dtNavMesh *nav_mesh;
|
||||||
@ -47,12 +49,12 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl
|
|||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
filter.setIncludeFlags(65535U);
|
filter.setIncludeFlags(65535U);
|
||||||
filter.setAreaCost(0, 1.0f); //Normal
|
filter.setAreaCost(0, 1.0f); //Normal
|
||||||
filter.setAreaCost(1, 1.0f); //Water
|
filter.setAreaCost(1, 2.0f); //Water
|
||||||
filter.setAreaCost(2, 1.0f); //Lava
|
filter.setAreaCost(2, 2.0f); //Lava
|
||||||
filter.setAreaCost(4, 1.0f); //PvP
|
filter.setAreaCost(4, 1.0f); //PvP
|
||||||
filter.setAreaCost(5, 1.0f); //Slime
|
filter.setAreaCost(5, 1.5f); //Slime
|
||||||
filter.setAreaCost(6, 1.0f); //Ice
|
filter.setAreaCost(6, 1.5f); //Ice
|
||||||
filter.setAreaCost(7, 1.0f); //V Water (Frigid Water)
|
filter.setAreaCost(7, 2.0f); //V Water (Frigid Water)
|
||||||
filter.setAreaCost(8, 1.0f); //General Area
|
filter.setAreaCost(8, 1.0f); //General Area
|
||||||
filter.setAreaCost(9, 1.0f); //Portal
|
filter.setAreaCost(9, 1.0f); //Portal
|
||||||
|
|
||||||
@ -104,6 +106,13 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl
|
|||||||
node.z = straight_path[i * 3 + 1];
|
node.z = straight_path[i * 3 + 1];
|
||||||
node.y = straight_path[i * 3 + 2];
|
node.y = straight_path[i * 3 + 2];
|
||||||
|
|
||||||
|
if (zone->HasMap()) {
|
||||||
|
auto best_z = zone->zonemap->FindBestZ(node, nullptr);
|
||||||
|
if (best_z != BEST_Z_INVALID) {
|
||||||
|
node.z = best_z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned short flag = 0;
|
unsigned short flag = 0;
|
||||||
if (dtStatusSucceed(m_impl->nav_mesh->getPolyFlags(straight_path_polys[i], &flag))) {
|
if (dtStatusSucceed(m_impl->nav_mesh->getPolyFlags(straight_path_polys[i], &flag))) {
|
||||||
if (flag & 512) {
|
if (flag & 512) {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (PathRecalcTimer->Check()) {
|
if (PathRecalcTimer->Check()) {
|
||||||
bool SameDestination = DistanceSquared(To, PathingDestination) < 4.0f;
|
bool SameDestination = DistanceSquared(To, PathingDestination) < 100.0f;
|
||||||
if (!SameDestination) {
|
if (!SameDestination) {
|
||||||
//We had a route but our target position moved too much
|
//We had a route but our target position moved too much
|
||||||
Route = zone->pathing->FindRoute(From, To);
|
Route = zone->pathing->FindRoute(From, To);
|
||||||
@ -46,7 +46,45 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtNextNode = DistanceSquared(From, (*Route.begin()).pos) < 4.0f;
|
if (!IsRooted()) {
|
||||||
|
bool AtPrevNode = DistanceSquared(From, PathingLastPosition) < 1.0f;
|
||||||
|
if (AtPrevNode) {
|
||||||
|
PathingLoopCount++;
|
||||||
|
|
||||||
|
if (PathingLoopCount > 5) {
|
||||||
|
SendPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto front = (*Route.begin()).pos;
|
||||||
|
Teleport(front);
|
||||||
|
Route.pop_front();
|
||||||
|
|
||||||
|
WaypointChanged = true;
|
||||||
|
NodeReached = true;
|
||||||
|
PathingLoopCount = 0;
|
||||||
|
|
||||||
|
return front;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PathingLastPosition = From;
|
||||||
|
PathingLoopCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PathingLastPosition = From;
|
||||||
|
PathingLoopCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AtNextNode = false;
|
||||||
|
if (flymode == 1) {
|
||||||
|
AtNextNode = DistanceSquared(From, (*Route.begin()).pos) < 4.0f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
float z_dist = From.z - (*Route.begin()).pos.z;
|
||||||
|
z_dist *= z_dist;
|
||||||
|
AtNextNode = DistanceSquaredNoZ(From, (*Route.begin()).pos) < 4.0f && z_dist < 25.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if (AtNextNode) {
|
if (AtNextNode) {
|
||||||
WaypointChanged = false;
|
WaypointChanged = false;
|
||||||
NodeReached = true;
|
NodeReached = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user