diff options
Diffstat (limited to 'src/server/scripts')
-rw-r--r-- | src/server/scripts/Commands/cs_mmaps.cpp | 108 |
1 files changed, 53 insertions, 55 deletions
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp index c1fc4d1a5e9..e4a0ebf7f24 100644 --- a/src/server/scripts/Commands/cs_mmaps.cpp +++ b/src/server/scripts/Commands/cs_mmaps.cpp @@ -60,60 +60,58 @@ public: static bool HandleMmapPathCommand(ChatHandler* handler, char const* args) { - if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) - { - handler->PSendSysMessage("NavMesh not loaded for current map."); - return true; - } - - handler->PSendSysMessage("mmap path:"); - - // units - Player* player = handler->GetSession()->GetPlayer(); - Unit* target = handler->getSelectedUnit(); - if (!player || !target) - { - handler->PSendSysMessage("Invalid target/source selection."); - return true; - } - - char* para = strtok((char*)args, " "); - - bool useStraightPath = false; - if (para && strcmp(para, "true") == 0) - useStraightPath = true; - - // unit locations - float x, y, z; - player->GetPosition(x, y, z); - - // path - PathGenerator path(target); - path.SetUseStraightPath(useStraightPath); - path.CalculatePath(x, y, z); - - PointsArray pointPath = path.GetPath(); - handler->PSendSysMessage("%s's path to %s:", target->GetName(), player->GetName()); - handler->PSendSysMessage("Building %s", useStraightPath ? "StraightPath" : "SmoothPath"); - handler->PSendSysMessage("length %i type %u", pointPath.size(), path.GetPathType()); - - Vector3 start = path.GetStartPosition(); - Vector3 end = path.GetEndPosition(); - Vector3 actualEnd = path.GetActualEndPosition(); - - handler->PSendSysMessage("start (%.3f, %.3f, %.3f)", start.x, start.y, start.z); - handler->PSendSysMessage("end (%.3f, %.3f, %.3f)", end.x, end.y, end.z); - handler->PSendSysMessage("actual end (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z); - - if (!player->isGameMaster()) - handler->PSendSysMessage("Enable GM mode to see the path points."); - - // this entry visible only to GM's with "gm on" - static const uint32 WAYPOINT_NPC_ENTRY = 1; - for (uint32 i = 0; i < pointPath.size(); ++i) - player->SummonCreature(WAYPOINT_NPC_ENTRY, pointPath[i].x, pointPath[i].y, pointPath[i].z, 0, TEMPSUMMON_TIMED_DESPAWN, 9000); - - return true; + if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) + { + handler->PSendSysMessage("NavMesh not loaded for current map."); + return true; + } + + handler->PSendSysMessage("mmap path:"); + + // units + Player* player = handler->GetSession()->GetPlayer(); + Unit* target = handler->getSelectedUnit(); + if (!player || !target) + { + handler->PSendSysMessage("Invalid target/source selection."); + return true; + } + + char* para = strtok((char*)args, " "); + + bool useStraightPath = false; + if (para && strcmp(para, "true") == 0) + useStraightPath = true; + + // unit locations + float x, y, z; + player->GetPosition(x, y, z); + + // path + PathGenerator path(target); + path.SetUseStraightPath(useStraightPath); + bool result = path.CalculatePath(x, y, z); + + PointsArray pointPath = path.GetPath(); + handler->PSendSysMessage("%s's path to %s:", target->GetName(), player->GetName()); + handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : "SmoothPath"); + handler->PSendSysMessage("Result: %s - Length: %i - Type: %u", (result ? "true" : "false"), pointPath.size(), path.GetPathType()); + + Vector3 start = path.GetStartPosition(); + Vector3 end = path.GetEndPosition(); + Vector3 actualEnd = path.GetActualEndPosition(); + + handler->PSendSysMessage("StartPosition (%.3f, %.3f, %.3f)", start.x, start.y, start.z); + handler->PSendSysMessage("EndPosition (%.3f, %.3f, %.3f)", end.x, end.y, end.z); + handler->PSendSysMessage("ActualEndPosition (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z); + + if (!player->isGameMaster()) + handler->PSendSysMessage("Enable GM mode to see the path points."); + + for (uint32 i = 0; i < pointPath.size(); ++i) + player->SummonCreature(VISUAL_WAYPOINT, pointPath[i].x, pointPath[i].y, pointPath[i].z, 0, TEMPSUMMON_TIMED_DESPAWN, 9000); + + return true; } static bool HandleMmapLocCommand(ChatHandler* handler, const char* args) @@ -290,4 +288,4 @@ public: void AddSC_mmaps_commandscript() { new mmaps_commandscript(); -}
\ No newline at end of file +} |