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 },
|
{ "taxinode", SEC_MODERATOR, false, &HandleGoTaxinodeCommand, "", NULL },
|
||||||
{ "trigger", SEC_MODERATOR, false, &HandleGoTriggerCommand, "", NULL },
|
{ "trigger", SEC_MODERATOR, false, &HandleGoTriggerCommand, "", NULL },
|
||||||
{ "zonexy", SEC_MODERATOR, false, &HandleGoZoneXYCommand, "", NULL },
|
{ "zonexy", SEC_MODERATOR, false, &HandleGoZoneXYCommand, "", NULL },
|
||||||
{ "xy", SEC_MODERATOR, false, &HandleGoXYCommand, "", NULL },
|
|
||||||
{ "xyz", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
|
{ "xyz", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
|
||||||
{ "ticket", SEC_MODERATOR, false, &HandleGoTicketCommand, "", NULL },
|
{ "ticket", SEC_MODERATOR, false, &HandleGoTicketCommand, "", NULL },
|
||||||
{ "", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
|
{ "", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL },
|
||||||
@@ -477,54 +476,7 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//teleport at coordinates
|
//teleport at coordinates, including Z and orientation
|
||||||
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
|
|
||||||
static bool HandleGoXYZCommand(ChatHandler* handler, const char* args)
|
static bool HandleGoXYZCommand(ChatHandler* handler, const char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
if (!*args)
|
||||||
@@ -536,24 +488,47 @@ public:
|
|||||||
char* py = strtok(NULL, " ");
|
char* py = strtok(NULL, " ");
|
||||||
char* pz = strtok(NULL, " ");
|
char* pz = strtok(NULL, " ");
|
||||||
char* pmapid = strtok(NULL, " ");
|
char* pmapid = strtok(NULL, " ");
|
||||||
|
char* port = strtok(NULL, " ");
|
||||||
|
|
||||||
if (!px || !py || !pz)
|
if (!px || !py)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
float x = (float)atof(px);
|
float x = (float)atof(px);
|
||||||
float y = (float)atof(py);
|
float y = (float)atof(py);
|
||||||
float z = (float)atof(pz);
|
float z;
|
||||||
|
float ort;
|
||||||
uint32 mapid;
|
uint32 mapid;
|
||||||
|
|
||||||
if (pmapid)
|
if (pmapid)
|
||||||
mapid = (uint32)atoi(pmapid);
|
mapid = (uint32)atoi(pmapid);
|
||||||
else
|
else
|
||||||
mapid = _player->GetMapId();
|
mapid = _player->GetMapId();
|
||||||
|
|
||||||
if (!MapManager::IsValidMapCoord(mapid, x, y, z))
|
if( port )
|
||||||
|
ort = (float)atof(port);
|
||||||
|
else
|
||||||
|
ort = _player->GetOrientation();
|
||||||
|
|
||||||
|
if( pz )
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
if (!MapManager::IsValidMapCoord(mapid, x, y, z))
|
||||||
handler->SetSentErrorMessage(true);
|
{
|
||||||
return false;
|
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
|
// stop flight if need
|
||||||
@@ -566,7 +541,7 @@ public:
|
|||||||
else
|
else
|
||||||
_player->SaveRecallPosition();
|
_player->SaveRecallPosition();
|
||||||
|
|
||||||
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
|
_player->TeleportTo(mapid, x, y, z, ort);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user