Skip to content

Commit

Permalink
Field Rations - Improve Vehicle Watersource Actions (#10676)
Browse files Browse the repository at this point in the history
Co-authored-by: johnb432 <[email protected]>
  • Loading branch information
mrschick and johnb432 authored Feb 9, 2025
1 parent d06d71e commit 1fb128b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
8 changes: 4 additions & 4 deletions addons/field_rations/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if !(hasInterface) exitWith {};
};

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

private _subActions = [
GVAR(subActions) = [
[
QGVAR(checkWater),
LLSTRING(CheckWater),
Expand Down Expand Up @@ -68,10 +68,10 @@ if !(hasInterface) exitWith {};
];

// Add water source actions to helper
[QGVAR(helper), 0, [], _mainAction] call EFUNC(interact_menu,addActionToClass);
[QGVAR(helper), 0, [], GVAR(mainAction)] call EFUNC(interact_menu,addActionToClass);
{
[QGVAR(helper), 0, [QGVAR(waterSource)], _x] call EFUNC(interact_menu,addActionToClass);
} forEach _subActions;
} forEach GVAR(subActions);

// Add inventory context menu option to consume items
private _eatOrDrinkCondition = [
Expand Down
32 changes: 24 additions & 8 deletions addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

params ["_interactionType"];

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

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

if (_waterRemaining != REFILL_WATER_DISABLED) then {
private _offset = [_x] call FUNC(getActionOffset);
private _helper = QGVAR(helper) createVehicleLocal [0, 0, 0];
_helper setVariable [QGVAR(waterSource), _x];
_helper attachTo [_x, _offset];
if (_offset isEqualTo [0, 0, 0]) then {
if !(_x getVariable [QGVAR(waterSourceActionsAdded), false]) then {
private _vehicle = _x;
_vehicle setVariable [QGVAR(waterSource), _vehicle];
_sourcesHelped pushBack _vehicle;
// Add water source actions to the vehicle itself
private _mainAction = [_vehicle, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject);
private _selfAction = [_vehicle, 1, ["ACE_SelfActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject);
{
[_vehicle, 0, _mainAction, _x] call EFUNC(interact_menu,addActionToObject);
[_vehicle, 1, _selfAction, _x] call EFUNC(interact_menu,addActionToObject);
} forEach GVAR(subActions);
_vehicle setVariable [QGVAR(waterSourceActionsAdded), true];
TRACE_3("Added interaction to vehicle",_x,typeOf _x,_waterRemaining);
};
} else {
private _helper = QGVAR(helper) createVehicleLocal [0, 0, 0];
_helper setVariable [QGVAR(waterSource), _x];
_helper attachTo [_x, _offset];

_addedHelpers pushBack _helper;
_sourcesHelped pushBack _x;
TRACE_3("Added interaction helper",_x,typeOf _x,_waterRemaining);
_addedHelpers pushBack _helper;
_sourcesHelped pushBack _x;
TRACE_3("Added interaction helper",_x,typeOf _x,_waterRemaining);
};
};
};
} forEach nearestObjects [ACE_player, [], 15];
Expand Down
4 changes: 3 additions & 1 deletion addons/field_rations/functions/fnc_checkWater.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ params ["_player", "_source"];
};
},
{},
LLSTRING(CheckingWater)
LLSTRING(CheckingWater),
{true},
["isNotInside"]
] call EFUNC(common,progressBar);
3 changes: 2 additions & 1 deletion addons/field_rations/functions/fnc_drinkFromSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ private _progressText = if (isNull _sourceConfig) then {
_fnc_onSuccess,
_fnc_onFailure,
_progressText,
_fnc_condition
_fnc_condition,
["isNotInside"]
] call EFUNC(common,progressBar);
3 changes: 2 additions & 1 deletion addons/field_rations/functions/fnc_refillItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ private _fnc_condition = {
_fnc_onSuccess,
_fnc_onFailure,
LLSTRING(Refilling),
_fnc_condition
_fnc_condition,
["isNotInside"]
] call EFUNC(common,progressBar);

0 comments on commit 1fb128b

Please sign in to comment.