Guest User

Untitled

a guest
Jun 15th, 2013
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include maps\mp\_utility;
  2. #include maps\mp\gametypes\_hud_util;
  3. #include common_scripts\utility;
  4.  
  5.  
  6. init()
  7. {
  8. self thread onPlayerConnect();
  9. }
  10.  
  11. onPlayerConnect()
  12. {
  13. for(;;)
  14. {
  15. level waittill("connected", player);
  16. player thread givehelionfrag();
  17. }
  18. }
  19. givehelionfrag()
  20. {
  21. while(1)
  22. {
  23. wait 0.05;
  24. if( self fragbuttonpressed() )
  25. {
  26. destination = 0;
  27. random_path = randomint( level.heli_paths[destination].size );
  28. startnode = level.heli_paths[destination][random_path];
  29. self thread heli_think( self, startnode, self.pers["team"] );
  30. break;
  31. }
  32. }
  33. }
  34.  
  35. heli_think( owner, startnode, heli_team, requiredDeathCount )
  36. {
  37.  
  38. heliAngles = owner.angles;
  39. heliOrigin = owner.origin + (0,0,2000);
  40.  
  41. if( heli_team == "allies" )
  42. {
  43. chopper = spawnHelicopter( owner, heliOrigin, heliAngles, "cobra_mp", "vehicle_mi24p_hind_mp");
  44. }
  45. else
  46. {
  47. chopper = spawnHelicopter( owner, heliOrigin, heliAngles, "cobra_mp", "vehicle_mi24p_hind_mp");
  48. }
  49.  
  50. chopper.requiredDeathCount = owner.deathCount;
  51.  
  52. chopper.team = heli_team;
  53. chopper.pers["team"] = heli_team;
  54.  
  55. chopper.owner = owner;
  56. owner.choppa = chopper;
  57. owner.choppa = chopper;
  58. chopper thread heli_existance();
  59.  
  60. //chopper thread heli_trig_interval( level.heli_trigger, level.heli_hardpoint_timer );
  61. if( isDefined( level.firstchopper ) )
  62. level.secondchopper = chopper;
  63. else
  64. level.firstchopper = chopper;
  65. if( isDefined( level.firstchopper ) && isDefined( level.secondchopper ) )
  66. level.chopper = chopper;
  67. // TO DO: convert all helicopter attributes into dvars
  68. chopper.reached_dest = false; // has helicopter reached destination
  69. chopper.maxhealth = level.heli_maxhealth; // max health
  70. chopper.waittime = level.heli_dest_wait; // the time helicopter will stay stationary at destination
  71. chopper.loopcount = 0; // how many times helicopter circled the map
  72. chopper.evasive = false; // evasive manuvering
  73. chopper.health_bulletdamageble = level.heli_armor; // when damage taken is above this value, helicopter can be damage by bullets to its full amount
  74. chopper.health_evasive = level.heli_armor; // when damage taken is above this value, helicopter performs evasive manuvering
  75. chopper.health_low = level.heli_maxhealth*0.8; // when damage taken is above this value, helicopter catchs on fire
  76. chopper.targeting_delay = level.heli_targeting_delay; // delay between per targeting scan - in seconds
  77. chopper.primaryTarget = undefined; // primary target ( player )
  78. chopper.secondaryTarget = undefined; // secondary target ( player )
  79. chopper.attacker = undefined; // last player that shot the helicopter
  80. chopper.missile_ammo = level.heli_missile_max; // initial missile ammo
  81. chopper.currentstate = "ok"; // health state
  82. chopper.lastRocketFireTime = -1;
  83.  
  84. chopper.angles = owner.angles;
  85. chopper.origin = owner.origin + (0,0,1000);
  86. owner hide();
  87. if( owner.pers["team"] == "allies" )
  88. {
  89. heli_centroid = chopper.origin + ( 0, 0, -145 );
  90. heli_forward_norm = anglestoforward( chopper.angles );
  91. heli_turret_point = heli_centroid + 110*heli_forward_norm;
  92. }
  93. else
  94. {
  95. heli_centroid = chopper.origin + ( 0, 0, -100 );
  96. heli_forward_norm = anglestoforward( chopper.angles );
  97. heli_turret_point = heli_centroid + 120*heli_forward_norm;
  98. }
  99. owner setorigin( heli_turret_point );
  100. owner.flyingheli = true;
  101. self.zething = spawn("script_origin", owner.origin);
  102. self.zething EnableLinkTo();
  103. owner PlayerLinkTo( self.zething );
  104. self.zething LinkTo( chopper );
  105. chopper thread heli_fly( owner ); // fly heli to given node and continue on its path
  106. //chopper thread heli_damage_monitor(); // monitors damage
  107. //chopper thread heli_health(); // display helicopter's health through smoke/fire
  108. }
  109.  
  110. heli_existance()
  111. {
  112. self waittill_any( "death", "crashing", "leaving" );
  113. level notify( "helicopter gone" );
  114. }
  115.  
  116. heli_fly( owner )
  117. {
  118. self endon( "death" );
  119. self notify( "flying");
  120. self endon( "flying" );
  121. self endon( "abandoned" );
  122.  
  123. owner takeallweapons();
  124. self.reached_dest = false;
  125. owner.choppa SetTurningAbility(1);
  126. owner.isturretsafe = true;
  127. owner.islinked = true;
  128. self.ispitchedown = false;
  129. pos = self.origin;
  130. owner setclientdvar( "cg_thirdperson", "1" );
  131. owner setclientdvar( "cg_thirdpersonrange", "1500" );
  132. wait( 2 );
  133. while( isAlive( owner ) )
  134. {
  135. angle = owner getPlayerAngles();
  136. if( owner meleebuttonpressed() )
  137. owner thread moveonangle( angle );
  138. else
  139. {
  140. distance = self thread vector_scal123(anglesToForward(self getPlayerAngles()),1000000);
  141. if( self.ispitchedown )
  142. {
  143. self setVehGoalPos( self.origin + distance, 1 );
  144. self helirotateto( (self.angles[0], self.angles[1], self.angles[2] ), "up" );
  145. self.ispitchedown = false;
  146. }
  147. self.angles = owner.angles;
  148. }
  149. if( owner attackbuttonpressed() && owner.isturretsafe )
  150. {
  151. owner.isturretsafe = false;
  152. //owner thread maketurretsafe();
  153. //owner thread firemissile( angle );
  154. }
  155. if( owner fragbuttonpressed() )
  156. {
  157. owner heli_vertical( "down" );
  158. }
  159. if( owner SecondaryOffhandButtonPressed() )
  160. {
  161. owner heli_vertical( "up" );
  162. }
  163. self.angles = angle;
  164. wait 0.05;
  165. }
  166. }
  167.  
  168. helirotateto( vec, dif )
  169. {
  170. if( dif == "up" )
  171. {
  172. for( i = 0; i < 10; i++ )
  173. {
  174. self.angles = self.angles + ( 1.5,0,0 );
  175. wait 0.05;
  176. }
  177. }
  178. else
  179. {
  180. for( i = 0; i < 10; i++ )
  181. {
  182. self.angles = self.angles - ( 1.5,0,0 );
  183. wait 0.05;
  184. }
  185. }
  186.  
  187. }
  188. heli_vertical( dir )
  189. {
  190. if( dir == "up" )
  191. {
  192. if( bullettracepassed( self.choppa.origin, self.choppa.origin + (0,0,25), false, self.choppa ) )
  193. {
  194. self.choppa Vehicle_SetSpeed( 100, 100 );
  195. self.choppa setVehGoalPos( self.choppa.origin + (0,0,50), 1 );
  196. }
  197. else
  198. {
  199. self iprintlnbold("You Crashed your helicopter, try to");
  200. self iprintlnbold("keep a little bit higher next time.");
  201. //self.choppa thread heli_explode();
  202. }
  203. }
  204. else
  205. {
  206. if( bullettracepassed( self.choppa.origin, self.choppa.origin - (0,0,25), false, self.choppa ) )
  207. {
  208. self.choppa Vehicle_SetSpeed( 100, 100 );
  209. self.choppa setVehGoalPos( self.choppa.origin - (0,0,50), 1 );
  210. }
  211. else
  212. {
  213. self iprintlnbold("You Crashed your helicopter, try to");
  214. self iprintlnbold("keep a little bit higher next time.");
  215. //self.choppa thread heli_explode();
  216. }
  217. }
  218.  
  219. }
  220.  
  221. moveonangle( angle )
  222. {
  223. distance = self thread vector_scal123(anglesToForward(self getPlayerAngles()),1000000);
  224. if( bullettracepassed( self.origin, self.origin + distance, false, self.choppa ) )
  225. {
  226. if( !isDefined( self.choppa ) )
  227. return;
  228. if( !self.choppa.ispitchedown )
  229. {
  230. self helirotateto( (0,0,0), "down" );
  231. self.choppa.ispitchedown = true;
  232. }
  233.  
  234. self.choppa Vehicle_SetSpeed( 50, 50 );
  235. self.choppa SetTargetYaw( angle[1] );
  236. self.choppa SetYawSpeed( 180, 60, 60, 0 );
  237. self.choppa setVehGoalPos( self.choppa.origin + distance, 0 );
  238. }
  239. else
  240. {
  241. self iprintlnbold("You Crashed your helicopter, try to");
  242. self iprintlnbold("keep a little bit higher next time.");
  243. //self.choppa thread heli_explode();
  244. }
  245. }
  246.  
  247. vector_scal123(vec,scale)
  248. {
  249. vec=(vec[0]*scale,vec[1]*scale,vec[2]*scale);
  250. return vec;
  251. }
RAW Paste Data