XADRENALINEIX

Jumper's Analog Fly Mod

May 18th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.78 KB | None | 0 0
  1. /*********************
  2. *  ANALOG FLY MOD  *
  3. *********************/
  4. #include <natives.h>
  5. #include <common.h>
  6. #include <strings.h>
  7. #include <types.h>
  8. #include <consts.h>
  9. /********************** PS3 CONTROLLER BUTTON MAP **********************/
  10. #define L1 0x4
  11. #define L2 0x5
  12. #define R1 0x6
  13. #define R2 0x7
  14. #define DPAD_UP 0x8
  15. #define DPAD_DOWN  0x9
  16. #define DPAD_LEFT  0xA
  17. #define DPAD_RIGHT 0xB
  18. #define START  0xC
  19. #define SELECT 0xD
  20. #define SQUARE 0xE
  21. #define TRIANGLE  0xF
  22. #define X  0x10
  23. #define CIRCLE 0x11
  24. #define STICK_L 0x12  //L3
  25. #define STICK_R 0x13  //R3
  26. /**************************************************  *********************/
  27. int activateFlyMod = false;
  28. int laX, laY, raX, raY;// analog sticks
  29. float paX, paY, paZ;// player coords old
  30. float pbX, pbY, pbZ;// player coords new
  31. float gcrotX, gcrotY, gcrotZ;// game cam rotation (Y is not used)
  32. float fincr;// distance to move (set by analog)
  33. float pbT;// weird trig stuffs
  34. Vehicle PlayerCar;
  35. Camera game_cam;
  36.  
  37. void MainLoop(void)
  38. {
  39. if (activateFlyMod)
  40. {
  41. GET_GAME_CAM(&game_cam);
  42. if (IS_CAM_ACTIVE(game_cam))
  43. {
  44. GET_CAM_ROT(game_cam, &gcrotX, &gcrotY, &gcrotZ);
  45. if (IS_CHAR_IN_ANY_CAR(GetPlayerPed()))
  46. {
  47. GET_CAR_CHAR_IS_USING(GetPlayerPed(), &PlayerCar);
  48. GET_CAR_COORDINATES(PlayerCar, &paX, &paY, &paZ);
  49. }
  50. if (!IS_CHAR_IN_ANY_CAR(GetPlayerPed()))
  51. {
  52. GET_CHAR_COORDINATES(GetPlayerPed(), &paX, &paY, &paZ);
  53. }
  54. GET_POSITION_OF_ANALOGUE_STICKS(0, &laX, &laY, &raX, &raY);
  55. fincr = (laY * laY) * 0.0001;
  56. if (IS_BUTTON_PRESSED(0, R1))
  57. {
  58. fincr = fincr * 4.0;
  59. PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", "Boost mode.", 100, 1);
  60. }
  61. pbT = (fincr * COS(gcrotX));
  62. if (laY < 0)
  63. {
  64. pbX = paX - (pbT * SIN(gcrotZ));
  65. pbY = paY + (pbT * COS(gcrotZ));
  66. pbZ = paZ + (fincr * SIN(gcrotX));
  67. }
  68. if (laY >= 0)
  69. {
  70. pbX = paX + (pbT * SIN(gcrotZ));
  71. pbY = paY - (pbT * COS(gcrotZ));
  72. pbZ = paZ - (fincr * SIN(gcrotX));
  73. }
  74. if (IS_BUTTON_PRESSED(0, L2))
  75. {
  76. pbZ = pbZ - fincr;
  77. }
  78. if (IS_BUTTON_PRESSED(0, R2))
  79. {
  80. pbZ = pbZ + fincr;
  81. }
  82. if (IS_CHAR_IN_ANY_CAR(GetPlayerPed()))
  83. {
  84. SET_CAR_COORDINATES_NO_OFFSET(PlayerCar, pbX, pbY, pbZ);
  85. }
  86. if (!IS_CHAR_IN_ANY_CAR(GetPlayerPed()))
  87. {
  88. pbZ = pbZ + 0.00450000;// no idea why a slight change in the z coord happens but this is to fix that, its still kind of screwy
  89. SET_CHAR_COORDINATES_NO_OFFSET(GetPlayerPed(), pbX, pbY, pbZ);
  90. }
  91. }
  92. }
  93.  
  94. }
  95.  
  96. void ButtonInput(void)
  97. {
  98.  
  99. if (IS_BUTTON_PRESSED(0, X) && IS_BUTTON_JUST_PRESSED(0, STICK_L))
  100. {
  101. if (activateFlyMod == true)
  102. {
  103. activateFlyMod = false;
  104. PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", "Fly mod disabled.", 5000, 1);
  105. }
  106. else
  107. {
  108. activateFlyMod = true;
  109. PRINT_STRING_WITH_LITERAL_STRING_NOW("STRING", "Fly mod enabled.", 5000, 1);
  110. }
  111. }
  112.  
  113. }
  114.  
  115. void main(void)
  116. {
  117. while(true)
  118. {
  119. WAIT(0);
  120. ButtonInput();
  121. MainLoop();
  122. }
  123. }
  124. [/CODE]
Advertisement
Add Comment
Please, Sign In to add comment