Field Rations - Add arsenal category (#9221)

* add field rations category

* improve macro

* second verse same as the first

* account for empty items

* switch to configClasses

* documentation

* add API variable

* Update docs/wiki/framework/field-rations-framework.md
This commit is contained in:
Grim 2023-07-07 07:14:35 +03:00 committed by GitHub
parent 04e41a4d5a
commit 30a0e55843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 1 deletions

View File

@ -40,6 +40,7 @@ class CfgWeapons {
XGVAR(replacementItem) = "ACE_WaterBottle_Half"; XGVAR(replacementItem) = "ACE_WaterBottle_Half";
XGVAR(consumeAnims)[] = {QGVAR(drinkStand), QGVAR(drinkCrouch), QGVAR(drinkProne)}; XGVAR(consumeAnims)[] = {QGVAR(drinkStand), QGVAR(drinkCrouch), QGVAR(drinkProne)};
XGVAR(consumeSounds)[] = {QGVAR(drink1), QGVAR(drink1), QGVAR(drink2)}; XGVAR(consumeSounds)[] = {QGVAR(drink1), QGVAR(drink1), QGVAR(drink2)};
ACE_isFieldRationItem = 1;
}; };
class ACE_WaterBottle_Half: ACE_WaterBottle { class ACE_WaterBottle_Half: ACE_WaterBottle {
@ -87,6 +88,7 @@ class CfgWeapons {
XGVAR(replacementItem) = "ACE_Canteen_Half"; XGVAR(replacementItem) = "ACE_Canteen_Half";
XGVAR(consumeAnims)[] = {QGVAR(drinkStand), QGVAR(drinkCrouch), QGVAR(drinkProne)}; XGVAR(consumeAnims)[] = {QGVAR(drinkStand), QGVAR(drinkCrouch), QGVAR(drinkProne)};
XGVAR(consumeSounds)[] = {QGVAR(drink1), QGVAR(drink1), QGVAR(drink2)}; XGVAR(consumeSounds)[] = {QGVAR(drink1), QGVAR(drink1), QGVAR(drink2)};
ACE_isFieldRationItem = 1;
}; };
class ACE_Canteen_Half: ACE_Canteen { class ACE_Canteen_Half: ACE_Canteen {
@ -132,6 +134,7 @@ class CfgWeapons {
XGVAR(consumeText) = CSTRING(DrinkingX); XGVAR(consumeText) = CSTRING(DrinkingX);
XGVAR(consumeAnims)[] = {QGVAR(drinkStandCan), QGVAR(drinkCrouchCan), QGVAR(drinkProneCan)}; XGVAR(consumeAnims)[] = {QGVAR(drinkStandCan), QGVAR(drinkCrouchCan), QGVAR(drinkProneCan)};
XGVAR(consumeSounds)[] = {QGVAR(drinkCan1), QGVAR(drinkCan1), QGVAR(drinkCan2)}; XGVAR(consumeSounds)[] = {QGVAR(drinkCan1), QGVAR(drinkCan1), QGVAR(drinkCan2)};
ACE_isFieldRationItem = 1;
}; };
class ACE_Can_Franta: ACE_Can_Spirit { class ACE_Can_Franta: ACE_Can_Spirit {
@ -164,6 +167,7 @@ class CfgWeapons {
XGVAR(consumeTime) = 10; XGVAR(consumeTime) = 10;
XGVAR(hungerSatiated) = 20; XGVAR(hungerSatiated) = 20;
XGVAR(consumeText) = CSTRING(EatingX); XGVAR(consumeText) = CSTRING(EatingX);
ACE_isFieldRationItem = 1;
}; };
class ACE_MRE_BeefStew: ACE_MRE_LambCurry { class ACE_MRE_BeefStew: ACE_MRE_LambCurry {
@ -225,7 +229,7 @@ class CfgWeapons {
model = QPATHTOF(data\mre_human.p3d); model = QPATHTOF(data\mre_human.p3d);
picture = QPATHTOF(ui\item_mre_human_co.paa); picture = QPATHTOF(ui\item_mre_human_co.paa);
}; };
// - Misc Food ------------------------------------------------------------ // - Misc Food ------------------------------------------------------------
class ACE_Sunflower_Seeds: ACE_ItemCore { class ACE_Sunflower_Seeds: ACE_ItemCore {
author = ECSTRING(common,ACETeam); author = ECSTRING(common,ACETeam);
@ -240,5 +244,6 @@ class CfgWeapons {
XGVAR(consumeTime) = 10; XGVAR(consumeTime) = 10;
XGVAR(hungerSatiated) = 10; XGVAR(hungerSatiated) = 10;
XGVAR(consumeText) = CSTRING(EatingX); XGVAR(consumeText) = CSTRING(EatingX);
ACE_isFieldRationItem = 1;
}; };
}; };

View File

@ -14,5 +14,6 @@ ACEX_PREP(handleEffects);
ACEX_PREP(handleHUD); ACEX_PREP(handleHUD);
ACEX_PREP(handleRespawn); ACEX_PREP(handleRespawn);
ACEX_PREP(refillItem); ACEX_PREP(refillItem);
ACEX_PREP(scanFieldRations);
ACEX_PREP(setRemainingWater); ACEX_PREP(setRemainingWater);
ACEX_PREP(update); ACEX_PREP(update);

View File

@ -8,6 +8,8 @@ PREP_RECOMPILE_END;
#include "initSettings.sqf" #include "initSettings.sqf"
#define ARSENAL_CATEGORY_ICON QPATHTOF(ui\icon_survival.paa)
// Init arrays of status modifiers // Init arrays of status modifiers
GVAR(thirstModifiers) = []; GVAR(thirstModifiers) = [];
GVAR(hungerModifiers) = []; GVAR(hungerModifiers) = [];
@ -18,4 +20,9 @@ GVAR(waterSourceP3Ds) = _cache select 0;
// List of refill action offsets corresponding to the p3ds in the array above // List of refill action offsets corresponding to the p3ds in the array above
GVAR(waterSourceOffsets) = _cache select 1; 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; ADDON = true;

View File

@ -30,3 +30,5 @@ private _waterSourceOffsets = [
uiNamespace setVariable [QGVAR(cacheP3Ds), compileFinal str [_waterSourceP3Ds, _waterSourceOffsets]]; uiNamespace setVariable [QGVAR(cacheP3Ds), compileFinal str [_waterSourceP3Ds, _waterSourceOffsets]];
TRACE_1("compiled",count _waterSourceP3Ds); TRACE_1("compiled",count _waterSourceP3Ds);
call FUNC(scanFieldRations);

View File

@ -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];

View File

@ -33,3 +33,5 @@
#define IDC_DRAINING_HUD_THIRST_ICON 7750 #define IDC_DRAINING_HUD_THIRST_ICON 7750
#define IDC_DRAINING_HUD_HUNGER_GROUP 7840 #define IDC_DRAINING_HUD_HUNGER_GROUP 7840
#define IDC_DRAINING_HUD_HUNGER_ICON 7850 #define IDC_DRAINING_HUD_HUNGER_ICON 7850
#define FIELD_RATIONS_ITEMS (createHashMapFromArray (call (uiNamespace getVariable [QXGVAR(fieldRationItems), {createHashMap}])))

View File

@ -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_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_refillAmount` | Number | Amount of water required to refill item (OPTIONAL)
`acex_field_rations_refillTime` | Number | Time required to refill item (in seconds) (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._ _* Value range is 0 to 100 and can be modified by the corresponding coefficient setting._