Advertisement
Guest User

ship

a guest
Oct 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.79 KB | None | 0 0
  1. #define NUM_SHIP_ROUTE_POINTS   20
  2. #define SHIP_HULL_ID            9585 // massive cargo ship's hull. This is used as the main object
  3. #define SHIP_MOVE_SPEED         10.0
  4. #define SHIP_DRAW_DISTANCE      3000.0
  5.  
  6. #define NUM_SHIP_ATTACHMENTS 10
  7.  
  8. new Float:gShipHullOrigin[3] =
  9. { -2409.8438, 1544.9453, 2.0000 }; // so we can convert world space to model space for attachment positions
  10.  
  11. new gShipAttachmentModelIds[NUM_SHIP_ATTACHMENTS] = {
  12. 9586, // Ship main platform
  13. 9761, // Ship rails
  14. 9584, // Bridge exterior
  15. 9698, // Bridge interior
  16. 9821, // Bridge interior doors
  17. 9818, // Bridge radio desk
  18. 9819, // Captain's desk
  19. 9822, // Captain's seat
  20. 9820, // Bridge ducts and lights
  21. 9590  // Cargo bay area
  22. };
  23.  
  24. new Float:gShipAttachmentPos[NUM_SHIP_ATTACHMENTS][3] = {
  25. // these are world space positions used on the original cargo ship in the game
  26. // they will be converted to model space before attaching
  27. {-2412.1250, 1544.9453, 12.0469},
  28. {-2411.3906, 1544.9453, 22.0781},
  29. {-2485.0781, 1544.9453, 21.1953},
  30. {-2473.5859, 1543.7734, 24.0781},
  31. {-2474.3594, 1547.2422, 19.7500},
  32. {-2470.2656, 1544.9609, 28.8672},
  33. {-2470.4531, 1551.1172, 28.1406},
  34. {-2470.9375, 1550.7500, 27.9063},
  35. {-2474.6250, 1545.0859, 27.0625},
  36. {-2403.5078, 1544.9453, 3.7188}
  37. };
  38.  
  39. // Pirate ship route points (position/rotation)
  40. new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][6] = {
  41. {2838.0313, -2371.9531, 7.2969,   0.00, 0.00, 270.0},//Porto
  42. {2844.4482, -2362.6050, 7.2969,   0.00, 0.00, 190.50},
  43. {2869.6379, -2310.5771, 7.2969,   0.00, 0.00, 156.36},
  44. {2917.0820, -2250.0437, 7.2969,   0.00, 0.00, 153.36},
  45. {3161.5376, -2055.3135, 7.2969,   0.00, 0.00, 145.74},
  46. {-1431.59937, 191.26247, 7.2969,   0.00, 0.00, 144.96},
  47. {3277.0647,-1968.2816, 7.2969,   0.00, 0.00, 167.52},
  48. {3532.0605,-1662.3719, 7.2969,   0.36, 0.06, 206.70},
  49. {4229.4663,-1070.0613, 7.2969,   0.36, 0.54, 244.80},
  50. {5216.6968,-602.6795, 7.2969,   1.92, -0.36, 283.26},
  51. {5372.9312,-658.6240, 7.2969,   0.92, -0.36, 316.32},
  52. {5542.2729,-884.8328, 7.2969,   0.92, -0.36, 342.54},
  53. {5568.6753,-1186.7546, 7.2969,   0.02, -0.06, 359.64},
  54. {5464.0508,-1684.8986, 7.2969,   0.02, -0.06, 359.64},
  55. {5260.2930,-2490.8940, 7.2969,   0.02, -0.06, 384.48},
  56. {4977.8237,-2990.7974, 7.2969,   0.02, -0.06, 378.54},
  57. {4580.2227,-3002.791, 7.2969,   0.02, -0.06, 356.28},
  58. {3643.6187, -3630.5256, 7.2969,   0.00, 0.00, 189.24},
  59. {3299.7607, -3455.6931, 7.2969,   0.00, 0.00, 215.22},
  60. {2870.5447, -2664.9153, 7.2969,   0.00, 0.00, 215.22}
  61. };
  62.  
  63.  
  64. new gShipCurrentPoint = 1; // current route point the ship is at. We start at route 1
  65.  
  66. // SA-MP objects
  67. new gMainShipObjectId;
  68. new gShipsAttachments[NUM_SHIP_ROUTE_POINTS];
  69. forward StartMovingTimer();
  70.  
  71. //-------------------------------------------------
  72.  
  73. public StartMovingTimer()
  74. {
  75.         MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  76.                                    gShipRoutePoints[gShipCurrentPoint][1],
  77.                                    gShipRoutePoints[gShipCurrentPoint][2],
  78.                                    SHIP_MOVE_SPEED / 2.0, // slower for the first route
  79.                                    gShipRoutePoints[gShipCurrentPoint][3],
  80.                                    gShipRoutePoints[gShipCurrentPoint][4],
  81.                                    gShipRoutePoints[gShipCurrentPoint][5]);
  82. }
  83.  
  84. //-------------------------------------------------
  85. forward PortoTrucker_ModeInit();
  86. public PortoTrucker_ModeInit()
  87. {
  88.     gMainShipObjectId = CreateObject(SHIP_HULL_ID, gShipRoutePoints[0][0], gShipRoutePoints[0][1], gShipRoutePoints[0][2],
  89.                                     gShipRoutePoints[0][3], gShipRoutePoints[0][4], gShipRoutePoints[0][5], SHIP_DRAW_DISTANCE);
  90.  
  91.     new x=0;
  92.     while(x != NUM_SHIP_ATTACHMENTS) {
  93.         gShipsAttachments[x] = CreateObject(gShipAttachmentModelIds[x], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
  94.         AttachObjectToObject(gShipsAttachments[x], gMainShipObjectId,
  95.                     gShipAttachmentPos[x][0] - gShipHullOrigin[0],
  96.                     gShipAttachmentPos[x][1] - gShipHullOrigin[1],
  97.                     gShipAttachmentPos[x][2] - gShipHullOrigin[2],
  98.                     0.0, 0.0, 0.0);
  99.         x++;
  100.     }
  101.     SetTimer("StartMovingTimer",30*1000,0); // pause at route 0 for 30 seconds
  102.  
  103.     return 1;
  104. }
  105.  
  106. //-------------------------------------------------
  107. forward PortoTrucker_ModeExit();
  108. public PortoTrucker_ModeExit()
  109. {
  110.     DestroyObject(gMainShipObjectId);
  111.     new x=0;
  112.     while(x != NUM_SHIP_ATTACHMENTS) {
  113.         DestroyObject(gShipsAttachments[x]);
  114.         x++;
  115.     }
  116.     return 1;
  117. }
  118.  
  119. //-------------------------------------------------
  120. forward OnObjectMoved_Porto(objectid);
  121. public OnObjectMoved_Porto(objectid)
  122. {
  123.     new string[128];
  124.     gShipCurrentPoint++;
  125.  
  126.     format(string, sizeof string, "Moveu navio: %d", gShipCurrentPoint);
  127.     SendClientMessageToAll(-1, string);
  128.     if(gShipCurrentPoint == 1)
  129.     {
  130.         SetTimer("StartMovingTimer",30*1000,0); // pause at route 5 for 300 seconds
  131.        
  132.         SendClientMessageToAll(-1, "O Navio está no porto");
  133.         return 1;
  134.     }
  135.  
  136.     if(gShipCurrentPoint == NUM_SHIP_ROUTE_POINTS)
  137.     {
  138.         gShipCurrentPoint = 0;
  139.  
  140.         MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  141.                                gShipRoutePoints[gShipCurrentPoint][1],
  142.                                gShipRoutePoints[gShipCurrentPoint][2],
  143.                                SHIP_MOVE_SPEED / 2.0, // slower for the last route
  144.                                gShipRoutePoints[gShipCurrentPoint][3],
  145.                                gShipRoutePoints[gShipCurrentPoint][4],
  146.                                gShipRoutePoints[gShipCurrentPoint][5]);
  147.         return 1;
  148.     }
  149.  
  150.     if(gShipCurrentPoint == 1) {
  151.         SetTimer("StartMovingTimer",30*1000,0); // pause at route 0 for 30 seconds
  152.         return 1;
  153.     }
  154.  
  155.     MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
  156.                                gShipRoutePoints[gShipCurrentPoint][1],
  157.                                gShipRoutePoints[gShipCurrentPoint][2],
  158.                                SHIP_MOVE_SPEED,
  159.                                gShipRoutePoints[gShipCurrentPoint][3],
  160.                                gShipRoutePoints[gShipCurrentPoint][4],
  161.                                gShipRoutePoints[gShipCurrentPoint][5]);
  162.  
  163.     return 1;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement