From 8f326bbe32ad6c7d7cda74c1cca376f1fb7b5351 Mon Sep 17 00:00:00 2001 From: cyberium Date: Wed, 25 Mar 2015 11:51:25 +0000 Subject: [PATCH] Add a debug command to show all possible random point for selected creature. (c2610) To use it - You must be GM - Select a creature and type ".mmap testheight" to view point (using default respawn radius) - If no selected creature it work around the player char itself. - You can specify the radius '.mmap testheight 20" --- src/game/ChatCommands/Level3.cpp | 61 ++++++++++++++++++++++++++++++++ src/game/WorldHandlers/Chat.cpp | 1 + src/game/WorldHandlers/Chat.h | 1 + 3 files changed, 63 insertions(+) diff --git a/src/game/ChatCommands/Level3.cpp b/src/game/ChatCommands/Level3.cpp index 1b72462c..b3b98ff0 100644 --- a/src/game/ChatCommands/Level3.cpp +++ b/src/game/ChatCommands/Level3.cpp @@ -6645,6 +6645,67 @@ bool ChatHandler::HandleMmapTestArea(char* args) return true; } +// use ".mmap testheight 10" selecting any creature/player +bool ChatHandler::HandleMmapTestHeight(char* args) +{ + float radius = 0.0f; + ExtractFloat(&args, radius); + if (radius > 40.0f) + radius = 40.0f; + + Unit* unit = getSelectedUnit(); + + Player* player = m_session->GetPlayer(); + if (!unit) + unit = player; + + if (unit->GetTypeId() == TYPEID_UNIT) + { + if (radius < 0.1f) + radius = static_cast(unit)->GetRespawnRadius(); + } + else + { + if (unit->GetTypeId() != TYPEID_PLAYER) + { + PSendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + return false; + } + } + + if (radius < 0.1f) + { + if (unit->GetTypeId() == TYPEID_UNIT) + PSendSysMessage("Provided spawn radius in table for %s is too small. using 5.0f instead."); + else + PSendSysMessage("Provided spawn radius is too small. using 5.0f instead."); + radius = 5.0f; + } + + float gx, gy, gz; + unit->GetPosition(gx, gy, gz); + + Creature* summoned = unit->SummonCreature(VISUAL_WAYPOINT, gx, gy, gz + 0.5f, 0, TEMPSUMMON_TIMED_DESPAWN, 20000); + summoned->CastSpell(summoned, 8599, false); + uint32 tryed = 1; + uint32 succeed = 0; + uint32 startTime = WorldTimer::getMSTime(); + for (; tryed < 500; ++tryed) + { + unit->GetPosition(gx, gy, gz); + if (unit->GetMap()->GetReachableRandomPosition(unit, gx, gy, gz, radius)) + { + unit->SummonCreature(VISUAL_WAYPOINT, gx, gy, gz, 0, TEMPSUMMON_TIMED_DESPAWN, 15000); + ++succeed; + if (succeed >= 100) + break; + } + } + uint32 genTime = WorldTimer::getMSTimeDiff(startTime, WorldTimer::getMSTime()); + PSendSysMessage("Generated %u valid points for %u try in %ums.", succeed, tryed, genTime); + return true; +} + bool ChatHandler::HandleServerResetAllRaidCommand(char* args) { PSendSysMessage("Global raid instances reset, all players in raid instances will be teleported to homebind!"); diff --git a/src/game/WorldHandlers/Chat.cpp b/src/game/WorldHandlers/Chat.cpp index 6f36262f..aef7a0e7 100644 --- a/src/game/WorldHandlers/Chat.cpp +++ b/src/game/WorldHandlers/Chat.cpp @@ -379,6 +379,7 @@ ChatCommand* ChatHandler::getCommandTable() { "loadedtiles", SEC_GAMEMASTER, false, &ChatHandler::HandleMmapLoadedTilesCommand, "", NULL }, { "stats", SEC_GAMEMASTER, false, &ChatHandler::HandleMmapStatsCommand, "", NULL }, { "testarea", SEC_GAMEMASTER, false, &ChatHandler::HandleMmapTestArea, "", NULL }, + { "testheight", SEC_GAMEMASTER, false, &ChatHandler::HandleMmapTestHeight, "", NULL }, { "", SEC_ADMINISTRATOR, false, &ChatHandler::HandleMmap, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; diff --git a/src/game/WorldHandlers/Chat.h b/src/game/WorldHandlers/Chat.h index 7d0c2505..fbce4c02 100644 --- a/src/game/WorldHandlers/Chat.h +++ b/src/game/WorldHandlers/Chat.h @@ -588,6 +588,7 @@ class ChatHandler bool HandleMmapStatsCommand(char* args); bool HandleMmap(char* args); bool HandleMmapTestArea(char* args); + bool HandleMmapTestHeight(char* args); //! Development Commands bool HandleSaveAllCommand(char* args);