2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2017-01-04 21:35:54 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
2024-06-05 19:36:39 +00:00
|
|
|
* Gets all magazines inside of an object.
|
2017-01-04 21:35:54 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2024-06-05 19:36:39 +00:00
|
|
|
* 0: Object <OBJECT>
|
2017-01-04 21:35:54 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2024-06-05 19:36:39 +00:00
|
|
|
* 0: Ammo array <ARRAY>
|
|
|
|
* - 0: Magazine classname <STRING>
|
|
|
|
* - 1: Ammo count <NUMBER>
|
|
|
|
* - 2: If a projectile should be spawned upon detonation <BOOL>
|
|
|
|
* 1: Total ammo count <NUMBER>
|
2017-01-04 21:35:54 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-06-05 19:36:39 +00:00
|
|
|
* cursorObject call ace_cookoff_fnc_getVehicleAmmo
|
2017-01-04 21:35:54 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2024-06-05 19:36:39 +00:00
|
|
|
params ["_object"];
|
|
|
|
TRACE_1("getVehicleAmmo",_object);
|
2017-01-04 21:35:54 +00:00
|
|
|
|
|
|
|
private _ammoToDetonate = [];
|
|
|
|
private _totalAmmo = 0;
|
2024-06-05 19:36:39 +00:00
|
|
|
private _cfgMagazines = configFile >> "CfgMagazines";
|
|
|
|
private _cfgAmmo = configFile >> "CfgAmmo";
|
|
|
|
private _ammo = "";
|
2017-01-04 21:35:54 +00:00
|
|
|
|
|
|
|
// Get ammo from turrets
|
|
|
|
{
|
2024-06-05 19:36:39 +00:00
|
|
|
// If the turret is an FFV seat, it takes magazines from the soldier
|
|
|
|
_x params ["_magazine", "", "_count"];
|
|
|
|
|
|
|
|
if (_count > 0 && {!(_magazine call FUNC(isMagazineFlare))}) then {
|
|
|
|
_ammo = getText (_cfgMagazines >> _magazine >> "ammo");
|
|
|
|
|
|
|
|
if (getText (_cfgAmmo >> _ammo >> "model") == "\A3\weapons_f\empty") then {
|
|
|
|
TRACE_2("skipping",_magazine,_ammo);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
};
|
|
|
|
|
|
|
|
_ammoToDetonate pushBack [_magazine, _count, true];
|
2017-01-04 21:35:54 +00:00
|
|
|
_totalAmmo = _totalAmmo + _count;
|
|
|
|
};
|
2024-06-05 19:36:39 +00:00
|
|
|
} forEach (magazinesAllTurrets [_object, true]);
|
2017-01-04 21:35:54 +00:00
|
|
|
|
|
|
|
// Get ammo from cargo space
|
|
|
|
{
|
2024-06-05 19:36:39 +00:00
|
|
|
_x params ["_magazine", "_count"];
|
|
|
|
|
|
|
|
if (_count > 0 && {!(_magazine call FUNC(isMagazineFlare))}) then {
|
2024-08-11 23:31:02 +00:00
|
|
|
_ammoToDetonate pushBack [_magazine, _count, random 1 < 0.5];
|
2017-01-04 21:35:54 +00:00
|
|
|
_totalAmmo = _totalAmmo + _count;
|
|
|
|
};
|
2024-06-05 19:36:39 +00:00
|
|
|
} forEach (magazinesAmmoCargo _object);
|
2017-01-04 21:35:54 +00:00
|
|
|
|
|
|
|
// Get ammo from transportAmmo / ace_rearm
|
2024-06-05 19:36:39 +00:00
|
|
|
private _configVehicle = configOf _object;
|
|
|
|
private _configSupply = (getNumber (_configVehicle >> "transportAmmo")) max (getNumber (_configVehicle >> QEGVAR(rearm,defaultSupply)));
|
2017-10-14 13:12:32 +00:00
|
|
|
|
2024-06-05 19:36:39 +00:00
|
|
|
if (_object getVariable [QEGVAR(rearm,isSupplyVehicle), _configSupply > 0]) then {
|
|
|
|
TRACE_1("transportAmmo vehicle - adding virtual ammo",typeOf _object);
|
2017-01-04 21:35:54 +00:00
|
|
|
|
2024-06-05 19:36:39 +00:00
|
|
|
_ammoToDetonate pushBack ["2000Rnd_65x39_belt", 2000, false];
|
2017-01-04 21:35:54 +00:00
|
|
|
_totalAmmo = _totalAmmo + 2000;
|
2024-06-05 19:36:39 +00:00
|
|
|
|
|
|
|
_ammoToDetonate pushBack ["20Rnd_105mm_HEAT_MP", 100, true];
|
2017-01-04 21:35:54 +00:00
|
|
|
_totalAmmo = _totalAmmo + 100;
|
2024-06-05 19:36:39 +00:00
|
|
|
|
|
|
|
_ammoToDetonate pushBack ["SatchelCharge_Remote_Mag", 10, true];
|
2021-10-14 15:49:27 +00:00
|
|
|
_totalAmmo = _totalAmmo + 10;
|
2017-01-04 21:35:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
[_ammoToDetonate, _totalAmmo]
|