Scripts/Commands: Unify .go xy and .go xyz commands, also add orientation parameter to the .go xyz command (so the command is now: .go xyz #x #y [#z [#mapid [#orientation]]])
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
DELETE FROM `command` WHERE `name` = 'go xyz';
|
||||
INSERT INTO `command` VALUES
|
||||
('go xyz',1,'Syntax: .go xyz #x #y [#z [#mapid [#orientation]]]\r\n\r\nTeleport player to point with (#x,#y,#z) coordinates at map #mapid with orientation #orientation. If z is not provided, ground/water level will be used. If mapid is not provided, the current map will be used. If #orientation is not provided, the current orientation will be used.');
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
{ "taxinode", SEC_MODERATOR, false, &HandleGoTaxinodeCommand, "", NULL },
|
||||
{ "trigger", SEC_MODERATOR, false, &HandleGoTriggerCommand, "", NULL },
|
||||
{ "zonexy", SEC_MODERATOR, false, &HandleGoZoneXYCommand, "", NULL },
|
||||
{ "xy", SEC_MODERATOR, false, &HandleGoXYCommand, "", NULL },
|
||||
{ "xyz", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
|
||||
{ "ticket", SEC_MODERATOR, false, &HandleGoTicketCommand, "", NULL },
|
||||
{ "", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
|
||||
@@ -477,54 +476,7 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
//teleport at coordinates
|
||||
static bool HandleGoXYCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
char* py = strtok(NULL, " ");
|
||||
char* pmapid = strtok(NULL, " ");
|
||||
|
||||
if (!px || !py)
|
||||
return false;
|
||||
|
||||
float x = (float)atof(px);
|
||||
float y = (float)atof(py);
|
||||
uint32 mapid;
|
||||
if (pmapid)
|
||||
mapid = (uint32)atoi(pmapid);
|
||||
else
|
||||
mapid = _player->GetMapId();
|
||||
|
||||
if (!MapManager::IsValidMapCoord(mapid, x, y))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
|
||||
Map const *map = sMapMgr->CreateBaseMap(mapid);
|
||||
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
|
||||
|
||||
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
|
||||
|
||||
return true;
|
||||
}
|
||||
//teleport at coordinates, including Z
|
||||
//teleport at coordinates, including Z and orientation
|
||||
static bool HandleGoXYZCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
@@ -536,25 +488,48 @@ public:
|
||||
char* py = strtok(NULL, " ");
|
||||
char* pz = strtok(NULL, " ");
|
||||
char* pmapid = strtok(NULL, " ");
|
||||
char* port = strtok(NULL, " ");
|
||||
|
||||
if (!px || !py || !pz)
|
||||
if (!px || !py)
|
||||
return false;
|
||||
|
||||
float x = (float)atof(px);
|
||||
float y = (float)atof(py);
|
||||
float z = (float)atof(pz);
|
||||
float z;
|
||||
float ort;
|
||||
uint32 mapid;
|
||||
|
||||
if (pmapid)
|
||||
mapid = (uint32)atoi(pmapid);
|
||||
else
|
||||
mapid = _player->GetMapId();
|
||||
|
||||
if( port )
|
||||
ort = (float)atof(port);
|
||||
else
|
||||
ort = _player->GetOrientation();
|
||||
|
||||
if( pz )
|
||||
{
|
||||
if (!MapManager::IsValidMapCoord(mapid, x, y, z))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
z = (float)atof(pz);
|
||||
}
|
||||
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())
|
||||
@@ -566,7 +541,7 @@ public:
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
|
||||
_player->TeleportTo(mapid, x, y, z, ort);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user