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 arsenal category #9221

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion addons/field_rations/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -240,5 +244,6 @@ class CfgWeapons {
XGVAR(consumeTime) = 10;
XGVAR(hungerSatiated) = 10;
XGVAR(consumeText) = CSTRING(EatingX);
ACE_isFieldRationItem = 1;
};
};
1 change: 1 addition & 0 deletions addons/field_rations/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
7 changes: 7 additions & 0 deletions addons/field_rations/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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) = [];
Expand All @@ -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;
2 changes: 2 additions & 0 deletions addons/field_rations/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ private _waterSourceOffsets = [

uiNamespace setVariable [QGVAR(cacheP3Ds), compileFinal str [_waterSourceP3Ds, _waterSourceOffsets]];
TRACE_1("compiled",count _waterSourceP3Ds);

call FUNC(scanFieldRations);
34 changes: 34 additions & 0 deletions addons/field_rations/functions/fnc_scanFieldRations.sqf
Original file line number Diff line number Diff line change
@@ -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];
2 changes: 2 additions & 0 deletions addons/field_rations/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}])))
1 change: 1 addition & 0 deletions docs/wiki/framework/field-rations-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down