Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
  2. {
  3. if (!*args)
  4. return false;
  5.  
  6. Player* player = handler->GetSession()->GetPlayer();
  7.  
  8. char* goX = strtok((char*)args, " ");
  9. char* goY = strtok(NULL, " ");
  10. char* goZ = strtok(NULL, " ");
  11. char* id = strtok(NULL, " ");
  12. char* port = strtok(NULL, " ");
  13.  
  14. if (!goX || !goY)
  15. return false;
  16.  
  17. float x = (float)atof(goX);
  18. float y = (float)atof(goY);
  19. float z;
  20. float ort = port ? (float)atof(port) : player->GetOrientation();
  21. uint32 mapId = id ? atoul(id) : player->GetMapId();
  22.  
  23. if (goZ)
  24. {
  25. z = (float)atof(goZ);
  26. if (!MapManager::IsValidMapCoord(mapId, x, y, z))
  27. {
  28. handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
  29. handler->SetSentErrorMessage(true);
  30. return false;
  31. }
  32. }
  33. else
  34. {
  35. if (!MapManager::IsValidMapCoord(mapId, x, y))
  36. {
  37. handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
  38. handler->SetSentErrorMessage(true);
  39. return false;
  40. }
  41. Map const* map = sMapMgr->CreateBaseMap(mapId);
  42. z = std::max(map->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
  43. }
  44.  
  45. // stop flight if need
  46. if (player->IsInFlight())
  47. {
  48. player->GetMotionMaster()->MovementExpired();
  49. player->CleanupAfterTaxiFlight();
  50. }
  51. // save only in non-flight case
  52. else
  53. player->SaveRecallPosition();
  54.  
  55. player->TeleportTo(mapId, x, y, z, ort);
  56. return true;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement