SHARE
TWEET

Untitled

a guest Sep 16th, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
  2.     {
  3.         if (!*args)
  4.             return false;
  5.        
  6.         Player* player = handler->GetSession()->GetPlayer();
  7.  
  8.         char* arg1 = strtok((char*)args, " ");
  9.         char* arg2 = strtok(NULL, " ");
  10.  
  11.         if (!arg1 || !arg2)
  12.         return false;
  13.        
  14.         char dir = arg1[0];
  15.         float value = float(atof(arg2));
  16.         float x = player->GetPositionX();
  17.         float y = player->GetPositionY();
  18.         float z = player->GetPositionZ();
  19.         float o = player->GetOrientation();
  20.         char* id = strtok(NULL, " ");
  21.         uint32 mapId = id ? atoul(id) : player->GetMapId();
  22.         Map const* map = sMapMgr->CreateBaseMap(mapId);
  23.         z = std::max(map->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
  24.        
  25.         // stop flight if need
  26.         if (player->IsInFlight())
  27.         {
  28.             player->GetMotionMaster()->MovementExpired();
  29.             player->CleanupAfterTaxiFlight();
  30.         }
  31.         // save only in non-flight case
  32.         else
  33.         player->SaveRecallPosition();
  34.    
  35.         switch (dir)
  36.     {
  37.     case 'l':
  38.         {
  39.            x = x + cos(o+(M_PI/2))*value;
  40.            y = y + sin(o+(M_PI/2))*value;
  41.  
  42.            player->TeleportTo(mapId, x, y, z, o);
  43.  
  44.             handler->PSendSysMessage("%s[Warp Info]%s You teleported %g yards in x direction",value);
  45.         }
  46.         break;
  47.      case 'r':
  48.         {
  49.            x = x + cos(o-(M_PI/2))*value;
  50.            y = y + sin(o-(M_PI/2))*value;
  51.  
  52.            player->TeleportTo(mapId, x, y, z, o);
  53.         }
  54.         break;
  55.     case 'f':
  56.         {
  57.             x = x + cosf(o)*value;
  58.             y = y + sinf(o)*value;
  59.  
  60.             player->TeleportTo(mapId, x, y, z, o);
  61.  
  62.         }
  63.         break;
  64.     case 'u':
  65.         {
  66.             player->TeleportTo(mapId, x, y, z + value, o);
  67.  
  68.         }
  69.         break;
  70.         case 'd':
  71.         {
  72.             player->TeleportTo(mapId, x, y, z - value, o);
  73.  
  74.         }
  75.         break;
  76.     case 'o':
  77.         {
  78.            float o = value * M_PI/180.0f + (o);
  79.  
  80.             player->TeleportTo(mapId, x, y, z, o);
  81.         }
  82.         break;
  83.     }
  84.     return true;
  85. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top