Advertisement
Guest User

zlt_fastrope.sqf

a guest
Feb 13th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.18 KB | None | 0 0
  1. //Enable Fast Roping script add to init
  2. //[] execVM "zlt_fastrope.sqf";
  3.  
  4. #define MAX_SPEED_WHILE_FASTROPING 10
  5. #define MAX_SPEED_ROPES_AVAIL 30
  6. #define MAX_ALT_ROPES_AVAIL 30
  7.  
  8. #define STR_TOSS_ROPES "Toss Ropes"
  9. #define STR_FAST_ROPE "Fast Rope"
  10. #define STR_CUT_ROPES "Cut Ropes"
  11.  
  12.  
  13. if (isdedicated) exitwith {};
  14. waituntil {player == player};
  15.  
  16. zlt_rope_ropes = [];
  17. zlt_mutexAction = false;
  18.  
  19. zlt_rope_helis = ["O_Heli_Light_02_unarmed_F",
  20.  
  21. "O_Heli_Light_02_F", "B_Heli_Transport_01_F",
  22.  
  23. "B_Heli_Transport_01_camo_F", "RHS_UH60M",
  24.  
  25. "RHS_UH60M_d", "CAF_CH146_F_D", "CAF_CH146_SF",
  26.  
  27. "B_Heli_Transport_03_F",
  28.  
  29. "B_Heli_Transport_03_unarmed_F",
  30.  
  31. "CFB_Helo_Chinook", "I_Heli_light_03_unarmed_F",
  32.  
  33. "CFB_Helo_Griffon_Unarmed", "O_Heli_Attack_02_F",
  34.  
  35. "O_Heli_Attack_02_black_F",
  36.  
  37. "I_Heli_Transport_02_F",
  38.  
  39. "B_Heli_Light_01_F","ST1_UH_80_MED_FG",
  40.  
  41. "MELB_MH6M", "RHS_CH_47F", "RHS_CH_47F_10",
  42.  
  43. "RHS_CH_47F_light"];
  44. zlt_rope_helidata =
  45. [
  46. [
  47. ["O_Heli_Light_02_unarmed_F", "O_Heli_Light_02_F"],
  48. [1.35,1.35,0],[-1.45,1.35,0]
  49. ],
  50. [
  51. ["B_Heli_Transport_01_F",
  52.  
  53. "B_Heli_Transport_01_camo_F", "CAF_CH146_F_D",
  54.  
  55. "CAF_CH146_SF","ST1_UH_80_MED_FG "],
  56. [-1.11,2.5,0],[1.13,2.5,0]
  57. ],
  58. [
  59. ["B_Heli_Transport_03_F",
  60.  
  61. "B_Heli_Transport_03_unarmed_F",
  62.  
  63. "CFB_Helo_Chinook"],
  64. [-1.11,-3.5,0],[1.08,-3.5,0]
  65. ],
  66. [
  67. ["I_Heli_light_03_unarmed_F",
  68.  
  69. "CFB_Helo_Griffon_Unarmed"],
  70. [0.7,2.5,0],[-0.9,2.5,0]
  71. ],
  72. [
  73. ["O_Heli_Attack_02_F", "O_Heli_Attack_02_black_F"],
  74. [1.3,1.3,0],[-1.3,1.3,0]
  75. ],
  76. [
  77. ["I_Heli_Transport_02_F"],
  78. [0,-5,0]
  79. ],
  80. [
  81. ["B_Heli_Light_01_F"],
  82. [1.1,0.5,0],[-1.1,0.5,0]
  83. ],
  84. [
  85. ["MELB_MH6M"],
  86. [1.15,0.05,1],[-1.15,0.05,1]
  87. ],
  88. [
  89. ["RHS_UH60M", "RHS_UH60M_d"],
  90. [-1.11,2.5,0],[1.44,1.92,0]
  91. ],
  92. [
  93. ["RHS_CH_47F_light", "RHS_CH_47F_10",
  94.  
  95. "RHS_CH_47F"],
  96. [0,-0.4,-25.5]
  97. ]
  98. ];
  99.  
  100.  
  101. zlt_fnc_tossropes = {
  102. private ["_heli","_ropes","_oropes","_rope"];
  103. _heli = _this;
  104. _ropes = [];
  105. _oropes = _heli getvariable ["zlt_ropes",[]];
  106. if (count _oropes != 0 ) exitWith {};
  107. random 0.3;
  108. {
  109. if ((typeof _heli) in (_x select 0)) exitwith {
  110. _ropes pushBack (_x select 1);
  111. if ( count (_x select 2) !=0 ) then {
  112. _ropes pushBack (_x select 2);
  113. };
  114. };
  115. } foreach zlt_rope_helidata;
  116.  
  117. sleep random 0.3;
  118. if ( count (_heli getvariable ["zlt_ropes",[]]) !=
  119.  
  120. 0 ) exitwith { zlt_mutexAction = false; };
  121. _heli animateDoor ['door_R', 1];
  122. _heli animateDoor ['door_L', 1];
  123. {
  124. _rope = ropeCreate [vehicle player, _x, (getPosATL
  125.  
  126. player select 2) + 3];
  127. _oropes pushBack _rope;
  128. } foreach _ropes;
  129.  
  130. _heli setvariable ["zlt_ropes",_oropes,true];
  131.  
  132. _heli spawn {
  133. private ["_heli","_ropes"];
  134. _heli = _this;
  135. while {alive _heli AND count (_heli
  136.  
  137. getVariable ["zlt_ropes", []]) != 0 AND (abs (speed
  138.  
  139. _heli) < MAX_SPEED_ROPES_AVAIL) AND ((getposATL
  140.  
  141. _heli select 2) <= MAX_ALT_ROPES_AVAIL ) } do {
  142. sleep 1;
  143. };
  144. _ropes = (_heli getVariable ["zlt_ropes",
  145.  
  146. []]);
  147. {ropeDestroy _x} forEach _ropes;
  148. _heli setVariable ["zlt_ropes", [], true];
  149. };
  150.  
  151. };
  152.  
  153. zlt_fnc_ropes_cond = {
  154. _veh = vehicle player;
  155. _flag = (_veh != player) and {(not
  156.  
  157. zlt_mutexAction)} and {count (_veh getvariable
  158.  
  159. ["zlt_ropes", []]) == 0} and { (typeof _veh) in
  160.  
  161. zlt_rope_helis } and {alive player and alive _veh
  162.  
  163. and (abs (speed _veh) < MAX_SPEED_ROPES_AVAIL ) and
  164.  
  165. ((getposATL _veh select 2) <= MAX_ALT_ROPES_AVAIL )
  166.  
  167. };
  168. _flag;
  169.  
  170. };
  171.  
  172. zlt_fnc_fastropeaiunits = {
  173. private ["_heli","_grunits"];
  174. diag_log ["zlt_fnc_fastropeaiunits", _this];
  175. _heli = _this select 0;
  176. _grunits = _this select 1;
  177.  
  178. dostop (driver _heli );
  179. (driver _heli) setBehaviour "Careless";
  180. (driver _heli) setCombatMode "Blue";
  181.  
  182. _heli spawn zlt_fnc_tossropes;
  183.  
  184. [_heli, _grunits] spawn {
  185. private ["_units","_heli"];
  186. sleep random 0.5;
  187. _units = _this select 1;
  188. _heli = _this select 0;
  189. _units = _units - [player];
  190. _units = _units - [driver _heli];
  191. {if (!alive _x or isplayer _x or vehicle _x !=
  192.  
  193. _heli) then {_units = _units - [_x];}; } foreach
  194.  
  195. _units;
  196.  
  197. { sleep (0.5 + random 0.7); _x spawn
  198.  
  199. zlt_fnc_fastropeUnit; } foreach _units;
  200. waituntil {sleep 0.5; { (getpos _x select 2) < 1 }
  201.  
  202. count _units == count _units; };
  203. sleep 10;
  204. (driver _heli) doFollow (leader group (driver _heli
  205.  
  206. ));
  207. (driver _heli) setBehaviour "Aware";
  208. (driver _heli) setCombatMode "White";
  209. _heli call zlt_fnc_cutropes;
  210.  
  211. };
  212. };
  213.  
  214.  
  215. zlt_fnc_fastrope = {
  216. diag_log ["fastrope", _this];
  217. zlt_mutexAction = true;
  218. sleep random 0.3;
  219. if (player == leader group player) then {
  220. [vehicle player, units group player] call
  221.  
  222. zlt_fnc_fastropeaiunits;
  223. };
  224. player call zlt_fnc_fastropeUnit;
  225. zlt_mutexAction = false;
  226. };
  227.  
  228. zlt_fnc_fastropeUnit = {
  229. _unit = _this;
  230. _veh = vehicle _unit;
  231. _ropes = (_veh getVariable ["zlt_ropes", []]);
  232. if (count _ropes == 0) exitWith {};
  233. _ropeSel = _ropes call BIS_fnc_selectRandom;
  234. _unit action ["Eject",_veh];
  235. sleep 0.5;
  236. _unit leaveVehicle _veh;
  237. moveOut _unit;
  238. _unit allowDamage false;
  239. _ropePos = (ropeEndPosition _ropeSel) select 0;
  240. _unit setPosATL [(_ropePos select 0),(_ropePos
  241.  
  242. select 1),(_ropePos select 2) -0.5];
  243. _unit switchMove "LadderRifleStatic";
  244. While {Alive _unit && (((getPos _unit) select
  245.  
  246. 2) > 1)} do
  247. {
  248. _unit switchMove "LadderRifleStatic";
  249. };
  250. _unit setVelocity [0,0,0];
  251. _unit playMove "LadderRifleDownOff";
  252. _unit allowDamage true;
  253. };
  254.  
  255.  
  256. zlt_fnc_cutropes = {
  257. _veh = _this;
  258. _ropes = (_veh getvariable ["zlt_ropes", []]);
  259. {ropeDestroy _x} foreach _ropes;
  260. _veh setvariable ["zlt_ropes", [], true];
  261. _veh animateDoor ['door_R', 0];
  262. _veh animateDoor ['door_L', 0];
  263.  
  264. };
  265.  
  266. zlt_fnc_removeropes = {
  267. (vehicle player) call zlt_fnc_cutropes;
  268. };
  269.  
  270. zlt_fnc_createropes = {
  271. zlt_mutexAction = true;
  272. (vehicle player) call zlt_fnc_tossropes;
  273. zlt_mutexAction = false;
  274. };
  275.  
  276.  
  277. player createDiarySubject
  278.  
  279. [STR_SCRIPTS_NAME,STR_SCRIPTS_NAME];
  280. player createDiaryRecord [STR_SCRIPTS_NAME,
  281.  
  282. [STR_SCRIPT_NAME, STR_HELP]];
  283.  
  284. player addAction["<t
  285.  
  286. color='#ffff00'>"+STR_TOSS_ROPES+"</t>",
  287.  
  288. zlt_fnc_createropes, [], -1, false, false, '','[]
  289.  
  290. call zlt_fnc_ropes_cond'];
  291. player addAction["<t
  292.  
  293. color='#ff0000'>"+STR_CUT_ROPES+"</t>",
  294.  
  295. zlt_fnc_removeropes, [], -1, false, false, '','not
  296.  
  297. zlt_mutexAction and count ((vehicle player)
  298.  
  299. getvariable ["zlt_ropes", []]) != 0'];
  300. player addAction["<t
  301.  
  302. color='#00ff00'>"+STR_FAST_ROPE+"</t>",
  303.  
  304. zlt_fnc_fastrope, [], 15, false, false, '','not
  305.  
  306. zlt_mutexAction and count ((vehicle player)
  307.  
  308. getvariable ["zlt_ropes", []]) != 0 and player !=
  309.  
  310. driver vehicle player'];
  311.  
  312. player addEventHandler ["Respawn", {
  313. player addAction["<t
  314.  
  315. color='#ffff00'>"+STR_TOSS_ROPES+"</t>",
  316.  
  317. zlt_fnc_createropes, [], -1, false, false, '','[]
  318.  
  319. call zlt_fnc_ropes_cond'];
  320. player addAction["<t
  321.  
  322. color='#ff0000'>"+STR_CUT_ROPES+"</t>",
  323.  
  324. zlt_fnc_removeropes, [], -1, false, false, '','not
  325.  
  326. zlt_mutexAction and count ((vehicle player)
  327.  
  328. getvariable ["zlt_ropes", []]) != 0'];
  329. player addAction["<t
  330.  
  331. color='#00ff00'>"+STR_FAST_ROPE+"</t>",
  332.  
  333. zlt_fnc_fastrope, [], 15, false, false, '','not
  334.  
  335. zlt_mutexAction and count ((vehicle player)
  336.  
  337. getvariable ["zlt_ropes", []]) != 0 and player !=
  338.  
  339. driver vehicle player'];
  340. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement