and again, with help from ai slop machine
This commit is contained in:
parent
ba8018c0ce
commit
a5a4636ac9
@ -10,12 +10,14 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
using namespace Acore::ChatCommands;
|
using namespace Acore::ChatCommands;
|
||||||
|
|
||||||
static constexpr float TELEPORT_DISTANCE = 250.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 = 1.0f;
|
static constexpr float MIN_RETELEPORT_DIST = 8.0f;
|
||||||
|
static constexpr float MIN_COORD_DELTA = 6.0f;
|
||||||
static constexpr uint32 RECHECK_DELAY_MS = 3000;
|
static constexpr uint32 RECHECK_DELAY_MS = 3000;
|
||||||
|
|
||||||
static const std::vector<uint32> kVeinEntries = {
|
static const std::vector<uint32> kVeinEntries = {
|
||||||
@ -27,7 +29,13 @@ static const std::vector<uint32> kVeinEntries = {
|
|||||||
189978,189979,189980,189981,195036,
|
189978,189979,189980,189981,195036,
|
||||||
};
|
};
|
||||||
|
|
||||||
static GameObject* FindNearestReadyVeinScan(Player* player, float maxRange, uint64 guidToExclude, float minDistance)
|
static inline float Dist3(float ax, float ay, float az, float bx, float by, float bz)
|
||||||
|
{
|
||||||
|
const float dx = ax - bx, dy = ay - by, dz = az - bz;
|
||||||
|
return std::sqrt(dx*dx + dy*dy + dz*dz);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GameObject* FindNearestReadyVeinScan(Player* player, float maxRange, float minDistanceFromPlayer, float excludeX, float excludeY, float excludeZ, float excludeRadius)
|
||||||
{
|
{
|
||||||
GameObject* nearest = nullptr;
|
GameObject* nearest = nullptr;
|
||||||
float nearestDist = std::numeric_limits<float>::infinity();
|
float nearestDist = std::numeric_limits<float>::infinity();
|
||||||
@ -40,15 +48,22 @@ static GameObject* FindNearestReadyVeinScan(Player* player, float maxRange, uint
|
|||||||
{
|
{
|
||||||
if (!go || !go->IsInWorld())
|
if (!go || !go->IsInWorld())
|
||||||
continue;
|
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);
|
|
||||||
if (d < minDistance)
|
const float gx = go->GetPositionX();
|
||||||
|
const float gy = go->GetPositionY();
|
||||||
|
const float gz = go->GetPositionZ();
|
||||||
|
|
||||||
|
if (excludeRadius > 0.0f && Dist3(gx, gy, gz, excludeX, excludeY, excludeZ) < excludeRadius)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
float d = player->GetDistance(go);
|
||||||
|
if (d < minDistanceFromPlayer)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (d <= maxRange && d < nearestDist)
|
if (d <= maxRange && d < nearestDist)
|
||||||
{
|
{
|
||||||
nearest = go;
|
nearest = go;
|
||||||
@ -63,15 +78,15 @@ static GameObject* FindNearestReadyVeinScan(Player* player, float maxRange, uint
|
|||||||
class TeleNodeRecheckEvent : public BasicEvent
|
class TeleNodeRecheckEvent : public BasicEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TeleNodeRecheckEvent(Player* player, uint64 lastNodeGuidRaw)
|
TeleNodeRecheckEvent(Player* player, float lastX, float lastY, float lastZ)
|
||||||
: _player(player), _lastNodeGuidRaw(lastNodeGuidRaw) { }
|
: _player(player), _lastX(lastX), _lastY(lastY), _lastZ(lastZ) { }
|
||||||
|
|
||||||
bool Execute(uint64, uint32) override
|
bool Execute(uint64, uint32) override
|
||||||
{
|
{
|
||||||
if (!_player || !_player->IsInWorld())
|
if (!_player || !_player->IsInWorld())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (GameObject* node = FindNearestReadyVeinScan(_player, TELEPORT_DISTANCE, _lastNodeGuidRaw, MIN_RETELEPORT_DIST))
|
if (GameObject* node = FindNearestReadyVeinScan(_player, TELEPORT_DISTANCE, MIN_RETELEPORT_DIST, _lastX, _lastY, _lastZ, MIN_COORD_DELTA))
|
||||||
{
|
{
|
||||||
_player->TeleportTo(
|
_player->TeleportTo(
|
||||||
node->GetMapId(),
|
node->GetMapId(),
|
||||||
@ -86,7 +101,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Player* _player;
|
Player* _player;
|
||||||
uint64 _lastNodeGuidRaw;
|
float _lastX, _lastY, _lastZ;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool DoTeleNode(Player* player)
|
static bool DoTeleNode(Player* player)
|
||||||
@ -100,20 +115,24 @@ static bool DoTeleNode(Player* player)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameObject* node = FindNearestReadyVeinScan(player, TELEPORT_DISTANCE, 0, 0.0f))
|
if (GameObject* node = FindNearestReadyVeinScan(player, TELEPORT_DISTANCE, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f))
|
||||||
{
|
{
|
||||||
uint64 lastGuid = node->GetGUID().GetRawValue();
|
const float nx = node->GetPositionX();
|
||||||
|
const float ny = node->GetPositionY();
|
||||||
|
const float nz = node->GetPositionZ();
|
||||||
|
|
||||||
player->TeleportTo(
|
player->TeleportTo(
|
||||||
node->GetMapId(),
|
node->GetMapId(),
|
||||||
node->GetPositionX(),
|
nx,
|
||||||
node->GetPositionY(),
|
ny,
|
||||||
node->GetPositionZ() + Z_BUMP,
|
nz + Z_BUMP,
|
||||||
node->GetOrientation()
|
node->GetOrientation()
|
||||||
);
|
);
|
||||||
|
|
||||||
player->m_Events.AddEvent(new TeleNodeRecheckEvent(player, lastGuid),
|
player->m_Events.AddEvent(
|
||||||
player->m_Events.CalculateTime(RECHECK_DELAY_MS));
|
new TeleNodeRecheckEvent(player, nx, ny, nz),
|
||||||
|
player->m_Events.CalculateTime(RECHECK_DELAY_MS)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user