diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index b440fdd3b..6cbd2db22 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1930,52 +1930,6 @@ XS(XS__repopzone) XSRETURN_EMPTY; } -XS(XS__ConnectNodeToNode); -XS(XS__ConnectNodeToNode) -{ - dXSARGS; - if (items != 4) - Perl_croak(aTHX_ "Usage: ConnectNodeToNode(node1, node2, teleport, doorid)"); - - int node1 = (int)SvIV(ST(0)); - int node2 = (int)SvIV(ST(1)); - int teleport = (int)SvIV(ST(2)); - int doorid = (int)SvIV(ST(3)); - - quest_manager.ConnectNodeToNode(node1, node2, teleport, doorid); - - XSRETURN_EMPTY; -} - -XS(XS__AddNode); -XS(XS__AddNode) -{ - dXSARGS; - //void QuestManager::AddNode(float x, float y, float z, float best_z, int32 requested_id); - if (items < 3 || items > 5) - Perl_croak(aTHX_ "Usage: AddNode(x, y, z, [best_z], [requested_id])"); - - int x = (int)SvIV(ST(0)); - int y = (int)SvIV(ST(1)); - int z = (int)SvIV(ST(2)); - int best_z = 0; - int requested_id = 0; - - if (items == 4) - { - best_z = (int)SvIV(ST(3)); - } - else if (items == 5) - { - best_z = (int)SvIV(ST(3)); - requested_id = (int)SvIV(ST(4)); - } - - quest_manager.AddNode(x, y, z, best_z, requested_id); - - XSRETURN_EMPTY; -} - XS(XS__npcrace); XS(XS__npcrace) { @@ -3867,8 +3821,6 @@ EXTERN_C XS(boot_quest) newXS(strcpy(buf, "reloadzonestaticdata"), XS__reloadzonestaticdata, file); newXS(strcpy(buf, "removetitle"), XS__removetitle, file); newXS(strcpy(buf, "repopzone"), XS__repopzone, file); - newXS(strcpy(buf, "ConnectNodeToNode"), XS__ConnectNodeToNode, file); - newXS(strcpy(buf, "AddNode"), XS__AddNode, file); newXS(strcpy(buf, "resettaskactivity"), XS__resettaskactivity, file); newXS(strcpy(buf, "respawn"), XS__respawn, file); newXS(strcpy(buf, "resume"), XS__resume, file); diff --git a/zone/mob.h b/zone/mob.h index 9fe5eccd1..43f1765e0 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -949,6 +949,7 @@ public: void SendTo(float new_x, float new_y, float new_z); void SendToFixZ(float new_x, float new_y, float new_z); void FixZ(); + float GetModelOffset() const; void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false); inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; } inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; } diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index b59146a12..6e5fd8c8f 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -1529,13 +1529,12 @@ void NPC::AI_DoMovement() { if (roambox_movingto_y > roambox_max_y || roambox_movingto_y < roambox_min_y) roambox_movingto_y = zone->random.Real(roambox_min_y+1,roambox_max_y-1); } - + Log(Logs::Detail, Logs::AI, "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)", roambox_distance, roambox_min_x, roambox_max_x, roambox_min_y, roambox_max_y, roambox_movingto_x, roambox_movingto_y); - - float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5); - new_z += (this->GetSize() / 1.55); - + + float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5) + GetModelOffset(); + if (!CalculateNewPosition(roambox_movingto_x, roambox_movingto_y, new_z, walksp, true)) { roambox_movingto_x = roambox_max_x + 1; // force update diff --git a/zone/pathfinder_nav_mesh.cpp b/zone/pathfinder_nav_mesh.cpp index f44e02ec9..eb74c9cf0 100644 --- a/zone/pathfinder_nav_mesh.cpp +++ b/zone/pathfinder_nav_mesh.cpp @@ -51,17 +51,18 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl filter.setIncludeFlags(65535U); filter.setAreaCost(0, 1.0f); //Normal filter.setAreaCost(1, 2.0f); //Water - filter.setAreaCost(2, 2.0f); //Lava + filter.setAreaCost(2, 4.0f); //Lava filter.setAreaCost(4, 1.0f); //PvP filter.setAreaCost(5, 1.5f); //Slime filter.setAreaCost(6, 1.5f); //Ice - filter.setAreaCost(7, 2.0f); //V Water (Frigid Water) + filter.setAreaCost(7, 3.0f); //V Water (Frigid Water) filter.setAreaCost(8, 1.0f); //General Area filter.setAreaCost(9, 1.0f); //Portal + filter.setAreaCost(10, 0.5f); //Prefer dtPolyRef start_ref; dtPolyRef end_ref; - glm::vec3 ext(15.0f, 15.0f, 15.0f); + glm::vec3 ext(15.0f, 100.0f, 15.0f); m_impl->query->findNearestPoly(¤t_location[0], &ext[0], &filter, &start_ref, 0); m_impl->query->findNearestPoly(&dest_location[0], &ext[0], &filter, &end_ref, 0); @@ -73,8 +74,8 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl } int npoly = 0; - dtPolyRef path[512] = { 0 }; - auto status = m_impl->query->findPath(start_ref, end_ref, ¤t_location[0], &dest_location[0], &filter, path, &npoly, 512); + dtPolyRef path[1024] = { 0 }; + auto status = m_impl->query->findPath(start_ref, end_ref, ¤t_location[0], &dest_location[0], &filter, path, &npoly, 1024); if (npoly) { glm::vec3 epos = dest_location; @@ -82,15 +83,15 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl m_impl->query->closestPointOnPoly(path[npoly - 1], &dest_location[0], &epos[0], 0); } - float straight_path[512 * 3]; - unsigned char straight_path_flags[512]; + float straight_path[2048 * 3]; + unsigned char straight_path_flags[2048]; int n_straight_polys; - dtPolyRef straight_path_polys[512]; + dtPolyRef straight_path_polys[2048]; status = m_impl->query->findStraightPath(¤t_location[0], &epos[0], path, npoly, straight_path, straight_path_flags, - straight_path_polys, &n_straight_polys, 512, DT_STRAIGHTPATH_ALL_CROSSINGS); + straight_path_polys, &n_straight_polys, 2048, DT_STRAIGHTPATH_AREA_CROSSINGS); if (status & DT_OUT_OF_NODES) { IPath Route; diff --git a/zone/pathing.cpp b/zone/pathing.cpp index 3756f449b..e805138e3 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -7,16 +7,16 @@ extern Zone *zone; -void AdjustRoute(std::list &nodes, int flymode) { +void AdjustRoute(std::list &nodes, int flymode, float offset) { if (!zone->HasMap() || !zone->HasWaterMap()) { return; } - + for (auto &node : nodes) { if (flymode == 0 || !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; + node.pos.z = best_z + offset; } } } @@ -40,7 +40,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if (Route.empty()) { Route = zone->pathing->FindRoute(From, To); - AdjustRoute(Route, flymode); + AdjustRoute(Route, flymode, GetModelOffset()); PathingDestination = To; WaypointChanged = true; @@ -58,7 +58,7 @@ 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 Route = zone->pathing->FindRoute(From, To); - AdjustRoute(Route, flymode); + AdjustRoute(Route, flymode, GetModelOffset()); PathingDestination = To; WaypointChanged = true; @@ -120,7 +120,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if (Route.empty()) { Route = zone->pathing->FindRoute(From, To); - AdjustRoute(Route, flymode); + AdjustRoute(Route, flymode, GetModelOffset()); PathingDestination = To; WaypointChanged = true; diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index b06f39ca5..0006398d4 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -672,82 +672,6 @@ void QuestManager::repopzone() { } } -void QuestManager::ConnectNodeToNode(int node1, int node2, int teleport, int doorid) { - //PATHING TODO - //if (!node1 || !node2) - //{ - // Log(Logs::General, Logs::Quests, "QuestManager::ConnectNodeToNode called without node1 or node2. Probably syntax error in quest file."); - //} - //else - //{ - // if (!teleport) - // { - // teleport = 0; - // } - // else if (teleport == 1 || teleport == -1) - // { - // teleport = -1; - // } - // - // if (!doorid) - // { - // doorid = 0; - // } - // - // if (!zone->pathing) - // { - // // if no pathing bits available, make them available. - // zone->pathing = new PathManager(); - // } - // - // if (zone->pathing) - // { - // zone->pathing->ConnectNodeToNode(node1, node2, teleport, doorid); - // Log(Logs::Moderate, Logs::Quests, "QuestManager::ConnectNodeToNode connecting node %i to node %i.", node1, node2); - // } - //} -} - -void QuestManager::AddNode(float x, float y, float z, float best_z, int32 requested_id) -{ - //PATHING TODO - - //if (!x || !y || !z) - //{ - // Log(Logs::General, Logs::Quests, "QuestManager::AddNode called without x, y, z. Probably syntax error in quest file."); - //} - // - //if (!best_z || best_z == 0) - //{ - // if (zone->zonemap) - // { - // glm::vec3 loc(x, y, z); - // best_z = zone->zonemap->FindBestZ(loc, nullptr); - // } - // else - // { - // best_z = z; - // } - //} - // - //if (!requested_id) - //{ - // requested_id = 0; - //} - // - //if (!zone->pathing) - //{ - // // if no pathing bits available, make them available. - // zone->pathing = new PathManager(); - //} - // - //if (zone->pathing) - //{ - // zone->pathing->AddNode(x, y, z, best_z, requested_id); - // Log(Logs::Moderate, Logs::Quests, "QuestManager::AddNode adding node at (%i, %i, %i).", x, y, z); - //} -} - void QuestManager::settarget(const char *type, int target_id) { QuestManagerCurrentQuestVars(); if (!owner || !owner->IsNPC()) diff --git a/zone/questmgr.h b/zone/questmgr.h index 0c846c013..a4deaba97 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -91,8 +91,6 @@ public: void depopall(int npc_type = 0); void depopzone(bool StartSpawnTimer = true); void repopzone(); - void ConnectNodeToNode(int node1, int node2, int teleport, int doorid); - void AddNode(float x, float y, float z, float best_z, int32 requested_id); void settarget(const char *type, int target_id); void follow(int entity_id, int distance); void sfollow(); diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 527173287..180d89867 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -769,7 +769,7 @@ void Mob::FixZ() { { /* Any more than 5 in the offset makes NPC's hop/snap to ceiling in small corridors */ float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5); - new_z += (this->GetSize() / 1.55); + new_z += GetModelOffset(); auto duration = timer.elapsed(); @@ -803,6 +803,108 @@ void Mob::FixZ() { } } +float Mob::GetModelOffset() const { + switch (race) { + case 436: + return 0.577f; + + case 430: + return 0.5f; + + case 432: + return 1.9f; + + case 435: + return 0.93f; + + case 450: + return 0.938f; + + case 479: + return 0.8f; + + case 451: + return 0.816f; + + case 437: + return 0.527f; + + case 439: + return 1.536f; + + case 415: + return 1.0f; + + case 438: + return 0.776f; + + case 452: + return 0.776f; + + case 441: + return 0.816f; + + case 440: + return 0.938f; + + case 468: + return 1.0f; + + case 459: + return 1.0f; + + case 462: + return 1.5f; + + case 530: + return 1.2f; + + case 549: + return 0.5f; + + case 548: + return 0.5f; + + case 547: + return 0.5f; + + case 604: + return 1.2f; + + case 653: + return 5.9f; + + case 658: + return 4.0f; + + case 323: + return 5.0f; + + case 663: + return 5.0f; + + case 664: + return 4.0f; + + case 703: + return 9.0f; + + case 688: + return 5.0f; + + case 669: + return 7.0f; + + case 687: + return 2.0f; + + case 686: + return 2.0f; + default: + return 3.125f; + } +} + int ZoneDatabase::GetHighestGrid(uint32 zoneid) { std::string query = StringFormat("SELECT COALESCE(MAX(id), 0) FROM grid WHERE zoneid = %i", zoneid);