diff --git a/zone/command.cpp b/zone/command.cpp index 9d4604dc2..f57b99613 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7260,6 +7260,7 @@ void command_pf(Client *c, const Seperator *sep) c->Message(0, "POS: (%.2f, %.2f, %.2f)", who->GetX(), who->GetY(), who->GetZ()); c->Message(0, "WP: %s (%d/%d)", to_string(who->GetCurrentWayPoint()).c_str(), who->IsNPC()?who->CastToNPC()->GetMaxWp():-1); c->Message(0, "pause=%d RAspeed=%d", who->GetCWPP(), who->GetRunAnimSpeed()); + who->DumpMovement(c); } else { c->Message(0, "ERROR: target required"); } diff --git a/zone/mob.h b/zone/mob.h index 82aaa81e4..14cb3c3a6 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -969,7 +969,7 @@ public: inline bool CheckAggro(Mob* other) {return hate_list.IsEntOnHateList(other);} float CalculateHeadingToTarget(float in_x, float in_y) { return HeadingAngleToMob(in_x, in_y); } - virtual void CalculateNewPosition(float x, float y, float z, float speed, bool check_z = true, bool calculate_heading = true); + void CalculateNewPosition(float x, float y, float z, float speed, bool check_z = true, bool calculate_heading = true); float CalculateDistance(float x, float y, float z); float GetGroundZ(float new_x, float new_y, float z_offset=0.0); void SendTo(float new_x, float new_y, float new_z); @@ -978,7 +978,8 @@ public: float GetDefaultRaceSize() const; void TryFixZ(int32 z_find_offset = 5, bool fix_client_z = false); void FixZ(int32 z_find_offset = 5, bool fix_client_z = false); - float GetFixedZ(glm::vec3 destination, int32 z_find_offset = 5); + float GetFixedZ(const glm::vec3 &destination, int32 z_find_offset = 5); + void DumpMovement(Client *to); void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; } diff --git a/zone/mob_movement_manager.cpp b/zone/mob_movement_manager.cpp index 2b5821ab0..76f71663b 100644 --- a/zone/mob_movement_manager.cpp +++ b/zone/mob_movement_manager.cpp @@ -185,6 +185,35 @@ void MobMovementManager::StopNavigation(Mob *who) { auto iter = _impl->MoveEntries.find(who); auto &ent = iter->second; ent.active = false; + + SendPosition(who); +} + +void MobMovementManager::Dump(Mob *m, Client *to) +{ + { + auto iter = _impl->Entries.find(m); + auto &ent = iter->second; + + to->Message(0, "Packet: anim=%d, heading=%.2f, dirty=%s, last_sent_time=%.2f, last_sent_time_long_dist=%.2f", + ent.animation, + ent.heading, + ent.dirty ? "true" : "false", + ent.last_sent_time, + ent.last_sent_time_long_distance); + } + + { + auto iter = _impl->MoveEntries.find(m); + auto &ent = iter->second; + + to->Message(0, "Movement: speed=%.2f, x=%.2f, y=%.2f, z=%.2f, active=%s", + ent.speed, + ent.x, + ent.y, + ent.z, + ent.active ? "true" : "false"); + } } bool MobMovementManager::HeadingEqual(float a, float b) diff --git a/zone/mob_movement_manager.h b/zone/mob_movement_manager.h index e45bcec55..2660e4b22 100644 --- a/zone/mob_movement_manager.h +++ b/zone/mob_movement_manager.h @@ -18,6 +18,7 @@ public: void SendPositionUpdate(Mob *who, bool send_to_self); void NavigateTo(Mob *who, float x, float y, float z, float speed); void StopNavigation(Mob *who); + void Dump(Mob *m, Client *to); static MobMovementManager &Get() { static MobMovementManager inst; diff --git a/zone/pathing.cpp b/zone/pathing.cpp index a2885c1f1..f835bfe67 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -7,21 +7,6 @@ extern Zone *zone; -void AdjustRoute(std::list &nodes, int flymode, float offset) { - if (!zone->HasMap() || !zone->HasWaterMap()) { - return; - } - - for (auto &node : nodes) { - if (flymode == GravityBehavior::Ground || !zone->watermap->InLiquid(node.pos)) { - auto best_z = zone->zonemap->FindBestZ(node.pos, nullptr); - if (best_z != BEST_Z_INVALID) { - node.pos.z = best_z + offset; - } - } - } -} - glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChanged, bool &NodeReached) { glm::vec3 To(ToX, ToY, ToZ); @@ -42,7 +27,6 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa bool partial = false; bool stuck = false; Route = zone->pathing->FindRoute(From, To, partial, stuck); - AdjustRoute(Route, flymode, GetZOffset()); PathingDestination = To; WaypointChanged = true; @@ -66,7 +50,6 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa bool partial = false; bool stuck = false; Route = zone->pathing->FindRoute(From, To, partial, stuck); - AdjustRoute(Route, flymode, GetZOffset()); PathingDestination = To; WaypointChanged = true; @@ -86,27 +69,27 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa } if (!IsRooted()) { - //bool AtPrevNode = DistanceSquared(From, PathingLastPosition) < 1.0f; - //if (AtPrevNode) { - // PathingLoopCount++; - // auto front = (*Route.begin()).pos; - // - // if (PathingLoopCount > 5) { - // Teleport(front); - // SendPosition(); - // Route.pop_front(); - // - // WaypointChanged = true; - // NodeReached = true; - // PathingLoopCount = 0; - // } - // - // return front; - //} - //else { + bool AtPrevNode = DistanceSquared(From, PathingLastPosition) < 1.0f; + if (AtPrevNode) { + PathingLoopCount++; + auto front = (*Route.begin()).pos; + + if (PathingLoopCount > 5) { + Teleport(front); + SendPosition(); + Route.pop_front(); + + WaypointChanged = true; + NodeReached = true; + PathingLoopCount = 0; + } + + return front; + } + else { PathingLastPosition = From; PathingLoopCount = 0; - //} + } } else { PathingLastPosition = From; @@ -133,7 +116,6 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa bool partial = false; bool stuck = false; Route = zone->pathing->FindRoute(From, To, partial, stuck); - AdjustRoute(Route, flymode, GetZOffset()); PathingDestination = To; WaypointChanged = true; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index e6fbbef5a..76680e0fb 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -573,7 +573,7 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) { } } -float Mob::GetFixedZ(glm::vec3 destination, int32 z_find_offset) { +float Mob::GetFixedZ(const glm::vec3 &destination, int32 z_find_offset) { BenchTimer timer; timer.reset(); @@ -615,6 +615,11 @@ float Mob::GetFixedZ(glm::vec3 destination, int32 z_find_offset) { return new_z; } +void Mob::DumpMovement(Client *to) +{ + mMovementManager->Dump(this, to); +} + void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) { glm::vec3 current_loc(m_Position);