From 3eee699a890e1f31cdb57ac00cba961485b484c3 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 3 Sep 2018 04:07:13 -0500 Subject: [PATCH] Calculate roambox destination z once and let navmesh pathfinding calculate it the rest of the time --- zone/mob_ai.cpp | 13 ++++++++----- zone/npc.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index ac40d30e4..bf09feb73 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -466,6 +466,7 @@ void NPC::AI_Init() roambox_distance = 0; roambox_destination_x = 0; roambox_destination_y = 0; + roambox_destination_z = 0; roambox_min_delay = 2500; roambox_delay = 2500; } @@ -1724,6 +1725,12 @@ void NPC::AI_DoMovement() { } } + glm::vec3 destination; + destination.x = roambox_destination_x; + destination.y = roambox_destination_y; + destination.z = m_Position.z; + roambox_destination_z = GetFixedZ(destination) + this->GetZOffset(); + Log(Logs::Detail, Logs::NPCRoamBox, "Calculate | NPC: %s distance %.3f | min_x %.3f | max_x %.3f | final_x %.3f | min_y %.3f | max_y %.3f | final_y %.3f", @@ -1737,16 +1744,12 @@ void NPC::AI_DoMovement() { roambox_destination_y); } - if (fix_z_timer.Check()) { - this->FixZ(); - } - bool waypoint_changed, node_reached; glm::vec3 Goal = UpdatePath( roambox_destination_x, roambox_destination_y, - m_Position.z, + roambox_destination_z, move_speed, waypoint_changed, node_reached diff --git a/zone/npc.h b/zone/npc.h index 52c8b2171..ec2676f60 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -540,6 +540,7 @@ protected: float roambox_distance; float roambox_destination_x; float roambox_destination_y; + float roambox_destination_z; uint32 roambox_delay; uint32 roambox_min_delay;