diff --git a/common/ruletypes.h b/common/ruletypes.h index 529c7d239..a278f58f3 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -151,6 +151,7 @@ RULE_BOOL(Character, UseOldBindWound, false) // Uses the original bind wound beh RULE_BOOL(Character, GrantHoTTOnCreate, false) // Grant Health of Target's Target leadership AA on character creation RULE_BOOL(Character, UseOldConSystem, false) // Grant Health of Target's Target leadership AA on character creation RULE_BOOL(Character, OPClientUpdateVisualDebug, false) // Shows a pulse and forward directional particle each time the client sends its position to server +RULE_BOOL(Character, AllowCrossClassTrainers, false) RULE_CATEGORY_END() RULE_CATEGORY(Mercs) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8a23b6996..01aadfd19 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -5750,10 +5750,10 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) glm::vec3 End(target->GetX(), target->GetY(), target->GetZ() + (target->GetSize() < 6.0 ? 6 : target->GetSize()) * HEAD_POSITION); bool partial = false; - bool error = false; - auto pathlist = zone->pathing->FindRoute(Start, End, partial, error); + bool stuck = false; + auto pathlist = zone->pathing->FindRoute(Start, End, partial, stuck); - if (pathlist.empty() || error || partial) + if (pathlist.empty() || partial) { EQApplicationPacket outapp(OP_FindPersonReply, 0); QueuePacket(&outapp); diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 62921f6ce..1e591de2f 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1527,9 +1527,11 @@ void Client::OPGMTraining(const EQApplicationPacket *app) return; //you can only use your own trainer, client enforces this, but why trust it - int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR); - if(GetClass() != trains_class) - return; + if (!RuleB(Character, AllowCrossClassTrainers)) { + int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR); + if (GetClass() != trains_class) + return; + } //you have to be somewhat close to a trainer to be properly using them if(DistanceSquared(m_Position,pTrainer->GetPosition()) > USE_NPC_RANGE2) @@ -1580,9 +1582,11 @@ void Client::OPGMEndTraining(const EQApplicationPacket *app) return; //you can only use your own trainer, client enforces this, but why trust it - int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR); - if(GetClass() != trains_class) - return; + if (!RuleB(Character, AllowCrossClassTrainers)) { + int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR); + if (GetClass() != trains_class) + return; + } //you have to be somewhat close to a trainer to be properly using them if(DistanceSquared(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2) @@ -1609,9 +1613,11 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app) return; //you can only use your own trainer, client enforces this, but why trust it - int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR); - if(GetClass() != trains_class) - return; + if (!RuleB(Character, AllowCrossClassTrainers)) { + int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR); + if (GetClass() != trains_class) + return; + } //you have to be somewhat close to a trainer to be properly using them if(DistanceSquared(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2) diff --git a/zone/mob.cpp b/zone/mob.cpp index a0b16c76c..42a7d01a8 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -445,7 +445,7 @@ Mob::Mob(const char* in_name, AssistAggro = false; npc_assist_cap = 0; - PathRecalcTimer.reset(new Timer(1500)); + PathRecalcTimer.reset(new Timer(500)); PathingLoopCount = 0; } @@ -1240,6 +1240,13 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) ns->spawn.flymode = 0; } + + if (RuleB(Character, AllowCrossClassTrainers) && ForWho) { + if (ns->spawn.class_ >= WARRIORGM && ns->spawn.class_ <= BERSERKERGM) { + int trainer_class = WARRIORGM + (ForWho->GetClass() - 1); + ns->spawn.class_ = trainer_class; + } + } } void Mob::CreateDespawnPacket(EQApplicationPacket* app, bool Decay) diff --git a/zone/pathfinder_interface.h b/zone/pathfinder_interface.h index 8ef9fb15a..2a874a50d 100644 --- a/zone/pathfinder_interface.h +++ b/zone/pathfinder_interface.h @@ -29,7 +29,7 @@ public: IPathfinder() { } virtual ~IPathfinder() { } - virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error) = 0; + virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck) = 0; virtual glm::vec3 GetRandomLocation() = 0; virtual void DebugCommand(Client *c, const Seperator *sep) = 0; diff --git a/zone/pathfinder_nav_mesh.cpp b/zone/pathfinder_nav_mesh.cpp index 904d7ce4a..8b4cfb2f5 100644 --- a/zone/pathfinder_nav_mesh.cpp +++ b/zone/pathfinder_nav_mesh.cpp @@ -33,16 +33,12 @@ PathfinderNavmesh::~PathfinderNavmesh() Clear(); } -IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error) +IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck) { partial = false; - error = false; if (!m_impl->nav_mesh) { - error = true; - IPath Route; - Route.push_back(end); - return Route; + return IPath(); } if (!m_impl->query) { @@ -74,10 +70,7 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl m_impl->query->findNearestPoly(&dest_location[0], &ext[0], &filter, &end_ref, 0); if (!start_ref || !end_ref) { - error = true; - IPath Route; - Route.push_back(end); - return Route; + return IPath(); } int npoly = 0; @@ -89,6 +82,11 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl if (path[npoly - 1] != end_ref) { m_impl->query->closestPointOnPoly(path[npoly - 1], &dest_location[0], &epos[0], 0); partial = true; + + auto dist = DistanceSquared(epos, current_location); + if (dist < 10.0f) { + stuck = true; + } } float straight_path[2048 * 3]; @@ -102,10 +100,7 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl straight_path_polys, &n_straight_polys, 2048, DT_STRAIGHTPATH_AREA_CROSSINGS); if (dtStatusFailed(status)) { - error = true; - IPath Route; - Route.push_back(end); - return Route; + return IPath(); } if (n_straight_polys) { @@ -292,11 +287,11 @@ void PathfinderNavmesh::Load(const std::string &path) void PathfinderNavmesh::ShowPath(Client * c, const glm::vec3 &start, const glm::vec3 &end) { bool partial = false; - bool error = false; - auto path = FindRoute(start, end, partial, error); + bool stuck = false; + auto path = FindRoute(start, end, partial, stuck); std::vector points; - if (!partial && !error) { + if (!partial) { FindPerson_Point p; for (auto &node : path) { diff --git a/zone/pathfinder_nav_mesh.h b/zone/pathfinder_nav_mesh.h index 583dd8183..e740e5ca7 100644 --- a/zone/pathfinder_nav_mesh.h +++ b/zone/pathfinder_nav_mesh.h @@ -9,7 +9,7 @@ public: PathfinderNavmesh(const std::string &path); virtual ~PathfinderNavmesh(); - virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error); + virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck); virtual glm::vec3 GetRandomLocation(); virtual void DebugCommand(Client *c, const Seperator *sep); diff --git a/zone/pathfinder_null.cpp b/zone/pathfinder_null.cpp index ec6160fe7..dce3d19f5 100644 --- a/zone/pathfinder_null.cpp +++ b/zone/pathfinder_null.cpp @@ -1,9 +1,9 @@ #include "pathfinder_null.h" -IPathfinder::IPath PathfinderNull::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error) +IPathfinder::IPath PathfinderNull::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck) { - error = false; partial = false; + stuck = false; IPath ret; ret.push_back(start); ret.push_back(end); diff --git a/zone/pathfinder_null.h b/zone/pathfinder_null.h index 885604b27..2c43e3085 100644 --- a/zone/pathfinder_null.h +++ b/zone/pathfinder_null.h @@ -8,7 +8,7 @@ public: PathfinderNull() { } virtual ~PathfinderNull() { } - virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error); + virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck); virtual glm::vec3 GetRandomLocation(); virtual void DebugCommand(Client *c, const Seperator *sep) { } }; \ No newline at end of file diff --git a/zone/pathfinder_waypoint.cpp b/zone/pathfinder_waypoint.cpp index 6489227b3..86dd4a4a4 100644 --- a/zone/pathfinder_waypoint.cpp +++ b/zone/pathfinder_waypoint.cpp @@ -114,21 +114,19 @@ PathfinderWaypoint::~PathfinderWaypoint() { } -IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error) +IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck) { + stuck = false; partial = false; - error = false; std::vector result_start_n; m_impl->Tree.query(boost::geometry::index::nearest(Point(start.x, start.y, start.z), 1), std::back_inserter(result_start_n)); if (result_start_n.size() == 0) { - error = true; return IPath(); } std::vector result_end_n; m_impl->Tree.query(boost::geometry::index::nearest(Point(end.x, end.y, end.z), 1), std::back_inserter(result_end_n)); if (result_end_n.size() == 0) { - error = true; return IPath(); } @@ -183,11 +181,7 @@ IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const g return Route; } - error = true; - IPath Route; - Route.push_front(start); - Route.push_back(glm::vec3(nearest_start.first.get<0>(), nearest_start.first.get<1>(), nearest_start.first.get<2>())); - return Route; + return IPath(); } glm::vec3 PathfinderWaypoint::GetRandomLocation() @@ -401,8 +395,8 @@ void PathfinderWaypoint::ShowNodes() void PathfinderWaypoint::ShowPath(Client *c, const glm::vec3 &start, const glm::vec3 &end) { bool partial = false; - bool error = false; - auto path = FindRoute(start, end, partial, error); + bool stuck = false; + auto path = FindRoute(start, end, partial, stuck); std::vector points; FindPerson_Point p; diff --git a/zone/pathfinder_waypoint.h b/zone/pathfinder_waypoint.h index d9aa726d1..3f6b99c9f 100644 --- a/zone/pathfinder_waypoint.h +++ b/zone/pathfinder_waypoint.h @@ -11,7 +11,7 @@ public: PathfinderWaypoint(const std::string &path); virtual ~PathfinderWaypoint(); - virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error); + virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck); virtual glm::vec3 GetRandomLocation(); virtual void DebugCommand(Client *c, const Seperator *sep); diff --git a/zone/pathing.cpp b/zone/pathing.cpp index bbe66d736..844ba6cde 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -40,13 +40,25 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if (Route.empty()) { bool partial = false; - bool error = false; - Route = zone->pathing->FindRoute(From, To, partial, error); + bool stuck = false; + Route = zone->pathing->FindRoute(From, To, partial, stuck); AdjustRoute(Route, flymode, GetModelOffset()); PathingDestination = To; WaypointChanged = true; NodeReached = false; + if (stuck) { + bool partial = false; + bool stuck = false; + auto r = zone->pathing->FindRoute(To, From, partial, stuck); + Route.clear(); + + auto final_node = r.back(); + Route.push_back(final_node); + AdjustRoute(Route, flymode, GetModelOffset()); + return (*Route.begin()).pos; + } + if (Route.empty()) { return To; } @@ -60,14 +72,26 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if (!SameDestination) { //We had a route but our target position moved too much bool partial = false; - bool error = false; - Route = zone->pathing->FindRoute(From, To, partial, error); + bool stuck = false; + Route = zone->pathing->FindRoute(From, To, partial, stuck); AdjustRoute(Route, flymode, GetModelOffset()); PathingDestination = To; WaypointChanged = true; NodeReached = false; + if (stuck) { + bool partial = false; + bool stuck = false; + auto r = zone->pathing->FindRoute(To, From, partial, stuck); + Route.clear(); + + auto final_node = r.back(); + Route.push_back(final_node); + AdjustRoute(Route, flymode, GetModelOffset()); + return (*Route.begin()).pos; + } + if (Route.empty()) { return To; } @@ -123,12 +147,24 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if (Route.empty()) { bool partial = false; - bool error = false; - Route = zone->pathing->FindRoute(From, To, partial, error); + bool stuck = false; + Route = zone->pathing->FindRoute(From, To, partial, stuck); AdjustRoute(Route, flymode, GetModelOffset()); PathingDestination = To; WaypointChanged = true; + if (stuck) { + bool partial = false; + bool stuck = false; + auto r = zone->pathing->FindRoute(To, From, partial, stuck); + Route.clear(); + + auto final_node = r.back(); + Route.push_back(final_node); + AdjustRoute(Route, flymode, GetModelOffset()); + return (*Route.begin()).pos; + } + if(Route.empty()) { return To; }