SAMP Gitlab CI Test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.7 KiB

  1. //
  2. // Used for testing interpolated rotations with MoveObject
  3. // Also used to test AttachObjectToObject
  4. // The other ferris wheel (that actually spins!)
  5. // Located on the opposite peer at LS
  6. //
  7. // SA-MP 0.3d and above
  8. //
  9. // - Kye 2011
  10. //
  11. #include <a_samp>
  12. #include "../include/gl_common.inc" // for PlaySoundForPlayersInRange()
  13. #define NUM_FERRIS_CAGES 10
  14. #define FERRIS_WHEEL_ID 18877
  15. #define FERRIS_CAGE_ID 18879
  16. #define FERRIS_BASE_ID 18878
  17. #define FERRIS_DRAW_DISTANCE 300.0
  18. #define FERRIS_WHEEL_SPEED 0.01
  19. #define FERRIS_WHEEL_Z_ANGLE -90.0 // This is the heading the entire ferris wheel is at (beware of gimbal lock)
  20. new Float:gFerrisOrigin[3] = {832.8393, -2046.1990, 27.0900};
  21. // Cage offsets for attaching to the main wheel
  22. new Float:gFerrisCageOffsets[NUM_FERRIS_CAGES][3] = {
  23. {0.0699, 0.0600, -11.7500},
  24. {-6.9100, -0.0899, -9.5000},
  25. {11.1600, 0.0000, -3.6300},
  26. {-11.1600, -0.0399, 3.6499},
  27. {-6.9100, -0.0899, 9.4799},
  28. {0.0699, 0.0600, 11.7500},
  29. {6.9599, 0.0100, -9.5000},
  30. {-11.1600, -0.0399, -3.6300},
  31. {11.1600, 0.0000, 3.6499},
  32. {7.0399, -0.0200, 9.3600}
  33. };
  34. // SA-MP objects
  35. new gFerrisWheel;
  36. new gFerrisBase;
  37. new gFerrisCages[NUM_FERRIS_CAGES];
  38. forward RotateWheel();
  39. //-------------------------------------------------
  40. new Float:gCurrentTargetYAngle = 0.0; // Angle of the Y axis of the wheel to rotate to.
  41. new gWheelTransAlternate = 0; // Since MoveObject requires some translation target to intepolate
  42. // rotation, the world pos target is alternated by a small amount.
  43. UpdateWheelTarget()
  44. {
  45. gCurrentTargetYAngle += 36.0; // There are 10 carts, so 360 / 10
  46. if(gCurrentTargetYAngle >= 360.0) {
  47. gCurrentTargetYAngle = 0.0;
  48. }
  49. if(gWheelTransAlternate) gWheelTransAlternate = 0;
  50. else gWheelTransAlternate = 1;
  51. }
  52. //-------------------------------------------------
  53. public RotateWheel()
  54. {
  55. UpdateWheelTarget();
  56. new Float:fModifyWheelZPos = 0.0;
  57. if(gWheelTransAlternate) fModifyWheelZPos = 0.05;
  58. MoveObject( gFerrisWheel, gFerrisOrigin[0], gFerrisOrigin[1], gFerrisOrigin[2]+fModifyWheelZPos,
  59. FERRIS_WHEEL_SPEED, 0.0, gCurrentTargetYAngle, FERRIS_WHEEL_Z_ANGLE );
  60. }
  61. //-------------------------------------------------
  62. public OnFilterScriptInit()
  63. {
  64. gFerrisWheel = CreateObject( FERRIS_WHEEL_ID, gFerrisOrigin[0], gFerrisOrigin[1], gFerrisOrigin[2],
  65. 0.0, 0.0, FERRIS_WHEEL_Z_ANGLE, FERRIS_DRAW_DISTANCE );
  66. gFerrisBase = CreateObject( FERRIS_BASE_ID, gFerrisOrigin[0], gFerrisOrigin[1], gFerrisOrigin[2],
  67. 0.0, 0.0, FERRIS_WHEEL_Z_ANGLE, FERRIS_DRAW_DISTANCE );
  68. new x=0;
  69. while(x != NUM_FERRIS_CAGES) {
  70. gFerrisCages[x] = CreateObject( FERRIS_CAGE_ID, gFerrisOrigin[0], gFerrisOrigin[1], gFerrisOrigin[2],
  71. 0.0, 0.0, FERRIS_WHEEL_Z_ANGLE, FERRIS_DRAW_DISTANCE );
  72. AttachObjectToObject( gFerrisCages[x], gFerrisWheel,
  73. gFerrisCageOffsets[x][0],
  74. gFerrisCageOffsets[x][1],
  75. gFerrisCageOffsets[x][2],
  76. 0.0, 0.0, FERRIS_WHEEL_Z_ANGLE, 0 );
  77. x++;
  78. }
  79. SetTimer("RotateWheel",3*1000,0);
  80. return 1;
  81. }
  82. //-------------------------------------------------
  83. public OnFilterScriptExit()
  84. {
  85. new x=0;
  86. DestroyObject(gFerrisWheel);
  87. DestroyObject(gFerrisBase);
  88. x=0;
  89. while(x != NUM_FERRIS_CAGES) {
  90. DestroyObject(gFerrisCages[x]);
  91. x++;
  92. }
  93. return 1;
  94. }
  95. //-------------------------------------------------
  96. public OnObjectMoved(objectid)
  97. {
  98. if(objectid != gFerrisWheel) return 0;
  99. SetTimer("RotateWheel",3*1000,0);
  100. return 1;
  101. }
  102. //-------------------------------------------------