Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.13 KB | None | 0 0
  1. /*
  2. * KillzoneKid Way - Tankowanie pojazdu
  3. */
  4. HVR_fnc_setFuel = {
  5. params ["_vehicle"];
  6. if(local _vehicle) then {
  7. _vehicle setFuel 1;
  8. } else {
  9. HVR_PV_setFuel = _vehicle;
  10. if(isDedicated) then {
  11. (owner _vehicle) publicVariableClient "HVR_PV_setFuel";
  12. } else {
  13. publicVariableServer "HVR_PV_setFuel";
  14. };
  15. };
  16. };
  17. "HVR_PV_setFuel" addPublicVariableEventHandler {
  18. (_this select 1) call HVR_fnc_setFuel;
  19. };
  20.  
  21. /*
  22. * KillzoneKid Way - Naprawianie pojazdu
  23. */
  24. HVR_fnc_setDamage = {
  25. params ["_vehicle"];
  26. if(local _vehicle) then {
  27. _vehicle setDamage 0;
  28. } else {
  29. HVR_PV_setDamage = _vehicle;
  30. if(isDedicated) then {
  31. (owner _vehicle) publicVariableClient "HVR_PV_setDamage";
  32. } else {
  33. publicVariableServer "HVR_PV_setDamage";
  34. };
  35. };
  36. };
  37. "HVR_PV_setDamage" addPublicVariableEventHandler {
  38. (_this select 1) call HVR_fnc_setDamage;
  39. };
  40.  
  41. /*
  42. * KillzoneKid Way - Zmiana podwieszenia na pylonie
  43. */
  44. HVR_fnc_setPylonLoadout = {
  45. params ["_vehicle", "_pylonIndex", "_weapon"];
  46. if(local _vehicle) then {
  47. hint "OK_LOCAL";
  48. _vehicle setPylonLoadOut [(_pylonIndex + 1), _weapon];
  49. } else {
  50. HVR_PV_setPylonLoadout = [_vehicle, _pylonIndex, _weapon];
  51. if(isDedicated) then {
  52. hint str (owner _vehicle);
  53. (owner _vehicle) publicVariableClient "HVR_PV_setPylonLoadout";
  54. } else {
  55. hint "OK_PUBLIC_TO_SERVER";
  56. publicVariableServer "HVR_PV_setPylonLoadout";
  57. };
  58. };
  59. };
  60. "HVR_PV_setPylonLoadout" addPublicVariableEventHandler {
  61. hint "VAR_PUBLISHED";
  62. (_this select 1) call HVR_fnc_setPylonLoadout;
  63. };
  64.  
  65. /* ***** ***** ***** */
  66. /* ***** ***** ***** */
  67. /* ***** ***** ***** */
  68.  
  69. /*
  70. * Sprawdza czy gracz jest w jednej ze stref serwisowania
  71. */
  72. HVR_fnc_isPlayerInServiceArea = {
  73. _playerInArea = false;
  74. {
  75. if(player inArea _x) exitWith { _playerInArea = true; };
  76. } forEach HVR_arr_serviceAreas;
  77. _playerInArea;
  78. };
  79.  
  80. /*
  81. * Zwraca strefę serwisowania w której aktualnie znajduje się gracz
  82. */
  83. HVR_fnc_getPlayerServiceArea = {
  84. _serviceArea = 0;
  85. {
  86. if(player inArea _x) exitWith { _serviceArea = _x; };
  87. } forEach HVR_arr_serviceAreas;
  88. _serviceArea;
  89. };
  90.  
  91. /*
  92. * Zwraca tablicę z pojazdami które aktualnie są w danej strefie
  93. */
  94. HVR_fnc_getVehiclesInArea = {
  95. params ["_area"];
  96. _vehiclesInArea = [];
  97. {
  98. if(_x inArea _area) then { _vehiclesInArea pushBack _x; };
  99. } foreach vehicles;
  100. _vehiclesInArea;
  101. };
  102.  
  103. /*
  104. * Sprawdza czy w danej strefie są jakieś pojazdy
  105. */
  106. HVR_fnc_areVehiclesInArea = {
  107. params ["_area"];
  108. _areVehicleInArea = false;
  109. _numOfVehicles = count (_area call HVR_fnc_getVehiclesInArea);
  110. if(_numOfVehicles > 0) then { _areVehicleInArea = true; };
  111. _areVehicleInArea;
  112. };
  113.  
  114. /*
  115. * Zwraca tablicę z pojazdami, które są w strefie serwisowej, w której jest gracz
  116. */
  117. HVR_fnc_getVehiclesInPlayerArea = {
  118. _vehiclesInArea = ([] call HVR_fnc_getPlayerServiceArea) call HVR_fnc_getVehiclesInArea;
  119. _vehiclesInArea;
  120. };
  121.  
  122. /*
  123. * Sprawdza czy gracz może otworzyć panel serwisowania
  124. */
  125. HVR_fnc_canOpenVssDialog = {
  126. _canPlayerOpen = false;
  127. _isVehicleInPlayerArea = false;
  128. if(([] call HVR_fnc_isPlayerInServiceArea)) then {
  129. _area = [] call HVR_fnc_getPlayerServiceArea;
  130. if((_area call HVR_fnc_areVehiclesInArea)) then {
  131. _canPlayerOpen = true;
  132. };
  133. };
  134. _canPlayerOpen;
  135. };
  136.  
  137. /* *********************** */
  138. /* FUNKCJE OBSŁUGUJĄCE GUI */
  139. /* *********************** */
  140.  
  141. /*
  142. * Ustawia nagłówek Dialogu
  143. */
  144. HVR_fnc_guiSetHeading = {
  145. params ["_string"];
  146. ctrlSetText [1202, _string];
  147. ctrlShow [1202, true];
  148. };
  149.  
  150. /*
  151. * Ustawia tekst na przycisku
  152. */
  153. HVR_fnc_guiSetButtonText = {
  154. params ["_btnIndex","_string"];
  155. ctrlSetText [1601 + _btnIndex, _string];
  156. ctrlShow [1601 + _btnIndex, true];
  157. };
  158.  
  159. /*
  160. * Ustawia akcję na przycisku
  161. */
  162. HVR_fnc_guiSetButtonAction = {
  163. params ["_btnIndex","_string"];
  164. buttonSetAction [1601 + _btnIndex, _string];
  165. ctrlShow [1601 + _btnIndex, true];
  166. };
  167.  
  168. /*
  169. * Ukrywa przycisk
  170. */
  171. HVR_fnc_guiHideButton = {
  172. params ["_btnIndex"];
  173. ctrlShow [1601 + _btnIndex, false];
  174. };
  175.  
  176. /*
  177. * Usuwa akcję, tekst z wszystkich przycisków i ukrywa je
  178. */
  179. HVR_fnc_guiResetView = {
  180. "" call HVR_fnc_guiSetHeading;
  181. for [{_i=0}, {_i<20}, {_i=_i+1}] do
  182. {
  183. [_i, ""] call HVR_fnc_guiSetButtonText;
  184. [_i, ""] call HVR_fnc_guiSetButtonAction;
  185. _i call HVR_fnc_guiHideButton;
  186. };
  187. };
  188.  
  189. /*
  190. * Powraca do widoku bazowego
  191. */
  192. fnc_VssViewBackToBase = {
  193. _vehiclesArray = [] call HVR_fnc_getVehiclesInPlayerArea;
  194. [] call HVR_fnc_guiResetView;
  195. [_vehiclesArray] call HVR_fnc_guiBaseView;
  196. };
  197.  
  198. /*
  199. * Wywołuje akcję naprawy pojazdu
  200. */
  201. HVR_fnc_repairVehicle = {
  202. params ["_netId"];
  203. [] call HVR_fnc_guiResetView;
  204. _vehicle = missionNamespace getVariable _netId;
  205. [2, [_vehicle], "HVR_fnc_setDamage"] call HVR_fnc_afterTime;
  206. //[_vehicle] call HVR_fnc_setDamage;
  207. _netId call HVR_fnc_guiVehicle;
  208. };
  209.  
  210. /*
  211. * Wywołuje akcję tankowania pojazdu
  212. */
  213. HVR_fnc_refuelVehicle = {
  214. params ["_netId"];
  215. [] call HVR_fnc_guiResetView;
  216. _vehicle = missionNamespace getVariable _netId;
  217. [2, [_vehicle], "HVR_fnc_setFuel"] call HVR_fnc_afterTime;
  218. //[_vehicle] call HVR_fnc_setFuel;
  219. _netId call HVR_fnc_guiVehicle;
  220. };
  221.  
  222. /*
  223. * Wywołuje akcję zmiany podwieszenia w pojeździe na wskazabyn pylonie
  224. */
  225. HVR_fnc_pylonLoadout = {
  226. params ["_netId", "_pylonIndex", "_weapon"];
  227. [] call HVR_fnc_guiResetView;
  228. _vehicle = missionNamespace getVariable _netId;
  229. [2, [_vehicle, _pylonIndex, _weapon], "HVR_fnc_setPylonLoadout"] call HVR_fnc_afterTime;
  230. //[_vehicle, _pylonIndex, _weapon] call HVR_fnc_setPylonLoadout;
  231. [_netId] call HVR_fnc_guiWeaponLoadout;
  232. };
  233.  
  234. /*
  235. * Widok ustawiania uzbrojenia na pylonie
  236. */
  237. HVR_fnc_guiPylonLoadout = {
  238. params ["_vehicleNetId", "_pylonIndex"];
  239. [] call HVR_fnc_guiResetView;
  240. _compatiblePylonMagazines = (missionNamespace getVariable _vehicleNetId) getCompatiblePylonMagazines (_pylonIndex + 1);
  241. ("Wybierz jaki rodzaj uzbrojenia chcesz umieścić na podwieszeniu nr " + str (_pylonIndex + 1)) call HVR_fnc_guiSetHeading;
  242.  
  243. _btnIndex = 1;
  244. {
  245. _magName = getText (configFile >> "CfgMagazines" >> _x >> "DisplayName");
  246. [_forEachIndex, _magName] call HVR_fnc_guiSetButtonText;
  247. [_forEachIndex, "[" + (str _vehicleNetId) + ", " + (str _pylonIndex) + ", " + (str _x) + "] call HVR_fnc_pylonLoadout"] call HVR_fnc_guiSetButtonAction;
  248. _btnIndex = _forEachIndex;
  249. } forEach _compatiblePylonMagazines;
  250.  
  251. [(_btnIndex + 1), "Zdejmij uzbrojenie"] call HVR_fnc_guiSetButtonText;
  252. [(_btnIndex + 1), "[" + (str _vehicleNetId) + ", " + (str _pylonIndex) + ", """"] call HVR_fnc_pylonLoadout"] call HVR_fnc_guiSetButtonAction;
  253.  
  254. [19, "Powrót"] call HVR_fnc_guiSetButtonText;
  255. [19, "[" + (str _vehicleNetId) + "] call HVR_fnc_guiWeaponLoadout"] call HVR_fnc_guiSetButtonAction;
  256. };
  257.  
  258. /*
  259. * Widok wyboru pylonu do zmiany uzbrojenia
  260. */
  261. HVR_fnc_guiWeaponLoadout = {
  262. params ["_vehicleNetId"];
  263. [] call HVR_fnc_guiResetView;
  264. _vehicle = missionNamespace getVariable _vehicleNetId;
  265. _vehicleName = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "DisplayName");
  266.  
  267. ("Konfiguracja podwieszonego uzbrojenia: " + _vehicleName) call HVR_fnc_guiSetHeading;
  268. {
  269. _magName = getText (configFile >> "CfgMagazines" >> _x >> "DisplayName");
  270. if(_x == "") then { _magName = "Brak uzbrojenia"; };
  271. [_forEachIndex, _magName] call HVR_fnc_guiSetButtonText;
  272. [_forEachIndex, "[" + (str _vehicleNetId) + ", " + (str _forEachIndex) + "] call HVR_fnc_guiPylonLoadout"] call HVR_fnc_guiSetButtonAction;
  273. } forEach (getPylonMagazines _vehicle);
  274.  
  275. [19, "Powrót"] call HVR_fnc_guiSetButtonText;
  276. [19, "[" + (str _vehicleNetId) + "] call HVR_fnc_guiVehicle"] call HVR_fnc_guiSetButtonAction;
  277. };
  278.  
  279. /*
  280. * Widok pojazdu
  281. */
  282. HVR_fnc_guiVehicle = {
  283. params ["_vehicleNetId"];
  284. [] call HVR_fnc_guiResetView;
  285. _vehicle = missionNamespace getVariable _vehicleNetId;
  286. _vehicleName = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "DisplayName");
  287.  
  288. ("Serwisowanie pojazdu: " + _vehicleName) call HVR_fnc_guiSetHeading;
  289. private _btnIndex = 0;
  290.  
  291. _totalVehicleDamage = 0;
  292. {
  293. _totalVehicleDamage = _totalVehicleDamage + _x;
  294. } forEach ((getAllHitPointsDamage _vehicle) select 2);
  295.  
  296. if(_totalVehicleDamage > 0) then {
  297. _damageLevel = str ( floor ( 100 * (damage _vehicle)));
  298. [_btnIndex, "Napraw pojazd (" + _damageLevel + "%)"] call HVR_fnc_guiSetButtonText;
  299. [_btnIndex, "[" + (str _vehicleNetId) + "] call HVR_fnc_repairVehicle"] call HVR_fnc_guiSetButtonAction;
  300. _btnIndex = _btnIndex + 1;
  301. // Pojazd uszkodzony - opcja naprawy
  302. };
  303.  
  304. if((fuel _vehicle) < 1) then {
  305. _fuelLevel = str (floor (100 * (fuel _vehicle)));
  306. [_btnIndex, "Zatankuj pojazd (" + _fuelLevel + "%)"] call HVR_fnc_guiSetButtonText;
  307. [_btnIndex, "[" + (str _vehicleNetId) + "] call HVR_fnc_refuelVehicle"] call HVR_fnc_guiSetButtonAction;
  308. _btnIndex = _btnIndex + 1;
  309. // Brak paliwa - opcja tankowania
  310. };
  311.  
  312. if(count (getPylonMagazines _vehicle) > 0) then {
  313. [_btnIndex, "Zarządzaj podwieszeniem"] call HVR_fnc_guiSetButtonText;
  314. [_btnIndex, "[" + (str _vehicleNetId) + "] call HVR_fnc_guiWeaponLoadout"] call HVR_fnc_guiSetButtonAction;
  315. _btnIndex = _btnIndex + 1;
  316. // Pojazd posiada podwieszenia - akcja zarządzania podwieszeniami
  317. };
  318.  
  319. [19, "Powrót"] call HVR_fnc_guiSetButtonText;
  320. [19, "[] call fnc_VssViewBackToBase"] call HVR_fnc_guiSetButtonAction;
  321. };
  322.  
  323. /*
  324. * Widok bazowy
  325. */
  326. HVR_fnc_guiBaseView = {
  327. params ["_vehicles"];
  328. "Wybierz pojazd do serwisowania" call HVR_fnc_guiSetHeading;
  329. {
  330. _vehicleName = getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "DisplayName");
  331. [_forEachIndex, _vehicleName] call HVR_fnc_guiSetButtonText;
  332. [_forEachIndex, "[" + (str (_x call BIS_fnc_objectVar)) + "] call HVR_fnc_guiVehicle"] call HVR_fnc_guiSetButtonAction;
  333. } forEach _vehicles;
  334. };
  335.  
  336. /*
  337. * Otwarcie Dialogu
  338. */
  339. HVR_fnc_vssOpenDialog = {
  340. _vehiclesArray = [] call HVR_fnc_getVehiclesInPlayerArea;
  341. createDialog "MilTabletController";
  342. [] call HVR_fnc_guiResetView;
  343. [_vehiclesArray] call HVR_fnc_guiBaseView;
  344. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement