Skip to content

Commit efdca89

Browse files
authored
Add Unload Vehicle Cargo keybind and context menu action (#528)
1 parent 4fece6a commit efdca89

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed

addons/context_actions/CfgContext.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ class EGVAR(context_menu,actions) {
315315
statement = QUOTE(_objects call FUNC(refuelVehicles));
316316
icon = "\a3\ui_f\data\igui\cfg\simpleTasks\types\refuel_ca.paa";
317317
};
318+
class UnloadViV {
319+
displayName = "$STR_A3_ModuleDepot_Unload";
320+
condition = QUOTE(_objects call FUNC(canUnloadViV));
321+
statement = QUOTE(_objects call FUNC(unloadViV));
322+
icon = "\a3\ui_f\data\IGUI\Cfg\Actions\unloadVehicle_ca.paa";
323+
};
318324
};
319325
class EditableObjects {
320326
displayName = CSTRING(EditableObjects);

addons/context_actions/XEH_PREP.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PREP(canRearmVehicles);
77
PREP(canRefuelVehicles);
88
PREP(canRepairVehicles);
99
PREP(canToggleSurrender);
10+
PREP(canUnloadViV);
1011
PREP(copyVehicleAppearance);
1112
PREP(getArtilleryActions);
1213
PREP(healUnits);
@@ -25,4 +26,5 @@ PREP(teleportPlayers);
2526
PREP(teleportZeus);
2627
PREP(toggleCaptive);
2728
PREP(toggleSurrender);
29+
PREP(unloadViV);
2830
PREP(updateEditableObjects);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Ampersand
4+
* Checks if the given objects list contains Vehicle-in-Vehicle cargo or carriers that can be unloaded.
5+
*
6+
* Arguments:
7+
* N: Objects <OBJECT>
8+
*
9+
* Return Value:
10+
* Can Unload Vehicles <BOOL>
11+
*
12+
* Example:
13+
* [_object] call zen_context_actions_fnc_canUnloadViV
14+
*
15+
* Public: No
16+
*/
17+
18+
_this findIf {!(getVehicleCargo _x isEqualTo []) || {!isNull isVehicleCargo _x}} != -1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Ampersand
4+
* Unloads Vehicle-in-Vehicle cargo and carriers from the objects list.
5+
*
6+
* Arguments:
7+
* N: Objects <OBJECT>
8+
*
9+
* Return Value:
10+
* None
11+
*
12+
* Example:
13+
* [_object] call zen_context_actions_fnc_unloadViV
14+
*
15+
* Public: No
16+
*/
17+
18+
{
19+
if (isNull isVehicleCargo _x) then {
20+
// Not being carried
21+
if !(getVehicleCargo _x isEqualTo []) then {
22+
_x setVehicleCargo objNull;
23+
};
24+
} else {
25+
// Being carried
26+
objNull setVehicleCargo _x;
27+
};
28+
} forEach _this;

addons/editor/initKeybinds.sqf

+18
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@
2727
};
2828
}, {}, [DIK_G, [false, true, false]]] call CBA_fnc_addKeybind; // Default: CTRL + G
2929

30+
[ELSTRING(main,DisplayName), QGVAR(unloadViV), [localize "STR_A3_ModuleDepot_Unload", LSTRING(UnloadViV_Description)], {
31+
if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then {
32+
{
33+
if (isNull isVehicleCargo _x) then {
34+
// Not being carried
35+
if !(getVehicleCargo _x isEqualTo []) then {
36+
_x setVehicleCargo objNull;
37+
};
38+
} else {
39+
// Being carried
40+
objNull setVehicleCargo _x;
41+
};
42+
} forEach SELECTED_OBJECTS;
43+
44+
true // handled, prevents vanilla eject
45+
};
46+
}, {}, [DIK_G, [false, false, true]]] call CBA_fnc_addKeybind; // Default: ALT + G
47+
3048
[ELSTRING(main,DisplayName), QGVAR(deepCopy), [LSTRING(DeepCopy), LSTRING(DeepCopy_Description)], {
3149
if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then {
3250
private _position = [nil, false] call EFUNC(common,getPosFromScreen);

addons/editor/stringtable.xml

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@
159159
<Polish>Wysadza pasażerów ze wszystkich wybranych pojazdów. Jeżeli pojazd jest w powietrzu, pasażerowie dostaną spadochron.\nJednostki zostaną wysadzone jedna po drugiej (nie wszystkie na raz).</Polish>
160160
<Japanese>選択された全車両から後部座席のユニットを脱出させます。もし車両が飛行中の場合はパラシュートが与えられます。\nなお脱出は一人づつ降りるようになっています (即時ではなく数秒づつ)。</Japanese>
161161
</Key>
162+
<Key ID="STR_ZEN_Editor_UnloadViV_Description">
163+
<English>Unloads all selected vehicle-in-vehicle cargo and carriers. A vehicle that is both cargo and carrying cargo will only be unloaded from its carrier.</English>
164+
</Key>
162165
<Key ID="STR_ZEN_Editor_DeployCountermeasures">
163166
<English>Deploy Countermeasures</English>
164167
<French>Déployer des contre-mesures</French>

0 commit comments

Comments
 (0)