Advertisement
Guest User

Untitled

a guest
Jul 10th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.04 KB | None | 0 0
  1. private ["_chopper","_exit","_cargo","_cantsee","_index","_last_index","_can_lift","_cargo_pos","_rel_pos","_cargo_x","_cargo_y","_cargo_z","_hud_y","_hud_x","_rel_y","_hud_x_1","_hud_y_1","_pic_cargo","_name_cargo","_text_action","_cargo_array","_array","_ui","_hud","_radar","_obj_img","_obj_pic","_arrow","_obj_name","_array_hud"];
  2. if (isDedicated) exitwith {};
  3.  
  4. disableSerialization;
  5. _cargo = objNull;
  6. BTC_Hud_Shown = false;
  7. 90000 cutRsc ["BTC_Hud","PLAIN"];
  8. _ui        = uiNamespace getVariable "HUD";
  9. _hud       = _ui displayCtrl 1000;
  10. _radar     = _ui displayCtrl 1001;
  11. _obj_img   = _ui displayCtrl 1002;
  12. _obj_pic   = _ui displayCtrl 1003;
  13. _arrow     = _ui displayCtrl 1004;
  14. _obj_name  = _ui displayCtrl 1005;
  15. _array_hud = [_hud, _radar,_obj_img,_obj_pic,_arrow,_obj_name];
  16. {_x ctrlShow false} foreach _array_hud;
  17. _chopper = objNull;_cargo_pos = [];_rel_pos = [];_cargo_x = 0;_cargo_y = 0;_cargo_z = 0;
  18. while {true} do
  19. {
  20.     if (!Alive player) then {
  21.         {_x ctrlShow false} foreach _array_hud;
  22.     };
  23.     if (BTC_Hud_Cond) then {
  24.         {_x ctrlShow false} foreach _array_hud;
  25.         BTC_Hud_Cond = false;
  26.     };
  27.    
  28.     waitUntil {
  29.         uiSleep 1;
  30.         (vehicle player != player && vehicle player iskindof "Helicopter" &&
  31.         ((count([vehicle player] call BTC_Get_liftable_array)) > 0))
  32.     };
  33.    
  34.     if (!(vehicle player == player) && driver vehicle player == player) then {
  35.         _chopper = vehicle player;
  36.         if (BTC_Hud_Cond) then {
  37.             BTC_liftHudId = _chopper addAction [("<t color=""#ED2744"">" + ("Выкл Lift HUD") + "</t>"),"scripts\=BTC=_Logistic\lift\hud.sqf", "", 0, false, false];
  38.         } else {
  39.             BTC_liftHudId = _chopper addAction [("<t color=""#ED2744"">" + ("Вкл Lift HUD") + "</t>"),"scripts\=BTC=_Logistic\lift\hud.sqf", "", 0, false, false];
  40.         };
  41.     };
  42.  
  43.     _array = [vehicle player] call BTC_get_liftable_array;
  44.     while {!(vehicle player == player) && (driver vehicle player == player)} do
  45.     {
  46.         _chopper  = vehicle player;
  47.         _can_lift = false;
  48.         _cargo_array = nearestObjects [_chopper, BTC_Liftable, 50];
  49.        
  50.         if (count _cargo_array > 1) then {
  51.             _cargo = objNull;
  52.             _index = 0;
  53.             _last_index = (count _cargo_array);
  54.             _exit = false;
  55.             waitUntil
  56.             {
  57.                 _index = _index + 1;
  58.                 if (_index >= _last_index) then {
  59.                     _exit = true;
  60.                 } else {
  61.                     _cantsee = lineIntersects [getposASL(_chopper), getposASL((_cargo_array select _index)), _chopper, (_cargo_array select _index)];
  62.                     if (!_cantsee) then {
  63.                         _cargo = _cargo_array select _index;
  64.                         _exit = true;
  65.                     };
  66.                 };
  67.                 _exit
  68.             };
  69.         } else {
  70.             _cargo = objNull;
  71.         };
  72.        
  73.         if (({_cargo isKindOf _x} count _array) > 0) then {
  74.             _can_lift = true;
  75.         };
  76.         if (!BTC_Hud_Cond && BTC_Hud_Shown) then {
  77.             {_x ctrlShow false} foreach _array_hud;
  78.             BTC_Hud_Shown = false;
  79.         };
  80.         if (_cargo isKindOf "Air" && getdammage _cargo != 1) then {
  81.             _can_lift = false;
  82.         };
  83.         if (!isNull _cargo && _can_lift) then {
  84.             _cargo_pos = getPosATL _cargo;
  85.             _rel_pos   = _chopper worldToModel _cargo_pos;
  86.             _cargo_x   = _rel_pos select 0;
  87.             _cargo_y   = _rel_pos select 1;
  88.             _cargo_z   = _rel_pos select 2;
  89.         };
  90.         if (!isNull _cargo && BTC_Hud_Cond) then {
  91.             if !(BTC_Hud_Shown) then {
  92.                 {_x ctrlShow true} foreach _array_hud;
  93.                 BTC_Hud_Shown = true;
  94.             };
  95.             if (_can_lift) then {
  96.                 _obj_img ctrlShow true;
  97.                 _hud_x   = (_rel_pos select 0) / 100;
  98.                 _rel_y   = (_rel_pos select 1);
  99.                 _hud_y   = 0;
  100.                 switch (true) do {
  101.                     case (_rel_y < 0): {_hud_y = (abs _rel_y) / 100};
  102.                     case (_rel_y > 0): {_hud_y = (0 - _rel_y) / 100};
  103.                 };
  104.                 _hud_x_1 = BTC_HUD_x + _hud_x;
  105.                 _hud_y_1 = BTC_HUD_y + _hud_y;
  106.                 _obj_img ctrlsetposition [_hud_x_1, _hud_y_1];
  107.                 _obj_img ctrlCommit 0;
  108.             } else {
  109.                 _obj_img ctrlShow false;
  110.             };
  111.            
  112.             _pic_cargo = "";
  113.             if (_cargo isKindOf "LandVehicle") then {
  114.                 _pic_cargo = getText (configFile >> "cfgVehicles" >> typeof _cargo >> "picture");
  115.             } else {
  116.                 _pic_cargo = "";
  117.             };
  118.            
  119.             _name_cargo = getText (configFile >> "cfgVehicles" >> typeof _cargo >> "displayName");
  120.             _obj_pic ctrlSetText _pic_cargo;
  121.             _obj_name ctrlSetText _name_cargo;
  122.             if ((abs _cargo_z) > BTC_lift_max_h) then {
  123.                 _arrow ctrlSetText "\ca\ui\data\arrow_down_ca.paa";
  124.             };
  125.             if ((abs _cargo_z) < BTC_lift_min_h) then {
  126.                 _arrow ctrlSetText "\ca\ui\data\arrow_up_ca.paa";
  127.             };
  128.             if ((abs _cargo_z) > BTC_lift_min_h && (abs _cargo_z) < BTC_lift_max_h) then {
  129.                 if !(_cargo getVariable ["BTC_Cannot_Lift", false]) then {
  130.                     _arrow ctrlSetText "\ca\ui\data\objective_complete_ca.paa";
  131.                 } else {
  132.                     _arrow ctrlSetText "\ca\ui\data\lock_on_ca.paa";
  133.                 };
  134.             };
  135.             if (!_can_lift && BTC_Hud_Cond) then {
  136.                 _arrow ctrlSetText "\ca\ui\data\objective_incomplete_ca.paa";
  137.             };
  138.         } else {
  139.             {_x ctrlShow false} foreach _array_hud;
  140.             BTC_Hud_Shown = false;
  141.         };
  142.         if (!isNull _cargo && BTC_lifted == 0 && _can_lift) then {
  143.             if (((abs _cargo_z) < BTC_lift_max_h) && ((abs _cargo_z) > BTC_lift_min_h) && ((abs _cargo_x) < BTC_lift_radius) && ((abs _cargo_y) < BTC_lift_radius)) then {
  144.                 if (BTC_lifted == 0 && BTC_lift == 1  && !(_cargo getVariable ["BTC_Cannot_Lift", false])) then {
  145.                     _name_cargo  = getText (configFile >> "cfgVehicles" >> typeof _cargo >> "displayName");
  146.                     _text_action = ("<t color=""#ED2744"">" + "Поднять " + (_name_cargo) + "</t>");
  147.                     BTC_liftActionId = _chopper addAction [_text_action, "scripts\=BTC=_Logistic\lift\attachCargo.sqf", [_cargo, _name_cargo], 7, true, true];
  148.                     BTC_lift = 0;
  149.                 };
  150.             };
  151.             if ((_cargo getVariable ["BTC_Cannot_Lift", false]) || (BTC_lift == 0 && (((abs _cargo_z) > BTC_lift_max_h) || ((abs _cargo_z) < BTC_lift_min_h) || ((abs _cargo_x) > BTC_lift_radius) || ((abs _cargo_y) > BTC_lift_radius)))) then {
  152.                 _chopper removeAction BTC_liftActionId;
  153.                 BTC_lift = 1;
  154.             };
  155.         };
  156.         if ((BTC_lifted == 1) && ((count (crew _cargo)) != 0)) then {
  157.             execVM "scripts\=BTC=_Logistic\lift\detachCargo.sqf";
  158.         };
  159.         uiSleep 0.1;
  160.     };
  161.     _chopper removeAction BTC_liftHudId;
  162.     if (BTC_lift == 0) then {
  163.         _chopper removeAction BTC_liftActionId;
  164.         BTC_lift = 1;
  165.     };
  166. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement