attempting to fix the node evaluation flush
This commit is contained in:
parent
bc6891d443
commit
ba8018c0ce
@ -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,21 +71,15 @@ 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)
|
_player->TeleportTo(
|
||||||
{
|
node->GetMapId(),
|
||||||
if (_player->GetDistance(node) >= MIN_RETELEPORT_DIST)
|
node->GetPositionX(),
|
||||||
{
|
node->GetPositionY(),
|
||||||
_player->TeleportTo(
|
node->GetPositionZ() + Z_BUMP,
|
||||||
node->GetMapId(),
|
node->GetOrientation()
|
||||||
node->GetPositionX(),
|
);
|
||||||
node->GetPositionY(),
|
|
||||||
node->GetPositionZ() + Z_BUMP,
|
|
||||||
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();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user