2015-08-15 16:43:13 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
|
|
|
* Show the resupplyable ammunition of all surrounding vehicles.
|
|
|
|
*
|
2016-06-06 18:42:20 +00:00
|
|
|
* Arguments:
|
2015-08-15 16:43:13 +00:00
|
|
|
* 0: Target <OBJECT>
|
|
|
|
*
|
2016-06-06 18:42:20 +00:00
|
|
|
* Return Value:
|
2015-08-15 16:43:13 +00:00
|
|
|
* ChildActions <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [tank] call ace_rearm_fnc_addRearmActions
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2017-06-08 16:47:52 +00:00
|
|
|
params [["_truck", objNull, [objNull]]];
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2016-02-27 20:05:19 +00:00
|
|
|
private _vehicles = nearestObjects [_truck, ["AllVehicles"], 20];
|
2017-06-08 16:47:52 +00:00
|
|
|
_vehicles = _vehicles select {(_x != _truck) && {!(_x isKindOf "CAManBase")} && {!(_x getVariable [QGVAR(disabled), false])}};
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2016-02-27 19:31:07 +00:00
|
|
|
private _vehicleActions = [];
|
2015-08-15 16:43:13 +00:00
|
|
|
{
|
2016-02-27 19:31:07 +00:00
|
|
|
private _vehicle = _x;
|
2017-06-08 16:47:52 +00:00
|
|
|
private _magazineHelper = [];
|
|
|
|
{
|
|
|
|
private _turretPath = _x;
|
|
|
|
private _magazines = [_vehicle, _turretPath] call FUNC(getVehicleMagazines);
|
2015-08-15 16:43:13 +00:00
|
|
|
{
|
2017-06-08 16:47:52 +00:00
|
|
|
private _magazine = _x;
|
|
|
|
if (!(_magazine in _magazineHelper)) then {
|
2017-05-18 16:13:31 +00:00
|
|
|
private _currentMagazines = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
|
2017-06-08 16:47:52 +00:00
|
|
|
private _maxMagazines = [_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines);
|
|
|
|
|
|
|
|
if ((_currentMagazines < _maxMagazines) || {(_vehicle magazineTurretAmmo [_magazine, _turretPath]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")}) then {
|
|
|
|
_magazineHelper pushBack _magazine;
|
2015-08-15 16:43:13 +00:00
|
|
|
};
|
2017-06-08 16:47:52 +00:00
|
|
|
};
|
2016-05-12 12:55:40 +00:00
|
|
|
false
|
2017-06-08 16:47:52 +00:00
|
|
|
} count _magazines;
|
|
|
|
false
|
|
|
|
} count REARM_TURRET_PATHS;
|
|
|
|
|
|
|
|
// 1.70 pylons
|
|
|
|
private _pylonConfigs = configProperties [configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"];
|
|
|
|
{
|
|
|
|
private _pylonName = configName _x;
|
|
|
|
private _pylonAmmo = _vehicle ammoOnPylon _pylonName;
|
|
|
|
private _pylonMagazine = (getPylonMagazines _vehicle) select _forEachIndex;
|
|
|
|
TRACE_3("",_pylonName,_pylonAmmo,_pylonMagazine);
|
|
|
|
|
|
|
|
if (_pylonAmmo > 0) then {
|
|
|
|
// Try to refill current pylon:
|
|
|
|
private _magAmmo = getNumber (configFile >> "CfgMagazines" >> _pylonMagazine >> "count");
|
|
|
|
if ((!(_pylonMagazine in _magazineHelper)) && {_pylonAmmo < _magAmmo}) then {
|
|
|
|
_magazineHelper pushBack _pylonMagazine;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// See what we magazines can add to the empty pylon:
|
|
|
|
private _hardpointMags = [_x] call FUNC(getHardpointMagazines);
|
|
|
|
{
|
|
|
|
if (!(_x in _magazineHelper)) then {
|
|
|
|
_magazineHelper pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach _hardpointMags;
|
|
|
|
};
|
|
|
|
} forEach _pylonConfigs;
|
|
|
|
|
|
|
|
_magazineHelper = _magazineHelper select {[_truck, _x] call FUNC(hasEnoughSupply)};
|
|
|
|
TRACE_2("can add",_x,_magazineHelper);
|
|
|
|
|
|
|
|
if (!(_magazineHelper isEqualTo [])) then {
|
2016-02-27 19:31:07 +00:00
|
|
|
private _icon = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Icon");
|
2015-08-15 16:43:13 +00:00
|
|
|
if !((_icon select [0, 1]) == "\") then {
|
|
|
|
_icon = "";
|
|
|
|
};
|
2015-08-16 00:18:53 +00:00
|
|
|
if (GVAR(level) == 0) then {
|
2017-06-08 16:47:52 +00:00
|
|
|
// [Level 0] adds a single action to rearm the entire vic
|
|
|
|
private _action = [_vehicle,
|
|
|
|
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
|
|
|
|
_icon,
|
|
|
|
{_this call FUNC(rearmEntireVehicle)},
|
|
|
|
{true},
|
|
|
|
{},
|
|
|
|
_vehicle] call EFUNC(interact_menu,createAction);
|
2016-02-27 20:05:19 +00:00
|
|
|
_vehicleActions pushBack [_action, [], _truck];
|
2015-08-16 00:18:53 +00:00
|
|
|
} else {
|
2017-06-08 16:47:52 +00:00
|
|
|
// [Level 1,2] - Add actions for each magazine
|
|
|
|
private _actions = [];
|
|
|
|
{
|
|
|
|
private _action = [_x,
|
|
|
|
getText(configFile >> "CfgMagazines" >> _x >> "displayName"),
|
|
|
|
getText(configFile >> "CfgMagazines" >> _x >> "picture"),
|
|
|
|
{_this call FUNC(takeAmmo)},
|
|
|
|
{true},
|
|
|
|
{},
|
|
|
|
[_x, _vehicle]] call EFUNC(interact_menu,createAction);
|
|
|
|
|
|
|
|
_actions pushBack [_action, [], _truck];
|
|
|
|
} forEach _magazineHelper;
|
|
|
|
|
|
|
|
private _action = [_vehicle,
|
2015-08-18 00:32:10 +00:00
|
|
|
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
|
|
|
|
_icon,
|
|
|
|
{},
|
|
|
|
{true},
|
|
|
|
{},
|
2015-08-16 00:18:53 +00:00
|
|
|
[]] call EFUNC(interact_menu,createAction);
|
2016-02-27 20:05:19 +00:00
|
|
|
_vehicleActions pushBack [_action, _actions, _truck];
|
2015-08-16 00:18:53 +00:00
|
|
|
};
|
2015-08-15 16:43:13 +00:00
|
|
|
};
|
2016-05-12 12:55:40 +00:00
|
|
|
false
|
|
|
|
} count _vehicles;
|
2015-08-16 00:18:53 +00:00
|
|
|
|
2015-08-15 16:43:13 +00:00
|
|
|
_vehicleActions
|