mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Commands: Implement .neargraveyard (find nearest graveyard from dbc). (#17301)
(cherry picked from commit e2c0189927)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
DELETE FROM `rbac_permissions` WHERE `id` = 841;
|
||||
INSERT INTO `rbac_permissions` (`id`, `name`) VALUES (841, 'Command: .debug neargraveyard');
|
||||
|
||||
DELETE FROM `rbac_linked_permissions` WHERE `id` = 196 AND `linkedId` = 841;
|
||||
INSERT INTO `rbac_linked_permissions` (`id`, `linkedId`) VALUES (196, 841);
|
||||
@@ -0,0 +1,8 @@
|
||||
DELETE FROM `command` WHERE `name` = 'debug neargraveyard';
|
||||
INSERT INTO `command` (`name`, `permission`, `help`) VALUES
|
||||
('debug neargraveyard', 841, 'Syntax: .debug neargraveyard [linked]\nFind the nearest graveyard from dbc or db (if linked)');
|
||||
|
||||
DELETE FROM `trinity_string` WHERE `entry` IN (82, 83);
|
||||
INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc6`, `content_loc7`) VALUES
|
||||
(82, 'Nearest graveyard found: %u (%.3f %.3f %.3f)', 'Cementerio mas cercano encontrado: %u (%.3f %.3f %.3f)', 'Cementerio mas cercano encontrado: %u (%.3f %.3f %.3f)'),
|
||||
(83, 'There are no graveyards near', 'No se ha encontrado ningun cementerio cerca', 'No se ha encontrado ningun cementerio cerca');
|
||||
@@ -745,9 +745,10 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMAND_PET_LEVEL = 838,
|
||||
RBAC_PERM_COMMAND_SERVER_SHUTDOWN_FORCE = 839,
|
||||
RBAC_PERM_COMMAND_SERVER_RESTART_FORCE = 840,
|
||||
RBAC_PERM_COMMAND_RELOAD_CHARACTER_TEMPLATE = 841,
|
||||
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING = 842,
|
||||
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYSCENE = 843,
|
||||
RBAC_PERM_COMMAND_NEARGRAVEYARD = 841,
|
||||
RBAC_PERM_COMMAND_RELOAD_CHARACTER_TEMPLATE = 842,
|
||||
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING = 843,
|
||||
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYSCENE = 844,
|
||||
|
||||
// custom permissions 1000+
|
||||
RBAC_PERM_MAX
|
||||
|
||||
@@ -112,7 +112,9 @@ enum TrinityStrings
|
||||
LANG_RBAC_PERM_REVOKED_NOT_IN_LIST = 79,
|
||||
LANG_PVPSTATS = 80,
|
||||
LANG_PVPSTATS_DISABLED = 81,
|
||||
// Free 82 - 95
|
||||
LANG_COMMAND_NEARGRAVEYARD = 82,
|
||||
LANG_COMMAND_NEARGRAVEYARD_NOTFOUND = 83,
|
||||
// Free 84 - 95
|
||||
|
||||
|
||||
LANG_GUILD_RENAME_ALREADY_EXISTS = 96,
|
||||
|
||||
@@ -24,6 +24,7 @@ EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "Cell.h"
|
||||
@@ -39,6 +40,7 @@ EndScriptData */
|
||||
#include "ScenePackets.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
class debug_commandscript : public CommandScript
|
||||
{
|
||||
@@ -99,7 +101,8 @@ public:
|
||||
{ "loadcells", rbac::RBAC_PERM_COMMAND_DEBUG_LOADCELLS, false, &HandleDebugLoadCellsCommand, "",},
|
||||
{ "phase", rbac::RBAC_PERM_COMMAND_DEBUG_PHASE, false, &HandleDebugPhaseCommand, "" },
|
||||
{ "boundary", rbac::RBAC_PERM_COMMAND_DEBUG_BOUNDARY, false, &HandleDebugBoundaryCommand, "" },
|
||||
{ "raidreset", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleDebugRaidResetCommand, "" }
|
||||
{ "raidreset", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleDebugRaidResetCommand, "" },
|
||||
{ "neargraveyard", rbac::RBAC_PERM_COMMAND_NEARGRAVEYARD, false, &HandleDebugNearGraveyard, "" },
|
||||
};
|
||||
static std::vector<ChatCommand> commandTable =
|
||||
{
|
||||
@@ -1547,6 +1550,53 @@ public:
|
||||
sInstanceSaveMgr->ForceGlobalReset(map, Difficulty(difficulty));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugNearGraveyard(ChatHandler* handler, char const* args)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
const WorldSafeLocsEntry* nearestLoc = nullptr;
|
||||
|
||||
if (stricmp(args, "linked"))
|
||||
{
|
||||
if (Battleground* bg = player->GetBattleground())
|
||||
nearestLoc = bg->GetClosestGraveYard(player);
|
||||
else
|
||||
{
|
||||
if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId()))
|
||||
nearestLoc = bf->GetClosestGraveYard(player);
|
||||
else
|
||||
nearestLoc = sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float x = player->GetPositionX();
|
||||
float y = player->GetPositionY();
|
||||
float z = player->GetPositionZ();
|
||||
float distNearest = std::numeric_limits<float>::max();
|
||||
|
||||
for (uint32 i = 0; i < sWorldSafeLocsStore.GetNumRows(); ++i)
|
||||
{
|
||||
const WorldSafeLocsEntry* loc = sWorldSafeLocsStore.LookupEntry(i);
|
||||
if (loc && loc->map_id == player->GetMapId())
|
||||
{
|
||||
float dist = (loc->x - x) * (loc->x - x) + (loc->y - y) * (loc->y - y) + (loc->z - z) * (loc->z - z);
|
||||
if (dist < distNearest)
|
||||
{
|
||||
distNearest = dist;
|
||||
nearestLoc = loc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nearestLoc)
|
||||
handler->PSendSysMessage(LANG_COMMAND_NEARGRAVEYARD, nearestLoc->ID, nearestLoc->x, nearestLoc->y, nearestLoc->z);
|
||||
else
|
||||
handler->PSendSysMessage(LANG_COMMAND_NEARGRAVEYARD_NOTFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_debug_commandscript()
|
||||
|
||||
Reference in New Issue
Block a user