Advertisement
Guest User

Fast Roping

a guest
Sep 30th, 2015
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.65 KB | None | 0 0
  1. /*
  2. fastrope.sqf made by UNKNOWN
  3. configured to work on Exile by Pato
  4. */
  5.  
  6. #define MAX_ALTITUDE_ROPES_AVAIL 70
  7. #define MIN_ALTITUDE_ROPES_AVAIL 5
  8. #define MAX_SPEED_ROPES_AVAIL 15
  9.  
  10. #define STR_TOSS_ROPES "Toss Ropes"
  11. #define STR_FAST_ROPE "Fast Rope"
  12. #define STR_CUT_ROPES "Cut Ropes"
  13.  
  14. if (isDedicated) exitWith {};
  15. waitUntil {player == player};
  16.  
  17. zlt_rope_ropes = [];
  18. zlt_mutexAction = false;
  19.  
  20. zlt_rope_helis =
  21.                 [
  22.                 "Exile_Chopper_Orca_CSAT",
  23.                 "Exile_Chopper_Orca_Black",
  24.                 "Exile_Chopper_Orca_BlackCustom",
  25.                 "Exile_Chopper_Hellcat_Green",
  26.                 "Exile_Chopper_Hellcat_FIA",
  27.                 "B_Heli_Transport_01_F",
  28.                 "B_Heli_Transport_01_camo_F",
  29.                 "O_Heli_Light_02_F",
  30.                 "I_Heli_light_03_F",
  31.                 "Exile_Chopper_Mohawk_FIA"
  32.                 ];
  33.  
  34. zlt_fnc_tossropes = {
  35.     private ["_heli","_ropes","_oropes","_rope"];
  36.     _heli = _this;
  37.     _ropes = [];
  38.     _oropes = _heli getVariable ["zlt_ropes",[]];
  39.     if (count _oropes != 0 ) exitWith {};
  40.     random 0.3;
  41.     if ( count (_heli getVariable ["zlt_ropes",[]]) != 0 ) exitWith { zlt_mutexAction = false; };
  42.     switch (typeOf _heli) do {
  43.         case "Exile_Chopper_Orca_CSAT": {};
  44.        
  45.         case "Exile_Chopper_Orca_Black": {};
  46.        
  47.         case "Exile_Chopper_Orca_BlackCustom": {};
  48.        
  49.         case "Exile_Chopper_Hellcat_Green": {};
  50.        
  51.         case "Exile_Chopper_Hellcat_FIA": {};
  52.        
  53.         case "O_Heli_Light_02_F": {};
  54.        
  55.         case "Exile_Chopper_Mohawk_FIA": {
  56.             _heli animateDoor ['Door_Back_L', 1];
  57.             _heli animateDoor ['Door_Back_R', 1];
  58.         };
  59.        
  60.         case "I_Heli_Transport_02_F": {
  61.             _heli animateDoor ['Door_Back_L', 1];
  62.             _heli animateDoor ['Door_Back_R', 1];
  63.         };
  64.        
  65.         case "B_Heli_Transport_01_F": {
  66.             _heli animateDoor ['door_R', 1];
  67.             _heli animateDoor ['door_L', 1];
  68.         };
  69.        
  70.         case "B_Heli_Transport_03_unarmed_F": {
  71.             _heli animateDoor ['Door_R_source', 1];
  72.             _heli animateDoor ['Door_L_source', 1];
  73.         };
  74.     };
  75.     _rope = ropeCreate [vehicle player, "slingload0", (getPosATL player select 2) + 3, (getPosATL player select 2) + 3, true];
  76.     _oropes = _oropes + [_rope];
  77.     _heli setVariable ["zlt_ropes",_oropes,true];
  78.    
  79.     _heli spawn {
  80.         private ["_heli","_ropes"];
  81.         _heli = _this;
  82.         while {alive _heli AND count (_heli getVariable ["zlt_ropes", []]) != 0 AND abs (speed _heli) < MAX_SPEED_ROPES_AVAIL } do {
  83.             sleep 0.3;
  84.         };
  85.         _ropes = (_heli getVariable ["zlt_ropes", []]);
  86.         {ropeDestroy _x} forEach _ropes;
  87.         _heli setVariable ["zlt_ropes", [], true];
  88.     };
  89.  
  90. };
  91.  
  92. zlt_fnc_ropes_cond = {
  93.     _veh = vehicle player;
  94.     _flag = (_veh != player) AND (playerSide == west) AND (player == driver vehicle player) AND ((getPos (_veh) select 2) < MAX_ALTITUDE_ROPES_AVAIL) AND ((getPos (_veh) select 2) > MIN_ALTITUDE_ROPES_AVAIL) AND {(not zlt_mutexAction)} AND !(player getVariable "restrained") AND {count (_veh getVariable ["zlt_ropes", []]) == 0} AND { (typeOf _veh) in zlt_rope_helis } AND {alive player AND alive _veh AND (abs (speed _veh) < MAX_SPEED_ROPES_AVAIL ) };
  95.     _flag;
  96. };
  97.  
  98. zlt_fnc_fastrope = {
  99.     zlt_mutexAction = true;
  100.     sleep rANDom 0.3;
  101.     player call zlt_fnc_fastropeUnit;
  102.     zlt_mutexAction = false;
  103. };
  104.  
  105. zlt_fnc_fastropeUnit = {
  106.     _veh = vehicle player;
  107.     _ropes = (_veh getVariable ["zlt_ropes", []]);
  108.     if (count _ropes == 0) exitWith {};
  109.     player action ["Eject",vehicle player];
  110.     sleep 0.5;
  111.     player leaveVehicle _veh;
  112.     moveOut player;
  113.     player allowDamage false;
  114.     _ropePos = ropeEndPosition (_ropes select 0) select 0;
  115.     player setPosATL [(getPosATL _veh select 0),(getPosATL _veh select 1),(getPosATL _veh select 2)-0.5];
  116.     player switchMove "LadderRifleStatic";
  117.     player setDir (getDir _veh - 90);
  118.     While {Alive player && (((getPos player) select 2) > 1.5)} do
  119.     {
  120.         player switchMove "LadderRifleStatic";
  121.     };
  122.     player setVelocity [0,0,0];
  123.     player playMove "LadderRifleDownOff";
  124.     player allowDamage true;
  125. };
  126.  
  127. zlt_fnc_cutropes = {
  128.     _veh = _this;
  129.     _ropes = (_veh getVariable ["zlt_ropes", []]);
  130.     {ropeDestroy _x} forEach _ropes;
  131.     _veh setVariable ["zlt_ropes", [], true];
  132.    
  133.     switch (typeOf _veh) do {
  134.    
  135.         case "Exile_Chopper_Orca_CSAT": {};
  136.        
  137.         case "Exile_Chopper_Orca_Black": {};
  138.        
  139.         case "Exile_Chopper_Orca_BlackCustom": {};
  140.        
  141.         case "Exile_Chopper_Hellcat_Green": {};
  142.        
  143.         case "Exile_Chopper_Hellcat_FIA": {};
  144.        
  145.         case "O_Heli_Light_02_F": {};
  146.        
  147.         case "Exile_Chopper_Mohawk_FIA": {
  148.             _heli animateDoor ['Door_Back_L', 1];
  149.             _heli animateDoor ['Door_Back_R', 1];
  150.         };
  151.        
  152.         case "O_Heli_Light_02_unarmed_F": {};
  153.        
  154.         case "I_Heli_Transport_02_F": {
  155.             _veh animateDoor ['Door_Back_L', 0];
  156.             _veh animateDoor ['Door_Back_R', 0];
  157.         };
  158.        
  159.         case "B_Heli_Transport_01_F": {
  160.             _veh animateDoor ['door_R', 0];
  161.             _veh animateDoor ['door_L', 0];
  162.         };
  163.        
  164.         case "B_Heli_Transport_03_unarmed_F": {
  165.             _veh animateDoor ['Door_R_source', 0];
  166.             _veh animateDoor ['Door_L_source', 0];
  167.         };
  168.     };
  169. };
  170.  
  171. zlt_fnc_removeropes = {
  172.     (vehicle player) call zlt_fnc_cutropes;
  173. };
  174.  
  175. zlt_fnc_createropes = {
  176.     zlt_mutexAction = true;
  177.     (vehicle player) call zlt_fnc_tossropes;
  178.     zlt_mutexAction = false;
  179. };
  180.  
  181. player createDiarySubject [STR_SCRIPTS_NAME,STR_SCRIPTS_NAME];
  182. player createDiaryRecord [STR_SCRIPTS_NAME,[STR_SCRIPT_NAME, STR_HELP]];
  183.  
  184. player addAction["<t color='#ffff00'>"+STR_TOSS_ROPES+"</t>", zlt_fnc_createropes, [], -1, false, false, '','[] call zlt_fnc_ropes_cond'];
  185. player addAction["<t color='#ff0000'>"+STR_CUT_ROPES+"</t>", zlt_fnc_removeropes, [], -1, false, false, '','not zlt_mutexAction AND count ((vehicle player) getVariable ["zlt_ropes", []]) != 0 AND player == driver vehicle player && !(player getVariable "restrained")'];
  186. player addAction["<t color='#00ff00'>"+STR_FAST_ROPE+"</t>", zlt_fnc_fastrope, [], 15, false, false, '','not zlt_mutexAction AND count ((vehicle player) getVariable ["zlt_ropes", []]) != 0 AND ((getPos (vehicle player) select 2) < MAX_ALTITUDE_ROPES_AVAIL) AND locked vehicle player == 0 AND player != driver vehicle player && !(player getVariable "restrained")'];
  187.  
  188. player addEventHANDler ["Respawn", {
  189.     player addAction["<t color='#ffff00'>"+STR_TOSS_ROPES+"</t>", zlt_fnc_createropes, [], -1, false, false, '','[] call zlt_fnc_ropes_cond'];
  190.     player addAction["<t color='#ff0000'>"+STR_CUT_ROPES+"</t>", zlt_fnc_removeropes, [], -1, false, false, '','not zlt_mutexAction AND count ((vehicle player) getVariable ["zlt_ropes", []]) != 0 AND player != driver vehicle player && !(player getVariable "restrained")'];
  191.     player addAction["<t color='#00ff00'>"+STR_FAST_ROPE+"</t>", zlt_fnc_fastrope, [], 15, false, false, '','not zlt_mutexAction AND count ((vehicle player) getVariable ["zlt_ropes", []]) != 0 AND ((getPos (vehicle player) select 2) < MAX_ALTITUDE_ROPES_AVAIL) AND locked vehicle player == 0 AND player != driver vehicle player && !(player getVariable "restrained")'];
  192. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement