mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Fear pathing fixups, random path rewrite, and nektulos / general roambox fixups where best Z axis is below the ground
This commit is contained in:
parent
904bc3e004
commit
e466f9b3f9
@ -157,41 +157,19 @@ void Mob::ProcessFlee()
|
||||
|
||||
void Mob::CalculateNewFearpoint() {
|
||||
if (RuleB(Pathing, Fear) && zone->pathing) {
|
||||
auto Node = zone->pathing->GetRandomLocation();
|
||||
auto Node = zone->pathing->GetRandomLocation(glm::vec3(GetX(), GetY(), GetZ()));
|
||||
if (Node.x != 0.0f || Node.y != 0.0f || Node.z != 0.0f) {
|
||||
|
||||
++Node.z;
|
||||
m_FearWalkTarget = Node;
|
||||
currently_fleeing = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Stun(6000);
|
||||
|
||||
Log(Logs::Detail,
|
||||
Logs::Pathing,
|
||||
"No path found to selected node. Falling through to old fear point selection.");
|
||||
}
|
||||
|
||||
int loop = 0;
|
||||
float ranx, rany, ranz;
|
||||
|
||||
currently_fleeing = true;
|
||||
while (loop < 100) //Max 100 tries
|
||||
{
|
||||
int ran = 250 - (loop * 2);
|
||||
loop++;
|
||||
ranx = GetX() + zone->random.Int(0, ran - 1) - zone->random.Int(0, ran - 1);
|
||||
rany = GetY() + zone->random.Int(0, ran - 1) - zone->random.Int(0, ran - 1);
|
||||
ranz = FindGroundZ(ranx, rany);
|
||||
if (ranz == BEST_Z_INVALID)
|
||||
continue;
|
||||
float fdist = ranz - GetZ();
|
||||
if (fdist >= -12 && fdist <= 12 && CheckCoordLosNoZLeaps(GetX(), GetY(), GetZ(), ranx, rany, ranz)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currently_fleeing)
|
||||
m_FearWalkTarget = glm::vec3(ranx, rany, ranz);
|
||||
}
|
||||
|
||||
|
||||
@ -802,6 +802,7 @@ void Client::AI_Process()
|
||||
if (AI_movement_timer->Check()) {
|
||||
// Check if we have reached the last fear point
|
||||
if(IsPositionEqualWithinCertainZ(glm::vec3(GetX(), GetY(), GetZ()), m_FearWalkTarget, 5.0f)) {
|
||||
StopNavigation();
|
||||
CalculateNewFearpoint();
|
||||
}
|
||||
|
||||
@ -1080,11 +1081,12 @@ void Mob::AI_Process() {
|
||||
else {
|
||||
if (AI_movement_timer->Check()) {
|
||||
// Check if we have reached the last fear point
|
||||
if (IsPositionEqualWithinCertainZ(glm::vec3(GetX(), GetY(), GetZ()), m_FearWalkTarget, 5.0f)) {
|
||||
if (DistanceNoZ(glm::vec3(GetX(), GetY(), GetZ()), m_FearWalkTarget) <= 5.0f) {
|
||||
// Calculate a new point to run to
|
||||
StopNavigation();
|
||||
CalculateNewFearpoint();
|
||||
}
|
||||
NavigateTo(
|
||||
RunTo(
|
||||
m_FearWalkTarget.x,
|
||||
m_FearWalkTarget.y,
|
||||
m_FearWalkTarget.z
|
||||
@ -1661,7 +1663,7 @@ void NPC::AI_DoMovement() {
|
||||
destination.x = roambox_destination_x;
|
||||
destination.y = roambox_destination_y;
|
||||
destination.z = m_Position.z;
|
||||
roambox_destination_z = GetFixedZ(destination) + this->GetZOffset();
|
||||
roambox_destination_z = zone->zonemap->FindClosestZ(glm::vec3(roambox_destination_x, roambox_destination_y, roambox_destination_z), nullptr) + this->GetZOffset();
|
||||
|
||||
Log(Logs::Detail,
|
||||
Logs::NPCRoamBox,
|
||||
|
||||
@ -30,7 +30,7 @@ public:
|
||||
virtual ~IPathfinder() { }
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck) = 0;
|
||||
virtual glm::vec3 GetRandomLocation() = 0;
|
||||
virtual glm::vec3 GetRandomLocation(const glm::vec3 &start) = 0;
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep) = 0;
|
||||
|
||||
static IPathfinder *Load(const std::string &zone);
|
||||
|
||||
@ -131,8 +131,11 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl
|
||||
return Route;
|
||||
}
|
||||
|
||||
glm::vec3 PathfinderNavmesh::GetRandomLocation()
|
||||
glm::vec3 PathfinderNavmesh::GetRandomLocation(const glm::vec3 &start)
|
||||
{
|
||||
if (start.x == 0.0f && start.y == 0.0)
|
||||
return glm::vec3(0.f);
|
||||
|
||||
if (!m_impl->nav_mesh) {
|
||||
return glm::vec3(0.f);
|
||||
}
|
||||
@ -143,14 +146,33 @@ glm::vec3 PathfinderNavmesh::GetRandomLocation()
|
||||
}
|
||||
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(65535U);
|
||||
filter.setIncludeFlags(65535U ^ 2048);
|
||||
filter.setAreaCost(0, 1.0f); //Normal
|
||||
filter.setAreaCost(1, 3.0f); //Water
|
||||
filter.setAreaCost(2, 5.0f); //Lava
|
||||
filter.setAreaCost(4, 1.0f); //PvP
|
||||
filter.setAreaCost(5, 2.0f); //Slime
|
||||
filter.setAreaCost(6, 2.0f); //Ice
|
||||
filter.setAreaCost(7, 4.0f); //V Water (Frigid Water)
|
||||
filter.setAreaCost(8, 1.0f); //General Area
|
||||
filter.setAreaCost(9, 0.1f); //Portal
|
||||
filter.setAreaCost(10, 0.1f); //Prefer
|
||||
|
||||
dtPolyRef randomRef;
|
||||
float point[3];
|
||||
|
||||
if (dtStatusSucceed(m_impl->query->findRandomPoint(&filter, []() {
|
||||
return (float)zone->random.Real(0.0, 1.0);
|
||||
}, &randomRef, point)))
|
||||
dtPolyRef start_ref;
|
||||
glm::vec3 current_location(start.x, start.z, start.y);
|
||||
glm::vec3 ext(5.0f, 100.0f, 5.0f);
|
||||
|
||||
m_impl->query->findNearestPoly(¤t_location[0], &ext[0], &filter, &start_ref, 0);
|
||||
|
||||
if (!start_ref)
|
||||
{
|
||||
return glm::vec3(0.f);
|
||||
}
|
||||
|
||||
if (dtStatusSucceed(m_impl->query->findRandomPointAroundCircle(start_ref, ¤t_location[0], 100.f, &filter, []() { return (float)zone->random.Real(0.0, 1.0); }, &randomRef, point)))
|
||||
{
|
||||
return glm::vec3(point[0], point[2], point[1]);
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ public:
|
||||
virtual ~PathfinderNavmesh();
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck);
|
||||
virtual glm::vec3 GetRandomLocation();
|
||||
virtual glm::vec3 GetRandomLocation(const glm::vec3 &start);
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep);
|
||||
|
||||
private:
|
||||
@ -20,4 +20,4 @@ private:
|
||||
|
||||
struct Implementation;
|
||||
std::unique_ptr<Implementation> m_impl;
|
||||
};
|
||||
};
|
||||
|
||||
@ -10,7 +10,7 @@ IPathfinder::IPath PathfinderNull::FindRoute(const glm::vec3 &start, const glm::
|
||||
return ret;
|
||||
}
|
||||
|
||||
glm::vec3 PathfinderNull::GetRandomLocation()
|
||||
glm::vec3 PathfinderNull::GetRandomLocation(const glm::vec3 &start)
|
||||
{
|
||||
return glm::vec3();
|
||||
}
|
||||
|
||||
@ -9,6 +9,6 @@ public:
|
||||
virtual ~PathfinderNull() { }
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck);
|
||||
virtual glm::vec3 GetRandomLocation();
|
||||
virtual glm::vec3 GetRandomLocation(const glm::vec3 &start);
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep) { }
|
||||
};
|
||||
};
|
||||
|
||||
@ -184,7 +184,7 @@ IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const g
|
||||
return IPath();
|
||||
}
|
||||
|
||||
glm::vec3 PathfinderWaypoint::GetRandomLocation()
|
||||
glm::vec3 PathfinderWaypoint::GetRandomLocation(const glm::vec3 &start)
|
||||
{
|
||||
if (m_impl->Nodes.size() > 0) {
|
||||
auto idx = zone->random.Int(0, (int)m_impl->Nodes.size() - 1);
|
||||
|
||||
@ -12,7 +12,7 @@ public:
|
||||
virtual ~PathfinderWaypoint();
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck);
|
||||
virtual glm::vec3 GetRandomLocation();
|
||||
virtual glm::vec3 GetRandomLocation(const glm::vec3 &start);
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep);
|
||||
|
||||
private:
|
||||
@ -28,4 +28,4 @@ private:
|
||||
|
||||
struct Implementation;
|
||||
std::unique_ptr<Implementation> m_impl;
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user