diff --git a/addons/reload/CfgActions.hpp b/addons/reload/CfgActions.hpp index bdef8adf28..a76be64ba3 100644 --- a/addons/reload/CfgActions.hpp +++ b/addons/reload/CfgActions.hpp @@ -1,4 +1,3 @@ - class CfgActions { class LoadMagazine; class LoadEmptyMagazine : LoadMagazine { diff --git a/addons/reload/CfgEventHandlers.hpp b/addons/reload/CfgEventHandlers.hpp index c93f74e0bd..75c2280e24 100644 --- a/addons/reload/CfgEventHandlers.hpp +++ b/addons/reload/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit)); diff --git a/addons/reload/CfgVehicles.hpp b/addons/reload/CfgVehicles.hpp index 84333a1a09..b6bd212015 100644 --- a/addons/reload/CfgVehicles.hpp +++ b/addons/reload/CfgVehicles.hpp @@ -3,13 +3,13 @@ class CfgVehicles { class CAManBase: Man { class ACE_Actions { class ACE_Weapon { - class ACE_LinkBelt { + class GVAR(LinkBelt) { displayName = "$STR_ACE_Reload_LinkBelt"; distance = 2.0; condition = QUOTE([ARR_2(_player, _target)] call FUNC(canLinkBelt)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt)); }; - class ACE_CheckAmmo { + class GVAR(CheckAmmo) { displayName = "$STR_ACE_Reload_checkAmmo"; distance = 2.0; condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo)); @@ -23,7 +23,7 @@ class CfgVehicles { class StaticWeapon: LandVehicle { class ACE_Actions { class ACE_MainActions { - class ACE_CheckAmmo { + class GVAR(CheckAmmo) { displayName = "$STR_ACE_Reload_checkAmmo"; distance = 2.0; condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo)); diff --git a/addons/reload/XEH_postInit.sqf b/addons/reload/XEH_postInit.sqf index faefbe449d..422ea183d3 100644 --- a/addons/reload/XEH_postInit.sqf +++ b/addons/reload/XEH_postInit.sqf @@ -7,10 +7,9 @@ if !(hasInterface) exitWith {}; ["ACE3", QGVAR(checkAmmo), localize "STR_ACE_Reload_checkAmmo", { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, (vehicle ACE_player), ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific - if !([ACE_player] call EFUNC(common,canUseWeapon) || - {(vehicle ACE_player) isKindOf 'StaticWeapon'}) exitWith {false}; + if !([ACE_player] call EFUNC(common,canUseWeapon) || {(vehicle ACE_player) isKindOf "StaticWeapon"}) exitWith {false}; // Statement [ACE_player] call FUNC(checkAmmo); diff --git a/addons/reload/functions/fnc_canCheckAmmo.sqf b/addons/reload/functions/fnc_canCheckAmmo.sqf index 4075e7a151..95ac2582a2 100644 --- a/addons/reload/functions/fnc_canCheckAmmo.sqf +++ b/addons/reload/functions/fnc_canCheckAmmo.sqf @@ -7,7 +7,12 @@ * 1: Target * * Return value: - * Can link belt + * Can link belt + * + * Example: + * [player, bob] call ace_reload_fnc_canCheckAmmo + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/reload/functions/fnc_checkAmmo.sqf b/addons/reload/functions/fnc_checkAmmo.sqf index a1001890cd..2499a9a893 100644 --- a/addons/reload/functions/fnc_checkAmmo.sqf +++ b/addons/reload/functions/fnc_checkAmmo.sqf @@ -33,8 +33,6 @@ if (count _this > 1) then { if (_unit == _target) then { _unit playActionNow "Gear"; -} else { - _unit playActionNow "PutDown"; }; [FUNC(displayAmmo), [_target], 1, 0.1] call EFUNC(common,waitAndExecute); diff --git a/addons/reload/functions/fnc_displayAmmo.sqf b/addons/reload/functions/fnc_displayAmmo.sqf index 06f3a39da3..ce08fbd062 100644 --- a/addons/reload/functions/fnc_displayAmmo.sqf +++ b/addons/reload/functions/fnc_displayAmmo.sqf @@ -14,7 +14,7 @@ EXPLODE_1_PVT(_this,_target); -private ["_weapon","_muzzle","_magazine","_showNumber","_ammo","_maxRounds","_count","_text","_color","_picture", "_a", "_string"]; +private ["_weapon","_muzzle","_magazine","_showNumber","_ammo","_maxRounds","_count","_text","_color","_picture","_ammoBarsStructuredText", "_a", "_loadedName", "_string"]; _weapon = currentWeapon _target; _muzzle = currentMuzzle _target; @@ -22,23 +22,23 @@ _magazine = currentMagazine _target; // currentWeapon returns "" for static weapons before they are shot once if (_target isKindOf "StaticWeapon") then { - if (_weapon == "") then { - if (count (weapons _target) == 1) then { - _weapon = (weapons _target) select 0; - _muzzle = _weapon; - }; - }; - - if (_magazine == "") then { - // Try to get magazine using magazinesAmmoFull - private ["_magazines"]; - _magazines = magazinesAmmoFull _target; - { - if (_x select 2) exitWith { - _magazine = _x select 0; + if (_weapon == "") then { + if (count (weapons _target) == 1) then { + _weapon = (weapons _target) select 0; + _muzzle = _weapon; }; - } forEach _magazines; - }; + }; + + if (_magazine == "") then { + // Try to get magazine using magazinesAmmoFull + private ["_magazines"]; + _magazines = magazinesAmmoFull _target; + { + if (_x select 2) exitWith { + _magazine = _x select 0; + }; + } forEach _magazines; + }; }; if (_magazine == "") exitWith {}; @@ -52,55 +52,56 @@ _count = 0; // not grenade launcher if (_muzzle == _weapon) then { - _maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count") max 1; + _maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count") max 1; - _ammo = _target ammo _weapon; - if (_maxRounds >= COUNT_BARS) then { - _count = round (COUNT_BARS * _ammo / _maxRounds); + _ammo = _target ammo _weapon; + if (_maxRounds >= COUNT_BARS) then { + _count = round (COUNT_BARS * _ammo / _maxRounds); - if (_ammo > 0) then {_count = _count max 1}; - if (_ammo < _maxRounds) then {_count = _count min (COUNT_BARS - 1)}; - } else { - _count = _ammo; - }; + if (_ammo > 0) then {_count = _count max 1}; + if (_ammo < _maxRounds) then {_count = _count min (COUNT_BARS - 1)}; + } else { + _count = _ammo; + }; -// grenade launcher + // grenade launcher } else { - _showNumber = true; + _showNumber = true; - _count = if (_magazine != "") then { - {_x == _magazine} count (magazines _target + [_magazine]) - } else { - {_x in getArray (configFile >> "CfgWeapons" >> _weapon >> _muzzle >> "Magazines")} count magazines _target - }; + _count = if (_magazine != "") then { + {_x == _magazine} count (magazines _target + [_magazine]) + } else { + {_x in getArray (configFile >> "CfgWeapons" >> _weapon >> _muzzle >> "Magazines")} count magazines _target + }; }; -_text = if (_showNumber) then { - parseText format ["%1x", _count] +_ammoBarsStructuredText = if (_showNumber) then { + parseText format ["%1x", _count] } else { - _color = [ - 2 * (1 - _ammo / _maxRounds) min 1, - 2 * _ammo / _maxRounds min 1, - 00 - ]; + _color = [((2 * (1 - _ammo / _maxRounds)) min 1), ((2 * _ammo / _maxRounds) min 1), 0]; - _string = ""; - for "_a" from 1 to _count do { - _string = _string + "|"; - }; - _text = [_string, _color] call EFUNC(common,stringToColoredText); + _string = ""; + for "_a" from 1 to _count do { + _string = _string + "|"; + }; + _text = [_string, _color] call EFUNC(common,stringToColoredText); - _string = ""; - for "_a" from (_count + 1) to (_maxRounds min COUNT_BARS) do { - _string = _string + "|"; - }; + _string = ""; + for "_a" from (_count + 1) to (_maxRounds min COUNT_BARS) do { + _string = _string + "|"; + }; - composeText [ - _text, - [_string, [0.5, 0.5, 0.5]] call EFUNC(common,stringToColoredText) - ] + composeText [_text, [_string, [0.5, 0.5, 0.5]] call EFUNC(common,stringToColoredText)]; }; -_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture"); -[_text, _picture] call EFUNC(common,displayTextPicture); +if (_target isKindOf "StaticWeapon") then { + //Vehicle mags (usualy) don't have pictures, so just show the text above ammo count + _loadedName = getText (configFile >> "CfgMagazines" >> _magazine >> "displaynameshort"); + _loadedName = parseText format ["%1", _loadedName]; + _text = composeText [_loadedName, linebreak, _ammoBarsStructuredText]; + [_text] call EFUNC(common,displayTextStructured); +} else { + _picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture"); + [_ammoBarsStructuredText, _picture] call EFUNC(common,displayTextPicture); +};