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 <vector>
#include <list>
#include <limits>
#include <cstdint>
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<uint32> kVeinEntries = {
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,
};
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<float>::infinity();
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)
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();