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"
This commit is contained in:
parent
c6210ba12c
commit
8f326bbe32
@ -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<Creature*>(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!");
|
||||
|
@ -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 }
|
||||
};
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user