Skip to content

Commit

Permalink
Field Rations - Add eat/drink context action to magazines (#10461)
Browse files Browse the repository at this point in the history
  • Loading branch information
DartRuffian authored and LinkIsGrim committed Nov 2, 2024
1 parent 57c7965 commit 3580f65
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions addons/field_rations/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,31 @@ if !(hasInterface) exitWith {};
} forEach _subActions;

// Add inventory context menu option to consume items
["ACE_ItemCore", ["CONTAINER"], LSTRING(EatDrink), [], QPATHTOF(ui\icon_survival.paa),
[
{true},
{
params ["", "", "_item"];
private _eatOrDrinkCondition = [
{true},
{
params ["", "", "_item"];

XGVAR(enabled) && {
private _config = configFile >> "CfgWeapons" >> _item;
getNumber (_config >> QXGVAR(thirstQuenched)) > 0
|| {getNumber (_config >> QXGVAR(hungerSatiated)) > 0}
}
XGVAR(enabled) && {
private _config = _item call CBA_fnc_getItemConfig;
getNumber (_config >> QXGVAR(thirstQuenched)) > 0
|| {getNumber (_config >> QXGVAR(hungerSatiated)) > 0}
}
],
{
params ["_unit", "", "_item"];
private _itemConfig = configFile >> "CfgWeapons" >> _item;
[objNull, _unit, [_item, _itemConfig, false]] call FUNC(consumeItem);
false
}
] call CBA_fnc_addItemContextMenuOption;
];
private _eatOrDrinkStatement = {
params ["_unit", "", "_item"];
private _itemConfig = _item call CBA_fnc_getItemConfig;
private _isMagazine = isClass (configFile >> "CfgMagazines" >> _item);
[objNull, _unit, [_item, _itemConfig, _isMagazine]] call FUNC(consumeItem);
false // Close context menu
};

{
[_x, ["CONTAINER"], LSTRING(EatDrink), [], QPATHTOF(ui\icon_survival.paa),
_eatOrDrinkCondition, _eatOrDrinkStatement
] call CBA_fnc_addItemContextMenuOption;
} forEach ["ACE_ItemCore", "CA_Magazine"];

// Add water source helpers when interaction menu is opened
["ace_interactMenuOpened", LINKFUNC(addWaterSourceInteractions)] call CBA_fnc_addEventHandler;
Expand Down

0 comments on commit 3580f65

Please sign in to comment.