mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Command: Add command for near creature finding
This commit is contained in:
@@ -87,6 +87,7 @@ public:
|
||||
static ChatCommand npcCommandTable[] =
|
||||
{
|
||||
{ "info", SEC_ADMINISTRATOR, false, &HandleNpcInfoCommand, "", NULL },
|
||||
{ "near", SEC_GAMEMASTER, false, &HandleNpcNearCommand, "", NULL },
|
||||
{ "move", SEC_GAMEMASTER, false, &HandleNpcMoveCommand, "", NULL },
|
||||
{ "playemote", SEC_ADMINISTRATOR, false, &HandleNpcPlayEmoteCommand, "", NULL },
|
||||
{ "say", SEC_MODERATOR, false, &HandleNpcSayCommand, "", NULL },
|
||||
@@ -631,6 +632,52 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleNpcNearCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
float distance = (!*args) ? 10.0f : float((atof(args)));
|
||||
uint32 count = 0;
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_NEAREST);
|
||||
stmt->setFloat(0, player->GetPositionX());
|
||||
stmt->setFloat(1, player->GetPositionY());
|
||||
stmt->setFloat(2, player->GetPositionZ());
|
||||
stmt->setUInt32(3, player->GetMapId());
|
||||
stmt->setFloat(4, player->GetPositionX());
|
||||
stmt->setFloat(5, player->GetPositionY());
|
||||
stmt->setFloat(6, player->GetPositionZ());
|
||||
stmt->setFloat(7, distance * distance);
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
float x = fields[2].GetFloat();
|
||||
float y = fields[3].GetFloat();
|
||||
float z = fields[4].GetFloat();
|
||||
uint16 mapId = fields[5].GetUInt16();
|
||||
|
||||
CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
|
||||
if (!creatureTemplate)
|
||||
continue;
|
||||
|
||||
handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name.c_str(), x, y, z, mapId);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//move selected creature
|
||||
static bool HandleNpcMoveCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user