Advertisement
Guest User

Wrath Of Genesis

a guest
Apr 17th, 2008
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. //==============================================================================
  2.  
  3. #include <a_samp>
  4.  
  5. //==============================================================================
  6.  
  7. forward MissleFly ( );
  8.  
  9. forward MissleLaunch ( );
  10.  
  11. //==============================================================================
  12.  
  13. new Text: RocketWarning;
  14.  
  15. //==============================================================================
  16.  
  17. new LaunchAt = 0; // 0 = Anyone 1 = Non admins
  18.  
  19. //==============================================================================
  20.  
  21. public OnFilterScriptInit ( )
  22. {
  23. SetTimer ( "MissleFly" , 100 , true );
  24.  
  25. SetTimer ( "MissleLaunch" , 1000 , true );
  26.  
  27. CreateMissleLauncher ( 355.116821 , 2029.626587 , 25.391882 );
  28. CreateMissleLauncher ( 188.230200 , 2081.575400 , 26.170501 );
  29. CreateMissleLauncher ( 238.203912 , 1698.624023 , 23.875014 );
  30. CreateMissleLauncher ( 15.7451134 , 1720.978434 , 23.875022 );
  31.  
  32. printf ( " " );
  33. printf ( "||======================================||" );
  34. printf ( "|| Anti Aircraft ||" );
  35. printf ( "|| Missle System ||" );
  36. printf ( "|| By WrathOfGenesis (FUDDS) ||" );
  37. printf ( "||======================================||" );
  38. printf ( " " );
  39.  
  40. for ( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
  41. {
  42. new Float: TEXTX = 230 , Float: TEXTY = 350;
  43.  
  44. RocketWarning = TextDrawCreate ( TEXTX , TEXTY , "~r~WARNING~w~: Heat Seeking Missle ~r~Detected" );
  45. TextDrawLetterSize ( RocketWarning , 0.55 , 2 );
  46. TextDrawFont ( RocketWarning , 3 );
  47. TextDrawSetOutline ( RocketWarning , 1 );
  48. }
  49.  
  50. return 1;
  51. }
  52.  
  53. //==============================================================================
  54.  
  55. new Float: MisslePositions [ 999 ] [ 4 ];
  56.  
  57. new TargetPos [ 999 ] [ 4 ];
  58.  
  59. new Missle [ 999 ];
  60.  
  61. new MissleIcons [ 999 ];
  62.  
  63. new MissleChase [ 999 ];
  64.  
  65. new MAX_MISSLES;
  66.  
  67. //==============================================================================
  68.  
  69. stock CreateMissleLauncher ( Float: X , Float: Y , Float: Z )
  70. {
  71. MisslePositions [ MAX_MISSLES ] [ 0 ] = X;
  72. MisslePositions [ MAX_MISSLES ] [ 1 ] = Y;
  73. MisslePositions [ MAX_MISSLES ] [ 2 ] = Z;
  74.  
  75. new missleid = MAX_MISSLES;
  76.  
  77. MAX_MISSLES = MAX_MISSLES += 1;
  78.  
  79. return missleid;
  80. }
  81.  
  82. //==============================================================================
  83.  
  84. stock Float: GetDistanceBetweenTwoPoints ( Float: X , Float: Y , Float: Z , Float: X2 , Float: Y2 , Float: Z2 )
  85. {
  86. return floatsqroot ( floatpower ( floatabs ( floatsub ( X , X2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Y , Y2 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( Z , Z2 ) ) , 2 ) );
  87. }
  88.  
  89. //==============================================================================
  90.  
  91. Float: GetXYInFrontOfPlayer ( playerid , &Float: X , &Float: Y , Float: distance )
  92. {
  93. new Float: Z;
  94.  
  95. GetPlayerPos ( playerid , X , Y , Z );
  96.  
  97. if ( IsPlayerInAnyVehicle ( playerid ) )
  98. {
  99. GetVehicleZAngle ( GetPlayerVehicleID ( playerid ) , Z );
  100. }
  101. else
  102. {
  103. GetPlayerFacingAngle ( playerid , Z );
  104. }
  105.  
  106. X += ( distance * floatsin ( - Z , degrees ) );
  107. Y += ( distance * floatcos ( - Z , degrees ) );
  108.  
  109. return Z;
  110. }
  111.  
  112. //==============================================================================
  113.  
  114. stock GetDistanceToPoint ( playerid , Float: X ,Float: Y , Float: Z )
  115. {
  116. new Float: X2 , Float: Y2 , Float: Z2;
  117.  
  118. GetPlayerPos ( playerid , X2 , Y2 , Z2 );
  119.  
  120. return floatround ( GetDistanceBetweenTwoPoints ( X , Y , Z , X2 , Y2 , Z2 ) );
  121. }
  122.  
  123. //==============================================================================
  124.  
  125. public MissleFly ( )
  126. {
  127. for ( new missleid = 0; missleid < MAX_MISSLES; missleid ++ )
  128. {
  129. if ( IsValidObject ( Missle [ missleid ] ) )
  130. {
  131. new Float: X, Float: Y, Float: Z;
  132.  
  133. GetPlayerPos ( MissleChase [ missleid ] , X , Y , Z );
  134.  
  135. TextDrawHideForPlayer ( MissleChase [ missleid ] , RocketWarning );
  136. TextDrawShowForPlayer ( MissleChase [ missleid ] , RocketWarning );
  137.  
  138. GetXYInFrontOfPlayer ( MissleChase [ missleid ] , X , Y , 5 );
  139.  
  140. TargetPos [ missleid ] [ 0 ] = floatround ( X );
  141. TargetPos [ missleid ] [ 1 ] = floatround ( Y );
  142. TargetPos [ missleid ] [ 2 ] = floatround ( Z + 3 );
  143.  
  144. MoveObject ( Missle [ missleid ] , X , Y , Z , 90 );
  145.  
  146. GetObjectPos ( Missle [ missleid ] , X , Y , Z );
  147.  
  148. RemovePlayerMapIcon ( Missle [ missleid ] , MissleIcons [ Missle [ missleid ] ] );
  149.  
  150. SetPlayerMapIcon( MissleChase [ missleid ] , MissleIcons [ Missle [ missleid ] ] , X , Y , Z , 0 , 0xFF0000AA );
  151.  
  152. new Float: health;
  153.  
  154. GetPlayerHealth ( MissleChase [ missleid ] , health );
  155.  
  156. if ( GetDistanceBetweenTwoPoints ( X , Y , Z , TargetPos [ missleid ] [ 0 ] , TargetPos [ missleid ] [ 1 ] , TargetPos [ missleid ] [ 2 ] ) < 6 || health < 1 )
  157. {
  158. DestroyMissle ( Missle [ missleid ] );
  159. }
  160. }
  161. }
  162. }
  163.  
  164. //==============================================================================
  165.  
  166. stock DestroyMissle ( missleid )
  167. {
  168. new Float: X, Float: Y, Float: Z;
  169.  
  170. GetObjectPos ( missleid , X , Y , Z );
  171.  
  172. DestroyObject ( missleid );
  173.  
  174. CreateExplosion ( X , Y , Z , 6 , 10 );
  175.  
  176. RemovePlayerMapIcon ( MissleChase [ MissleIcons [ missleid ] ] , MissleIcons [ missleid ] );
  177.  
  178. TextDrawHideForPlayer ( MissleChase [ missleid ] , RocketWarning );
  179. }
  180.  
  181. //==============================================================================
  182.  
  183. public MissleLaunch ( )
  184. {
  185. for ( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
  186. {
  187. new totallaunched;
  188.  
  189. for ( new missleid = 0; missleid < MAX_MISSLES; missleid ++ )
  190. {
  191. if ( GetDistanceToPoint ( playerid , MisslePositions [ missleid ] [ 0 ] , MisslePositions [ missleid ] [ 1 ] , MisslePositions [ missleid ] [ 2 ] ) < 300 )
  192. {
  193. if ( IsPlayerInAnyVehicle ( playerid ) && IsAircraft ( GetPlayerVehicleID ( playerid ) ) )
  194. {
  195. if ( IsPlayerAdmin ( playerid ) )
  196. {
  197. if ( LaunchAt == 1 )
  198. {
  199. totallaunched = 1;
  200. }
  201. }
  202.  
  203. if ( !IsValidObject ( Missle [ missleid ] ) && totallaunched == 0 )
  204. {
  205. new Float: X, Float: Y, Float: Z;
  206.  
  207. GetPlayerPos ( playerid , X , Y , Z );
  208.  
  209. TargetPos [ missleid ] [ 0 ] = floatround ( X );
  210. TargetPos [ missleid ] [ 1 ] = floatround ( Y );
  211. TargetPos [ missleid ] [ 2 ] = floatround ( Z );
  212.  
  213. MissleChase [ missleid ] = playerid;
  214.  
  215. totallaunched = totallaunched = 1;
  216.  
  217. Missle [ missleid ] = CreateObject ( 354 , MisslePositions [ missleid ] [ 0 ] , MisslePositions [ missleid ] [ 1 ] , MisslePositions [ missleid ] [ 2 ] , 0 , 0 , 0 );
  218.  
  219. MoveObject ( Missle [ missleid ] , X , Y , Z , 15 );
  220.  
  221. MissleIcons [ Missle [ missleid ] ] = missleid;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }
  228.  
  229. //==============================================================================
  230.  
  231. stock IsAircraft ( vehicleid )
  232. {
  233. switch ( GetVehicleModel ( vehicleid ) )
  234. {
  235. case
  236. 465,425,417,497,563,592,
  237. 548,577,511,512,501,447,
  238. 460,513,520,469,487,488,
  239. 553,464,476,519,593,539
  240. :
  241. {
  242. return 1;
  243. }
  244. }
  245. return 0;
  246. }
  247.  
  248. //==============================================================================
  249.  
  250. public OnPlayerDisconnect ( playerid , reason )
  251. {
  252. TextDrawHideForPlayer ( playerid , RocketWarning );
  253.  
  254. return 1;
  255. }
  256.  
  257. //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement