mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 22:01:30 +00:00
Rule for setting max navmesh nodes, default set higher than current to improve accuracy
This commit is contained in:
parent
c2300d514c
commit
d65a97e556
@ -293,6 +293,7 @@ RULE_BOOL(Pathing, Find, true, "Enable pathing for FindPerson requests from the
|
|||||||
RULE_BOOL(Pathing, Fear, true, "Enable pathing for fear")
|
RULE_BOOL(Pathing, Fear, true, "Enable pathing for fear")
|
||||||
RULE_REAL(Pathing, NavmeshStepSize, 100.0f, "")
|
RULE_REAL(Pathing, NavmeshStepSize, 100.0f, "")
|
||||||
RULE_REAL(Pathing, ShortMovementUpdateRange, 130.0f, "")
|
RULE_REAL(Pathing, ShortMovementUpdateRange, 130.0f, "")
|
||||||
|
RULE_INT(Pathing, MaxNavmeshNodes, 4092)
|
||||||
RULE_CATEGORY_END()
|
RULE_CATEGORY_END()
|
||||||
|
|
||||||
RULE_CATEGORY(Watermap)
|
RULE_CATEGORY(Watermap)
|
||||||
|
|||||||
@ -1300,7 +1300,9 @@ void MobMovementManager::PushEvadeCombat(MobMovementEntry &mob_movement_entry)
|
|||||||
*/
|
*/
|
||||||
void MobMovementManager::HandleStuckBehavior(Mob *who, float x, float y, float z, MobMovementMode mob_movement_mode)
|
void MobMovementManager::HandleStuckBehavior(Mob *who, float x, float y, float z, MobMovementMode mob_movement_mode)
|
||||||
{
|
{
|
||||||
auto sb = who->GetStuckBehavior();
|
LogDebug("Handle stuck behavior for {0} at ({1}, {2}, {3}) with movement_mode {4}", who->GetName(), x, y, z, mob_movement_mode);
|
||||||
|
|
||||||
|
auto sb = who->GetStuckBehavior();
|
||||||
MobStuckBehavior behavior = RunToTarget;
|
MobStuckBehavior behavior = RunToTarget;
|
||||||
|
|
||||||
if (sb >= 0 && sb < MaxStuckBehavior) {
|
if (sb >= 0 && sb < MaxStuckBehavior) {
|
||||||
@ -1308,7 +1310,7 @@ void MobMovementManager::HandleStuckBehavior(Mob *who, float x, float y, float z
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto eiter = _impl->Entries.find(who);
|
auto eiter = _impl->Entries.find(who);
|
||||||
auto &ent = (*eiter);
|
auto &ent = (*eiter);
|
||||||
|
|
||||||
switch (sb) {
|
switch (sb) {
|
||||||
case RunToTarget:
|
case RunToTarget:
|
||||||
@ -1323,8 +1325,7 @@ void MobMovementManager::HandleStuckBehavior(Mob *who, float x, float y, float z
|
|||||||
PushStopMoving(ent.second);
|
PushStopMoving(ent.second);
|
||||||
break;
|
break;
|
||||||
case EvadeCombat:
|
case EvadeCombat:
|
||||||
//PushEvadeCombat(ent.second);
|
PushEvadeCombat(ent.second);
|
||||||
PushStopMoving(ent.second);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
extern Zone *zone;
|
extern Zone *zone;
|
||||||
|
|
||||||
const int MaxNavmeshNodes = 1024;
|
|
||||||
|
|
||||||
struct PathfinderNavmesh::Implementation
|
struct PathfinderNavmesh::Implementation
|
||||||
{
|
{
|
||||||
dtNavMesh *nav_mesh;
|
dtNavMesh *nav_mesh;
|
||||||
@ -45,7 +43,7 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl
|
|||||||
m_impl->query = dtAllocNavMeshQuery();
|
m_impl->query = dtAllocNavMeshQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_impl->query->init(m_impl->nav_mesh, MaxNavmeshNodes);
|
m_impl->query->init(m_impl->nav_mesh, RuleI(Pathing, MaxNavmeshNodes));
|
||||||
glm::vec3 current_location(start.x, start.z, start.y);
|
glm::vec3 current_location(start.x, start.z, start.y);
|
||||||
glm::vec3 dest_location(end.x, end.z, end.y);
|
glm::vec3 dest_location(end.x, end.z, end.y);
|
||||||
|
|
||||||
@ -143,7 +141,7 @@ IPathfinder::IPath PathfinderNavmesh::FindPath(const glm::vec3 &start, const glm
|
|||||||
m_impl->query = dtAllocNavMeshQuery();
|
m_impl->query = dtAllocNavMeshQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_impl->query->init(m_impl->nav_mesh, MaxNavmeshNodes);
|
m_impl->query->init(m_impl->nav_mesh, RuleI(Pathing, MaxNavmeshNodes));
|
||||||
glm::vec3 current_location(start.x, start.z, start.y);
|
glm::vec3 current_location(start.x, start.z, start.y);
|
||||||
glm::vec3 dest_location(end.x, end.z, end.y);
|
glm::vec3 dest_location(end.x, end.z, end.y);
|
||||||
|
|
||||||
@ -174,18 +172,13 @@ IPathfinder::IPath PathfinderNavmesh::FindPath(const glm::vec3 &start, const glm
|
|||||||
|
|
||||||
int npoly = 0;
|
int npoly = 0;
|
||||||
dtPolyRef path[max_polys] = { 0 };
|
dtPolyRef path[max_polys] = { 0 };
|
||||||
m_impl->query->findPath(start_ref, end_ref, ¤t_location[0], &dest_location[0], &filter, path, &npoly, max_polys);
|
auto status = m_impl->query->findPath(start_ref, end_ref, ¤t_location[0], &dest_location[0], &filter, path, &npoly, max_polys);
|
||||||
|
|
||||||
if (npoly) {
|
if (npoly) {
|
||||||
glm::vec3 epos = dest_location;
|
glm::vec3 epos = dest_location;
|
||||||
if (path[npoly - 1] != end_ref) {
|
if (path[npoly - 1] != end_ref) {
|
||||||
m_impl->query->closestPointOnPoly(path[npoly - 1], &dest_location[0], &epos[0], 0);
|
m_impl->query->closestPointOnPoly(path[npoly - 1], &dest_location[0], &epos[0], 0);
|
||||||
partial = true;
|
partial = true;
|
||||||
|
|
||||||
auto dist = DistanceSquared(epos, current_location);
|
|
||||||
if (dist < 10000.0f) {
|
|
||||||
stuck = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int n_straight_polys;
|
int n_straight_polys;
|
||||||
@ -313,7 +306,7 @@ glm::vec3 PathfinderNavmesh::GetRandomLocation(const glm::vec3 &start)
|
|||||||
|
|
||||||
if (!m_impl->query) {
|
if (!m_impl->query) {
|
||||||
m_impl->query = dtAllocNavMeshQuery();
|
m_impl->query = dtAllocNavMeshQuery();
|
||||||
m_impl->query->init(m_impl->nav_mesh, MaxNavmeshNodes);
|
m_impl->query->init(m_impl->nav_mesh, RuleI(Pathing, MaxNavmeshNodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
dtQueryFilter filter;
|
dtQueryFilter filter;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user