Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field Rations - Add eat/drink context action to magazines #10461

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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