cs_go.cpp
Code:
//teleport at coordinates, including Z and orientation
static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* player = handler->GetSession()->GetPlayer();
char* goX = strtok((char*)args, " ");
char* goY = strtok(NULL, " ");
char* goZ = strtok(NULL, " ");
char* id = strtok(NULL, " ");
char* port = strtok(NULL, " ");
if (!goX || !goY)
return false;
float x = (float)atof(goX);
float y = (float)atof(goY);
float z;
float ort = port ? (float)atof(port) : player->GetOrientation();
uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
if (goZ)
{
z = (float)atof(goZ);
if (!MapManager::IsValidMapCoord(mapId, x, y, z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true);
return false;
}
}
else
{
if (!MapManager::IsValidMapCoord(mapId, x, y))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true);
return false;
}
Map const* map = sMapMgr->CreateBaseMap(mapId);
z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
}
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
player->TeleportTo(mapId, x, y, z, ort);
return true;
}
So maybe this would work for example:
Code:
//teleport at coordinates, including Z and orientation
static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* player = handler->GetSession()->GetPlayer();
char* goX = strtok((char*)args, " ");
char* goY = strtok(NULL, " ");
char* goZ = strtok(NULL, " ");
char* id = strtok(NULL, " ");
char* port = strtok(NULL, " ");
if (!goX || !goY)
return false;
float x = (float)atof(goX);
float y = (float)atof(goY);
float z = (float)atof(goZ);
float ort = port ? (float)atof(port) : player->GetOrientation();
uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
player->TeleportTo(mapId, player->GetPositionX() + x, player->GetPositionY() + y, player->GetPositionZ() + z, ort);
return true;
}
Untested. But you save the X, Y, and Z that has been input through the chat, then when you teleport the player send them to their current location plus those input values. Orientation I made it go to what you set rather than adding to it.
Orientation works in radians, so it will always look like weird values looking at the raw number. Degree to Radian comparison:

Also every value is a float, and floats can never be exactly zero due to how it works (I think from memory).
A float is made up of a mantissa and exponent, in a two's complement form. The mantissa is multiplied by the exponent from memory.
This diagram makes things clearer: