From 1dd817ffd14a672f7dc96d35843b9e0495722f38 Mon Sep 17 00:00:00 2001 From: Dystopian Date: Sat, 13 Oct 2018 20:07:32 +0300 Subject: [PATCH] Zeus - Add Repair and Rearm interactions (#6632) * Add Repair and Rearm interaction to zeus * Optimize remoteControl statement --- addons/interaction/ACE_ZeusActions.hpp | 30 +++++++++++++++---- addons/rearm/ACE_ZeusActions.hpp | 16 ++++++++++ addons/rearm/config.cpp | 1 + .../functions/fnc_rearmEntireVehicle.sqf | 2 +- .../fnc_rearmEntireVehicleSuccess.sqf | 10 +++---- .../fnc_rearmEntireVehicleSuccessLocal.sqf | 22 +++++++++----- 6 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 addons/rearm/ACE_ZeusActions.hpp diff --git a/addons/interaction/ACE_ZeusActions.hpp b/addons/interaction/ACE_ZeusActions.hpp index af6b4504e11..40b3caa097f 100644 --- a/addons/interaction/ACE_ZeusActions.hpp +++ b/addons/interaction/ACE_ZeusActions.hpp @@ -3,10 +3,11 @@ class ACE_ZeusActions { class ZeusUnits { displayName = "$STR_A3_RscDisplayCurator_ModeUnits_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeUnits_ca.paa"; - condition = QUOTE((count (curatorSelected select 0)) > 0); + condition = QUOTE(!([] isEqualTo (curatorSelected select 0))); class stance { displayName = "$STR_A3_RscAttributeUnitPos_Title"; + condition = QUOTE(-1 < (curatorSelected select 0) findIf {_x isKindOf 'CAManBase'}); class prone { displayName = "$STR_Pos_Down"; @@ -33,14 +34,33 @@ class ACE_ZeusActions { class remoteControl { displayName = "$STR_A3_CfgVehicles_ModuleRemoteControl_F"; icon = "\A3\Modules_F_Curator\Data\portraitRemoteControl_ca.paa"; - statement = "_unit = objNull; { if ((side _x in [east,west,resistance,civilian]) && !(isPlayer _x)) exitWith { _unit = _x; }; } forEach (curatorSelected select 0); bis_fnc_curatorObjectPlaced_mouseOver = ['OBJECT',_unit]; (group _target) createUnit ['ModuleRemoteControl_F',[0,0,0],[],0,'NONE'];"; + condition = QUOTE(-1 < (curatorSelected select 0) findIf {_x isKindOf 'CAManBase'}); + statement = QUOTE( \ + private _units = curatorSelected select 0; \ + private _unit = _units param [ARR_2( \ + _units findIf { \ + side _x in [ARR_4(east,west,resistance,civilian)] \ + && !(isPlayer _x) \ + }, \ + objNull \ + )]; \ + bis_fnc_curatorObjectPlaced_mouseOver = [ARR_2('OBJECT',_unit)]; \ + group _target createUnit [ARR_5('ModuleRemoteControl_F',[ARR_3(0,0,0)],[],0,'NONE')]; \ + ); + }; + + class GVAR(repair) { + displayName = "$STR_repair"; + icon = "\A3\ui_f\data\igui\cfg\actions\repair_ca.paa"; + condition = QUOTE(-1 < (curatorSelected select 0) findIf {_x isKindOf 'AllVehicles' && {!(_x isKindOf 'Man')}}); + statement = QUOTE({if (_x isKindOf 'AllVehicles' && {!(_x isKindOf 'Man')}) then {_x setDamage 0}} forEach (curatorSelected select 0)); }; }; class ZeusGroups { displayName = "$STR_A3_RscDisplayCurator_ModeGroups_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeGroups_ca.paa"; - condition = QUOTE((count (curatorSelected select 1)) > 0); + condition = QUOTE(!([] isEqualTo (curatorSelected select 1))); class behaviour { displayName = "$STR_Combat_Mode"; @@ -145,7 +165,7 @@ class ACE_ZeusActions { class ZeusWaypoints { displayName = "Waypoints"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeRecent_ca.paa"; - condition = QUOTE((count (curatorSelected select 2)) > 0); + condition = QUOTE(!([] isEqualTo (curatorSelected select 2))); class behaviour { displayName = "$STR_Combat_Mode"; @@ -250,6 +270,6 @@ class ACE_ZeusActions { class ZeusMarkers { displayName = "$STR_A3_RscDisplayCurator_ModeMarkers_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeMarkers_ca.paa"; - condition = QUOTE((count (curatorSelected select 3)) > 0); + condition = QUOTE(!([] isEqualTo (curatorSelected select 3))); }; }; diff --git a/addons/rearm/ACE_ZeusActions.hpp b/addons/rearm/ACE_ZeusActions.hpp new file mode 100644 index 00000000000..126e37e969c --- /dev/null +++ b/addons/rearm/ACE_ZeusActions.hpp @@ -0,0 +1,16 @@ +class ACE_ZeusActions { + class ZeusUnits { + class GVAR(rearm) { + displayName = CSTRING(Rearm); + icon = "\z\ace\addons\rearm\ui\icon_rearm_interact.paa"; + condition = QUOTE(-1 < (curatorSelected select 0) findIf {_x isKindOf 'AllVehicles' && {!(_x isKindOf 'Man')}}); + statement = QUOTE( \ + { \ + if (_x isKindOf 'AllVehicles' && {!(_x isKindOf 'Man')}) then { \ + [ARR_2(objNull,_x)] call ace_rearm_fnc_rearmEntireVehicleSuccess; \ + }; \ + } forEach (curatorSelected select 0); \ + ); + }; + }; +}; diff --git a/addons/rearm/config.cpp b/addons/rearm/config.cpp index 348ca8751bc..8addee89d55 100644 --- a/addons/rearm/config.cpp +++ b/addons/rearm/config.cpp @@ -15,6 +15,7 @@ class CfgPatches { }; #include "ACE_Settings.hpp" +#include "ACE_ZeusActions.hpp" #include "CfgEventHandlers.hpp" #include "CfgAmmo.hpp" diff --git a/addons/rearm/functions/fnc_rearmEntireVehicle.sqf b/addons/rearm/functions/fnc_rearmEntireVehicle.sqf index b136c5d2671..b3147f976c2 100644 --- a/addons/rearm/functions/fnc_rearmEntireVehicle.sqf +++ b/addons/rearm/functions/fnc_rearmEntireVehicle.sqf @@ -23,7 +23,7 @@ TRACE_3("rearmEntireVehicle",_truck,_player,_vehicle); [ TIME_PROGRESSBAR(10), [_truck, _vehicle, _player], - FUNC(rearmEntireVehicleSuccess), + {(_this select 0) call FUNC(rearmEntireVehicleSuccess)}, "", format [localize LSTRING(BasicRearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName")], { diff --git a/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf b/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf index f3eecbb2451..699b37ed400 100644 --- a/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf +++ b/addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf @@ -4,21 +4,19 @@ * Rearm an entire vehicle. * * Arguments: - * 0: Rearm information - * 0: Ammo Truck - * 1: Vehicle + * 0: Ammo Truck + * 1: Vehicle * * Return Value: * None * * Example: - * [[ammo_truck, tank]] call ace_rearm_fnc_rearmEntireVehicleSuccess + * [ammo_truck, tank] call ace_rearm_fnc_rearmEntireVehicleSuccess * * Public: No */ -params ["_args"]; -_args params ["_truck", "_vehicle"]; +params ["_truck", "_vehicle"]; TRACE_2("rearmEntireVehicleSuccess",_truck,_vehicle); if (isServer) then { diff --git a/addons/rearm/functions/fnc_rearmEntireVehicleSuccessLocal.sqf b/addons/rearm/functions/fnc_rearmEntireVehicleSuccessLocal.sqf index 90845648bab..6d48cd338fd 100644 --- a/addons/rearm/functions/fnc_rearmEntireVehicleSuccessLocal.sqf +++ b/addons/rearm/functions/fnc_rearmEntireVehicleSuccessLocal.sqf @@ -24,30 +24,38 @@ TRACE_3("rearmEntireVehicleSuccessLocal",_truck,_vehicle,_turretPath); private _magazines = ([_vehicle] call FUNC(getNeedRearmMagazines)) select {(_x select 1) isEqualTo _turretPath}; { _x params ["_magazineClass", "_magTurretPath", "_isPylonMag", "_pylonIndex", "_maxMagazines", "_currentMagazines", "_maxRoundsPerMag", "_currentRounds"]; - + // Array of planned ammo counts in every magazine after the rearm is complete private _plannedRounds = +_currentRounds; - + // Trying to fill all existing magazines. { if (_x < _maxRoundsPerMag) then { - if ((GVAR(supply) == 0) || {[_truck, _magazineClass, (_maxRoundsPerMag - _x)] call FUNC(removeMagazineFromSupply)}) then { + if ( + GVAR(supply) == 0 + || {isNull _truck} // zeus rearm + || {[_truck, _magazineClass, (_maxRoundsPerMag - _x)] call FUNC(removeMagazineFromSupply)} + ) then { _plannedRounds set [_forEachIndex, _maxRoundsPerMag]; }; }; } forEach _currentRounds; - + // Trying to add new full magazines, if there is space left. if (_currentMagazines < _maxMagazines) then { for "_idx" from 1 to (_maxMagazines - _currentMagazines) do { - if ((GVAR(supply) == 0) || {[_truck, _magazineClass, _maxRoundsPerMag] call FUNC(removeMagazineFromSupply)}) then { + if ( + GVAR(supply) == 0 + || {isNull _truck} // zeus rearm + || {[_truck, _magazineClass, _maxRoundsPerMag] call FUNC(removeMagazineFromSupply)} + ) then { _plannedRounds pushBack _maxRoundsPerMag; }; }; }; - + TRACE_2("rearming",_x,_plannedRounds); - + // Updating new ammo counts to vehicle. if (_isPylonMag) then { _vehicle setAmmoOnPylon [_pylonIndex, (_plannedRounds select 0)];