diff options
author | Joeri Thissen <msn@chocochaos.com> | 2011-08-21 10:40:02 +0200 |
---|---|---|
committer | QAston <qaston@gmail.com> | 2011-08-21 10:40:29 +0200 |
commit | 4f1864cfe9d0ad4937bd58bbe421fe9c6cb7426b (patch) | |
tree | a7f7b8266c62e95ba7ab0a9132014ea2f074c699 /src | |
parent | 0946843875b62357c66ee805cc932cd56c842ea8 (diff) |
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]]])
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Commands/cs_go.cpp | 87 |
1 files changed, 31 insertions, 56 deletions
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 1fa697f3f44..a551e8293d5 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -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,8 +476,8 @@ public: return true; } - //teleport at coordinates - static bool HandleGoXYCommand(ChatHandler* handler, const char* args) + //teleport at coordinates, including Z and orientation + static bool HandleGoXYZCommand(ChatHandler* handler, const char* args) { if (!*args) return false; @@ -487,75 +486,51 @@ public: char* px = strtok((char*)args, " "); char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); char* pmapid = strtok(NULL, " "); + char* port = strtok(NULL, " "); if (!px || !py) return false; float x = (float)atof(px); float y = (float)atof(py); + float z; + float ort; 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()) + + if( port ) + ort = (float)atof(port); + else + ort = _player->GetOrientation(); + + if( pz ) { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + 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); } - // 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) - { - if (!*args) - return false; - - Player* _player = handler->GetSession()->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py || !pz) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); else - mapid = _player->GetMapId(); - - if (!MapManager::IsValidMapCoord(mapid, x, y, z)) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); - handler->SetSentErrorMessage(true); - return false; + 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; } |