Advertisement
YiinY

clickwarp

Oct 27th, 2012
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.58 KB | None | 0 0
  1. void clickWarp()
  2. {
  3.     traceLastFunc("clickWarp()");
  4.  
  5.     if (!g_iCursorEnabled) return;
  6.     if (gta_menu_active()) return;
  7.     if ( cheat_state->state == CHEAT_STATE_VEHICLE ) return;
  8.  
  9.  
  10.     POINT cursor_pos;
  11.     if (GetCursorPos(&cursor_pos) && ScreenToClient(pPresentParam.hDeviceWindow, &cursor_pos))
  12.     {
  13.         D3DXVECTOR3 poss, screenposs;
  14.         float pos[3];
  15.         char buf[256];
  16.  
  17.         CVehicle *pCVehicleTeleport = NULL;
  18.         screenposs.x = (float)cursor_pos.x;
  19.         screenposs.y = (float)cursor_pos.y;
  20.         screenposs.z = 700.0f;
  21.  
  22.         CalcWorldCoors(&screenposs, &poss);
  23.  
  24.         CVector vecTarget(poss.x, poss.y, poss.z);
  25.  
  26.         // setup variables
  27.         CVector             vecOrigin, vecGroundPos;
  28.         CColPoint           *pCollision = NULL;
  29.         CEntitySAInterface  *pCollisionEntity = NULL;
  30.  
  31.         // origin = our camera
  32.         vecOrigin = *pGame->GetCamera()->GetCam(pGame->GetCamera()->GetActiveCam())->GetSource();
  33.  
  34.         // check for collision
  35.         bool bCollision = GTAfunc_ProcessLineOfSight( &vecOrigin, &vecTarget, &pCollision, &pCollisionEntity,
  36.             1, 1, 0, 1, 1, 0, 0, 0 );
  37.  
  38.         if (bCollision && pCollision)
  39.         {
  40.             // calculate position to check for ground
  41.             vecGroundPos = *pCollision->GetPosition();
  42.             vecGroundPos = vecGroundPos - (*pCollision->GetNormal() * 0.5f);
  43.  
  44.             // get ground position from collision position
  45.             if (pPedSelf->GetAreaCode() == 0)
  46.             {
  47.                 vecGroundPos.fZ = pGameInterface->GetWorld()->FindGroundZForPosition(vecGroundPos.fX, vecGroundPos.fY);
  48.             }
  49.             else
  50.             {
  51.                 CVector vecGroundPosSlightlyAbove = vecGroundPos;
  52.                 vecGroundPosSlightlyAbove.fZ += 1.0f;
  53.                 vecGroundPos.fZ = pGameInterface->GetWorld()->FindGroundZFor3DPosition(&vecGroundPosSlightlyAbove);
  54.             }
  55.  
  56.             // setup some stuff for vehicle jumper
  57.             if (pCollisionEntity && pCollisionEntity->nType == ENTITY_TYPE_VEHICLE)
  58.             {
  59.                 pCVehicleTeleport = pGameInterface->GetPools()->GetVehicle((DWORD *)pCollisionEntity);
  60.                 if (pCVehicleTeleport)
  61.                 {
  62.                     const struct vehicle_entry *vehicleEntry = gta_vehicle_get_by_id(pCVehicleTeleport->GetModelIndex());
  63.                     if (vehicleEntry != NULL)
  64.                     {
  65.                         sprintf(buf, "Warp to %s", vehicleEntry->name);
  66.                     }
  67.                 }
  68.                 else
  69.                 {
  70.                     sprintf(buf, "Distance %0.2f", vect3_dist(&vecOrigin.fX, &vecGroundPos.fX));
  71.                 }
  72.             }
  73.             // setup some stuff for normal warp
  74.             else
  75.             {
  76.                 sprintf(buf, "Distance %0.2f", vect3_dist(&vecOrigin.fX, &vecGroundPos.fX));
  77.             }
  78.  
  79.             // destroy the collision object
  80.             pCollision->Destroy();
  81.         }
  82.         else
  83.         {
  84.             iClickWarpEnabled = 0; // force disable, prevents clicks
  85.             //toggleSAMPCursor(0);
  86.             return;
  87.         }
  88. ... a lot of more code. ClickWarp default function.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement