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

33 lines
1.0 KiB
Plaintext

// by commy2
private ["_scope", "_allMags", "_allMuzzles", "_magazines", "_start", "_index", "_nextMagazine"];
_scope = _this select 0; //"All", "Frag" or "NonFrag"
_allMags = missionNamespace getVariable [format ["AGM_WeaponSelect_%1Magazines", _scope], []];
_allMuzzles = missionNamespace getVariable [format ["AGM_WeaponSelect_%1Muzzles", _scope], []];
_magazines = magazines AGM_player;
_start = [AGM_WeaponSelect_CurrentGrenadeMuzzleOther, AGM_WeaponSelect_CurrentGrenadeMuzzleFrag] select AGM_WeaponSelect_CurrentGrenadeMuzzleIsFrag;
_index = _allMuzzles find _start;
scopeName "SearchMain";
_nextMagazine = "";
for "_index" from (_index + 1) to (count _allMuzzles - 1) do {
{
if (_x in (_allMags select _index)) exitWith {_nextMagazine = _x; breakTo "SearchMain"};
} count _magazines;
};
if (_nextMagazine != "") exitWith {_nextMagazine};
for "_index" from 0 to _index do {
{
if (_x in (_allMags select _index)) exitWith {_nextMagazine = _x; breakTo "SearchMain"};
} count _magazines;
};
_nextMagazine