feat(Scripts/Commands): .debug boundary to visualize CreatureBoundary (#22099)

Co-authored-by: avarishd <46330494+avarishd@users.noreply.github.com>
Co-authored-by: treeston <treeston.mmoc@gmail.com>
This commit is contained in:
Jelle Meeus
2025-05-30 16:42:11 +02:00
committed by GitHub
parent 4ad3df7210
commit b15507eb06
4 changed files with 141 additions and 1 deletions

View File

@@ -105,7 +105,8 @@ public:
{ "unitstate", HandleDebugUnitStateCommand, SEC_ADMINISTRATOR, Console::No },
{ "objectcount", HandleDebugObjectCountCommand, SEC_ADMINISTRATOR, Console::Yes},
{ "dummy", HandleDebugDummyCommand, SEC_ADMINISTRATOR, Console::No },
{ "mapdata", HandleDebugMapDataCommand, SEC_ADMINISTRATOR, Console::No }
{ "mapdata", HandleDebugMapDataCommand, SEC_ADMINISTRATOR, Console::No },
{ "boundary", HandleDebugBoundaryCommand, SEC_ADMINISTRATOR, Console::No }
};
static ChatCommandTable commandTable =
{
@@ -1388,6 +1389,27 @@ public:
handler->PSendSysMessage("Created Cells In Map: {} / {}", map->GetCreatedCellsInMapCount(), TOTAL_NUMBER_OF_CELLS_PER_MAP * TOTAL_NUMBER_OF_CELLS_PER_MAP);
return true;
}
static bool HandleDebugBoundaryCommand(ChatHandler* handler, Optional<uint32> durationArg, Optional<EXACT_SEQUENCE("fill")> fill, Optional<EXACT_SEQUENCE("z")> checkZ)
{
Player* player = handler->GetPlayer();
if (!player)
return false;
Creature* target = handler->getSelectedCreature();
if (!target || !target->IsAIEnabled)
return false;
uint32 duration = durationArg.value_or(5 * IN_MILLISECONDS);
if (duration > 180 * IN_MILLISECONDS) // arbitrary upper limit
duration = 180 * IN_MILLISECONDS;
int32 errMsg = target->AI()->VisualizeBoundary(duration, player, fill.has_value(), checkZ.has_value());
if (errMsg > 0)
handler->PSendSysMessage(errMsg);
return true;
}
};
void AddSC_debug_commandscript()