Fix water actions on vehicles with no waterActionOffset

This commit is contained in:
mrschick 2024-08-07 15:31:30 +02:00
parent de9c29d869
commit c452f94779
2 changed files with 25 additions and 10 deletions

View File

@ -17,7 +17,7 @@ if !(hasInterface) exitWith {};
};
// Compile water source actions
private _mainAction = [
GVAR(mainAction) = [
QGVAR(waterSource),
LLSTRING(WaterSource),
QPATHTOF(ui\icon_water_tap.paa),
@ -40,7 +40,7 @@ if !(hasInterface) exitWith {};
[false, false, false, false, true]
] call EFUNC(interact_menu,createAction);
private _subActions = [
GVAR(subActions) = [
[
QGVAR(checkWater),
LLSTRING(CheckWater),
@ -70,10 +70,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
["ACE_ItemCore", ["CONTAINER"], LSTRING(EatDrink), [], QPATHTOF(ui\icon_survival.paa),

View File

@ -49,13 +49,28 @@ 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);
{
[_vehicle, 0, _mainAction, _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];