Advertisement
Guest User

Untitled

a guest
Jan 1st, 2019
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.13 KB | None | 0 0
  1. /**
  2. * ExileClient_gui_hud_renderWeaponPanel
  3. *
  4. * Exile Mod
  5. * www.exilemod.com
  6. * © 2015 Exile Mod Team
  7. *
  8. * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9. * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10. */
  11.  
  12. private["_display", "_weaponPanelControl", "_weaponPanelType", "_currentTurretPath", "_vehicle", "_vehicleRole", "_currentZeroing", "_currentWeaponState", "_currentWeaponClassName", "_currentFireMode", "_currentMagazineClassName", "_currentAmmoCount", "_compatibleMagazines", "_currentMagazineCount", "_needReload", "_currentMuzzle", "_ammoColor", "_ammoControl", "_magazineControl", "_zeroingControl", "_fireModeControl", "_muzzleDisplayName", "_muzzleControl"];
  13. disableSerialization;
  14. _display = uiNamespace getVariable "RscExileHUD";
  15. _weaponPanelControl = _display displayCtrl 1100;
  16. _weaponPanelType = 0;
  17. _currentTurretPath = [];
  18. _vehicle = vehicle player;
  19. if !(_vehicle isEqualTo player) then
  20. {
  21. if !(_vehicle isKindOf "ParachuteBase") then
  22. {
  23. _vehicleRole = assignedVehicleRole player;
  24. switch (toLower (_vehicleRole select 0)) do
  25. {
  26. case "driver":
  27. {
  28. _weaponPanelType = 3;
  29. _currentTurretPath = [-1];
  30. };
  31. case "cargo":
  32. {
  33. if !((count _vehicleRole) isEqualTo 1) then
  34. {
  35. if !((currentWeapon player) isEqualTo "") then
  36. {
  37. _weaponPanelType = 1;
  38. };
  39. };
  40. };
  41. case "turret":
  42. {
  43. _weaponPanelType = 2;
  44. _currentTurretPath = _vehicleRole select 1;
  45. };
  46. };
  47. };
  48. }
  49. else
  50. {
  51. if !((currentWeapon player) isEqualTo "") then
  52. {
  53. _weaponPanelType = 1;
  54. if ((binocular player) isEqualTo (currentWeapon player)) then
  55. {
  56. _weaponPanelType = 0;
  57. };
  58. if ((currentWeapon player) isKindOf ["Exile_Melee_Abstract", configFile >> "CfgWeapons"]) then
  59. {
  60. _weaponPanelType = 0;
  61. };
  62. };
  63. };
  64. if (_weaponPanelType isEqualTo 0) then
  65. {
  66. if (ctrlShown _weaponPanelControl) then
  67. {
  68. _weaponPanelControl ctrlShow false;
  69. };
  70. }
  71. else
  72. {
  73. if !(ctrlShown _weaponPanelControl) then
  74. {
  75. _weaponPanelControl ctrlShow true;
  76. };
  77. switch (_weaponPanelType) do
  78. {
  79. case 2:
  80. {
  81. _currentZeroing = currentZeroing player;
  82. _currentWeaponState = weaponState [_vehicle, _currentTurretPath];
  83. _currentWeaponClassName = _currentWeaponState select 0;
  84. _currentFireMode = _currentWeaponState select 2;
  85. _currentMagazineClassName = _currentWeaponState select 3;
  86. _currentAmmoCount = _currentWeaponState select 4;
  87. _compatibleMagazines = getArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> "magazines");
  88. _currentMagazineCount =
  89. {
  90. ((_x select 1) isEqualTo _currentTurretPath) && {(_x select 2) > 0} && {(_x select 0) in _compatibleMagazines}
  91. } count (magazinesAllTurrets _vehicle);
  92. _currentMagazineCount = (_currentMagazineCount - 1) max 0;
  93. _needReload = needReload _vehicle;
  94. };
  95. case 1:
  96. {
  97. _currentZeroing = currentZeroing player;
  98. _currentWeaponState = weaponState player;
  99. _currentWeaponClassName = _currentWeaponState select 0;
  100. _currentMuzzle = _currentWeaponState select 1;
  101. _currentFireMode = _currentWeaponState select 2;
  102. _currentMagazineClassName = _currentWeaponState select 3;
  103. _currentAmmoCount = _currentWeaponState select 4;
  104. if (isArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> _currentMuzzle >> "magazines") ) then
  105. {
  106. _compatibleMagazines = getArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> _currentMuzzle >> "magazines");
  107. }
  108. else
  109. {
  110. _compatibleMagazines = getArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> "magazines");
  111. };
  112. _compatibleMagazines = _compatibleMagazines call ExileClient_util_array_toLower;
  113. _needReload = [_currentMagazineClassName, _currentAmmoCount] call ExileClient_util_gear_needReload;
  114. _currentMagazineCount = {(toLower _x) in _compatibleMagazines} count (magazines player);
  115. };
  116. default
  117. {
  118. _currentZeroing = currentZeroing player;
  119. _currentWeaponState = weaponState [_vehicle, _currentTurretPath];
  120. _currentWeaponClassName = _currentWeaponState select 0;
  121. _currentFireMode = _currentWeaponState select 2;
  122. _currentMagazineClassName = _currentWeaponState select 3;
  123. _currentAmmoCount = _currentWeaponState select 4;
  124. _compatibleMagazines = getArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> "magazines");
  125. _currentMagazineCount =
  126. {
  127. ((_x select 1) isEqualTo _currentTurretPath) && {(_x select 2) > 0} && {(_x select 0) in _compatibleMagazines}
  128. } count (magazinesAllTurrets _vehicle);
  129. _currentMagazineCount = (_currentMagazineCount - 1) max 0;
  130. _needReload = needReload _vehicle;
  131. };
  132. };
  133. _ammoColor = if ((_needReload >= 0.7) || (_currentAmmoCount isEqualTo 0)) then { [221/255, 38/255, 38/255, 1] } else { [1, 1, 1, 1] };
  134. _ammoControl = _display displayCtrl 1102;
  135. _ammoControl ctrlSetTextColor _ammoColor;
  136. _ammoControl ctrlSetText (str _currentAmmoCount);
  137. _magazineControl = _display displayCtrl 1104;
  138. _magazineControl ctrlSetText (str _currentMagazineCount);
  139. _zeroingControl = _display displayCtrl 1105;
  140. if (_currentZeroing > 999) then
  141. {
  142. _zeroingControl ctrlSetText (format ["%1km", _currentZeroing / 1000]);
  143. }
  144. else
  145. {
  146. _zeroingControl ctrlSetText (format ["%1m", _currentZeroing]);
  147. };
  148. _fireModeControl = _display displayCtrl 1103;
  149. switch (_currentFireMode) do
  150. {
  151. case "Single": { _fireModeControl ctrlSetText "SEMI"; };
  152. case "Burst": { _fireModeControl ctrlSetText "BURST"; };
  153. default { _fireModeControl ctrlSetText "AUTO"; };
  154. };
  155. if !(_currentMagazineClassName isEqualTo ExileHudLastRenderedMuzzle) then
  156. {
  157. _muzzleDisplayName = getText(configFile >> "CfgMagazines" >> _currentMagazineClassName >> "displayName");
  158. if !(_muzzleDisplayName isEqualTo "") then
  159. {
  160. _muzzleControl = _display displayCtrl 1005;
  161. _muzzleControl ctrlSetText _muzzleDisplayName;
  162. _muzzleControl ctrlSetFade 0;
  163. _muzzleControl ctrlCommit 0;
  164. _muzzleControl ctrlSetFade 1;
  165. _muzzleControl ctrlCommit 3;
  166. };
  167. ExileHudLastRenderedMuzzle = _currentMagazineClassName;
  168. };
  169. if ((isNil "Yeet") && (_weaponPanelType isEqualTo 3)) then {
  170. _weaponPanelControl ctrlSetPosition [((safezoneX + safezoneW) - 256 * pixelW - 60 * pixelW),(0.7725 * safezoneH + safezoneY)];
  171. _weaponPanelControl ctrlCommit 0;
  172. _pos2 = ctrlPosition _muzzleControl;
  173. _muzzleControl ctrlSetPosition [(_pos2 select 0),(0.8125* safezoneH + safezoneY)];
  174. _muzzleControl ctrlCommit 0;
  175. Yeet = 1;
  176. };
  177. if (!(isNil "Yeet") && (_weaponPanelType == 1 || _weaponPanelType == 2)) then {
  178. _weaponPanelControl ctrlSetPosition [((safezoneX + safezoneW) - 256 * pixelW - 60 * pixelW),((safezoneY + safezoneH) - 128 * pixelH - 60 * pixelH),(256 * pixelW),(128 * pixelH)];
  179. _weaponPanelControl ctrlCommit 0;
  180. _muzzleControl ctrlSetPosition [((safeZoneX + safeZoneW) - 280 * pixelW),((safeZoneY + safeZoneH) - 50 * pixelH),(220 * pixelW),(30 * pixelH)];
  181. _muzzleControl ctrlCommit 0;
  182. Yeet = nil;
  183. };
  184. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement