2015-08-18 00:32:10 +00:00
|
|
|
/*
|
2017-09-29 19:53:25 +00:00
|
|
|
* Author: Tuupertunut
|
|
|
|
* Returns information about every magazine that can be rearmed in the vehicle. Multiple mags of
|
|
|
|
* same class in the same turret are grouped together for practical reasons.
|
2015-08-18 00:32:10 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2016-02-27 20:05:19 +00:00
|
|
|
* 0: Vehicle <OBJECT>
|
2015-08-18 00:32:10 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-09-29 19:53:25 +00:00
|
|
|
* Magazine info <ARRAY of ARRAYs>
|
|
|
|
* Child arrays:
|
|
|
|
* 0: Magazine class <STRING>
|
|
|
|
* 1: Turret path <ARRAY>
|
|
|
|
* 2: Is pylon magazine <BOOLEAN>
|
|
|
|
* 3: Pylon index (-1 if not pylon) <NUMBER>
|
|
|
|
* 4: Max magazines <NUMBER>
|
|
|
|
* 5: Current magazines <NUMBER>
|
|
|
|
* 6: Max rounds per magazine <NUMBER>
|
|
|
|
* 7: Current rounds in magazines <ARRAY of NUMBERs>
|
2015-08-18 00:32:10 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2017-09-29 19:53:25 +00:00
|
|
|
* [tank] call ace_rearm_fnc_getNeedRearmMagazines
|
2015-08-18 00:32:10 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
params ["_vehicle"];
|
2015-08-18 00:32:10 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
private _magazineInfo = [];
|
2015-08-18 00:32:10 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
// 1.70 pylons
|
|
|
|
private _pylonConfigs = configProperties [configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"];
|
|
|
|
{
|
|
|
|
private _pylonConfig = _x;
|
|
|
|
|
|
|
|
// Strangely, a 1-based index.
|
|
|
|
private _pylonIndex = _forEachIndex + 1;
|
|
|
|
|
|
|
|
// Retrieving pylon magazine by index. If the pylon is empty, it is marked with "".
|
|
|
|
private _pylonMagazine = (getPylonMagazines _vehicle) select (_pylonIndex - 1);
|
|
|
|
|
|
|
|
// Only care about pylons that have a magazine.
|
|
|
|
if (!(_pylonMagazine isEqualTo "")) then {
|
|
|
|
|
|
|
|
private _maxRounds = getNumber (configFile >> "CfgMagazines" >> _pylonMagazine >> "count");
|
|
|
|
private _currentRounds = _vehicle ammoOnPylon _pylonIndex;
|
|
|
|
|
|
|
|
if (_currentRounds < _maxRounds) then {
|
2017-09-30 16:14:41 +00:00
|
|
|
// getPylonTurret expects 0 based index, and returns driver turret as [-1]
|
|
|
|
private _pylonTurret = [_vehicle, (_pylonIndex - 1)] call EFUNC(common,getPylonTurret);
|
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
_magazineInfo pushBack [_pylonMagazine, _pylonTurret, true, _pylonIndex, 1, 1, _maxRounds, [_currentRounds]];
|
2015-08-18 00:32:10 +00:00
|
|
|
};
|
|
|
|
};
|
2017-09-29 19:53:25 +00:00
|
|
|
} forEach _pylonConfigs;
|
2015-08-18 00:32:10 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
private _turrets = [_vehicle] call FUNC(getAllRearmTurrets);
|
|
|
|
{
|
|
|
|
private _turretPath = _x;
|
|
|
|
private _magazines = [_vehicle, _turretPath] call FUNC(getTurretConfigMagazines);
|
2015-08-18 00:32:10 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
// _magazines without duplicates
|
|
|
|
private _magazineClasses = _magazines arrayIntersect _magazines;
|
|
|
|
|
2017-06-08 16:47:52 +00:00
|
|
|
{
|
2017-09-29 19:53:25 +00:00
|
|
|
private _magazineClass = _x;
|
|
|
|
|
|
|
|
private _maxMagazines = [_vehicle, _turretPath, _magazineClass] call FUNC(getMaxMagazines);
|
|
|
|
private _maxRoundsPerMag = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count");
|
|
|
|
|
|
|
|
/* Array of ammo counts in every magazine. Example: [200, 200, 152] means 2 mags with 200
|
|
|
|
* rounds and 1 mag with 152 rounds. */
|
|
|
|
private _currentRounds = [_vehicle, _turretPath, _magazineClass] call FUNC(getTurretMagazineAmmo);
|
|
|
|
private _currentMagazines = count _currentRounds;
|
2017-06-08 16:47:52 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
/* If there is space for new magazines or if some magazines are not full, add the magazine
|
|
|
|
* type to _magazineInfo. */
|
|
|
|
if ((_currentMagazines < _maxMagazines) || {({_x < _maxRoundsPerMag} count _currentRounds) > 0}) then {
|
|
|
|
_magazineInfo pushBack [_magazineClass, _turretPath, false, -1, _maxMagazines, _currentMagazines, _maxRoundsPerMag, _currentRounds];
|
2017-06-08 16:47:52 +00:00
|
|
|
};
|
2017-09-29 19:53:25 +00:00
|
|
|
|
|
|
|
} forEach _magazineClasses;
|
|
|
|
} forEach _turrets;
|
2017-06-08 16:47:52 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
TRACE_2("getNeedRearmMagazines",_vehicle,_magazineInfo);
|
|
|
|
_magazineInfo
|