|
8 | 8 | * 1: Vehicle <OBJECT> |
9 | 9 | * |
10 | 10 | * Return Value: |
11 | | - * Modified interaction menu <ARRAY> |
| 11 | + * Interaction menu <ARRAY> |
12 | 12 | * |
13 | 13 | * Example: |
14 | 14 | * [player, vehicle player] call AIMEE_change_ammo_fnc_magazinesVehicleMenus |
|
19 | 19 | params ["_unit", "_target"]; |
20 | 20 |
|
21 | 21 | private _turret = _target unitTurret _unit; |
22 | | -(weaponState [_target, _turret]) params ["_weapon", "_muzzle", "", "_magazine"]; |
23 | 22 |
|
24 | | -// Do not allow menu creation for vanilla autocannons that use different firemodes to switch ammunition types instead of magazines |
25 | | -if (_weapon in ["autocannon_40mm_CTWS", "autocannon_30mm_CTWS", "autocannon_30mm", "ACE_cannon_20mm_Rh202"]) exitWith {[]}; |
| 23 | +if (_turret isEqualTo []) exitWith { |
| 24 | + [] // return |
| 25 | +}; |
| 26 | + |
| 27 | +(weaponState [_target, _turret]) params ["_weapon", "_muzzle", "", "_magazine"]; |
26 | 28 |
|
27 | 29 | // Returns case correct magazines |
28 | | -private _allAvailableMags = (_target magazinesTurret [_turret, false]) call CBA_fnc_getArrayElements; |
29 | | -private _compatibleMags = compatibleMagazines [_weapon, _muzzle] - [_magazine]; |
| 30 | +private _magazines = (_target magazinesTurret [_turret, false]) call CBA_fnc_getArrayElements; |
| 31 | + |
| 32 | +if (_magazines isEqualTo []) exitWith { |
| 33 | + [] // return |
| 34 | +}; |
| 35 | + |
| 36 | +private _compatibleMags = (compatibleMagazines [_weapon, _muzzle]) - [_magazine]; |
30 | 37 | private _menus = []; |
31 | 38 | private _class = ""; |
32 | 39 | private _config = ""; |
33 | 40 | private _cfgMagazines = configFile >> "CfgMagazines"; |
34 | 41 |
|
35 | | -for "_i" from 0 to (count _allAvailableMags) - 2 step 2 do { |
36 | | - _class = _allAvailableMags select _i; |
| 42 | +for "_i" from 0 to (count _magazines) - 2 step 2 do { |
| 43 | + _class = _magazines select _i; |
37 | 44 |
|
38 | 45 | // Find compatible magazines |
39 | | - if (_class in _compatibleMags) then { |
40 | | - _config = _cfgMagazines >> _class; |
41 | | - |
42 | | - _menus pushBack [ |
43 | | - [ |
44 | | - format [QGVAR(magazineVehicle_%1), _class], // Action name |
45 | | - getText (_config >> "displayName"), // Name of action shown in menu |
46 | | - getText (_config >> "picture"), // Icon |
47 | | - {[_player, _target, _this select 2] call FUNC(loadMagazine)}, // Statement |
48 | | - {true}, // Condition |
49 | | - nil, |
50 | | - [_weapon, _muzzle, _class, _turret] // Action parameters |
51 | | - ] call ace_interact_menu_fnc_createAction, |
52 | | - [], |
53 | | - _target |
54 | | - ]; |
| 46 | + if !(_class in _compatibleMags) then { |
| 47 | + continue; |
55 | 48 | }; |
| 49 | + |
| 50 | + _config = _cfgMagazines >> _class; |
| 51 | + |
| 52 | + _menus pushBack [ |
| 53 | + [ |
| 54 | + format [QGVAR(magazineVehicle_%1), _class], // Action name |
| 55 | + getText (_config >> "displayName"), // Name of action shown in menu |
| 56 | + getText (_config >> "picture"), // Icon |
| 57 | + {[_player, _target, _this select 2] call FUNC(loadMagazine)}, // Statement |
| 58 | + {true}, // Condition |
| 59 | + nil, |
| 60 | + [_weapon, _muzzle, _class, _turret] // Action parameters |
| 61 | + ] call ace_interact_menu_fnc_createAction, |
| 62 | + [], |
| 63 | + _target |
| 64 | + ]; |
56 | 65 | }; |
57 | 66 |
|
58 | | -_menus |
| 67 | +_menus // return |
0 commit comments