diff --git a/addons/field_rations/CfgWeapons.hpp b/addons/field_rations/CfgWeapons.hpp index 760d41290f..b100ba4e90 100644 --- a/addons/field_rations/CfgWeapons.hpp +++ b/addons/field_rations/CfgWeapons.hpp @@ -40,6 +40,7 @@ class CfgWeapons { XGVAR(replacementItem) = "ACE_WaterBottle_Half"; XGVAR(consumeAnims)[] = {QGVAR(drinkStand), QGVAR(drinkCrouch), QGVAR(drinkProne)}; XGVAR(consumeSounds)[] = {QGVAR(drink1), QGVAR(drink1), QGVAR(drink2)}; + ACE_isFieldRationItem = 1; }; class ACE_WaterBottle_Half: ACE_WaterBottle { @@ -87,6 +88,7 @@ class CfgWeapons { XGVAR(replacementItem) = "ACE_Canteen_Half"; XGVAR(consumeAnims)[] = {QGVAR(drinkStand), QGVAR(drinkCrouch), QGVAR(drinkProne)}; XGVAR(consumeSounds)[] = {QGVAR(drink1), QGVAR(drink1), QGVAR(drink2)}; + ACE_isFieldRationItem = 1; }; class ACE_Canteen_Half: ACE_Canteen { @@ -132,6 +134,7 @@ class CfgWeapons { XGVAR(consumeText) = CSTRING(DrinkingX); XGVAR(consumeAnims)[] = {QGVAR(drinkStandCan), QGVAR(drinkCrouchCan), QGVAR(drinkProneCan)}; XGVAR(consumeSounds)[] = {QGVAR(drinkCan1), QGVAR(drinkCan1), QGVAR(drinkCan2)}; + ACE_isFieldRationItem = 1; }; class ACE_Can_Franta: ACE_Can_Spirit { @@ -164,6 +167,7 @@ class CfgWeapons { XGVAR(consumeTime) = 10; XGVAR(hungerSatiated) = 20; XGVAR(consumeText) = CSTRING(EatingX); + ACE_isFieldRationItem = 1; }; class ACE_MRE_BeefStew: ACE_MRE_LambCurry { @@ -225,7 +229,7 @@ class CfgWeapons { model = QPATHTOF(data\mre_human.p3d); picture = QPATHTOF(ui\item_mre_human_co.paa); }; - + // - Misc Food ------------------------------------------------------------ class ACE_Sunflower_Seeds: ACE_ItemCore { author = ECSTRING(common,ACETeam); @@ -240,5 +244,6 @@ class CfgWeapons { XGVAR(consumeTime) = 10; XGVAR(hungerSatiated) = 10; XGVAR(consumeText) = CSTRING(EatingX); + ACE_isFieldRationItem = 1; }; }; diff --git a/addons/field_rations/XEH_PREP.hpp b/addons/field_rations/XEH_PREP.hpp index 68833a495b..2035345f47 100644 --- a/addons/field_rations/XEH_PREP.hpp +++ b/addons/field_rations/XEH_PREP.hpp @@ -14,5 +14,6 @@ ACEX_PREP(handleEffects); ACEX_PREP(handleHUD); ACEX_PREP(handleRespawn); ACEX_PREP(refillItem); +ACEX_PREP(scanFieldRations); ACEX_PREP(setRemainingWater); ACEX_PREP(update); diff --git a/addons/field_rations/XEH_preInit.sqf b/addons/field_rations/XEH_preInit.sqf index c4efb567ed..ede921483e 100644 --- a/addons/field_rations/XEH_preInit.sqf +++ b/addons/field_rations/XEH_preInit.sqf @@ -8,6 +8,8 @@ PREP_RECOMPILE_END; #include "initSettings.sqf" +#define ARSENAL_CATEGORY_ICON QPATHTOF(ui\icon_survival.paa) + // Init arrays of status modifiers GVAR(thirstModifiers) = []; GVAR(hungerModifiers) = []; @@ -18,4 +20,9 @@ GVAR(waterSourceP3Ds) = _cache select 0; // List of refill action offsets corresponding to the p3ds in the array above GVAR(waterSourceOffsets) = _cache select 1; +// Custom Arsenal Tab +if (["ace_arsenal"] call EFUNC(common,isModLoaded)) then { + [keys FIELD_RATIONS_ITEMS, LLSTRING(DisplayName), ARSENAL_CATEGORY_ICON] call EFUNC(arsenal,addRightPanelButton); +}; + ADDON = true; diff --git a/addons/field_rations/XEH_preStart.sqf b/addons/field_rations/XEH_preStart.sqf index eec59ff8f7..88109cf9ee 100644 --- a/addons/field_rations/XEH_preStart.sqf +++ b/addons/field_rations/XEH_preStart.sqf @@ -30,3 +30,5 @@ private _waterSourceOffsets = [ uiNamespace setVariable [QGVAR(cacheP3Ds), compileFinal str [_waterSourceP3Ds, _waterSourceOffsets]]; TRACE_1("compiled",count _waterSourceP3Ds); + +call FUNC(scanFieldRations); diff --git a/addons/field_rations/functions/fnc_scanFieldRations.sqf b/addons/field_rations/functions/fnc_scanFieldRations.sqf new file mode 100644 index 0000000000..395b3ba45b --- /dev/null +++ b/addons/field_rations/functions/fnc_scanFieldRations.sqf @@ -0,0 +1,34 @@ +#include "script_component.hpp" +/* + * Author: Salluci + * Caches all item classnames used as field rations, their thirst/hunger values, and whether they are treated as magazines + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call acex_field_rations_fnc_scanFieldRations + * + * Public: No + */ + +private _list = createHashMap; +private _cfgWeapons = configFile >> "CfgWeapons"; +private _cfgMagazines = configFile >> "CfgMagazines"; + +private _fnc_isFieldRationItem = toString { + (getNumber (_x >> "ACE_isFieldRationItem") isEqualTo 1) || {(getNumber (_x >> QXGVAR(thirstQuenched))) > 0} || {(getNumber (_x >> QXGVAR(hungerSatiated))) > 0} || {(getText (_x >> QXGVAR(refillItem))) isNotEqualTo ""} +}; + +{ + _list set [configName _x, ""]; +} forEach (_fnc_isFieldRationItem configClasses _cfgWeapons); + +{ + _list set [configName _x, ""]; +} forEach (_fnc_isFieldRationItem configClasses _cfgMagazines); + +uiNamespace setVariable [QXGVAR(fieldRationItems), compileFinal str _list]; diff --git a/addons/field_rations/script_component.hpp b/addons/field_rations/script_component.hpp index 9811493029..bcde75fe9c 100644 --- a/addons/field_rations/script_component.hpp +++ b/addons/field_rations/script_component.hpp @@ -33,3 +33,5 @@ #define IDC_DRAINING_HUD_THIRST_ICON 7750 #define IDC_DRAINING_HUD_HUNGER_GROUP 7840 #define IDC_DRAINING_HUD_HUNGER_ICON 7850 + +#define FIELD_RATIONS_ITEMS (createHashMapFromArray (call (uiNamespace getVariable [QXGVAR(fieldRationItems), {createHashMap}]))) diff --git a/docs/wiki/framework/field-rations-framework.md b/docs/wiki/framework/field-rations-framework.md index 54d2b22e90..bc433e7d52 100644 --- a/docs/wiki/framework/field-rations-framework.md +++ b/docs/wiki/framework/field-rations-framework.md @@ -28,6 +28,7 @@ Config Name | Type | Description `acex_field_rations_refillItem` | String | Makes an item refillable, class name of item added when refilled (OPTIONAL) `acex_field_rations_refillAmount` | Number | Amount of water required to refill item (OPTIONAL) `acex_field_rations_refillTime` | Number | Time required to refill item (in seconds) (OPTIONAL) +`ACE_isFieldRationItem` | Number | Force adds the item to the ACE Field Rations category in ACE Arsenal (OPTIONAL) _* Value range is 0 to 100 and can be modified by the corresponding coefficient setting._