From 14b9b22ca34b02a3c4e2dcaf6f3350bb2d0262aa Mon Sep 17 00:00:00 2001 From: KimLS Date: Sat, 16 Jan 2016 20:35:18 -0800 Subject: [PATCH] Will no longer use bestz snapping every frame if a navmesh is available. Fix for inliquid --- common/pathfind.h | 1 + zone/mob.cpp | 2 +- zone/pathing.cpp | 2 +- zone/water_map_v1.cpp | 3 ++- zone/water_map_v2.cpp | 3 ++- zone/waypoints.cpp | 31 ++----------------------------- 6 files changed, 9 insertions(+), 33 deletions(-) diff --git a/common/pathfind.h b/common/pathfind.h index 725a284a4..b15b69d86 100644 --- a/common/pathfind.h +++ b/common/pathfind.h @@ -77,6 +77,7 @@ public: //Expects locations in EQEmu internal format eg what #loc returns not what /loc returns. PathfindingRoute FindRoute(const glm::vec3 ¤t_location, const glm::vec3 &dest_location); bool GetRandomPoint(const glm::vec3 &start, float radius, glm::vec3 &pos); + bool Loaded() const { return m_nav_mesh != nullptr; } private: dtNavMesh *m_nav_mesh; dtNavMeshQuery *m_nav_query; diff --git a/zone/mob.cpp b/zone/mob.cpp index e8d317d7d..5812a0685 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -109,7 +109,7 @@ Mob::Mob(const char* in_name, m_TargetV(glm::vec3()), flee_timer(FLEE_CHECK_TIMER), m_Position(position), - m_pos_update_timer(8000) + m_pos_update_timer(3000) //this can be much longer but really need to redo ai and movement code first. { targeted = 0; tar_ndx=0; diff --git a/zone/pathing.cpp b/zone/pathing.cpp index c8c3903bd..911a43c77 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -73,7 +73,7 @@ void Mob::TrySnapToMap() { if (snap && zone->HasMap()) { if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { + (zone->HasWaterMap() && !zone->watermap->InLiquid(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 3.5f; m_Position.z = newz; diff --git a/zone/water_map_v1.cpp b/zone/water_map_v1.cpp index 431df4224..b052321d1 100644 --- a/zone/water_map_v1.cpp +++ b/zone/water_map_v1.cpp @@ -27,7 +27,8 @@ bool WaterMapV1::InLava(const glm::vec3& location) const { } bool WaterMapV1::InLiquid(const glm::vec3& location) const { - return InWater(location) || InLava(location); + auto rtype = ReturnRegionType(location); + return rtype == RegionTypeWater || rtype == RegionTypeLava || rtype == RegionTypeVWater; } bool WaterMapV1::Load(FILE *fp) { diff --git a/zone/water_map_v2.cpp b/zone/water_map_v2.cpp index a57999a48..9f469d09c 100644 --- a/zone/water_map_v2.cpp +++ b/zone/water_map_v2.cpp @@ -30,7 +30,8 @@ bool WaterMapV2::InLava(const glm::vec3& location) const { } bool WaterMapV2::InLiquid(const glm::vec3& location) const { - return InWater(location) || InLava(location); + auto rtype = ReturnRegionType(location); + return rtype == RegionTypeWater || rtype == RegionTypeLava || rtype == RegionTypeVWater; } bool WaterMapV2::Load(FILE *fp) { diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 5accc3340..d79e3fa00 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -526,8 +526,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo NPCFlyMode = 1; } + //lets_move //fix up pathing Z - if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) + if(!NPCFlyMode && checkZ && !zone->pathing.Loaded() && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) @@ -784,34 +785,6 @@ bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ NPCFlyMode = 1; } - //TODO: lets_move - ////fix up pathing Z - //if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) - //{ - // if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - // (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) - // { - // glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); - // - // float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; - // - // Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x,m_Position.y,m_Position.z); - // - // if ((newz > -2000) && - // std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. - // { - // if (std::abs(x - m_Position.x) < 0.5 && std::abs(y - m_Position.y) < 0.5) { - // if (std::abs(z - m_Position.z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) - // m_Position.z = z; - // else - // m_Position.z = newz + 1; - // } - // else - // m_Position.z = newz+1; - // } - // } - //} - //OP_MobUpdate if((old_test_vector!=test_vector) || tar_ndx>20){ //send update tar_ndx=0;