Advertisement
Guest User

=BTC=_functions.sqf

a guest
Apr 1st, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Created by =BTC= Giallustio
  3. version 0.8
  4. Visit us at:
  5. http://www.blacktemplars.altervista.org/
  6. 06/03/2012
  7. */
  8. //Functions
  9. BTC_assign_actions =
  10. {
  11.     if ([player] call BTC_is_class_can_revive) then {player addAction [("<t color=""#ED2744"">") + ("First aid") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_first_aid], 8, true, true, "", "[] call BTC_check_action_first_aid"];};
  12.     player addAction [("<t color=""#ED2744"">") + ("Drag") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_drag], 8, true, true, "", "[] call BTC_check_action_drag"];
  13.     player addAction [("<t color=""#ED2744"">") + ("Pull out injured") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_pull_out], 8, true, true, "", "[] call BTC_pull_out_check"];
  14. };
  15. BTC_get_gear =
  16. {
  17.     private ["_array_mag","_id","_display_name","_count","_array_class","_array_bullet","_array_class_x","_array_bullet_x","_r_mag_d","_h_mag_d"];
  18.     _gear = [];
  19.     _weapons = weapons player;
  20.     _prim_weap = primaryWeapon player;
  21.     _prim_items = primaryWeaponItems player;
  22.     _sec_weap = secondaryWeapon player;
  23.     _sec_items = secondaryWeaponItems player;
  24.     _items_assigned = assignedItems player;
  25.     _handgun = handgunWeapon player;
  26.     _handgun_items = handgunItems player;
  27.     _goggles = goggles player;
  28.     _headgear = headgear player;
  29.     _uniform = uniform player;
  30.     _uniform_items = uniformItems player;
  31.     _vest = vest player;
  32.     _vest_items = vestItems player;
  33.     _back_pack = backpack player;
  34.     _back_pack_items = backpackItems player;
  35.     _back_pack_weap = getWeaponCargo (unitBackpack player);
  36.     _weap_sel = currentWeapon player;
  37.     _weap_mode = currentWeaponMode player;
  38.     _at_mag = "";_r_mag = "";_h_mag = "";
  39.     if (_sec_weap != "") then {player selectWeapon _sec_weap;_at_mag = currentMagazine player;_at_mag_d = currentMagazineDetail player;};
  40.     if (_handgun != "") then {player selectWeapon _handgun;_h_mag = currentMagazine player;_h_mag_d = currentMagazineDetail player;};
  41.     if (_prim_weap != "") then {player selectWeapon _prim_weap;_r_mag = currentMagazine player;_r_mag_d = currentMagazineDetail player;};
  42.     player selectWeapon _weap_sel;
  43.     _fire_mode_array = getArray (configFile >> "cfgWeapons" >> _weap_sel >> "modes");
  44.     _fire_mode = _fire_mode_array find _weap_mode;
  45.     if (_fire_mode != -1) then {player action ["SWITCHWEAPON", player, player, _fire_mode];};
  46.     //diag_log text format ["%1 - %3 - %2",_fire_mode_array,_fire_mode,_weap_mode];
  47.     _mags   = magazines player;
  48.     _magd   = magazinesDetail player;
  49.     //diag_log text format ["%1",_r_mag_d];
  50.     if (_r_mag != "" && _r_mag_d != "") then {_mags = _mags + [_r_mag];_magd = _magd + [_r_mag_d];};
  51.     if (_h_mag != "" && _r_mag_d != "") then {_mags = _mags + [_h_mag];_magd = _magd + [_h_mag_d];};
  52.     BTC_compile_count = 0;
  53.     _mags_g = [];
  54.     _array_class  = [];
  55.     _array_bullet = [];
  56.     {
  57.         _array_mag  = toArray _x;
  58.         _cond_class = false;_cond_bullet = false;_array_class_x  = [];_array_bullet_x = [];
  59.         for "_i" from 0 to (count _array_mag - 1) do
  60.         {
  61.             _n = _array_mag select _i;
  62.             if (_n == 40 && ((count _array_mag) - _i <= 7)) then {_cond_class = true;};   // 40 = '('
  63.             if !(_cond_class) then
  64.             {
  65.                 _array_class_x = _array_class_x + [_n];
  66.             }
  67.             else
  68.             {
  69.                 if (_n == 47) then {_cond_bullet = true;};  // 47 = '/'
  70.                 if (_n != 40 && _n != 41 && _n != 47 && !_cond_bullet) then {_array_bullet_x = _array_bullet_x + [_n];}; // 41 = ')'
  71.             };
  72.         };
  73.         _array_class = _array_class + [toString _array_class_x];
  74.         _array_bullet = _array_bullet + [toString _array_bullet_x];
  75.     } foreach _magd;
  76.     //diag_log text format ["%1",_array_class];
  77.     //diag_log text format ["%1",_array_bullet];
  78.    
  79.     diag_log format ["_array_class_x: %1",_array_class_x];
  80.     diag_log format ["_array_class (string): %1",_array_class];
  81.     diag_log format ["_array_bullet (string): %1",_array_bullet];
  82.  
  83.     {
  84.         _display_name = getText(configFile >> "CfgMagazines" >> _x >> "displayName");
  85.        
  86.        
  87. //      _id = _array_class find _display_name;
  88.        
  89.         _id = [_display_name, _magd] call fnc_searchArray;
  90.         diag_log format ["_display_name: %1 - _id: %2",_display_name, _id];
  91.        
  92.     //  _count = _array_bullet select _id;
  93.        
  94.         _count = 0;  // set count to zero for the moment since the _array_bullet is not returning integers
  95.        
  96.         if (_id > -1) then {
  97.             _array_class set [_id,0];_array_class = _array_class - [0];
  98.             _array_bullet set [_id,0];_array_bullet = _array_bullet - [0];
  99.             call compile format ["BTC_compile_count = %1;", _count];
  100.             _mags_g = _mags_g + [[_x,BTC_compile_count]];
  101.         };
  102.        
  103.     } foreach _mags;
  104.     _gear =
  105.     [
  106.         _uniform,
  107.         _vest,
  108.         _goggles,
  109.         _headgear,
  110.         _back_pack,
  111.         _back_pack_items,
  112.         _back_pack_weap,
  113.         _weapons,
  114.         _prim_items,
  115.         _sec_items,
  116.         _handgun_items,
  117.         _items_assigned,
  118.         _uniform_items,
  119.         _vest_items,
  120.         _weap_sel,
  121.         _mags_g,
  122.         _at_mag
  123.     ];
  124.     _gear
  125. };
  126. BTC_set_gear =
  127. {
  128.     /*_gear =
  129.     [
  130.         _uniform,0
  131.         _vest,1
  132.         _goggles,2
  133.         _headgear,3
  134.         _back_pack,4
  135.         _back_pack_items,5
  136.         _back_pack_weap,6
  137.         _weapons,7
  138.         _prim_items,8
  139.         _sec_items,9
  140.         _handgun_items,10
  141.         _items_assigned,11
  142.         _uniform_items,12
  143.         _vest_items,13
  144.         _weap_sel,14
  145.         _mags_g,15
  146.         _at_mag
  147.     ];*/
  148.     _unit = _this select 0;
  149.     _gear = _this select 1;
  150.     removeAllweapons _unit;
  151.     removeuniform _unit;
  152.     removevest _unit;
  153.     removeheadgear _unit;
  154.     removegoggles _unit;
  155.     removeBackPack _unit;
  156.     {_unit removeItem _x} foreach (items _unit);
  157.     {_unit unassignItem _x;_unit removeItem _x} foreach (assignedItems _unit);
  158.     ////////////////////////
  159.     if ((_gear select 0) != "") then {_unit addUniform (_gear select 0);};
  160.     if ((_gear select 1) != "") then {_unit addVest (_gear select 1);};
  161.     _unit addBackpack "B_AssaultPack_blk";
  162.     if (count (_gear select 11) > 0) then {{if (_x != "") then {_unit addItem _x;_unit assignItem _x;sleep 0.01;};} foreach (_gear select 11);};
  163.     removeBackPack _unit;
  164.     if ((_gear select 4) != "") then {_unit addBackPack (_gear select 4);clearAllItemsFromBackpack _unit;};
  165.     {if !(isClass (configFile >> "cfgMagazines" >> _x)) then {_unit addItem _x;};sleep 0.1;} foreach (_gear select 12);
  166.     {if !(isClass (configFile >> "cfgMagazines" >> _x)) then {_unit addItem _x;};sleep 0.1;} foreach (_gear select 13);            
  167.     {if !(isClass (configFile >> "cfgMagazines" >> _x)) then {_unit addItem _x;};sleep 0.1;} foreach (_gear select 5);
  168.     if ((_gear select 2) != "") then {_unit addGoggles (_gear select 2);};
  169.     if ((_gear select 3) != "") then {_unit addHeadgear (_gear select 3);};
  170.     if (count (BTC_back_pack_weap select 0) > 0) then
  171.     {
  172.         for "_i" from 0 to (count (BTC_back_pack_weap select 0) - 1) do
  173.         {
  174.             (unitBackpack _unit) addweaponCargoGlobal [(BTC_back_pack_weap select 0) select _i,(BTC_back_pack_weap select 1) select _i];
  175.         };         
  176.     };
  177.     //MAGS
  178.     {_unit addMagazine _x;} foreach (_gear select 15);
  179.     if ((_gear select 16) != "") then {_unit addMagazine (_gear select 16)};
  180.     {if (isClass (configFile >> "cfgWeapons" >> _x)) then {_unit addweapon _x;};} foreach (_gear select 7);
  181.     {_unit removeItemFromPrimaryWeapon _x} foreach (primaryWeaponItems _unit);
  182.     if (count (_gear select 8) > 0) then {{_unit addPrimaryWeaponItem _x;} foreach (_gear select 8);};
  183.     if (count (_gear select 9) > 0) then {{_unit addSecondaryWeaponItem _x;} foreach (_gear select 9);};
  184.     if (count (_gear select 10) > 0) then {{_unit addHandgunItem _x;} foreach (_gear select 10);};
  185.     _unit selectweapon (_gear select 14);
  186. };
  187. BTC_fnc_handledamage =
  188. {
  189.     _player = _this select 0;
  190.     _enemy  = _this select 3;
  191.     _damage = _this select 2;
  192.     _part   = _this select 1;
  193.     if (Alive _player) then
  194.     {
  195.         BTC_gear = [] call BTC_get_gear;
  196.     };
  197.     _damage
  198.     //if (format ["%1", _player getVariable "BTC_need_revive"] == "1") then {} else {_damage};
  199. };
  200. BTC_fnc_PVEH =
  201. {
  202.     //0 - first aid - create // [0,east,pos]
  203.     //1 - first aid - delete
  204.     _array = _this select 1;
  205.     _type  = _array select 0;
  206.     switch (true) do
  207.     {
  208.         case (_type == 0) :
  209.         {
  210.             _side = _array select 1;
  211.             _unit = _array select 3;
  212.             if (_side == BTC_side) then
  213.             {
  214.                 _pos = _array select 2;
  215.                 _marker = createmarkerLocal [format ["FA_%1", _pos], _pos];
  216.                 format ["FA_%1", _pos] setmarkertypelocal "mil_box";
  217.                 format ["FA_%1", _pos] setMarkerTextLocal format ["F.A. %1", name _unit];
  218.                 format ["FA_%1", _pos] setmarkerColorlocal "ColorGreen";
  219.                 format ["FA_%1", _pos] setMarkerSizeLocal [0.3, 0.3];
  220.                 [_pos,_unit] spawn
  221.                 {
  222.                     _pos  = _this select 0;
  223.                     _unit = _this select 1;
  224.                     while {(!(isNull _unit) && (format ["%1", _unit getVariable "BTC_need_revive"] == "1"))} do
  225.                     {
  226.                         format ["FA_%1", _pos] setMarkerPosLocal getpos _unit;
  227.                         sleep 1;
  228.                     };
  229.                     deleteMarker format ["FA_%1", _pos];
  230.                 };
  231.             };
  232.         };
  233.         case (_type == 1) : {(_array select 1) setDir 180;(_array select 1) playMoveNow "AinjPpneMstpSnonWrflDb_grab";};
  234.         case (_type == 2) :
  235.         {
  236.             private ["_injured"];
  237.             _injured = (_array select 1);
  238.             [_injured] spawn
  239.             {
  240.                 _injured = _this select 0;
  241.                 _injured allowDamage false;
  242.                 WaitUntil {sleep 1; (isNull _injured) || (format ["%1", _injured getVariable "BTC_need_revive"] == "0")};
  243.                 _injured allowDamage true;
  244.             };
  245.         };
  246.         case (_type == 3) :
  247.         {
  248.             private ["_injured","_veh"];
  249.             _injured = (_array select 1);
  250.             _veh     = (_array select 2);
  251.             if (name _injured == name player) then {_injured moveInCargo _veh};
  252.         };
  253.         case (_type == 4) :
  254.         {
  255.             private ["_array_injured"];
  256.             _array_injured = (_array select 1);
  257.             {
  258.                 if (name player == name _x) then {unAssignVehicle player;player action ["eject", vehicle player];};
  259.             } foreach _array_injured;
  260.         };
  261.     };
  262. };
  263. BTC_first_aid =
  264. {
  265.     private ["_injured","_array_item_injured","_array_item","_cond"];
  266.     _men = nearestObjects [player, ["Man"], 2];
  267.     if (count _men > 1) then {_injured = _men select 1;};
  268.     if (format ["%1",_injured getVariable "BTC_need_revive"] != "1") exitWith {};
  269.     _array_item = items player;
  270.     _array_item_injured = items _injured;
  271.     _cond = false;
  272.     if (BTC_need_first_aid == 0) then {_cond = true;};
  273.     if ((_array_item_injured find "FirstAidKit" == -1) && (BTC_need_first_aid == 1)) then {_cond = false;} else {_cond = true;};
  274.     if (!_cond && BTC_need_first_aid == 1) then {if ((_array_item find "FirstAidKit" == -1)) then {_cond = false;} else {_cond = true;};};
  275.     if (!_cond) exitWith {hint "Can't revive him";};
  276.     if (BTC_need_first_aid == 1) then {if (_array_item_injured find "FirstAidKit" == -1) then {player removeItem "FirstAidKit";};};
  277.     player playMove "AinvPknlMstpSlayWrflDnon_medic";
  278.     sleep 5;
  279.     waitUntil {!Alive player || (animationState player != "AinvPknlMstpSlayWrflDnon_medic" && animationState player != "amovpercmstpsraswrfldnon_amovpknlmstpsraswrfldnon" && animationState player != "amovpknlmstpsraswrfldnon_ainvpknlmstpslaywrfldnon" && animationState player != "ainvpknlmstpslaywrfldnon_amovpknlmstpsraswrfldnon")};
  280.     if (Alive player && Alive _injured) then
  281.     {
  282.         _injured setVariable ["BTC_need_revive",0,true];
  283.         _injured playMoveNow "AinjPpneMstpSnonWrflDnon_rolltoback";
  284.     };
  285. };
  286. BTC_drag =
  287. {
  288.     private ["_injured"];
  289.     _men = nearestObjects [player, ["Man"], 2];
  290.     if (count _men > 1) then {_injured = _men select 1;};
  291.     if (format ["%1",_injured getVariable "BTC_need_revive"] != "1") exitWith {};
  292.     BTC_dragging = true;
  293.     _injured attachTo [player, [0, 1.1, 0.092]];
  294.     player playMoveNow "AcinPknlMstpSrasWrflDnon";
  295.     _id = player addAction [("<t color=""#ED2744"">") + ("Release") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_release], 9, true, true, "", "true"];
  296.     _injured playMoveNow "AinjPpneMstpSnonWrflDb_grab";
  297.     BTC_drag_pveh = [1,_injured];publicVariable "BTC_drag_pveh";
  298.     WaitUntil {!Alive player || ((animationstate player == "acinpknlmstpsraswrfldnon") || (animationstate player == "acinpknlmwlksraswrfldb"))};
  299.     private ["_act","_veh_selected","_array","_array_veh","_name_veh","_text_action","_action_id"];
  300.     _act = 0;_veh_selected = objNull;_array_veh = [];
  301.     while {!isNull player && alive player && !isNull _injured && alive _injured && format ["%1", _injured getVariable "BTC_need_revive"] == "1" && BTC_dragging} do
  302.     {
  303.         _array = nearestObjects [player, ["Air","LandVehicle"], 5];
  304.         _array_veh = [];
  305.         {if (_x emptyPositions "cargo" != 0) then {_array_veh = _array_veh + [_x];};} foreach _array;
  306.         if (count _array_veh == 0) then {_veh_selected = objNull;};
  307.         if (count _array_veh > 0 && _veh_selected != _array_veh select 0) then
  308.         {
  309.             _veh_selected    = _array_veh select 0;
  310.             _name_veh        = getText (configFile >> "cfgVehicles" >> typeof _veh_selected >> "displayName");
  311.             _text_action     = ("<t color=""#ED2744"">" + "Load wounded in " + (_name_veh) + "</t>");
  312.             _action_id = player addAction [_text_action,"=BTC=_revive\=BTC=_addAction.sqf",[[_injured,_veh_selected],BTC_load_in], 7, true, true];
  313.             _act  = 1;
  314.         };
  315.         if (count _array_veh == 0 && _act == 1) then {player removeAction _action_id;_act = 0;};
  316.         sleep 0.1;
  317.     };
  318.     if (_act == 1) then {player removeAction _action_id;};
  319.     player playMoveNow "AmovPknlMstpSrasWrflDnon";
  320.     detach _injured;
  321.     if (format ["%1",_injured getVariable "BTC_need_revive"] == "1") then {_injured playMoveNow "AinjPpneMstpSnonWrflDb_release";};
  322.     player removeAction _id;
  323.     BTC_dragging = false;
  324. };
  325. BTC_release =
  326. {
  327.     BTC_dragging = false;
  328. };
  329. BTC_load_in =
  330. {
  331.     _injured = _this select 0;
  332.     _veh     = _this select 1;
  333.     BTC_dragging = false;
  334.     BTC_load_pveh = [3,_injured,_veh];publicVariable "BTC_load_pveh";
  335. };
  336. BTC_pull_out =
  337. {
  338.     _array = nearestObjects [player, ["Air","LandVehicle"], 5];
  339.     _array_injured = [];
  340.     if (count _array != 0) then
  341.     {
  342.         {
  343.             if (format ["%1",_x getVariable "BTC_need_revive"] == "1") then {_array_injured = _array_injured + [_x];};
  344.         } foreach crew (_array select 0);
  345.     };
  346.     BTC_pullout_pveh = [4,_array_injured];publicVariable "BTC_pullout_pveh";
  347. };
  348. BTC_pull_out_check =
  349. {
  350.     _cond = false;
  351.     _array = nearestObjects [player, ["Air","LandVehicle"], 5];
  352.     if (count _array != 0) then
  353.     {
  354.         {
  355.             if (format ["%1",_x getVariable "BTC_need_revive"] == "1") then {_cond = true;};
  356.         } foreach crew (_array select 0);
  357.     };
  358.     _cond
  359. };
  360. BTC_player_killed =
  361. {
  362.     private ["_type_backpack","_weapons","_magazines","_weapon_backpack","_ammo_backpack","_score","_score_array","_name","_body_marker"];
  363.     titleText ["", "BLACK OUT"];
  364.     _body = _this select 0;
  365.     [_body] spawn
  366.     {
  367.         _body = _this select 0;
  368.         _dir = getDir _body;
  369.         _pos = getPosATL vehicle _body;
  370.         if (BTC_active_lifes == 1) then {BTC_lifes = BTC_lifes - 1;};
  371.         if (BTC_active_lifes == 1 && BTC_lifes == 0) exitWith BTC_out_of_lifes;
  372.         if (BTC_lifes != 0 || BTC_active_lifes == 0) then
  373.         {
  374.             WaitUntil {Alive player};
  375.             _body_marker = player;
  376.             if (BTC_pvp == 0) then {player setcaptive true;};
  377.             //player setvehicleInit "this allowDamage false;";ProcessInitCommands;
  378.             BTC_killed_pveh = [2,_body_marker];publicVariable "BTC_killed_pveh";player allowDamage false;
  379.             player setVariable ["BTC_need_revive",1,true];
  380.             player switchMove "AinjPpneMstpSnonWrflDnon";
  381.             _actions = [] spawn BTC_assign_actions;
  382.             if (BTC_respawn_gear == 1) then
  383.             {
  384.                 _gear = [player,BTC_gear] spawn BTC_set_gear;
  385.             };
  386.             WaitUntil {animationstate player == "ainjppnemstpsnonwrfldnon"};
  387.             sleep 2;
  388.             player setDir _dir;
  389.             player setPosATL _pos;
  390.             deletevehicle _body;
  391.             _side = side player;
  392.             _injured = player;
  393.             if (BTC_injured_marker == 1) then {BTC_marker_pveh = [0,BTC_side,_pos,_body_marker];publicVariable "BTC_marker_pveh";};
  394.             disableUserInput true;
  395.             for [{_n = BTC_revive_time_min}, {_n != 0 && damage player > 0.2}, {_n = _n - 0.5}] do
  396.             {
  397.                 if (BTC_active_lifes == 1) then {titleText [format ["Lifes remaining: %1",BTC_lifes], "BLACK FADED"];} else {titleText ["", "BLACK FADED"];};
  398.                 sleep 0.5;
  399.             };
  400.             if (BTC_black_screen == 0) then {titleText ["", "BLACK IN"];};
  401.             disableUserInput false;
  402.             _time = time;
  403.             _timeout = _time + BTC_revive_time_max;
  404.             private ["_id","_lifes"];
  405.             if (BTC_disable_respawn == 1) then {player enableSimulation false;};
  406.             if (BTC_black_screen == 0 && BTC_disable_respawn == 0) then {if (BTC_action_respawn == 0) then {_dlg = createDialog "BTC_respawn_button_dialog";} else {_id = player addAction [("<t color=""#ED2744"">") + ("Respawn") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_player_respawn], 9, true, true, "", "true"];};};
  407.             if (BTC_black_screen == 1 && BTC_disable_respawn == 0) then {_dlg = createDialog "BTC_respawn_button_dialog";};
  408.             while {format ["%1", player getVariable "BTC_need_revive"] == "1" && time < _timeout} do
  409.             {
  410.                 if (BTC_black_screen == 0) then {if (animationstate player != "ainjppnemstpsnonwrfldnon" && animationstate player != "AinjPpneMstpSnonWrflDb_grab" && vehicle player == player) then {player switchMove "AinjPpneMstpSnonWrflDnon";};};
  411.                 if (BTC_disable_respawn == 0) then {if (BTC_black_screen == 1 || (BTC_black_screen == 0 && BTC_action_respawn == 0)) then {if (!Dialog) then {_dlg = createDialog "BTC_respawn_button_dialog";};};};
  412.                 _healer = call BTC_check_healer;
  413.                 _lifes = "";
  414.                 if (BTC_active_lifes == 1) then {_lifes = format ["Lifes remaining: %1",BTC_lifes];};
  415.                 if (BTC_black_screen == 1) then {titleText [format ["%1\n%2\n%3", round (_timeout - time),_healer,_lifes], "BLACK FADED"]} else {hintSilent format ["%1\n%2\n%3", round (_timeout - time),_healer,_lifes];};
  416.                 sleep 0.5;
  417.             };
  418.             closedialog 0;
  419.             if (time > _timeout && format ["%1", player getVariable "BTC_need_revive"] == "1") then
  420.             {
  421.                 _respawn = [] spawn BTC_player_respawn;
  422.             };
  423.             if (format ["%1", player getVariable "BTC_need_revive"] == "0" && !BTC_respawn_cond) then
  424.             {
  425.                 if (BTC_black_screen == 1) then {titleText ["", "BLACK IN"];} else {hintSilent "";};
  426.                 if (BTC_need_first_aid == 1 && ((items player) find "FirstAidKit" != -1)) then {player removeItem "FirstAidKit";};
  427.                 player playMove "amovppnemstpsraswrfldnon";
  428.                 player playMove "";
  429.             };
  430.             if (BTC_black_screen == 0 && BTC_action_respawn == 1 && BTC_disable_respawn == 0) then {player removeAction _id;};
  431.             if (BTC_pvp == 0) then {player setcaptive false;};
  432.             if (BTC_disable_respawn == 1) then {player enableSimulation true;};
  433.             //player setvehicleInit "this allowDamage true;";ProcessInitCommands;
  434.             player allowDamage true;
  435.             hintSilent "";
  436.         };
  437.     };
  438. };
  439. BTC_check_healer =
  440. {
  441.     _pos = getpos player;
  442.     _men = [];_dist = 501;_healer = objNull;_healers = [];
  443.     _msg = "No healer in 500 m";
  444.     _men = nearestObjects [_pos, BTC_who_can_revive, 500];
  445.     if (count _men > 0) then
  446.     {
  447.         {if (Alive _x && format ["%1",_x getVariable "BTC_need_revive"] != "1" && ([_x,player] call BTC_can_revive) && isPlayer _x && side _x == BTC_side) then {_healers = _healers + [_x];};} foreach _men;
  448.         if (count _healers > 0) then
  449.         {
  450.             {
  451.                 if (_x distance _pos < _dist) then {_healer = _x;_dist = _x distance _pos;};
  452.             } foreach _healers;
  453.             if !(isNull _healer) then {_msg = format ["%1 could heal you! He is %2 m away!", name _healer,round(_healer distance _pos)];};
  454.         };
  455.     };
  456.     _msg
  457. };
  458. BTC_player_respawn =
  459. {
  460.     BTC_respawn_cond = true;
  461.     player setVariable ["BTC_need_revive",0,true];
  462.     if (BTC_black_screen == 0) then {titleText ["", "BLACK OUT"];};
  463.     sleep 0.2;
  464.     if (BTC_black_screen == 0) then {titleText ["", "BLACK FADED"];};
  465.     if (vehicle player != player) then {unAssignVehicle player;player action ["eject", vehicle player];};
  466.     player setPos getMarkerPos BTC_respawn_marker;
  467.     sleep 1;
  468.     player setDamage 0;
  469.     player switchMove "amovpercmstpslowwrfldnon";
  470.     player switchMove "";
  471.     if (BTC_respawn_time > 0) then
  472.     {
  473.         player enableSimulation false;
  474.         player setpos [0,0,6000];
  475.         player setVelocity [0,0,0];
  476.         sleep 1;
  477.         private ["_n"];
  478.         for [{_n = BTC_respawn_time}, {_n != 0}, {_n = _n - 1}] do
  479.         {
  480.             private ["_msg"];
  481.             player enableSimulation false;
  482.             player setpos [0,0,6000];
  483.             player setVelocity [0,0,0];
  484.             titleText [format ["Respawn in %1",_n], "BLACK FADED"];
  485.             sleep 1;
  486.         };
  487.         player enableSimulation true;
  488.         deTach player;
  489.         player setVelocity [0,0,0];
  490.         player setPos getMarkerPos BTC_respawn_marker;
  491.         deleteVehicle _obj;
  492.     };
  493.     if (BTC_black_screen == 0 || BTC_respawn_time > 0) then
  494.     {  
  495.         titleText ["", "BLACK IN"];
  496.         sleep 2;
  497.         titleText ["", "PLAIN"];
  498.     };
  499.     player setVariable ["BTC_need_revive",0,true];
  500.     BTC_respawn_cond = false;
  501.     if (BTC_black_screen == 1 && BTC_respawn_time == 0) then {titleText ["", "BLACK IN"];sleep 2;titleText ["", "PLAIN"];};
  502. };
  503. BTC_check_action_first_aid =
  504. {
  505.     private ["_injured","_array_item_injured"];
  506.     _cond = false;
  507.     _array_item = items player;
  508.     _men = nearestObjects [vehicle player, ["Man"], 2];
  509.     if (count _men > 1 && format ["%1", player getVariable "BTC_need_revive"] == "0") then
  510.     {
  511.         if (format ["%1", (_men select 1) getVariable "BTC_need_revive"] == "1" && !BTC_dragging) then {_cond = true;};
  512.         _injured = _men select 1;
  513.     };
  514.     if (_cond && BTC_pvp == 1) then
  515.     {
  516.         if (side (_men select 1) == BTC_side) then {_cond = true;} else {_cond = false;};
  517.     };
  518.     if (_cond && BTC_need_first_aid == 1) then
  519.     {
  520.        
  521.         if (_array_item find "FirstAidKit" == -1) then {_cond = false;};
  522.         _array_item_injured = items _injured;
  523.         if (!_cond && _array_item_injured find "FirstAidKit" != -1) then {_cond = true;};
  524.     };
  525.     _cond
  526. };
  527. BTC_check_action_drag =
  528. {
  529.     _cond = false;
  530.     _men = nearestObjects [vehicle player, ["Man"], 2];
  531.     if (count _men > 1) then
  532.     {
  533.         if (format ["%1", (_men select 1) getVariable "BTC_need_revive"] == "1" && !BTC_dragging) then {_cond = true;};
  534.     };
  535.     _cond
  536. };
  537. BTC_is_class_can_revive =
  538. {
  539.     _unit    = _this select 0;
  540.     _cond = false;
  541.     {if (_unit isKindOf _x) then {_cond = true};} foreach BTC_who_can_revive;
  542.     _cond
  543. };
  544. BTC_can_revive =
  545. {
  546.     _unit    = _this select 0;
  547.     _injured = _this select 1;
  548.     _array_item_unit    = items _unit;
  549.     _array_item_injured = items _injured;
  550.     _cond = false;
  551.     {if (_unit isKindOf _x) then {_cond = true};} foreach BTC_who_can_revive;
  552.     if (_cond && BTC_need_first_aid == 1) then
  553.     {
  554.         if (_array_item_unit find "FirstAidKit" == -1) then {_cond = false;};
  555.         if (!_cond && _array_item_injured find "FirstAidKit" != -1) then {_cond = true;};
  556.     };
  557.     _cond
  558. };
  559. //Mobile
  560. BTC_move_to_mobile =
  561. {
  562.     _var = _this select 0;
  563.     _side = "";
  564.     switch (true) do
  565.     {
  566.         case (BTC_side == west) : {_side = "BTC_mobile_west";};
  567.         case (BTC_side == east) : {_side = "BTC_mobile_east";};
  568.         case (BTC_side == guer) : {_side = "BTC_mobile_guer";};
  569.     };
  570.     _mobile = objNull;
  571.     {
  572.         if ((typeName (_x getvariable _side)) == "STRING") then
  573.         {
  574.             if ((_x getvariable _side) == _var) then {_mobile = _x;};
  575.         };
  576.     } foreach vehicles;
  577.     if (isNull _mobile) exitWith {};
  578.     if (speed _mobile > 2) exitWith {hint "Mobile respawn is moving! Can't move there!";};
  579.     _pos = getPos _mobile;
  580.     titleText ["Get Ready", "BLACK OUT"];
  581.     sleep 3;
  582.     titleText ["Get Ready", "BLACK FADED"];
  583.     sleep 2;
  584.     titleText ["", "BLACK IN"];
  585.     player setPos [(_pos select 0) + ((random 50) - (random 50)), (_pos select 1) + ((random 50) - (random 50)), 0];
  586. };
  587. BTC_mobile_marker =
  588. {
  589.     _var = _this select 0;
  590.     _side = "";
  591.     switch (true) do
  592.     {
  593.         case (BTC_side == west) : {_side = "BTC_mobile_west";};
  594.         case (BTC_side == east) : {_side = "BTC_mobile_east";};
  595.         case (BTC_side == guer) : {_side = "BTC_mobile_guer";};
  596.     };
  597.     while {true} do
  598.     {
  599.         _obj = objNull;
  600.         while {isNull _obj} do
  601.         {
  602.             {
  603.                 if (format ["%1",_x getVariable _side] == _var && Alive _x) then {_obj = _x;};
  604.             } foreach vehicles;
  605.             sleep 1;
  606.         };
  607.         deleteMarkerLocal format ["%1", _var];
  608.         _marker = createmarkerLocal [format ["%1", _var], getPos _obj];
  609.         format ["%1", _var] setmarkertypelocal "mil_dot";
  610.         format ["%1", _var] setMarkerTextLocal format ["%1", _var];
  611.         format ["%1", _var] setmarkerColorlocal "ColorGreen";
  612.         format ["%1", _var] setMarkerSizeLocal [0.5, 0.5];
  613.         hint format ["%1 is available!", _var];
  614.         while {Alive _obj} do
  615.         {
  616.             format ["%1", _var] setMarkerPosLocal (getPos _obj);
  617.             if (speed _obj < 2) then {format ["%1", _var] setMarkerTextLocal format ["%1 deployed", _var];format ["%1", _var] setmarkerColorlocal "ColorGreen";} else {format ["%1", _var] setMarkerTextLocal format ["%1 is moving", _var];format ["%1", _var] setmarkerColorlocal "ColorBlack";};
  618.             sleep 1;
  619.         };
  620.         hint format ["%1 has been destroyed!", _var];
  621.         format ["%1", _var] setMarkerTextLocal format ["%1 destroyed!", _var];
  622.         format ["%1", _var] setmarkerColorlocal "ColorRed";
  623.         if (BTC_mobile_respawn == 0) exitWith {};
  624.     };
  625. };
  626. BTC_mobile_check =
  627. {
  628.     _var = str (_this select 0);
  629.     _side = "";
  630.     switch (true) do
  631.     {
  632.         case (BTC_side == west) : {_side = "BTC_mobile_west";};
  633.         case (BTC_side == east) : {_side = "BTC_mobile_east";};
  634.         case (BTC_side == guer) : {_side = "BTC_mobile_guer";};
  635.     };
  636.     _cond = false;
  637.     {
  638.         if ((typeName (_x getvariable _side)) == "STRING") then
  639.         {
  640.             if ((_x getvariable _side) == _var) then {_cond = true;};
  641.         };
  642.     } foreach vehicles;
  643.     _cond
  644. };
  645. BTC_vehicle_mobile_respawn =
  646. {
  647.     _veh  = _this select 0;
  648.     _var  = _this select 1;
  649.     _set  = _this select 2;
  650.     _type = typeOf _veh;
  651.     _pos  = getPos _veh;
  652.     _dir  = getDir _veh;
  653.     waitUntil {sleep 1; !Alive _veh};
  654.     _veh setVariable [_set,0,true];
  655.     sleep BTC_mobile_respawn_time;
  656.     _veh  = _type createVehicle _pos;
  657.     _veh setDir _dir;
  658.     _veh setVelocity [0, 0, -1];
  659.     _veh setVariable [_set,_var,true];
  660.     _resp = [_veh,_var,_set] spawn BTC_vehicle_mobile_respawn;
  661.     _veh setpos _pos;
  662. };
  663. BTC_out_of_lifes =
  664. {
  665.     removeAllWeapons player;
  666.     player enableSimulation false;
  667.     titleText ["You have no more lifes", "BLACK FADED"];//BLACK FADED
  668.     sleep 1;
  669.     while {true} do
  670.     {
  671.         player enableSimulation false;
  672.         player setpos [0,0,6000];
  673.         player setVelocity [0,0,0];
  674.         titleText ["You have no more lifes", "BLACK FADED"];
  675.         sleep 1;
  676.     };
  677. };
  678. BTC_revive_loop =
  679. {
  680.     while {true} do
  681.     {
  682.         sleep 1;
  683.         if (Alive player && format ["%1",player getVariable "BTC_need_revive"] != "1") then
  684.         {
  685.             //hintsilent format ["%1 %2",currentWeaponMode player,currentMagazineDetail player];
  686.             //diag_log text format ["SAVED %1",dialog];
  687.             BTC_gear = [] call BTC_get_gear;
  688.         };
  689.     };
  690. };
  691.  
  692.  
  693.  
  694.  
  695. fnc_find =
  696. {
  697. private ["_haystackCount", "_needleCount", "_foundPos",
  698.     "_haystackIndex", "_needleIndex","_haystack","_needle","_initialIndex"];
  699.  
  700. _haystack = _this select 0;
  701. _needle = _this select 1;
  702. _initialIndex = _this select 2;
  703.  
  704. if ((typeName _haystack) == "STRING") then
  705. {
  706.     _haystack = toArray _haystack;
  707. };
  708.  
  709. if ((typeName _needle) == "STRING") then
  710. {
  711.     _needle = toArray _needle;
  712. };
  713.  
  714. _haystackCount = count _haystack;
  715. _needleCount = count _needle;
  716. _foundPos = -1;
  717.  
  718. for [ { _haystackIndex = _initialIndex; _needleIndex = 0 },
  719.     { (_haystackIndex < _haystackCount) and (_foundPos == -1)},
  720.     { _haystackIndex = _haystackIndex + 1} ] do
  721. {
  722.     if ((_haystack select _haystackIndex) == (_needle select _needleIndex)) then
  723.     {
  724.         // Matched a single character.
  725.         _needleIndex = _needleIndex + 1;
  726.        
  727.         // Found the whole needle.
  728.         if (_needleIndex == _needleCount) then
  729.         {
  730.             _foundPos = _haystackIndex - (_needleCount - 1);
  731.         };
  732.     }
  733.     else{if (_needleIndex > 0) then
  734.     {
  735.         // Found only a partial needle; start again.
  736.         _haystackIndex = _haystackIndex - _needleIndex;
  737.         _needleIndex = 0;
  738.     }; };
  739. };
  740.  
  741. _foundPos;
  742. };
  743.  
  744.  
  745.  
  746. fnc_searchArray = {
  747.         private ["_needle","_haystack","_key","_i","_thisid","_found"];
  748.         _needle = _this select 0;
  749.         _haystack = _this select 1;        
  750.  
  751.         _found = false;
  752.         _key = -1;
  753.  
  754.             for [{_i=0},{_i < count _haystack && !_found},{_i=_i+1}] do    
  755.             {
  756.                  _thisHaystack = _haystack select _i;
  757.                  _thisid = [_thisHaystack,_needle,0] call fnc_find;
  758.                 // diag_log format ["fnc_searchArray (_thisid): %1",_thisid];
  759.                  
  760.                   if (_thisid != -1) then  {_key = _i;  
  761.                   //    diag_log format ["fnc_searchArray (_key): %1",_key];
  762.                     _found = true;
  763.                     };
  764.             };
  765.         _key;
  766.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement