From b92e83a465639126383c4217eac3c050cfedbf0e Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 3 Sep 2018 01:51:40 -0500 Subject: [PATCH] Fix client pathing Z while feared --- zone/mob.h | 2 +- zone/mob_ai.cpp | 42 ++++++++++++++++++++++++------------------ zone/waypoints.cpp | 36 ++++++++++++++++++++++-------------- 3 files changed, 47 insertions(+), 33 deletions(-) diff --git a/zone/mob.h b/zone/mob.h index 763fa61b7..4dafe2bf9 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -988,7 +988,7 @@ public: void SendToFixZ(float new_x, float new_y, float new_z); float GetZOffset() const; float GetDefaultRaceSize() const; - void FixZ(int32 z_find_offset = 5); + void FixZ(int32 z_find_offset = 5, bool fix_client_z = false); float GetFixedZ(glm::vec3 destination, int32 z_find_offset = 5); void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 405ff3643..fcc54f244 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -779,44 +779,50 @@ void Client::AI_Process() } } - if(RuleB(Combat, EnableFearPathing)){ - if(currently_fleeing) { + if (RuleB(Combat, EnableFearPathing)) { + if (currently_fleeing) { - if (fix_z_timer_engaged.Check()) - this->FixZ(); + if (fix_z_timer.Check()) + this->FixZ(5, true); - if(IsRooted()) { + if (IsRooted()) { //make sure everybody knows were not moving, for appearance sake - if(IsMoving()) - { - if(GetTarget()) + if (IsMoving()) { + if (GetTarget()) SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY())); SetCurrentSpeed(0); } //continue on to attack code, ensuring that we execute the engaged code engaged = true; - } else { - if(AI_movement_timer->Check()) { + } + else { + if (AI_movement_timer->Check()) { int speed = GetFearSpeed(); animation = speed; speed *= 2; SetCurrentSpeed(speed); // Check if we have reached the last fear point if ((std::abs(GetX() - m_FearWalkTarget.x) < 0.1) && - (std::abs(GetY() - m_FearWalkTarget.y) < 0.1)) { + (std::abs(GetY() - m_FearWalkTarget.y) < 0.1)) { // Calculate a new point to run to CalculateNewFearpoint(); } - if(!RuleB(Pathing, Fear) || !zone->pathing) + + if (!RuleB(Pathing, Fear) || !zone->pathing) CalculateNewPosition(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, speed, true); - else - { - bool WaypointChanged, NodeReached; + else { + bool waypoint_changed, node_reached; - glm::vec3 Goal = UpdatePath(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, - speed, WaypointChanged, NodeReached); + glm::vec3 Goal = UpdatePath( + m_FearWalkTarget.x, + m_FearWalkTarget.y, + m_FearWalkTarget.z, + speed, + waypoint_changed, + node_reached + ); - if(WaypointChanged) + if (waypoint_changed) tar_ndx = 20; CalculateNewPosition(Goal.x, Goal.y, Goal.z, speed); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 5e1f0dd82..36c996ce8 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -793,26 +793,34 @@ float Mob::GetFixedZ(glm::vec3 destination, int32 z_find_offset) { return new_z; } -void Mob::FixZ(int32 z_find_offset /*= 5*/) { +void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) { glm::vec3 current_loc(m_Position); - float new_z = GetFixedZ(current_loc, z_find_offset); - if (!IsClient() && new_z != m_Position.z) { - if ((new_z > -2000) && new_z != BEST_Z_INVALID) { - if (RuleB(Map, MobZVisualDebug)) { - this->SendAppearanceEffect(78, 0, 0, 0, 0); - } + if (IsClient() && !fix_client_z) + return; - m_Position.z = new_z; + float new_z = GetFixedZ(current_loc, z_find_offset); + + if (new_z == m_Position.z) + return; + + if ((new_z > -2000) && new_z != BEST_Z_INVALID) { + if (RuleB(Map, MobZVisualDebug)) { + this->SendAppearanceEffect(78, 0, 0, 0, 0); } - else { - if (RuleB(Map, MobZVisualDebug)) { - this->SendAppearanceEffect(103, 0, 0, 0, 0); - } - Log(Logs::General, Logs::FixZ, "%s is failing to find Z %f", - this->GetCleanName(), std::abs(m_Position.z - new_z)); + m_Position.z = new_z; + } + else { + if (RuleB(Map, MobZVisualDebug)) { + this->SendAppearanceEffect(103, 0, 0, 0, 0); } + + Log(Logs::General, + Logs::FixZ, + "%s is failing to find Z %f", + this->GetCleanName(), + std::abs(m_Position.z - new_z)); } }