Advertisement
AdamKadmon

Untitled

Dec 28th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 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", "_currentMuzzle", "_currentFireMode", "_currentMagazineClassName", "_currentAmmoCount", "_currentMagazineCount", "_needReload", "_compatibleMagazines", "_ammoColor", "_ammoControl", "_formattedAmmoCount", "_magazineControl", "_zeroingControl", "_fireModeControl", "_muzzleDisplayName", "_muzzleControl"];
  13. disableSerialization;
  14. _display = uiNamespace getVariable "RscExileHUD";
  15. _weaponPanelControl = _display displayCtrl 1100;
  16. _weaponPanelType = 0;
  17. _currentTurretPath = -1;
  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 = 0;
  29. };
  30. case "cargo":
  31. {
  32. if !((count _vehicleRole) isEqualTo 1) then
  33. {
  34. if !((currentWeapon player) isEqualTo "") then
  35. {
  36. _weaponPanelType = 1;
  37. };
  38. };
  39. };
  40. case "turret":
  41. {
  42. _weaponPanelType = 2;
  43. _currentTurretPath = (_vehicleRole select 1) select 0;
  44. };
  45. };
  46. };
  47. }
  48. else
  49. {
  50. if !((currentWeapon player) isEqualTo "") then
  51. {
  52. _weaponPanelType = 1;
  53. if ((binocular player) isEqualTo (currentWeapon player)) then
  54. {
  55. _weaponPanelType = 0;
  56. };
  57. if ((currentWeapon player) isKindOf ["Exile_Melee_Abstract", configFile >> "CfgWeapons"]) then
  58. {
  59. _weaponPanelType = 0;
  60. };
  61. };
  62. };
  63. if (_weaponPanelType isEqualTo 0) then
  64. {
  65. if (ctrlShown _weaponPanelControl) then
  66. {
  67. _weaponPanelControl ctrlShow false;
  68. };
  69. }
  70. else
  71. {
  72. if !(ctrlShown _weaponPanelControl) then
  73. {
  74. _weaponPanelControl ctrlShow true;
  75. };
  76. switch (_weaponPanelType) do
  77. {
  78. case 2:
  79. {
  80. _currentZeroing = currentZeroing player;
  81. _currentWeaponState = weaponState [_vehicle, [_currentTurretPath]];
  82. _currentWeaponClassName = _currentWeaponState select 0;
  83. _currentMuzzle = _currentWeaponState select 1;
  84. _currentFireMode = _currentWeaponState select 2;
  85. _currentMagazineClassName = _currentWeaponState select 3;
  86. _currentAmmoCount = _currentWeaponState select 4;
  87. _currentMagazineCount = ((count (magazinesAmmoFull _vehicle)) - 1) max 0;
  88. _needReload = needReload _vehicle;
  89. };
  90. case 1:
  91. {
  92. _currentZeroing = currentZeroing player;
  93. _currentWeaponState = weaponState player;
  94. _currentWeaponClassName = _currentWeaponState select 0;
  95. _currentMuzzle = _currentWeaponState select 1;
  96. _currentFireMode = _currentWeaponState select 2;
  97. _currentMagazineClassName = _currentWeaponState select 3;
  98. _currentAmmoCount = _currentWeaponState select 4;
  99. _currentMagazineCount = 0;
  100. if (isArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> _currentMuzzle >> "magazines") ) then
  101. {
  102. _compatibleMagazines = getArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> _currentMuzzle >> "magazines");
  103. _compatibleMagazines = _compatibleMagazines call ExileClient_util_array_toLower;
  104. }
  105. else
  106. {
  107. _compatibleMagazines = getArray (configFile >> "CfgWeapons" >> _currentWeaponClassName >> "magazines");
  108. _compatibleMagazines = _compatibleMagazines call ExileClient_util_array_toLower;
  109. };
  110. _needReload = [_currentMagazineClassName, _currentAmmoCount] call ExileClient_util_gear_needReload;
  111. {
  112. if ((toLower _x) in _compatibleMagazines) then
  113. {
  114. _currentMagazineCount = _currentMagazineCount + 1;
  115. };
  116. }
  117. forEach (magazines player);
  118. };
  119. };
  120. _ammoColor = if ((_needReload >= 0.7) || (_currentAmmoCount isEqualTo 0)) then { [221/255, 38/255, 38/255, 1] } else { [1, 1, 1, 1] };
  121. _ammoControl = _display displayCtrl 1102;
  122. _ammoControl ctrlSetTextColor _ammoColor;
  123. if (_currentAmmoCount > 999) then
  124. {
  125. _formattedAmmoCount = [_currentAmmoCount/1000, 1] call ExileClient_util_math_floor;
  126. _currentAmmoCount = format ["%1k", _formattedAmmoCount];
  127. _ammoControl ctrlSetText _currentAmmoCount;
  128. }
  129. else
  130. {
  131. _ammoControl ctrlSetText (str _currentAmmoCount);
  132. };
  133. _magazineControl = _display displayCtrl 1104;
  134. _magazineControl ctrlSetText (str _currentMagazineCount);
  135. _zeroingControl = _display displayCtrl 1105;
  136. if (_currentZeroing > 999) then
  137. {
  138. _zeroingControl ctrlSetText (format ["%1km", _currentZeroing / 1000]);
  139. }
  140. else
  141. {
  142. _zeroingControl ctrlSetText (format ["%1m", _currentZeroing]);
  143. };
  144. _fireModeControl = _display displayCtrl 1103;
  145. switch (_currentFireMode) do
  146. {
  147. case "Single": { _fireModeControl ctrlSetText "SEMI"; };
  148. case "Burst": { _fireModeControl ctrlSetText "BURST"; };
  149. default { _fireModeControl ctrlSetText "AUTO"; };
  150. };
  151. if !(_currentMagazineClassName isEqualTo ExileHudLastRenderedMuzzle) then
  152. {
  153. _muzzleDisplayName = getText(configFile >> "CfgMagazines" >> _currentMagazineClassName >> "displayName");
  154. if !(_muzzleDisplayName isEqualTo "") then
  155. {
  156. _muzzleControl = _display displayCtrl 1005;
  157. _muzzleControl ctrlSetText _muzzleDisplayName;
  158. _muzzleControl ctrlSetFade 0;
  159. _muzzleControl ctrlCommit 0;
  160. _muzzleControl ctrlSetFade 1;
  161. _muzzleControl ctrlCommit 3;
  162. };
  163. ExileHudLastRenderedMuzzle = _currentMagazineClassName;
  164. };
  165. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement