Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void clickWarp()
- {
- traceLastFunc("clickWarp()");
- if (!g_iCursorEnabled) return;
- if (gta_menu_active()) return;
- if ( cheat_state->state == CHEAT_STATE_VEHICLE ) return;
- POINT cursor_pos;
- if (GetCursorPos(&cursor_pos) && ScreenToClient(pPresentParam.hDeviceWindow, &cursor_pos))
- {
- D3DXVECTOR3 poss, screenposs;
- float pos[3];
- char buf[256];
- CVehicle *pCVehicleTeleport = NULL;
- screenposs.x = (float)cursor_pos.x;
- screenposs.y = (float)cursor_pos.y;
- screenposs.z = 700.0f;
- CalcWorldCoors(&screenposs, &poss);
- CVector vecTarget(poss.x, poss.y, poss.z);
- // setup variables
- CVector vecOrigin, vecGroundPos;
- CColPoint *pCollision = NULL;
- CEntitySAInterface *pCollisionEntity = NULL;
- // origin = our camera
- vecOrigin = *pGame->GetCamera()->GetCam(pGame->GetCamera()->GetActiveCam())->GetSource();
- // check for collision
- bool bCollision = GTAfunc_ProcessLineOfSight( &vecOrigin, &vecTarget, &pCollision, &pCollisionEntity,
- 1, 1, 0, 1, 1, 0, 0, 0 );
- if (bCollision && pCollision)
- {
- // calculate position to check for ground
- vecGroundPos = *pCollision->GetPosition();
- vecGroundPos = vecGroundPos - (*pCollision->GetNormal() * 0.5f);
- // get ground position from collision position
- if (pPedSelf->GetAreaCode() == 0)
- {
- vecGroundPos.fZ = pGameInterface->GetWorld()->FindGroundZForPosition(vecGroundPos.fX, vecGroundPos.fY);
- }
- else
- {
- CVector vecGroundPosSlightlyAbove = vecGroundPos;
- vecGroundPosSlightlyAbove.fZ += 1.0f;
- vecGroundPos.fZ = pGameInterface->GetWorld()->FindGroundZFor3DPosition(&vecGroundPosSlightlyAbove);
- }
- // setup some stuff for vehicle jumper
- if (pCollisionEntity && pCollisionEntity->nType == ENTITY_TYPE_VEHICLE)
- {
- pCVehicleTeleport = pGameInterface->GetPools()->GetVehicle((DWORD *)pCollisionEntity);
- if (pCVehicleTeleport)
- {
- const struct vehicle_entry *vehicleEntry = gta_vehicle_get_by_id(pCVehicleTeleport->GetModelIndex());
- if (vehicleEntry != NULL)
- {
- sprintf(buf, "Warp to %s", vehicleEntry->name);
- }
- }
- else
- {
- sprintf(buf, "Distance %0.2f", vect3_dist(&vecOrigin.fX, &vecGroundPos.fX));
- }
- }
- // setup some stuff for normal warp
- else
- {
- sprintf(buf, "Distance %0.2f", vect3_dist(&vecOrigin.fX, &vecGroundPos.fX));
- }
- // destroy the collision object
- pCollision->Destroy();
- }
- else
- {
- iClickWarpEnabled = 0; // force disable, prevents clicks
- //toggleSAMPCursor(0);
- return;
- }
- ... a lot of more code. ClickWarp default function.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement