mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Pathing] Improvements to handling tight corridors pathing, clipping detection and recovery (#2826)
This commit is contained in:
+24
-7
@@ -771,17 +771,15 @@ float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) {
|
||||
float new_z = destination.z;
|
||||
|
||||
if (zone->HasMap()) {
|
||||
|
||||
if (flymode == GravityBehavior::Flying)
|
||||
if (flymode == GravityBehavior::Flying) {
|
||||
return new_z;
|
||||
}
|
||||
|
||||
if (zone->HasWaterMap() && zone->watermap->InLiquid(glm::vec3(m_Position)))
|
||||
if (zone->HasWaterMap() && zone->watermap->InLiquid(glm::vec3(m_Position))) {
|
||||
return new_z;
|
||||
}
|
||||
|
||||
/*
|
||||
* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors
|
||||
*/
|
||||
new_z = FindDestGroundZ(destination, z_find_offset);
|
||||
new_z = FindDestGroundZ(destination, (-GetZOffset() / 2));
|
||||
if (new_z != BEST_Z_INVALID) {
|
||||
new_z += GetZOffset();
|
||||
|
||||
@@ -790,6 +788,20 @@ float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) {
|
||||
}
|
||||
}
|
||||
|
||||
// prevent ceiling clipping
|
||||
// if client is close in distance (not counting Z) and we clipped up into a ceiling
|
||||
// this helps us snap back down (or up) if it were to happen
|
||||
// other fixes were put in place to prevent clipping into the ceiling to begin with
|
||||
if (std::abs(new_z - m_Position.z) > 15) {
|
||||
LogFixZ("TRIGGER clipping detection");
|
||||
auto t = GetTarget();
|
||||
if (t && DistanceNoZ(GetPosition(), t->GetPosition()) < 20) {
|
||||
new_z = FindDestGroundZ(t->GetPosition(), -t->GetZOffset());
|
||||
new_z += GetZOffset();
|
||||
GMMove(t->GetPosition().x, t->GetPosition().y, new_z, t->GetPosition().w);
|
||||
}
|
||||
}
|
||||
|
||||
auto duration = timer.elapsed();
|
||||
|
||||
LogFixZ("[{}] returned [{}] at [{}] [{}] [{}] - Took [{}]",
|
||||
@@ -833,6 +845,10 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) {
|
||||
}
|
||||
|
||||
m_Position.z = new_z;
|
||||
|
||||
if (RuleB(Map, MobPathingVisualDebug)) {
|
||||
DrawDebugCoordinateNode(fmt::format("{} new fixed z node", GetCleanName()), GetPosition());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (RuleB(Map, MobZVisualDebug)) {
|
||||
@@ -928,6 +944,7 @@ float Mob::GetZOffset() const {
|
||||
case RACE_RABBIT_668:
|
||||
offset = 5.0f;
|
||||
break;
|
||||
case RACE_WURM_158:
|
||||
case RACE_BLIND_DREAMER_669:
|
||||
offset = 7.0f;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user