2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
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:
|
2017-09-29 19:53:25 +00:00
|
|
|
* 0: Ammo Truck <OBJECT>
|
2019-07-05 22:57:22 +00:00
|
|
|
* 1: Player <OBJECT>
|
2015-08-15 16:43:13 +00:00
|
|
|
*
|
2016-06-06 18:42:20 +00:00
|
|
|
* Return Value:
|
2015-08-15 16:43:13 +00:00
|
|
|
* ChildActions <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
2019-07-05 22:57:22 +00:00
|
|
|
* [tank, player] call ace_rearm_fnc_addRearmActions
|
2015-08-15 16:43:13 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2019-07-05 22:57:22 +00:00
|
|
|
params ["_truck", "_player"];
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2019-09-04 00:06:50 +00:00
|
|
|
private _vehicles = nearestObjects [_truck, ["AllVehicles"], GVAR(distance)];
|
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
|
|
|
|
2019-07-05 22:57:22 +00:00
|
|
|
private _cswCarryMagazines = [];
|
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;
|
2019-07-05 22:57:22 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
// Array of magazines that can be rearmed in the vehicle
|
|
|
|
private _needRearmMags = ([_vehicle] call FUNC(getNeedRearmMagazines)) apply {_x select 0};
|
2019-07-05 22:57:22 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
// _needRearmMags without duplicates
|
|
|
|
private _magazineHelper = _needRearmMags arrayIntersect _needRearmMags;
|
2017-06-08 16:47:52 +00:00
|
|
|
|
|
|
|
_magazineHelper = _magazineHelper select {[_truck, _x] call FUNC(hasEnoughSupply)};
|
2019-07-05 22:57:22 +00:00
|
|
|
|
|
|
|
if (["ace_csw"] call EFUNC(common,isModLoaded)) then {
|
|
|
|
([_vehicle] call EFUNC(csw,aceRearmGetCarryMagazines)) params ["_turretMagsCSW", "_allCarryMags"];
|
|
|
|
TRACE_3("csw compat",_vehicle,_turretMagsCSW,_allCarryMags);
|
|
|
|
_cswCarryMagazines append _allCarryMags;
|
|
|
|
_magazineHelper = _magazineHelper - _turretMagsCSW;
|
|
|
|
};
|
|
|
|
|
2017-06-08 16:47:52 +00:00
|
|
|
TRACE_2("can add",_x,_magazineHelper);
|
2019-07-05 22:57:22 +00:00
|
|
|
|
2017-06-08 16:47:52 +00:00
|
|
|
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
|
2017-09-29 19:53:25 +00:00
|
|
|
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 = [];
|
|
|
|
{
|
2017-09-29 19:53:25 +00:00
|
|
|
private _action = [
|
|
|
|
_x,
|
2019-01-31 00:31:01 +00:00
|
|
|
_x call FUNC(getMagazineName),
|
2017-09-29 19:53:25 +00:00
|
|
|
getText(configFile >> "CfgMagazines" >> _x >> "picture"),
|
|
|
|
{_this call FUNC(takeAmmo)},
|
|
|
|
{true},
|
|
|
|
{},
|
|
|
|
[_x, _vehicle]
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
2017-06-08 16:47:52 +00:00
|
|
|
|
|
|
|
_actions pushBack [_action, [], _truck];
|
|
|
|
} forEach _magazineHelper;
|
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
private _action = [
|
|
|
|
_vehicle,
|
2015-08-18 00:32:10 +00:00
|
|
|
getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName"),
|
|
|
|
_icon,
|
|
|
|
{},
|
|
|
|
{true},
|
|
|
|
{},
|
2017-09-29 19:53:25 +00:00
|
|
|
[]
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
2019-07-05 22:57:22 +00:00
|
|
|
|
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
|
|
|
};
|
2017-09-29 19:53:25 +00:00
|
|
|
} forEach _vehicles;
|
2015-08-16 00:18:53 +00:00
|
|
|
|
2019-07-05 22:57:22 +00:00
|
|
|
if (!(_cswCarryMagazines isEqualTo [])) then {
|
|
|
|
_cswCarryMagazines = _cswCarryMagazines arrayIntersect _cswCarryMagazines;
|
|
|
|
_cswCarryMagazines = _cswCarryMagazines select {[_truck, _x] call FUNC(hasEnoughSupply)};
|
|
|
|
private _baseAction = [QGVAR(cswTake), "CSW", "", {}, {true}] call EFUNC(interact_menu,createAction);
|
|
|
|
private _subActions = _cswCarryMagazines apply {
|
|
|
|
private _action = [
|
|
|
|
_x,
|
|
|
|
_x call FUNC(getMagazineName),
|
|
|
|
getText(configFile >> "CfgMagazines" >> _x >> "picture"),
|
|
|
|
{_this call FUNC(takeAmmo)},
|
|
|
|
{true},
|
|
|
|
{},
|
|
|
|
[_x, _player]
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
[_action, [], _truck];
|
|
|
|
};
|
|
|
|
_vehicleActions pushBack [_baseAction, _subActions, _truck];
|
|
|
|
};
|
|
|
|
|
2015-08-15 16:43:13 +00:00
|
|
|
_vehicleActions
|