initial
commit
This commit is contained in:
parent
6fbb485eb5
commit
1498d6fb86
12
README.md
12
README.md
@ -1,3 +1,11 @@
|
|||||||
# mod-teleport-to-node
|
#  AzerothCore
|
||||||
|
|
||||||
An azerothcore module for teleporting to resource nodes
|
## mod-teleport-to-node
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
An azerothcore module for teleporting to resource nodes
|
||||||
|
|
||||||
|
## How to use ingame
|
||||||
|
|
||||||
|
Type the command .telenode to teleport to a nearby resource node (Currently just mining nodes)
|
||||||
|
|||||||
101
src/teleport-to-node.cpp
Normal file
101
src/teleport-to-node.cpp
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#include "ScriptMgr.h"
|
||||||
|
#include "CommandScript.h"
|
||||||
|
#include "Chat.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "GameObject.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// === CONFIG ===
|
||||||
|
static constexpr float TELEPORT_DISTANCE = 200.0f; // yards
|
||||||
|
static constexpr float Z_BUMP = 1.5f; // anti-clip offset
|
||||||
|
|
||||||
|
// Mining node entries (trim this list to what you actually want)
|
||||||
|
static const std::vector<uint32> kVeinEntries = {
|
||||||
|
324, 1610, 1667, 1731, 1732, 1733, 1734, 2054, 2055, 3763, 3764, 19903,
|
||||||
|
73940, 73941, 103711, 103713, 105569, 123848, 150080, 150082, 175404,
|
||||||
|
176643, 177388, 179144, 179224, 180215, 181109, 181248, 181249, 181557,
|
||||||
|
185557, 191133, 1735, 2040, 2047, 2653, 73939, 123309, 123310, 150079,
|
||||||
|
150081, 165658, 176645, 181108, 181555, 181556, 181569, 181570, 185877,
|
||||||
|
189978, 189979, 189980, 189981, 195036,
|
||||||
|
};
|
||||||
|
|
||||||
|
static GameObject* FindNearestVein(Player* player, float maxRange)
|
||||||
|
{
|
||||||
|
GameObject* nearest = nullptr;
|
||||||
|
float nearestDist = std::numeric_limits<float>::infinity();
|
||||||
|
|
||||||
|
for (uint32 entry : kVeinEntries)
|
||||||
|
{
|
||||||
|
if (GameObject* go = player->FindNearestGameObject(entry, maxRange))
|
||||||
|
{
|
||||||
|
float d = player->GetDistance(go);
|
||||||
|
if (d <= maxRange && d < nearestDist)
|
||||||
|
{
|
||||||
|
nearest = go;
|
||||||
|
nearestDist = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nearest;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool DoTeleNode(Player* player)
|
||||||
|
{
|
||||||
|
if (!player)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (player->IsInCombat())
|
||||||
|
{
|
||||||
|
ChatHandler(player->GetSession()).PSendSysMessage("You can't use this while in combat.");
|
||||||
|
return true; // handled
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameObject* node = FindNearestVein(player, TELEPORT_DISTANCE))
|
||||||
|
{
|
||||||
|
player->TeleportTo(
|
||||||
|
node->GetMapId(),
|
||||||
|
node->GetPositionX(),
|
||||||
|
node->GetPositionY(),
|
||||||
|
node->GetPositionZ() + Z_BUMP,
|
||||||
|
node->GetOrientation()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChatHandler(player->GetSession()).PSendSysMessage("No mining nodes found within range.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class telenode_commandscript : public CommandScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
telenode_commandscript() : CommandScript("telenode_commandscript") { }
|
||||||
|
|
||||||
|
ChatCommandTable GetCommands() const override
|
||||||
|
{
|
||||||
|
static ChatCommandTable commandTable =
|
||||||
|
{
|
||||||
|
// .telenode
|
||||||
|
{ "telenode",
|
||||||
|
[](ChatHandler* handler)
|
||||||
|
{
|
||||||
|
if (Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr)
|
||||||
|
return DoTeleNode(player);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
SEC_PLAYER, // usable by anyone; override via DB 'command' table if desired
|
||||||
|
Console::No
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return commandTable;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Module entry point (call this from your module's loader)
|
||||||
|
void Addmod_telenodeScripts()
|
||||||
|
{
|
||||||
|
new telenode_commandscript();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user