2015-08-15 16:43:13 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
|
|
|
* Show the resupplyable ammunition of all surrounding vehicles.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Target <OBJECT>
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* ChildActions <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [tank] call ace_rearm_fnc_addRearmActions
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-05-12 12:55:40 +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];
|
2015-08-18 00:32:10 +00:00
|
|
|
if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles
|
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 _actions = [];
|
|
|
|
private _vehicle = _x;
|
|
|
|
private _needToAdd = false;
|
|
|
|
private _action = [];
|
2016-02-27 20:05:19 +00:00
|
|
|
if !((_vehicle == _truck) || (_vehicle isKindOf "CAManBase")) then {
|
2016-02-27 19:31:07 +00:00
|
|
|
private _magazineHelper = [];
|
2015-08-15 16:43:13 +00:00
|
|
|
{
|
2016-02-27 19:31:07 +00:00
|
|
|
private _turretPath = _x;
|
|
|
|
private _magazines = [_vehicle, _turretPath] call FUNC(getVehicleMagazines);
|
2015-08-15 16:43:13 +00:00
|
|
|
{
|
2016-02-27 19:31:07 +00:00
|
|
|
private _magazine = _x;
|
2016-02-01 19:05:53 +00:00
|
|
|
_currentMagazines = { _x == _magazine } count (_vehicle magazinesTurret _turretPath);
|
|
|
|
if ((_currentMagazines < ([_vehicle, _turretPath, _magazine] call FUNC(getMaxMagazines))) && !(_magazine in _magazineHelper)) then {
|
2015-08-18 00:32:10 +00:00
|
|
|
_action = [_magazine,
|
|
|
|
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
|
|
|
|
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
|
2015-08-20 17:51:22 +00:00
|
|
|
{_this call FUNC(takeAmmo)},
|
2015-08-18 00:32:10 +00:00
|
|
|
{true},
|
|
|
|
{},
|
2015-08-16 00:18:53 +00:00
|
|
|
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
|
2016-02-27 20:05:19 +00:00
|
|
|
if (GVAR(supply) == 0 || {(GVAR(supply) == 1) && ([_truck, _magazine] call FUNC(hasEnoughSupply))} || {(GVAR(supply) == 2) && ([_truck, _magazine] call FUNC(magazineInSupply))}) then {
|
|
|
|
_actions pushBack [_action, [], _truck];
|
2016-02-27 19:31:07 +00:00
|
|
|
_magazineHelper pushBack _magazine;
|
|
|
|
_needToAdd = true;
|
|
|
|
};
|
2015-08-15 16:43:13 +00:00
|
|
|
} else {
|
|
|
|
if (((_vehicle magazineTurretAmmo [_magazine, _turretPath]) < getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) && !(_magazine in _magazineHelper)) then {
|
2015-08-18 00:32:10 +00:00
|
|
|
_action = [_magazine,
|
|
|
|
getText(configFile >> "CfgMagazines" >> _magazine >> "displayName"),
|
|
|
|
getText(configFile >> "CfgMagazines" >> _magazine >> "picture"),
|
2015-08-20 17:51:22 +00:00
|
|
|
{_this call FUNC(takeAmmo)},
|
2015-08-18 00:32:10 +00:00
|
|
|
{true},
|
|
|
|
{},
|
2015-08-16 00:18:53 +00:00
|
|
|
[_magazine, _vehicle]] call EFUNC(interact_menu,createAction);
|
2016-02-27 20:05:19 +00:00
|
|
|
if (GVAR(supply) == 0 || {(GVAR(supply) == 1) && ([_truck, _magazine] call FUNC(hasEnoughSupply))} || {(GVAR(supply) == 2) && ([_truck, _magazine] call FUNC(magazineInSupply))}) then {
|
|
|
|
_actions pushBack [_action, [], _truck];
|
2016-02-27 19:31:07 +00:00
|
|
|
_magazineHelper pushBack _magazine;
|
|
|
|
_needToAdd = true;
|
|
|
|
};
|
2015-08-15 16:43:13 +00:00
|
|
|
};
|
|
|
|
};
|
2016-05-12 12:55:40 +00:00
|
|
|
false
|
|
|
|
} count _magazines;
|
|
|
|
false
|
|
|
|
} count REARM_TURRET_PATHS;
|
2015-08-15 16:43:13 +00:00
|
|
|
};
|
2015-11-23 16:08:06 +00:00
|
|
|
if (_needToAdd && !(_vehicle getVariable [QGVAR(disabled), false])) 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 {
|
2015-08-18 00:32:10 +00:00
|
|
|
_action = [_vehicle,
|
|
|
|
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
|
|
|
|
_icon,
|
|
|
|
{_this call FUNC(rearmEntireVehicle)},
|
|
|
|
{true},
|
|
|
|
{},
|
2015-08-16 00:18:53 +00:00
|
|
|
_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 {
|
2015-08-18 00:32:10 +00:00
|
|
|
_action = [_vehicle,
|
|
|
|
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
|