From ba8018c0cee4979a74e65abdf2cf0a1308dc1f54 Mon Sep 17 00:00:00 2001 From: Flerp Date: Fri, 31 Oct 2025 07:01:35 -0700 Subject: [PATCH] attempting to fix the node evaluation flush --- src/teleport-to-node.cpp | 45 +++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/teleport-to-node.cpp b/src/teleport-to-node.cpp index 02e4125..4cb3889 100644 --- a/src/teleport-to-node.cpp +++ b/src/teleport-to-node.cpp @@ -7,15 +7,16 @@ #include "EventProcessor.h" #include +#include #include #include using namespace Acore::ChatCommands; -static constexpr float TELEPORT_DISTANCE = 200.0f; +static constexpr float TELEPORT_DISTANCE = 250.0f; static constexpr float Z_BUMP = 1.5f; -static constexpr float MIN_RETELEPORT_DIST = 8.0f; -static constexpr uint32 RECHECK_DELAY_MS = 5000; +static constexpr float MIN_RETELEPORT_DIST = 1.0f; +static constexpr uint32 RECHECK_DELAY_MS = 3000; static const std::vector kVeinEntries = { 324,1610,1667,1731,1732,1733,1734,2054,2055,3763,3764,19903, @@ -26,21 +27,28 @@ static const std::vector kVeinEntries = { 189978,189979,189980,189981,195036, }; -static GameObject* FindNearestReadyVein(Player* player, float maxRange) +static GameObject* FindNearestReadyVeinScan(Player* player, float maxRange, uint64 guidToExclude, float minDistance) { GameObject* nearest = nullptr; float nearestDist = std::numeric_limits::infinity(); for (uint32 entry : kVeinEntries) { - if (GameObject* go = player->FindNearestGameObject(entry, maxRange)) + std::list lst; + player->GetGameObjectListWithEntryInGrid(lst, entry, maxRange); + for (GameObject* go : lst) { + if (!go || !go->IsInWorld()) + continue; + if (guidToExclude && go->GetGUID().GetRawValue() == guidToExclude) + continue; if (go->getLootState() != LootState::GO_READY) continue; if (go->GetGoState() != GOState::GO_STATE_READY) continue; - float d = player->GetDistance(go); + if (d < minDistance) + continue; if (d <= maxRange && d < nearestDist) { nearest = go; @@ -48,6 +56,7 @@ static GameObject* FindNearestReadyVein(Player* player, float maxRange) } } } + return nearest; } @@ -62,21 +71,15 @@ public: if (!_player || !_player->IsInWorld()) return true; - if (GameObject* node = FindNearestReadyVein(_player, TELEPORT_DISTANCE)) + if (GameObject* node = FindNearestReadyVeinScan(_player, TELEPORT_DISTANCE, _lastNodeGuidRaw, MIN_RETELEPORT_DIST)) { - if (node->GetGUID().GetRawValue() != _lastNodeGuidRaw) - { - if (_player->GetDistance(node) >= MIN_RETELEPORT_DIST) - { - _player->TeleportTo( - node->GetMapId(), - node->GetPositionX(), - node->GetPositionY(), - node->GetPositionZ() + Z_BUMP, - node->GetOrientation() - ); - } - } + _player->TeleportTo( + node->GetMapId(), + node->GetPositionX(), + node->GetPositionY(), + node->GetPositionZ() + Z_BUMP, + node->GetOrientation() + ); } return true; } @@ -97,7 +100,7 @@ static bool DoTeleNode(Player* player) return true; } - if (GameObject* node = FindNearestReadyVein(player, TELEPORT_DISTANCE)) + if (GameObject* node = FindNearestReadyVeinScan(player, TELEPORT_DISTANCE, 0, 0.0f)) { uint64 lastGuid = node->GetGUID().GetRawValue();