Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
- Player* player = handler->GetSession()->GetPlayer();
- char* arg1 = strtok((char*)args, " ");
- char* arg2 = strtok(NULL, " ");
- if (!arg1 || !arg2)
- return false;
- char dir = arg1[0];
- float value = float(atof(arg2));
- float x = player->GetPositionX();
- float y = player->GetPositionY();
- float z = player->GetPositionZ();
- float o = player->GetOrientation();
- char* id = strtok(NULL, " ");
- uint32 mapId = id ? atoul(id) : player->GetMapId();
- Map const* map = sMapMgr->CreateBaseMap(mapId);
- z = std::max(map->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
- // stop flight if need
- if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- player->SaveRecallPosition();
- switch (dir)
- {
- case 'l':
- {
- x = x + cos(o+(M_PI/2))*value;
- y = y + sin(o+(M_PI/2))*value;
- player->TeleportTo(mapId, x, y, z, o);
- handler->PSendSysMessage("%s[Warp Info]%s You teleported %g yards in x direction",value);
- }
- break;
- case 'r':
- {
- x = x + cos(o-(M_PI/2))*value;
- y = y + sin(o-(M_PI/2))*value;
- player->TeleportTo(mapId, x, y, z, o);
- }
- break;
- case 'f':
- {
- x = x + cosf(o)*value;
- y = y + sinf(o)*value;
- player->TeleportTo(mapId, x, y, z, o);
- }
- break;
- case 'u':
- {
- player->TeleportTo(mapId, x, y, z + value, o);
- }
- break;
- case 'd':
- {
- player->TeleportTo(mapId, x, y, z - value, o);
- }
- break;
- case 'o':
- {
- float o = value * M_PI/180.0f + (o);
- player->TeleportTo(mapId, x, y, z, o);
- }
- break;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement