ACE3/TO_MERGE/agm/WeaponSelect/functions/fn_selectGrenadeFrag.sqf

46 lines
1.4 KiB
Plaintext
Raw Normal View History

/*
* Author: CAA-Picard, commy2
*
* Cycle through frags.
*
* Argument:
* None
*
* Return value:
* None
*/
private ["_player", "_nextMuzzle"];
_player = _this select 0;
_nextMuzzle = ["Frag"] call AGM_WeaponSelect_fnc_findNextGrenadeMuzzle;
if (_nextMuzzle != "") then {
AGM_WeaponSelect_CurrentGrenadeMuzzleFrag = _nextMuzzle;
private ["_magazines", "_magazine", "_count", "_return"];
_magazines = AGM_WeaponSelect_FragMagazines select (AGM_WeaponSelect_FragMuzzles find _nextMuzzle);
reverse _magazines;
_magazine = "";
_count = {_return = _x in _magazines; if (_return) then {_magazine = _x}; _return} count magazines _player;
// There is a muzzle with magazines --> cycle to it
[_player, _nextMuzzle] call AGM_WeaponSelect_fnc_setNextGrenadeMuzzle;
[_magazine, _count] call AGM_WeaponSelect_fnc_displayGrenadeTypeAndNumber;
[uiNamespace getVariable "AGM_dlgSoldier", true] call AGM_WeaponSelect_fnc_toggleGrenadeCount;
} else {
// There is a no muzzle with magazines --> select nothing
AGM_WeaponSelect_CurrentGrenadeMuzzleFrag = "";
_text = [localize "STR_AGM_WeaponSelect_NoFragsLeft", [1,0,0]] call AGM_Core_fnc_stringToColoredText;
[composeText [lineBreak, _text]] call AGM_Core_fnc_displayTextStructured;
[uiNamespace getVariable "AGM_dlgSoldier", false] call AGM_WeaponSelect_fnc_toggleGrenadeCount;
};
AGM_WeaponSelect_CurrentGrenadeMuzzleIsFrag = true;