adding herb nodes and yayherb command
This commit is contained in:
parent
42110c57ca
commit
02ac3d3dac
@ -26,12 +26,20 @@ static const std::vector<uint32> kVeinEntries = {
|
|||||||
189978,189979,189980,189981,195036,
|
189978,189979,189980,189981,195036,
|
||||||
};
|
};
|
||||||
|
|
||||||
static GameObject* FindNearestReadyVein(Player* player, float maxRange)
|
static const std::vector<uint32> kHerbEntries = {
|
||||||
|
1618,1617,1619,1620,1621,2045,1622,1623,1628,1624,2041,2042,2046,2043,2044,2866,
|
||||||
|
142140,142141,142142,142143,142144,142145,176583,176584,176639,176586,176640,
|
||||||
|
176587,176641,176588,176589,181270,183044,181271,181272,183045,181277,181275,
|
||||||
|
183043,181276,181278,181279,181282,181280,181285,181281,181284,190169,190170,
|
||||||
|
189973,191019,190172,190171,190176
|
||||||
|
};
|
||||||
|
|
||||||
|
static GameObject* FindNearestReady(Player* player, float maxRange, const std::vector<uint32>& entries)
|
||||||
{
|
{
|
||||||
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 : entries)
|
||||||
{
|
{
|
||||||
if (GameObject* go = player->FindNearestGameObject(entry, maxRange))
|
if (GameObject* go = player->FindNearestGameObject(entry, maxRange))
|
||||||
{
|
{
|
||||||
@ -51,18 +59,18 @@ static GameObject* FindNearestReadyVein(Player* player, float maxRange)
|
|||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TeleNodeRecheckEvent : public BasicEvent
|
class TeleRecheckEvent : public BasicEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TeleNodeRecheckEvent(Player* player, uint64 lastNodeGuidRaw)
|
TeleRecheckEvent(Player* player, uint64 lastNodeGuidRaw, const std::vector<uint32>* entries)
|
||||||
: _player(player), _lastNodeGuidRaw(lastNodeGuidRaw) { }
|
: _player(player), _lastNodeGuidRaw(lastNodeGuidRaw), _entries(entries) { }
|
||||||
|
|
||||||
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 = FindNearestReadyVein(_player, TELEPORT_DISTANCE))
|
if (GameObject* node = FindNearestReady(_player, TELEPORT_DISTANCE, *_entries))
|
||||||
{
|
{
|
||||||
if (node->GetGUID().GetRawValue() != _lastNodeGuidRaw)
|
if (node->GetGUID().GetRawValue() != _lastNodeGuidRaw)
|
||||||
{
|
{
|
||||||
@ -84,9 +92,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
Player* _player;
|
Player* _player;
|
||||||
uint64 _lastNodeGuidRaw;
|
uint64 _lastNodeGuidRaw;
|
||||||
|
const std::vector<uint32>* _entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool DoTeleNode(Player* player)
|
static bool DoTeleToList(Player* player, const std::vector<uint32>& entries)
|
||||||
{
|
{
|
||||||
if (!player)
|
if (!player)
|
||||||
return false;
|
return false;
|
||||||
@ -97,7 +106,7 @@ static bool DoTeleNode(Player* player)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameObject* node = FindNearestReadyVein(player, TELEPORT_DISTANCE))
|
if (GameObject* node = FindNearestReady(player, TELEPORT_DISTANCE, entries))
|
||||||
{
|
{
|
||||||
uint64 lastGuid = node->GetGUID().GetRawValue();
|
uint64 lastGuid = node->GetGUID().GetRawValue();
|
||||||
|
|
||||||
@ -109,12 +118,12 @@ static bool DoTeleNode(Player* player)
|
|||||||
node->GetOrientation()
|
node->GetOrientation()
|
||||||
);
|
);
|
||||||
|
|
||||||
player->m_Events.AddEvent(new TeleNodeRecheckEvent(player, lastGuid),
|
player->m_Events.AddEvent(new TeleRecheckEvent(player, lastGuid, &entries),
|
||||||
player->m_Events.CalculateTime(RECHECK_DELAY_MS));
|
player->m_Events.CalculateTime(RECHECK_DELAY_MS));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChatHandler(player->GetSession()).PSendSysMessage("No mining nodes found within range.");
|
ChatHandler(player->GetSession()).PSendSysMessage("No objects found within range.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -130,6 +139,7 @@ public:
|
|||||||
static ChatCommandTable commandTable =
|
static ChatCommandTable commandTable =
|
||||||
{
|
{
|
||||||
{ "yaynode", HandleTeleNode, SEC_PLAYER, Console::No },
|
{ "yaynode", HandleTeleNode, SEC_PLAYER, Console::No },
|
||||||
|
{ "yayherb", HandleTeleHerb, SEC_PLAYER, Console::No },
|
||||||
};
|
};
|
||||||
return commandTable;
|
return commandTable;
|
||||||
}
|
}
|
||||||
@ -148,7 +158,23 @@ private:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DoTeleNode(player);
|
return DoTeleToList(player, kVeinEntries);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleTeleHerb(ChatHandler* handler)
|
||||||
|
{
|
||||||
|
if (!handler)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
|
||||||
|
if (!player)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage("Player only.");
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DoTeleToList(player, kHerbEntries);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user