adding logic to re evaluate nodes
This commit is contained in:
parent
340ec5221e
commit
04802e3938
@ -8,6 +8,7 @@
|
||||
#include "ChatCommand.h"
|
||||
#include "Player.h"
|
||||
#include "GameObject.h"
|
||||
#include "GameTime.h"
|
||||
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
@ -30,7 +31,7 @@ namespace
|
||||
189978,189979,189980,189981,195036,
|
||||
};
|
||||
|
||||
static GameObject* FindNearestVein(Player* player, float maxRange)
|
||||
static GameObject* FindNearestReadyVein(Player* player, float maxRange, float minDistanceFromPlayer)
|
||||
{
|
||||
GameObject* nearest = nullptr;
|
||||
float nearestDist = std::numeric_limits<float>::infinity();
|
||||
@ -40,6 +41,15 @@ namespace
|
||||
if (GameObject* go = player->FindNearestGameObject(entry, maxRange))
|
||||
{
|
||||
float d = player->GetDistance(go);
|
||||
if (d < minDistanceFromPlayer)
|
||||
continue;
|
||||
|
||||
if (go->IsInUse())
|
||||
continue;
|
||||
|
||||
if (go->GetLootState() != GO_READY)
|
||||
continue;
|
||||
|
||||
if (d <= maxRange && d < nearestDist)
|
||||
{
|
||||
nearest = go;
|
||||
@ -58,10 +68,13 @@ namespace
|
||||
if (player->IsInCombat())
|
||||
{
|
||||
ChatHandler(player->GetSession()).PSendSysMessage("You can't use this while in combat.");
|
||||
return true; // handled
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GameObject* node = FindNearestVein(player, TELEPORT_DISTANCE))
|
||||
// Skip anything within ~8 yards so we don't pick the node we just mined
|
||||
constexpr float kMinReTeleportDist = 8.0f;
|
||||
|
||||
if (GameObject* node = FindNearestReadyVein(player, TELEPORT_DISTANCE, kMinReTeleportDist))
|
||||
{
|
||||
player->TeleportTo(
|
||||
node->GetMapId(),
|
||||
@ -77,7 +90,6 @@ namespace
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class telenode_commandscript : public CommandScript
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user