diff --git a/zone/mob.cpp b/zone/mob.cpp index ac8baa99e..3087ccfb7 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -317,9 +317,7 @@ Mob::Mob(const char* in_name, wandertype=0; pausetype=0; cur_wp = 0; - cur_wp_x = 0; - cur_wp_y = 0; - cur_wp_z = 0; + m_CurrentWayPoint = xyz_heading::Origin(); cur_wp_pause = 0; patrol=0; follow=0; diff --git a/zone/mob.h b/zone/mob.h index 493288c51..f1e79d1a1 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -862,10 +862,10 @@ public: Shielders_Struct shielder[MAX_SHIELDERS]; Trade* trade; - inline float GetCWPX() const { return(cur_wp_x); } - inline float GetCWPY() const { return(cur_wp_y); } - inline float GetCWPZ() const { return(cur_wp_z); } - inline float GetCWPH() const { return(cur_wp_heading); } + inline float GetCWPX() const { return(m_CurrentWayPoint.m_X); } + inline float GetCWPY() const { return(m_CurrentWayPoint.m_Y); } + inline float GetCWPZ() const { return(m_CurrentWayPoint.m_Z); } + inline float GetCWPH() const { return(m_CurrentWayPoint.m_Heading); } inline float GetCWPP() const { return(static_cast(cur_wp_pause)); } inline int GetCWP() const { return(cur_wp); } void SetCurrentWP(uint16 waypoint) { cur_wp = waypoint; } @@ -1189,11 +1189,9 @@ protected: int pausetype; int cur_wp; - float cur_wp_x; - float cur_wp_y; - float cur_wp_z; + xyz_heading m_CurrentWayPoint; int cur_wp_pause; - float cur_wp_heading; + int patrol; float fear_walkto_x; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index da579a2db..e36ffb11a 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1724,15 +1724,15 @@ void NPC::AI_DoMovement() { } // endif (movetimercompleted==true) else if (!(AIwalking_timer->Enabled())) { // currently moving - if (cur_wp_x == GetX() && cur_wp_y == GetY()) + if (m_CurrentWayPoint.m_X == GetX() && m_CurrentWayPoint.m_Y == GetY()) { // are we there yet? then stop mlog(AI__WAYPOINTS, "We have reached waypoint %d (%.3f,%.3f,%.3f) on grid %d", cur_wp, GetX(), GetY(), GetZ(), GetGrid()); SetWaypointPause(); if(GetAppearance() != eaStanding) SetAppearance(eaStanding, false); SetMoving(false); - if (cur_wp_heading >= 0.0) { - SetHeading(cur_wp_heading); + if (m_CurrentWayPoint.m_Heading >= 0.0) { + SetHeading(m_CurrentWayPoint.m_Heading); } SendPosition(); @@ -1748,12 +1748,12 @@ void NPC::AI_DoMovement() { else { // not at waypoint yet, so keep moving if(!RuleB(Pathing, AggroReturnToGrid) || !zone->pathing || (DistractedFromGrid == 0)) - CalculateNewPosition2(cur_wp_x, cur_wp_y, cur_wp_z, walksp, true); + CalculateNewPosition2(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, walksp, true); else { bool WaypointChanged; bool NodeReached; - Map::Vertex Goal = UpdatePath(cur_wp_x, cur_wp_y, cur_wp_z, walksp, WaypointChanged, NodeReached); + Map::Vertex Goal = UpdatePath(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, walksp, WaypointChanged, NodeReached); if(WaypointChanged) tar_ndx = 20; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index f786eeb57..678504c1c 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -122,7 +122,7 @@ void NPC::ResumeWandering() return; } - if (cur_wp_x == GetX() && cur_wp_y == GetY()) + if (m_CurrentWayPoint.m_X == GetX() && m_CurrentWayPoint.m_Y == GetY()) { // are we we at a waypoint? if so, trigger event and start to next char temp[100]; itoa(cur_wp,temp,10); //do this before updating to next waypoint @@ -201,11 +201,8 @@ void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot) mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z); } - cur_wp_x = mtx; - cur_wp_y = mty; - cur_wp_z = mtz; + m_CurrentWayPoint = xyz_heading(mtx, mty, mtz, mth); cur_wp_pause = 0; - cur_wp_heading = mth; pLastFightingDelayMoving = 0; if(AIwalking_timer->Enabled()) AIwalking_timer->Start(100); @@ -221,26 +218,23 @@ void NPC::UpdateWaypoint(int wp_index) cur = Waypoints.begin(); cur += wp_index; - cur_wp_x = cur->x; - cur_wp_y = cur->y; - cur_wp_z = cur->z; + m_CurrentWayPoint = xyz_heading(cur->x, cur->y, cur->z, cur->heading); cur_wp_pause = cur->pause; - cur_wp_heading = cur->heading; - mlog(AI__WAYPOINTS, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, cur_wp_x, cur_wp_y, cur_wp_z, cur_wp_heading); + mlog(AI__WAYPOINTS, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z, m_CurrentWayPoint.m_Heading); //fix up pathing Z if(zone->HasMap() && RuleB(Map, FixPathingZAtWaypoints)) { if(!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(cur_wp_x, cur_wp_y, cur_wp_z))) + (zone->HasWaterMap() && !zone->watermap->InWater(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z))) { - Map::Vertex dest(cur_wp_x, cur_wp_y, cur_wp_z); + Map::Vertex dest(m_CurrentWayPoint.m_X, m_CurrentWayPoint.m_Y, m_CurrentWayPoint.m_Z); float newz = zone->zonemap->FindBestZ(dest, nullptr); if( (newz > -2000) && ABS(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaWaypoint)) - cur_wp_z = newz + 1; + m_CurrentWayPoint.m_Z = newz + 1; } }