Advertisement
Gr8Boi

Lift_init.sqf

Jul 20th, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.49 KB | None | 0 0
  1. /*
  2. Modified by Torndeco for DayZ Epoch
  3. All credits & rights go to =BTC= Giallustio
  4. Please don't bug original author about bugs that i have introduced.
  5. */
  6.  
  7. /*
  8. Created by =BTC= Giallustio
  9. Version: 0.52
  10. Date: 05/02/2012
  11. Visit us at: http://www.blacktemplars.altervista.org/
  12. You are not allowed to modify this file and redistribute it without permission given by me (Giallustio).
  13. */
  14.  
  15. 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"];
  16. if (isDedicated) exitwith {};
  17.  
  18. disableSerialization;
  19. _cargo = objNull;
  20. BTC_Hud_Shown = false;
  21. 90000 cutRsc ["BTC_Hud","PLAIN"];
  22. _ui = uiNamespace getVariable "HUD";
  23. _hud = _ui displayCtrl 1000;
  24. _radar = _ui displayCtrl 1001;
  25. _obj_img = _ui displayCtrl 1002;
  26. _obj_pic = _ui displayCtrl 1003;
  27. _arrow = _ui displayCtrl 1004;
  28. _obj_name = _ui displayCtrl 1005;
  29. _array_hud = [_hud, _radar,_obj_img,_obj_pic,_arrow,_obj_name];
  30. {_x ctrlShow false} foreach _array_hud;
  31. _chopper = objNull;_cargo_pos = [];_rel_pos = [];_cargo_x = 0;_cargo_y = 0;_cargo_z = 0;
  32. while {true} do
  33. {
  34. if (!Alive player) then {
  35. {_x ctrlShow false} foreach _array_hud;
  36. };
  37. if (BTC_Hud_Cond) then {
  38. {_x ctrlShow false} foreach _array_hud;
  39. BTC_Hud_Cond = false;
  40. };
  41.  
  42. waitUntil {
  43. sleep 1;
  44. (vehicle player != player && vehicle player iskindof "Helicopter" &&
  45. ((count([vehicle player] call BTC_Get_liftable_array)) > 0))
  46. };
  47.  
  48. if (!(vehicle player == player) && driver vehicle player == player) then {
  49. _chopper = vehicle player;
  50. if (BTC_Hud_Cond) then {
  51. BTC_liftHudId = _chopper addAction [("<t color=""#ED2744"">" + ("Lift Hud Off") + "</t>"),"=BTC=_Logistic\=BTC=_Lift\=BTC=_Hud.sqf", "", 0, false, false];
  52. } else {
  53. BTC_liftHudId = _chopper addAction [("<t color=""#ED2744"">" + ("Lift Hud On") + "</t>"),"=BTC=_Logistic\=BTC=_Lift\=BTC=_Hud.sqf", "", 0, false, false];
  54. };
  55. };
  56.  
  57. _array = [vehicle player] call BTC_get_liftable_array;
  58. while {!(vehicle player == player) && (driver vehicle player == player)} do
  59. {
  60. _chopper = vehicle player;
  61. _can_lift = false;
  62. _cargo_array = nearestObjects [_chopper, BTC_Liftable, 50];
  63.  
  64. if (count _cargo_array > 1) then {
  65. _cargo = objNull;
  66. _index = 0;
  67. _last_index = (count _cargo_array);
  68. _exit = false;
  69. waitUntil
  70. {
  71. _index = _index + 1;
  72. if (_index >= _last_index) then {
  73. _exit = true;
  74. } else {
  75. _cantsee = lineIntersects [getposASL(_chopper), getposASL((_cargo_array select _index)), _chopper, (_cargo_array select _index)];
  76. if (!_cantsee) then {
  77. _cargo = _cargo_array select _index;
  78. _exit = true;
  79. };
  80. };
  81. _exit
  82. };
  83. } else {
  84. _cargo = objNull;
  85. };
  86.  
  87. if (({_cargo isKindOf _x} count _array) > 0) then {
  88. _can_lift = true;
  89. };
  90. if (!BTC_Hud_Cond && BTC_Hud_Shown) then {
  91. {_x ctrlShow false} foreach _array_hud;
  92. BTC_Hud_Shown = false;
  93. };
  94. if (_cargo isKindOf "Air" && getdammage _cargo != 1) then {
  95. _can_lift = false;
  96. };
  97. if (!isNull _cargo && _can_lift) then {
  98. _cargo_pos = getPosATL _cargo;
  99. _rel_pos = _chopper worldToModel _cargo_pos;
  100. _cargo_x = _rel_pos select 0;
  101. _cargo_y = _rel_pos select 1;
  102. _cargo_z = _rel_pos select 2;
  103. };
  104. if (!isNull _cargo && BTC_Hud_Cond) then {
  105. if !(BTC_Hud_Shown) then {
  106. {_x ctrlShow true} foreach _array_hud;
  107. BTC_Hud_Shown = true;
  108. };
  109. if (_can_lift) then {
  110. _obj_img ctrlShow true;
  111. _hud_x = (_rel_pos select 0) / 100;
  112. _rel_y = (_rel_pos select 1);
  113. _hud_y = 0;
  114. switch (true) do {
  115. case (_rel_y < 0): {_hud_y = (abs _rel_y) / 100};
  116. case (_rel_y > 0): {_hud_y = (0 - _rel_y) / 100};
  117. };
  118. _hud_x_1 = BTC_HUD_x + _hud_x;
  119. _hud_y_1 = BTC_HUD_y + _hud_y;
  120. _obj_img ctrlsetposition [_hud_x_1, _hud_y_1];
  121. _obj_img ctrlCommit 0;
  122. } else {
  123. _obj_img ctrlShow false;
  124. };
  125.  
  126. _pic_cargo = "";
  127. if (_cargo isKindOf "LandVehicle") then {
  128. _pic_cargo = getText (configFile >> "cfgVehicles" >> typeof _cargo >> "picture");
  129. } else {
  130. _pic_cargo = "";
  131. };
  132.  
  133. _name_cargo = getText (configFile >> "cfgVehicles" >> typeof _cargo >> "displayName");
  134. _obj_pic ctrlSetText _pic_cargo;
  135. _obj_name ctrlSetText _name_cargo;
  136. if ((abs _cargo_z) > BTC_lift_max_h) then {
  137. _arrow ctrlSetText "\ca\ui\data\arrow_down_ca.paa";
  138. };
  139. if ((abs _cargo_z) < BTC_lift_min_h) then {
  140. _arrow ctrlSetText "\ca\ui\data\arrow_up_ca.paa";
  141. };
  142. if ((abs _cargo_z) > BTC_lift_min_h && (abs _cargo_z) < BTC_lift_max_h) then {
  143. if !(_cargo getVariable ["BTC_Cannot_Lift", false]) then {
  144. _arrow ctrlSetText "\ca\ui\data\objective_complete_ca.paa";
  145. } else {
  146. _arrow ctrlSetText "\ca\ui\data\lock_on_ca.paa";
  147. };
  148. };
  149. if (!_can_lift && BTC_Hud_Cond) then {
  150. _arrow ctrlSetText "\ca\ui\data\objective_incomplete_ca.paa";
  151. };
  152. } else {
  153. {_x ctrlShow false} foreach _array_hud;
  154. BTC_Hud_Shown = false;
  155. };
  156. if (!isNull _cargo && BTC_lifted == 0 && _can_lift) then {
  157. 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 {
  158. if (BTC_lifted == 1) then {
  159. _chopper removeAction BTC_liftActionId;
  160. if ((count (crew _cargo)) != 0) then {
  161. execVM "=BTC=_Logistic\=BTC=_Lift\=BTC=_detachCargo.sqf";
  162. };
  163. };
  164. if (BTC_lifted == 0 && BTC_lift == 1 && !(_cargo getVariable ["BTC_Cannot_Lift", false])) then {
  165. _name_cargo = getText (configFile >> "cfgVehicles" >> typeof _cargo >> "displayName");
  166. _text_action = ("<t color=""#ED2744"">" + "Lift " + (_name_cargo) + "</t>");
  167. BTC_liftActionId = _chopper addAction [_text_action, "=BTC=_Logistic\=BTC=_Lift\=BTC=_attachCargo.sqf", [_cargo, _name_cargo], 7, true, true];
  168. BTC_lift = 0;
  169. };
  170. };
  171. 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 {
  172. _chopper removeAction BTC_liftActionId;
  173. BTC_lift = 1;
  174. };
  175. };
  176. sleep 0.1;
  177. };
  178. _chopper removeAction BTC_liftHudId;
  179. if (BTC_lift == 0) then {
  180. _chopper removeAction BTC_liftActionId;
  181. BTC_lift = 1;
  182. };
  183. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement