Skip to content

Commit eb1a282

Browse files
committed
Improve vehicle water actions
Fix unreachable water actions on vehicles with no waterActionOffset Allow water actions from within a vehicle with no waterActionOffset
1 parent 4598c8a commit eb1a282

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

addons/field_rations/XEH_postInit.sqf

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if !(hasInterface) exitWith {};
1515
};
1616

1717
// Compile water source actions
18-
private _mainAction = [
18+
GVAR(mainAction) = [
1919
QGVAR(waterSource),
2020
LLSTRING(WaterSource),
2121
QPATHTOF(ui\icon_water_tap.paa),
@@ -38,7 +38,7 @@ if !(hasInterface) exitWith {};
3838
[false, false, false, false, true]
3939
] call EFUNC(interact_menu,createAction);
4040

41-
private _subActions = [
41+
GVAR(subActions) = [
4242
[
4343
QGVAR(checkWater),
4444
LLSTRING(CheckWater),
@@ -68,10 +68,10 @@ if !(hasInterface) exitWith {};
6868
];
6969

7070
// Add water source actions to helper
71-
[QGVAR(helper), 0, [], _mainAction] call EFUNC(interact_menu,addActionToClass);
71+
[QGVAR(helper), 0, [], GVAR(mainAction)] call EFUNC(interact_menu,addActionToClass);
7272
{
7373
[QGVAR(helper), 0, [QGVAR(waterSource)], _x] call EFUNC(interact_menu,addActionToClass);
74-
} forEach _subActions;
74+
} forEach GVAR(subActions);
7575

7676
// Add inventory context menu option to consume items
7777
private _eatOrDrinkCondition = [

addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf

+24-8
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818

1919
params ["_interactionType"];
2020

21-
// Ignore when self-interaction, mounted vehicle interaction, or water source actions are disabled
21+
// Ignore during self-interaction or when water source actions are disabled
2222
if (
2323
_interactionType != 0
24-
|| {!isNull objectParent ACE_player}
2524
|| {XGVAR(waterSourceActions) == 0}
2625
) exitWith {};
2726

@@ -49,13 +48,30 @@ TRACE_1("Starting interact PFH",_interactionType);
4948

5049
if (_waterRemaining != REFILL_WATER_DISABLED) then {
5150
private _offset = [_x] call FUNC(getActionOffset);
52-
private _helper = QGVAR(helper) createVehicleLocal [0, 0, 0];
53-
_helper setVariable [QGVAR(waterSource), _x];
54-
_helper attachTo [_x, _offset];
51+
if (_offset isEqualTo [0,0,0]) then {
52+
if !(_x getVariable [QGVAR(waterSourceActionsAdded), false]) then {
53+
private _vehicle = _x;
54+
_vehicle setVariable [QGVAR(waterSource), _vehicle];
55+
_sourcesHelped pushBack _vehicle;
56+
// Add water source actions to the vehicle itself
57+
private _mainAction = [_vehicle, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject);
58+
private _selfAction = [_vehicle, 1, ["ACE_SelfActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject);
59+
{
60+
[_vehicle, 0, _mainAction, _x] call EFUNC(interact_menu,addActionToObject);
61+
[_vehicle, 1, _selfAction, _x] call EFUNC(interact_menu,addActionToObject);
62+
} forEach GVAR(subActions);
63+
_vehicle setVariable [QGVAR(waterSourceActionsAdded), true];
64+
TRACE_3("Added interaction to vehicle",_x,typeOf _x,_waterRemaining);
65+
};
66+
} else {
67+
private _helper = QGVAR(helper) createVehicleLocal [0, 0, 0];
68+
_helper setVariable [QGVAR(waterSource), _x];
69+
_helper attachTo [_x, _offset];
5570

56-
_addedHelpers pushBack _helper;
57-
_sourcesHelped pushBack _x;
58-
TRACE_3("Added interaction helper",_x,typeOf _x,_waterRemaining);
71+
_addedHelpers pushBack _helper;
72+
_sourcesHelped pushBack _x;
73+
TRACE_3("Added interaction helper",_x,typeOf _x,_waterRemaining);
74+
};
5975
};
6076
};
6177
} forEach nearestObjects [ACE_player, [], 15];

addons/field_rations/functions/fnc_checkWater.sqf

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ params ["_player", "_source"];
3434
};
3535
},
3636
{},
37-
LLSTRING(CheckingWater)
37+
LLSTRING(CheckingWater),
38+
{true},
39+
["isNotInside"]
3840
] call EFUNC(common,progressBar);

addons/field_rations/functions/fnc_drinkFromSource.sqf

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,6 @@ private _progressText = if (isNull _sourceConfig) then {
7676
_fnc_onSuccess,
7777
_fnc_onFailure,
7878
_progressText,
79-
_fnc_condition
79+
_fnc_condition,
80+
["isNotInside"]
8081
] call EFUNC(common,progressBar);

addons/field_rations/functions/fnc_refillItem.sqf

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ private _fnc_condition = {
7878
_fnc_onSuccess,
7979
_fnc_onFailure,
8080
LLSTRING(Refilling),
81-
_fnc_condition
81+
_fnc_condition,
82+
["isNotInside"]
8283
] call EFUNC(common,progressBar);

0 commit comments

Comments
 (0)