Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

ACEX Field Rations #114

Merged
merged 52 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
18efeb9
Initial commit
mharis001 Feb 9, 2018
750ffd6
Add settings
mharis001 Feb 9, 2018
726693c
Begin postInit work
mharis001 Feb 9, 2018
65433e4
Add refill actions
mharis001 Feb 9, 2018
95e7dab
Add items and drinking sound
mharis001 Feb 10, 2018
3fb38e2
Add update function loop
mharis001 Feb 10, 2018
12207f0
Add consume actions
mharis001 Feb 10, 2018
730650a
More refill action work
mharis001 Feb 11, 2018
5e043ef
Add HUD and more update function work
mharis001 Feb 12, 2018
5a49c61
Function headers
mharis001 Feb 12, 2018
d2062c1
Handle respawn
mharis001 Feb 12, 2018
95b9da7
Add translations
mharis001 Mar 2, 2018
1491d47
Various improvements
mharis001 Mar 2, 2018
b93b968
Add README file and refill action always show
mharis001 Mar 2, 2018
8218100
RVMAT config guidelines and PBOPREFIX new line
mharis001 Apr 14, 2018
6cfd0fa
HUD improvements: ability to reposition and settings
mharis001 Apr 15, 2018
7a5d0d1
Fix requiredAddons and add to AUTHORS.txt
mharis001 Apr 23, 2018
25735bd
Misc improvements to refill actions
mharis001 May 26, 2018
c9efe80
Add handleRespawn to PREP
mharis001 Jun 2, 2018
8306cd7
Remove addRefillActions function, move to postInit + refill icon
mharis001 Jun 2, 2018
536376c
Update water refill system to include water supply
mharis001 Jun 6, 2018
95e0fcf
Compile water sources list at preStart
mharis001 Jun 6, 2018
3ac9788
Allow time settings to be set to lower values
mharis001 Jun 6, 2018
12d2ffb
Refactor update loop and 1 sec update interval
mharis001 Aug 3, 2018
b060554
Add handleEffects function
mharis001 Aug 3, 2018
166362a
Move ACEX prefix to stringtable for settings category
mharis001 Aug 3, 2018
050474f
Change HUD thirst icon to water drop
mharis001 Aug 4, 2018
ed8c3fa
Rework HUD and add draining icon HUD type
mharis001 Aug 4, 2018
3068b61
Update HUD settings
mharis001 Aug 5, 2018
5f747b8
Re-integrate HUD transparency setting
mharis001 Aug 6, 2018
b961046
Re-add auto showing of HUD and when hovering interaction
mharis001 Aug 6, 2018
6a43bf0
Optimize getConsumableChildren function
mharis001 Aug 7, 2018
9500715
Re-add repositioning of HUD and update IGUI preview
mharis001 Aug 7, 2018
cef69ca
Add drink animations
mharis001 Oct 3, 2018
792cb28
Update CfgWeapons with new entries
mharis001 Oct 3, 2018
970a541
Update consumable functions for new entries
mharis001 Oct 6, 2018
5c769a1
Add water actions to map objects
PabstMirror Nov 4, 2018
c76dc77
Merge remote-tracking branch 'upstream/114work2' into fieldRations
mharis001 Nov 4, 2018
348a75f
Add drinkable soda cans
mharis001 Nov 6, 2018
5e6352e
Make drinking animations transition
mharis001 Nov 7, 2018
54832a0
Add new drinking sounds
mharis001 Nov 7, 2018
7f2507f
Animation and sound syncing for consumeItem
mharis001 Nov 7, 2018
5a9a232
delay a frame for progress bar
PabstMirror Nov 15, 2018
9401255
Cleanup stringtables and water source actions
mharis001 Nov 16, 2018
d850e95
Add fade delay to HUD when hovering on interaction
mharis001 Nov 16, 2018
c7b226c
Add soda can animations and sounds
mharis001 Nov 17, 2018
6b93969
Add placeable items
mharis001 Nov 17, 2018
8c5a1db
Clearer config entry names
mharis001 Nov 18, 2018
767c35e
Action offset support for p3ds
mharis001 Nov 18, 2018
f3a1938
Disable Debug
PabstMirror Nov 19, 2018
cce250f
Merge remote-tracking branch 'origin/fieldRations' into fieldRations
mharis001 Nov 19, 2018
5974b52
Show refill actions when source has supply of 0
mharis001 Nov 19, 2018
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
1 change: 1 addition & 0 deletions addons/field_rations/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\acex\addons\field_rations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty newline missing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought $PBOPREFIX$ files did not have newline at end, or at least according to this: https://community.bistudio.com/wiki/PBOPREFIX

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's false. And we don't even use BI's Addon Builder anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BI Addon builder doesn't even use PBOPREFIX file.

17 changes: 17 additions & 0 deletions addons/field_rations/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
7 changes: 7 additions & 0 deletions addons/field_rations/CfgSounds.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CfgSounds {
class GVAR(drinking) {
name = QGVAR(drinking);
sound[] = {QPATHTOF(sounds\drinkingSound.ogg), 1, 1};
titles[] = {};
};
};
48 changes: 48 additions & 0 deletions addons/field_rations/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_SelfActions {
class ACEX_FieldRations {
displayName = CSTRING(MainInteractionText);
condition = QUOTE(GVAR(enabled));
exceptions[] = {"isNotInside"};
statement = QUOTE(GVAR(hudInteractionHover) = true; [0.5] call FUNC(showHud));
runOnHover = 1;
insertChildren = QUOTE((_this select 1) call FUNC(getConsumableChildren));
icon = QPATHTOF(ui\icon_survival.paa);
};
};
};

class Items_base_F;
class Land_WaterBarrel_F: Items_base_F {
GVAR(refillSource) = 1;
};
class Land_BarrelWater_F: Items_base_F {
GVAR(refillSource) = 1;
};
class Land_BarrelWater_grey_F: Items_base_F {
GVAR(refillSource) = 1;
};
class Land_WaterTank_F: Items_base_F {
GVAR(refillSource) = 1;
};

class Stall_base_F;
class Land_StallWater_F: Stall_base_F {
GVAR(refillSource) = 1;
};

class Land_StorageBladder_02_F;
class StorageBladder_02_water_forest_F: Land_StorageBladder_02_F {
GVAR(refillSource) = 1;
};
class StorageBladder_02_water_sand_F: Land_StorageBladder_02_F {
GVAR(refillSource) = 1;
};

class NonStrategic;
class Land_Water_source_F: NonStrategic {
GVAR(refillSource) = 1;
};
};
163 changes: 163 additions & 0 deletions addons/field_rations/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
class CfgWeapons {
class ACE_ItemCore;
class CBA_MiscItem_ItemInfo;

// Water Bottles
class ACE_WaterBottle: ACE_ItemCore {
author = ACECSTRING(common,ACETeam);
scope = 2;
displayName = CSTRING(WaterBottle_DisplayName);
descriptionShort = CSTRING(WaterBottle_Description);
model = "\a3\structures_f_epa\items\food\bottleplastic_v2_f.p3d";
picture = QPATHTOF(ui\item_waterbottle_full_co.paa);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 5;
};
GVAR(consumeTime) = 5;
GVAR(consumeEffect) = QGVAR(drinking);
GVAR(isDrinkable) = 7.5;
GVAR(replacementItem) = "ACE_WaterBottle_half";
};

class ACE_WaterBottle_half: ACE_WaterBottle {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(WaterBottleHalf_DisplayName);
descriptionShort = CSTRING(WaterBottleHalf_Description);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 3;
};
GVAR(replacementItem) = "ACE_WaterBottle_empty";
GVAR(onRefill) = "ACE_WaterBottle";
};

class ACE_WaterBottle_empty: ACE_WaterBottle {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(WaterBottleEmpty_DisplayName);
descriptionShort = CSTRING(WaterBottleEmpty_Description);
picture = QPATHTOF(ui\item_waterbottle_empty_co.paa);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 1;
};
GVAR(isDrinkable) = 0;
GVAR(replacementItem) = "";
GVAR(onRefill) = "ACE_WaterBottle";
};

// Canteens
class ACE_Canteen: ACE_ItemCore {
author = ACECSTRING(common,ACETeam);
scope = 2;
displayName = CSTRING(Canteen_DisplayName);
descriptionShort = CSTRING(Canteen_Description);
model = "\a3\structures_f_epa\items\food\canteen_f.p3d";
picture = QPATHTOF(ui\item_canteen_co.paa);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 5;
};
GVAR(consumeTime) = 5;
GVAR(consumeEffect) = QGVAR(drinking);
GVAR(consumeActionText) = CSTRING(DrinkFromCanteen);
GVAR(isDrinkable) = 10;
GVAR(replacementItem) = "ACE_Canteen_half";
};

class ACE_Canteen_half: ACE_Canteen {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(CanteenHalf_DisplayName);
descriptionShort = CSTRING(CanteenHalf_Description);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 3;
};
GVAR(consumeActionText) = CSTRING(DrinkFromCanteenHalf);
GVAR(replacementItem) = "ACE_Canteen_empty";
GVAR(onRefill) = "ACE_Canteen";
};

class ACE_Canteen_empty: ACE_Canteen {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(CanteenEmpty_DisplayName);
descriptionShort = CSTRING(CanteenEmpty_Description);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 1;
};
GVAR(isDrinkable) = 0;
GVAR(consumeActionText) = "";
GVAR(replacementItem) = "";
GVAR(onRefill) = "ACE_Canteen";
};

// MREs
class ACE_MRE_LambCurry: ACE_ItemCore {
author = ACECSTRING(common,ACETeam);
scope = 2;
displayName = CSTRING(MRE_LambCurry_DisplayName);
descriptionShort = CSTRING(MRE_LambCurry_Description);
model = QPATHTOF(data\mre_type1.p3d);
picture = QPATHTOF(ui\item_mre_type1_co.paa);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 5;
};
GVAR(consumeTime) = 8;
GVAR(isEatable) = 20;
};

class ACE_MRE_Rice: ACE_MRE_LambCurry {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(MRE_Rice_DisplayName);
descriptionShort = CSTRING(MRE_Rice_Description);
model = QPATHTOF(data\mre_type2.p3d);
picture = QPATHTOF(ui\item_mre_type2_co.paa);
};

class ACE_MRE_CreamTomatoSoup: ACE_MRE_LambCurry {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(MRE_CreamTomatoSoup_DisplayName);
descriptionShort = CSTRING(MRE_CreamTomatoSoup_Description);
model = QPATHTOF(data\mre_type3.p3d);
picture = QPATHTOF(ui\item_mre_type3_co.paa);
};

class ACE_MRE_CreamChickenSoup: ACE_MRE_CreamTomatoSoup {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(MRE_CreamChickenSoup_DisplayName);
descriptionShort = CSTRING(MRE_CreamChickenSoup_Description);
};

class ACE_MRE_ChickenTikkaMasala: ACE_MRE_LambCurry {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(MRE_ChickenTikkaMasala_DisplayName);
descriptionShort = CSTRING(MRE_ChickenTikkaMasala_Description);
model = QPATHTOF(data\mre_type4.p3d);
picture = QPATHTOF(ui\item_mre_type4_co.paa);
};

class ACE_MRE_SteakVegetables: ACE_MRE_LambCurry {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(MRE_SteakVegetables_DisplayName);
descriptionShort = CSTRING(MRE_SteakVegetables_Description);
model = QPATHTOF(data\mre_type5.p3d);
picture = QPATHTOF(ui\item_mre_type5_co.paa);
};

class ACE_MRE_MeatballsPasta: ACE_MRE_LambCurry {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(MRE_MeatballsPasta_DisplayName);
descriptionShort = CSTRING(MRE_MeatballsPasta_Description);
model = QPATHTOF(data\mre_type6.p3d);
picture = QPATHTOF(ui\item_mre_type6_co.paa);
};

class ACE_MRE_ChickenHerbDumplings: ACE_MRE_MeatballsPasta {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(MRE_ChickenHerbDumplings_DisplayName);
descriptionShort = CSTRING(MRE_ChickenHerbDumplings_Description);
};

class ACE_Humanitarian_Ration: ACE_MRE_LambCurry {
author = ACECSTRING(common,ACETeam);
displayName = CSTRING(Humanitarian_Ration_DisplayName);
descriptionShort = CSTRING(Humanitarian_Ration_Description);
model = QPATHTOF(data\mre_human.p3d);
picture = QPATHTOF(ui\item_mre_human_co.paa);
};
};
13 changes: 13 additions & 0 deletions addons/field_rations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
acex_field_rations
==================

Provides a survival style, hunger and thirst system.
Adds consumable items such as MREs.

## Maintainers

The people responsible for merging changes to this component or answering potential questions.

- [mharis001](https://github.com/mharis001)
- [PabstMirror](https://github.com/PabstMirror)
- [Glowbal](https://github.com/Glowbal)
30 changes: 30 additions & 0 deletions addons/field_rations/RscTitles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class RscPicture;

class RscTitles {
class GVAR(hud) {
idd = -1;
fadeIn = 0;
fadeOut = 0;
duration = 999999;
movingEnable = 0;
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(hud),_this select 0)]);
onUnload = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(hud),displayNull)]);
class controls {
class thirstStatus: RscPicture {
idc = IDC_THIRST;
x = "(safeZoneX + safeZoneW) - (4.2 * ((safeZoneW / safeZoneH) min 1.2) / 40)";
y = "(safeZoneY + safeZoneH) - (2.1 * (((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25))";
w = "2 * (((safeZoneW / safeZoneH) min 1.2) / 40)";
h = "2 * ((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25)";
sizeEx = 0.032;
text = QPATHTOF(ui\icon_hud_thirststatus.paa);
colorText[] = {1, 1, 1, 1};
};
class hungerStatus: thirstStatus {
idc = IDC_HUNGER;
x = "(safeZoneX + safeZoneW) - (2.1 * ((safeZoneW / safeZoneH) min 1.2) / 40)";
text = QPATHTOF(ui\icon_hud_hungerstatus.paa);
};
};
};
};
8 changes: 8 additions & 0 deletions addons/field_rations/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREP(addRefillActions);
PREP(canConsumeItem);
PREP(canRefillItem);
PREP(consumeItem);
PREP(getConsumableChildren);
PREP(refillItem);
PREP(showHud);
PREP(update);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing handleRespawn

42 changes: 42 additions & 0 deletions addons/field_rations/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "script_component.hpp"

if !(hasInterface) exitWith {};

["ace_settingsInitialized", {
TRACE_3("Settings Initialized",GVAR(enabled),GVAR(timeWithoutWater),GVAR(timeWithoutFood));

if !(GVAR(enabled)) exitWith {};

// Add Advanced Fatigue duty factor
if (missionNamespace getVariable [QACEGVAR(advanced_fatigue,enabled), false]) then {
LOG("Adding Duty Factor");
[QUOTE(ADDON), {
(linearConversion [75, 0, _this getVariable [QGVAR(thirst), 100], 1, 2, true]) * (linearConversion [60, 0, _this getVariable [QGVAR(hunger), 100], 1, 1.5, true])
}] call ACEFUNC(advanced_fatigue,addDutyFactor);
};

// HUD variables
GVAR(hudInteractionHover) = false;
GVAR(hudIsShowing) = false;

[] call FUNC(addRefillActions);

// Start update loop with 10 second interval and 60 second MP sync
[LINKFUNC(update), CBA_missionTime + MP_SYNC_INTERVAL, 10] call CBA_fnc_waitAndExecute;

// Add event to hide HUD if it was shown through interact menu hover
["ace_interactMenuClosed", {
if (GVAR(hudInteractionHover)) then {
GVAR(hudInteractionHover) = false;
[3] call FUNC(showHud);
};
}] call CBA_fnc_addEventHandler;

// Add respawn eventhandler to reset necessary variables, done through script so only added if field rations is enabled
["CAManBase", "respawn", LINKFUNC(handleRespawn)] call CBA_fnc_addClassEventHandler;

#ifdef DEBUG_MODE_FULL
["ACE_player thirst", {ACE_player getVariable [QGVAR(thirst), 100]}, [true, 0, 100]] call ACEFUNC(common,watchVariable);
["ACE_player hunger", {ACE_player getVariable [QGVAR(hunger), 100]}, [true, 0, 100]] call ACEFUNC(common,watchVariable);
#endif
}] call CBA_fnc_addEventHandler;
11 changes: 11 additions & 0 deletions addons/field_rations/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#include "initSettings.sqf"

ADDON = true;
3 changes: 3 additions & 0 deletions addons/field_rations/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
21 changes: 21 additions & 0 deletions addons/field_rations/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"acex_main"};
author = ACECSTRING(common,ACETeam);
authors[]= {"mharis001", "Glowbal", "PabstMirror"};
url = ACECSTRING(main,URL);
VERSION_CONFIG;
};
};

#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "CfgSounds.hpp"
#include "RscTitles.hpp"
Loading