Skip to content

Commit

Permalink
Zeus - Add Repair and Rearm interactions (#6632)
Browse files Browse the repository at this point in the history
* Add Repair and Rearm interaction to zeus

* Optimize remoteControl statement
  • Loading branch information
Dystopian authored and PabstMirror committed Oct 13, 2018
1 parent 6ad2843 commit d7c7ead
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 19 deletions.
30 changes: 25 additions & 5 deletions addons/interaction/ACE_ZeusActions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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)));
};
};
16 changes: 16 additions & 0 deletions addons/rearm/ACE_ZeusActions.hpp
Original file line number Diff line number Diff line change
@@ -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); \
);
};
};
};
1 change: 1 addition & 0 deletions addons/rearm/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CfgPatches {
};

#include "ACE_Settings.hpp"
#include "ACE_ZeusActions.hpp"
#include "CfgEventHandlers.hpp"

#include "CfgAmmo.hpp"
Expand Down
2 changes: 1 addition & 1 deletion addons/rearm/functions/fnc_rearmEntireVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
{
Expand Down
10 changes: 4 additions & 6 deletions addons/rearm/functions/fnc_rearmEntireVehicleSuccess.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
* Rearm an entire vehicle.
*
* Arguments:
* 0: Rearm information <ARRAY>
* 0: Ammo Truck <OBJECT>
* 1: Vehicle <OBJECT>
* 0: Ammo Truck <OBJECT>
* 1: Vehicle <OBJECT>
*
* 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 {
Expand Down
22 changes: 15 additions & 7 deletions addons/rearm/functions/fnc_rearmEntireVehicleSuccessLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down

0 comments on commit d7c7ead

Please sign in to comment.