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.

177 lines
6.4 KiB

  1. //
  2. // Used for testing interpolated rotations with MoveObject
  3. // Also used to test AttachObjectToObject
  4. // A pirate ship goes around and visits some route points
  5. //
  6. // SA-MP 0.3d and above
  7. //
  8. // - Kye 2011
  9. //
  10. #include <a_samp>
  11. #include "../include/gl_common.inc" // for PlaySoundForPlayersInRange()
  12. #define NUM_SHIP_ROUTE_POINTS 25
  13. #define SHIP_OBJECT_ID 8493 // pirate ship
  14. #define SHIP_SKULL_ATTACH 3524
  15. #define SHIP_RAILS_ATTACH 9159
  16. #define SHIP_LINES_ATTACH 8981
  17. #define SHIP_MOVE_SPEED 10.0
  18. #define SHIP_DRAW_DISTANCE 800.0
  19. // Pirate ship route points (position/rotation)
  20. new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][6] = {
  21. {-2389.81, 1434.84, 13.51, 0.00, 0.0, -87.36},
  22. {-2319.54, 1450.75, 13.91, 1.0, 0.0, -71.70},
  23. {-2245.87, 1479.80, 14.21, 5.00, 0.0, -63.84},
  24. {-2168.53, 1535.31, 15.73, 1.00, 0.0, -50.76},
  25. {-2096.43, 1634.13, 15.73, 0.00, 0.0, -36.60},
  26. {-2036.11, 1734.57, 15.27, -1.00, 0.0, -20.22},
  27. {-2018.20, 1841.61, 15.27, -5.00, 0.00, -4.86},
  28. {-2043.70, 1936.95, 15.27, -1.00, 0.00, 25.32},
  29. {-2104.07, 2023.54, 12.78, 0.00, 0.00, 49.14},
  30. {-2206.40, 2065.64, 16.76, 1.00, 0.00, 73.32},
  31. {-2298.24, 2070.62, 14.59, 5.00, 0.00, 91.62},
  32. {-2412.24, 2067.55, 14.59, 1.00, 0.00, 91.62},
  33. {-2528.28, 2057.22, 12.30, 0.00, 0.00, 99.78},
  34. {-2626.64, 2032.14, 17.04, -1.00, 0.00, 106.98},
  35. {-2727.60, 1996.95, 15.36, -5.00, 0.00, 106.98},
  36. {-2808.88, 1953.08, 15.36, -1.00, 0.00, 121.62},
  37. {-2886.19, 1876.19, 16.68, 0.00, 0.00, 143.16},
  38. {-2911.09, 1782.21, 16.68, -1.00, 0.00, 173.34},
  39. {-2898.36, 1678.83, 14.88, 0.00, 0.00, 194.58},
  40. {-2851.29, 1601.46, 16.13, 1.00, 0.00, 228.42},
  41. {-2760.72, 1557.18, 16.13, 0.00, 0.00, 257.52},
  42. {-2665.41, 1535.22, 16.13, -1.00, 0.00, 257.52},
  43. {-2589.06, 1509.08, 16.13, 0.00, 0.00, 239.88},
  44. {-2517.74, 1463.39, 14.59, 1.00, 0.00, 243.78},
  45. {-2456.12, 1441.11, 14.59, 0.00, 0.00, 254.76}
  46. };
  47. new gShipCurrentPoint = 1; // current route point the ship is at
  48. // SA-MP objects
  49. new gMainShipObjectId;
  50. new gShipSkullAttachment[4];
  51. new gShipRailsAttachment;
  52. new gShipLinesAttachment;
  53. forward StartMovingTimer();
  54. //-------------------------------------------------
  55. public StartMovingTimer()
  56. {
  57. MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  58. gShipRoutePoints[gShipCurrentPoint][1],
  59. gShipRoutePoints[gShipCurrentPoint][2],
  60. SHIP_MOVE_SPEED / 4.0, // bit slower for the first point
  61. gShipRoutePoints[gShipCurrentPoint][3],
  62. gShipRoutePoints[gShipCurrentPoint][4],
  63. gShipRoutePoints[gShipCurrentPoint][5]);
  64. }
  65. //-------------------------------------------------
  66. public OnFilterScriptInit()
  67. {
  68. gMainShipObjectId = CreateObject(SHIP_OBJECT_ID, gShipRoutePoints[0][0], gShipRoutePoints[0][1], gShipRoutePoints[0][2],
  69. gShipRoutePoints[0][3], gShipRoutePoints[0][4], gShipRoutePoints[0][5], SHIP_DRAW_DISTANCE);
  70. gShipSkullAttachment[0] = CreateObject(SHIP_SKULL_ATTACH, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  71. AttachObjectToObject(gShipSkullAttachment[0], gMainShipObjectId, 4.11, -5.53, -9.78, 0.0, 0.0, 90.0);
  72. gShipSkullAttachment[1] = CreateObject(SHIP_SKULL_ATTACH, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  73. AttachObjectToObject(gShipSkullAttachment[1], gMainShipObjectId, -4.11, -5.53, -9.78, 0.0, 0.0, -90.0);
  74. gShipSkullAttachment[2] = CreateObject(SHIP_SKULL_ATTACH, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  75. AttachObjectToObject(gShipSkullAttachment[2], gMainShipObjectId, -4.3378, -15.2887, -9.7863, 0.0, 0.0, -90.0);
  76. gShipSkullAttachment[3] = CreateObject(SHIP_SKULL_ATTACH, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  77. AttachObjectToObject(gShipSkullAttachment[3], gMainShipObjectId, 4.3378, -15.2887, -9.7863, 0.0, 0.0, 90.0);
  78. gShipRailsAttachment = CreateObject(SHIP_RAILS_ATTACH, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  79. AttachObjectToObject(gShipRailsAttachment, gMainShipObjectId, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  80. gShipLinesAttachment = CreateObject(SHIP_LINES_ATTACH, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  81. AttachObjectToObject(gShipLinesAttachment, gMainShipObjectId, -0.5468, -6.1875, -0.4375, 0.0, 0.0, 0.0);
  82. SetTimer("StartMovingTimer",30*1000,0); // pause at route 0 for 30 seconds
  83. return 1;
  84. }
  85. //-------------------------------------------------
  86. public OnFilterScriptExit()
  87. {
  88. new x=0;
  89. DestroyObject(gMainShipObjectId);
  90. x=0;
  91. while(x != 4) {
  92. DestroyObject(gShipSkullAttachment[x]);
  93. x++;
  94. }
  95. DestroyObject(gShipRailsAttachment);
  96. DestroyObject(gShipLinesAttachment);
  97. return 1;
  98. }
  99. //-------------------------------------------------
  100. public OnObjectMoved(objectid)
  101. {
  102. if(objectid != gMainShipObjectId) return 0;
  103. if(gShipCurrentPoint > 0 && !(gShipCurrentPoint % 3)) {
  104. // play some seagulls audio every 3 points
  105. PlaySoundForPlayersInRange(6200, 100.0, gShipRoutePoints[gShipCurrentPoint][0],
  106. gShipRoutePoints[gShipCurrentPoint][1],
  107. gShipRoutePoints[gShipCurrentPoint][2]);
  108. }
  109. gShipCurrentPoint++;
  110. if(gShipCurrentPoint == NUM_SHIP_ROUTE_POINTS) {
  111. gShipCurrentPoint = 0;
  112. MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  113. gShipRoutePoints[gShipCurrentPoint][1],
  114. gShipRoutePoints[gShipCurrentPoint][2],
  115. SHIP_MOVE_SPEED / 4.0, // slower for the last route
  116. gShipRoutePoints[gShipCurrentPoint][3],
  117. gShipRoutePoints[gShipCurrentPoint][4],
  118. gShipRoutePoints[gShipCurrentPoint][5]);
  119. return 1;
  120. }
  121. if(gShipCurrentPoint == 1) {
  122. // Before heading to the first route we should wait a bit
  123. SetTimer("StartMovingTimer",30*1000,0); // pause at route 0 for 30 seconds
  124. return 1;
  125. }
  126. /*
  127. new tempdebug[256+1];
  128. format(tempdebug,256,"The ship is at route: %d", gShipCurrentPoint);
  129. SendClientMessageToAll(0xFFFFFFFF,tempdebug);*/
  130. MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  131. gShipRoutePoints[gShipCurrentPoint][1],
  132. gShipRoutePoints[gShipCurrentPoint][2],
  133. SHIP_MOVE_SPEED,
  134. gShipRoutePoints[gShipCurrentPoint][3],
  135. gShipRoutePoints[gShipCurrentPoint][4],
  136. gShipRoutePoints[gShipCurrentPoint][5]);
  137. return 1;
  138. }
  139. //-------------------------------------------------