2015-01-17 17:26:51 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: esteldunedain
|
2015-01-17 17:26:51 +00:00
|
|
|
* Select the next grenade muzzle to throw.
|
|
|
|
*
|
2015-08-08 12:40:23 +00:00
|
|
|
* Arguments:
|
2015-08-04 01:08:21 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Muzzlename <STRING>
|
2015-01-17 17:26:51 +00:00
|
|
|
*
|
2015-08-08 12:40:23 +00:00
|
|
|
* Return Value:
|
2015-01-17 17:26:51 +00:00
|
|
|
* None
|
2015-08-08 12:40:23 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, currentMuzzle player] call ace_weaponselect_fnc_setNextGrenadeMuzzle
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-17 17:26:51 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-04-17 20:45:00 +00:00
|
|
|
private ["_uniformMags", "_vestMags", "_backpackMags", "_i", "_uniformMagsToRemove", "_vestMagsToRemove", "_backpackMagsToRemove", "_firstMagazine", "_throwMuzzleNames"];
|
2015-01-17 17:26:51 +00:00
|
|
|
|
2015-08-04 01:08:21 +00:00
|
|
|
params ["_unit", "_muzzle"];
|
|
|
|
|
2015-01-17 17:26:51 +00:00
|
|
|
_uniformMags = getMagazineCargo uniformContainer _unit;
|
|
|
|
_vestMags = getMagazineCargo vestContainer _unit;
|
2015-04-17 20:45:00 +00:00
|
|
|
_backpackMags = getMagazineCargo backpackContainer _unit;
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
_uniformMagsToRemove = [];
|
|
|
|
_vestMagsToRemove = [];
|
2015-04-17 20:45:00 +00:00
|
|
|
_backpackMagsToRemove = [];
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
_firstMagazine = "";
|
|
|
|
_throwMuzzleNames = getArray (configfile >> "CfgWeapons" >> "Throw" >> "muzzles");
|
|
|
|
|
|
|
|
// Collect which magazines to remove
|
|
|
|
{
|
|
|
|
private "_muzzleMagazines";
|
|
|
|
_muzzleMagazines = getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines" );
|
|
|
|
|
|
|
|
if (_x != _muzzle) then {
|
|
|
|
|
|
|
|
{
|
|
|
|
private "_index";
|
|
|
|
_index = (_uniformMags select 0) find _x;
|
|
|
|
if (_index > -1) then {
|
|
|
|
_uniformMagsToRemove = _uniformMagsToRemove + [[_x, (_uniformMags select 1) select _index]];
|
|
|
|
};
|
|
|
|
|
|
|
|
_index = (_vestMags select 0) find _x;
|
|
|
|
if (_index > -1) then {
|
|
|
|
_vestMagsToRemove = _vestMagsToRemove + [[_x, (_vestMags select 1) select _index]];
|
|
|
|
};
|
|
|
|
|
|
|
|
_index = (_backpackMags select 0) find _x;
|
|
|
|
if (_index > -1) then {
|
|
|
|
_backpackMagsToRemove = _backpackMagsToRemove + [[_x, (_backpackMags select 1) select _index]];
|
|
|
|
};
|
|
|
|
} forEach _muzzleMagazines;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
{
|
|
|
|
private "_index";
|
|
|
|
_index = (_uniformMags select 0) find _x;
|
|
|
|
if (_index > -1) then {
|
|
|
|
_firstMagazine = _x;
|
|
|
|
};
|
|
|
|
|
|
|
|
_index = (_vestMags select 0) find _x;
|
|
|
|
if (_index > -1) then {
|
|
|
|
_firstMagazine = _x;
|
|
|
|
};
|
|
|
|
|
|
|
|
_index = (_backpackMags select 0) find _x;
|
|
|
|
if (_index > -1) then {
|
|
|
|
_firstMagazine = _x;
|
|
|
|
};
|
|
|
|
} forEach _muzzleMagazines;
|
|
|
|
|
|
|
|
};
|
|
|
|
} forEach _throwMuzzleNames;
|
|
|
|
|
|
|
|
// Remove all magazines except those we are switching to --> this breaks the selector
|
|
|
|
{
|
|
|
|
for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do {
|
|
|
|
_unit removeItem (_x select 0);
|
|
|
|
};
|
|
|
|
} forEach _uniformMagsToRemove;
|
|
|
|
|
|
|
|
{
|
|
|
|
for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do {
|
|
|
|
_unit removeItem (_x select 0);
|
|
|
|
};
|
|
|
|
} forEach _vestMagsToRemove;
|
|
|
|
|
|
|
|
{
|
|
|
|
for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do {
|
|
|
|
_unit removeItem (_x select 0);
|
|
|
|
};
|
2015-04-17 20:45:00 +00:00
|
|
|
} forEach _backpackMagsToRemove;
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
// Readd magazines
|
|
|
|
{
|
|
|
|
for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do {
|
2015-03-24 04:18:00 +00:00
|
|
|
_unit addItemToUniform (_x select 0);
|
2015-01-17 17:26:51 +00:00
|
|
|
};
|
|
|
|
} forEach _uniformMagsToRemove;
|
|
|
|
|
|
|
|
{
|
|
|
|
for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do {
|
2015-03-24 04:18:00 +00:00
|
|
|
_unit addItemToVest (_x select 0);
|
2015-01-17 17:26:51 +00:00
|
|
|
};
|
|
|
|
} forEach _vestMagsToRemove;
|
|
|
|
|
|
|
|
{
|
|
|
|
for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do {
|
2015-03-24 04:18:00 +00:00
|
|
|
_unit addItemToBackpack (_x select 0);
|
2015-01-17 17:26:51 +00:00
|
|
|
};
|
2015-04-17 20:45:00 +00:00
|
|
|
} forEach _backpackMagsToRemove;
|