2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2017-01-04 21:35:54 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Gets all magazines inside of a vehicle.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Vehicle <Object>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* 0: Ammo Array <ARRAY>
|
2023-08-09 03:51:20 +00:00
|
|
|
* - 0: Magazine Classname <STRING>
|
|
|
|
* - 1: Ammo Count <NUMBER>
|
2017-01-04 21:35:54 +00:00
|
|
|
* 1: Total Ammo Count <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [vehicle player] call ace_cookoff_fnc_getVehicleAmmo
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_vehicle"];
|
|
|
|
TRACE_1("getVehicleAmmo",_vehicle);
|
|
|
|
|
|
|
|
private _ammoToDetonate = [];
|
|
|
|
private _totalAmmo = 0;
|
|
|
|
|
|
|
|
// Get ammo from turrets
|
|
|
|
{
|
2021-10-14 15:49:27 +00:00
|
|
|
_x params ["_mag", "_turret", "_count"];
|
|
|
|
// if the turret is an FFV seat, it takes magazines from the soldier
|
2022-06-06 11:50:53 +00:00
|
|
|
if (_count > 0) then {
|
2023-03-18 19:24:27 +00:00
|
|
|
if (_mag call FUNC(isMagazineFlare)) then {continue};
|
2017-10-14 13:12:32 +00:00
|
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _mag >> "ammo");
|
|
|
|
private _model = getText (configFile >> "CfgAmmo" >> _ammo >> "model");
|
|
|
|
if (_model == "\A3\weapons_f\empty") exitWith {TRACE_3("skipping",_mag,_ammo,_model);};
|
2017-01-04 21:35:54 +00:00
|
|
|
_ammoToDetonate pushBack [_mag, _count];
|
|
|
|
_totalAmmo = _totalAmmo + _count;
|
|
|
|
};
|
2022-06-06 11:50:53 +00:00
|
|
|
} forEach (magazinesAllTurrets [_vehicle, true]);
|
2017-01-04 21:35:54 +00:00
|
|
|
|
|
|
|
// Get ammo from cargo space
|
|
|
|
{
|
|
|
|
_x params ["_mag", "_count"];
|
|
|
|
if (_count > 0) then {
|
2023-03-18 19:24:27 +00:00
|
|
|
if (_mag call FUNC(isMagazineFlare)) then {continue};
|
2017-01-04 21:35:54 +00:00
|
|
|
_ammoToDetonate pushBack [_mag, _count];
|
|
|
|
_totalAmmo = _totalAmmo + _count;
|
|
|
|
};
|
2021-10-14 15:49:27 +00:00
|
|
|
} forEach (magazinesAmmoCargo _vehicle);
|
2017-01-04 21:35:54 +00:00
|
|
|
|
|
|
|
// Get ammo from transportAmmo / ace_rearm
|
2021-02-18 18:58:08 +00:00
|
|
|
private _vehCfg = configOf _vehicle;
|
2017-10-14 13:12:32 +00:00
|
|
|
|
|
|
|
private _configSupply = (getNumber (_vehCfg >> "transportAmmo")) max (getNumber (_vehCfg >> QEGVAR(rearm,defaultSupply)));
|
|
|
|
if (_vehicle getVariable [QEGVAR(rearm,isSupplyVehicle), (_configSupply > 0)]) then {
|
2017-01-04 21:35:54 +00:00
|
|
|
TRACE_1("transportAmmo vehicle - adding virtual ammo",typeOf _vehicle);
|
|
|
|
|
|
|
|
_ammoToDetonate pushBack ["2000Rnd_65x39_belt", 2000];
|
|
|
|
_totalAmmo = _totalAmmo + 2000;
|
|
|
|
_ammoToDetonate pushBack ["20Rnd_105mm_HEAT_MP", 100];
|
|
|
|
_totalAmmo = _totalAmmo + 100;
|
2021-10-14 15:49:27 +00:00
|
|
|
_ammoToDetonate pushBack ["SatchelCharge_Remote_Mag", 10];
|
|
|
|
_totalAmmo = _totalAmmo + 10;
|
2017-01-04 21:35:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
[_ammoToDetonate, _totalAmmo]
|