attempting to fix the node evaluation flush

This commit is contained in:
Flerp 2025-10-31 07:01:35 -07:00
parent bc6891d443
commit ba8018c0ce

View File

@ -7,15 +7,16 @@
#include "EventProcessor.h" #include "EventProcessor.h"
#include <vector> #include <vector>
#include <list>
#include <limits> #include <limits>
#include <cstdint> #include <cstdint>
using namespace Acore::ChatCommands; 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 Z_BUMP = 1.5f;
static constexpr float MIN_RETELEPORT_DIST = 8.0f; static constexpr float MIN_RETELEPORT_DIST = 1.0f;
static constexpr uint32 RECHECK_DELAY_MS = 5000; static constexpr uint32 RECHECK_DELAY_MS = 3000;
static const std::vector<uint32> kVeinEntries = { static const std::vector<uint32> kVeinEntries = {
324,1610,1667,1731,1732,1733,1734,2054,2055,3763,3764,19903, 324,1610,1667,1731,1732,1733,1734,2054,2055,3763,3764,19903,
@ -26,21 +27,28 @@ static const std::vector<uint32> kVeinEntries = {
189978,189979,189980,189981,195036, 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; GameObject* nearest = nullptr;
float nearestDist = std::numeric_limits<float>::infinity(); float nearestDist = std::numeric_limits<float>::infinity();
for (uint32 entry : kVeinEntries) for (uint32 entry : kVeinEntries)
{ {
if (GameObject* go = player->FindNearestGameObject(entry, maxRange)) std::list<GameObject*> 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) if (go->getLootState() != LootState::GO_READY)
continue; continue;
if (go->GetGoState() != GOState::GO_STATE_READY) if (go->GetGoState() != GOState::GO_STATE_READY)
continue; continue;
float d = player->GetDistance(go); float d = player->GetDistance(go);
if (d < minDistance)
continue;
if (d <= maxRange && d < nearestDist) if (d <= maxRange && d < nearestDist)
{ {
nearest = go; nearest = go;
@ -48,6 +56,7 @@ static GameObject* FindNearestReadyVein(Player* player, float maxRange)
} }
} }
} }
return nearest; return nearest;
} }
@ -62,11 +71,7 @@ public:
if (!_player || !_player->IsInWorld()) if (!_player || !_player->IsInWorld())
return true; 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( _player->TeleportTo(
node->GetMapId(), node->GetMapId(),
@ -76,8 +81,6 @@ public:
node->GetOrientation() node->GetOrientation()
); );
} }
}
}
return true; return true;
} }
@ -97,7 +100,7 @@ static bool DoTeleNode(Player* player)
return true; return true;
} }
if (GameObject* node = FindNearestReadyVein(player, TELEPORT_DISTANCE)) if (GameObject* node = FindNearestReadyVeinScan(player, TELEPORT_DISTANCE, 0, 0.0f))
{ {
uint64 lastGuid = node->GetGUID().GetRawValue(); uint64 lastGuid = node->GetGUID().GetRawValue();