From de9c29d869a6dc5fbd9b5567be9f7aa6f63d48f4 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Wed, 7 Aug 2024 13:15:40 +0200 Subject: [PATCH 1/8] Hunger/Thirst Faiting cooldown of 45s --- addons/field_rations/XEH_postInit.sqf | 2 ++ addons/field_rations/functions/fnc_handleEffects.sqf | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/field_rations/XEH_postInit.sqf b/addons/field_rations/XEH_postInit.sqf index 9fc8406abaf..9344eebcbb0 100644 --- a/addons/field_rations/XEH_postInit.sqf +++ b/addons/field_rations/XEH_postInit.sqf @@ -6,6 +6,8 @@ if !(hasInterface) exitWith {}; // Exit if not enabled if (!XGVAR(enabled)) exitWith {}; + XGVAR(lastUnconEvent) = 0; + // Add Advanced Fatigue duty factor if (XGVAR(affectAdvancedFatigue) && {missionNamespace getVariable [QEGVAR(advanced_fatigue,enabled), false]}) then { [QUOTE(ADDON), { diff --git a/addons/field_rations/functions/fnc_handleEffects.sqf b/addons/field_rations/functions/fnc_handleEffects.sqf index ad60a743ad0..69870742278 100644 --- a/addons/field_rations/functions/fnc_handleEffects.sqf +++ b/addons/field_rations/functions/fnc_handleEffects.sqf @@ -27,12 +27,14 @@ if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith { // Exit if unit is not awake, below are animation based consequences if !(_player call EFUNC(common,isAwake)) exitWith {}; -// Set unit unconscious (chance based on how high thirst/hunger are) +// Set unit unconscious with 45s cooldown (chance based on how high thirst/hunger are) if ( GETEGVAR(medical,enabled,false) && + {(CBA_missionTime - XGVAR(lastUnconEvent)) > 45} && {(_thirst > 85 || {_hunger > 85}) && {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]}} ) exitWith { [_player, true, 5, true] call EFUNC(medical,setUnconscious); + XGVAR(lastUnconEvent) = CBA_missionTime; }; // Make unit fall if moving fast From c452f94779aa670587c81a14222d42e6cd3b85ab Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:31:30 +0200 Subject: [PATCH 2/8] Fix water actions on vehicles with no waterActionOffset --- addons/field_rations/XEH_postInit.sqf | 8 +++--- .../fnc_addWaterSourceInteractions.sqf | 27 ++++++++++++++----- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/addons/field_rations/XEH_postInit.sqf b/addons/field_rations/XEH_postInit.sqf index 9344eebcbb0..d11c4b44501 100644 --- a/addons/field_rations/XEH_postInit.sqf +++ b/addons/field_rations/XEH_postInit.sqf @@ -17,7 +17,7 @@ if !(hasInterface) exitWith {}; }; // Compile water source actions - private _mainAction = [ + GVAR(mainAction) = [ QGVAR(waterSource), LLSTRING(WaterSource), QPATHTOF(ui\icon_water_tap.paa), @@ -40,7 +40,7 @@ if !(hasInterface) exitWith {}; [false, false, false, false, true] ] call EFUNC(interact_menu,createAction); - private _subActions = [ + GVAR(subActions) = [ [ QGVAR(checkWater), LLSTRING(CheckWater), @@ -70,10 +70,10 @@ if !(hasInterface) exitWith {}; ]; // Add water source actions to helper - [QGVAR(helper), 0, [], _mainAction] call EFUNC(interact_menu,addActionToClass); + [QGVAR(helper), 0, [], GVAR(mainAction)] call EFUNC(interact_menu,addActionToClass); { [QGVAR(helper), 0, [QGVAR(waterSource)], _x] call EFUNC(interact_menu,addActionToClass); - } forEach _subActions; + } forEach GVAR(subActions); // Add inventory context menu option to consume items ["ACE_ItemCore", ["CONTAINER"], LSTRING(EatDrink), [], QPATHTOF(ui\icon_survival.paa), diff --git a/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf b/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf index d45ea877ca0..ae69fee97da 100644 --- a/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf +++ b/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf @@ -49,13 +49,28 @@ TRACE_1("Starting interact PFH",_interactionType); if (_waterRemaining != REFILL_WATER_DISABLED) then { private _offset = [_x] call FUNC(getActionOffset); - private _helper = QGVAR(helper) createVehicleLocal [0, 0, 0]; - _helper setVariable [QGVAR(waterSource), _x]; - _helper attachTo [_x, _offset]; + if (_offset isEqualTo [0,0,0]) then { + if !(_x getVariable [QGVAR(waterSourceActionsAdded), false]) then { + private _vehicle = _x; + _vehicle setVariable [QGVAR(waterSource), _vehicle]; + _sourcesHelped pushBack _vehicle; + // Add water source actions to the vehicle itself + private _mainAction = [_vehicle, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject); + { + [_vehicle, 0, _mainAction, _x] call EFUNC(interact_menu,addActionToObject); + } forEach GVAR(subActions); + _vehicle setVariable [QGVAR(waterSourceActionsAdded), true]; + TRACE_3("Added interaction to vehicle",_x,typeOf _x,_waterRemaining); + }; + } else { + private _helper = QGVAR(helper) createVehicleLocal [0, 0, 0]; + _helper setVariable [QGVAR(waterSource), _x]; + _helper attachTo [_x, _offset]; - _addedHelpers pushBack _helper; - _sourcesHelped pushBack _x; - TRACE_3("Added interaction helper",_x,typeOf _x,_waterRemaining); + _addedHelpers pushBack _helper; + _sourcesHelped pushBack _x; + TRACE_3("Added interaction helper",_x,typeOf _x,_waterRemaining); + }; }; }; } forEach nearestObjects [ACE_player, [], 15]; From 831bf92ca1c663888353deed7977533007b401e2 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sat, 10 Aug 2024 15:29:53 +0200 Subject: [PATCH 3/8] Allow water actions from within vehicle --- .../functions/fnc_addWaterSourceInteractions.sqf | 5 +++-- addons/field_rations/functions/fnc_checkWater.sqf | 4 +++- addons/field_rations/functions/fnc_drinkFromSource.sqf | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf b/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf index ae69fee97da..52e1254f0f8 100644 --- a/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf +++ b/addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf @@ -18,10 +18,9 @@ params ["_interactionType"]; -// Ignore when self-interaction, mounted vehicle interaction, or water source actions are disabled +// Ignore during self-interaction or when water source actions are disabled if ( _interactionType != 0 - || {vehicle ACE_player != ACE_player} || {XGVAR(waterSourceActions) == 0} ) exitWith {}; @@ -56,8 +55,10 @@ TRACE_1("Starting interact PFH",_interactionType); _sourcesHelped pushBack _vehicle; // Add water source actions to the vehicle itself private _mainAction = [_vehicle, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject); + private _selfAction = [_vehicle, 1, ["ACE_SelfActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject); { [_vehicle, 0, _mainAction, _x] call EFUNC(interact_menu,addActionToObject); + [_vehicle, 1, _selfAction, _x] call EFUNC(interact_menu,addActionToObject); } forEach GVAR(subActions); _vehicle setVariable [QGVAR(waterSourceActionsAdded), true]; TRACE_3("Added interaction to vehicle",_x,typeOf _x,_waterRemaining); diff --git a/addons/field_rations/functions/fnc_checkWater.sqf b/addons/field_rations/functions/fnc_checkWater.sqf index 32167e61140..12a831a627b 100644 --- a/addons/field_rations/functions/fnc_checkWater.sqf +++ b/addons/field_rations/functions/fnc_checkWater.sqf @@ -34,5 +34,7 @@ params ["_player", "_source"]; }; }, {}, - LLSTRING(CheckingWater) + LLSTRING(CheckingWater), + {true}, + ["isNotInside"] ] call EFUNC(common,progressBar); diff --git a/addons/field_rations/functions/fnc_drinkFromSource.sqf b/addons/field_rations/functions/fnc_drinkFromSource.sqf index cf0d18018b1..6199eaee7bc 100644 --- a/addons/field_rations/functions/fnc_drinkFromSource.sqf +++ b/addons/field_rations/functions/fnc_drinkFromSource.sqf @@ -76,5 +76,6 @@ private _progressText = if (isNull _sourceConfig) then { _fnc_onSuccess, _fnc_onFailure, _progressText, - _fnc_condition + _fnc_condition, + ["isNotInside"] ] call EFUNC(common,progressBar); From 389defeac1a9b790b07fb8ddab58eee66c5aad4f Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sat, 10 Aug 2024 18:55:33 +0200 Subject: [PATCH 4/8] WIP Selectable high thirst/hunger consequence --- .../functions/fnc_handleEffects.sqf | 20 ++++++++++++++----- addons/field_rations/initSettings.inc.sqf | 9 +++++++++ addons/field_rations/stringtable.xml | 15 ++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/addons/field_rations/functions/fnc_handleEffects.sqf b/addons/field_rations/functions/fnc_handleEffects.sqf index 69870742278..980454cac7f 100644 --- a/addons/field_rations/functions/fnc_handleEffects.sqf +++ b/addons/field_rations/functions/fnc_handleEffects.sqf @@ -27,14 +27,24 @@ if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith { // Exit if unit is not awake, below are animation based consequences if !(_player call EFUNC(common,isAwake)) exitWith {}; -// Set unit unconscious with 45s cooldown (chance based on how high thirst/hunger are) +// Trigger high thirst/hunger consequence if ( GETEGVAR(medical,enabled,false) && - {(CBA_missionTime - XGVAR(lastUnconEvent)) > 45} && - {(_thirst > 85 || {_hunger > 85}) && {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]}} + {(_thirst > 85 || {_hunger > 85})} ) exitWith { - [_player, true, 5, true] call EFUNC(medical,setUnconscious); - XGVAR(lastUnconEvent) = CBA_missionTime; + if (XGVAR(nearDepletedConsequence) == 1) then { // Set unit unconscious with a 45s cooldown + if ( + (CBA_missionTime - XGVAR(lastUnconEvent)) > 45 && + {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]} + ) then { + [_player, true, 5, true] call EFUNC(medical,setUnconscious); + XGVAR(lastUnconEvent) = CBA_missionTime; + }; + } else { // Add pain + if (ACE_Player getVariable [QEGVAR(medical,pain), 0] < 0.1) then { + [ACE_Player, 0.1] call ace_medical_fnc_adjustPainLevel; + }; + }; }; // Make unit fall if moving fast diff --git a/addons/field_rations/initSettings.inc.sqf b/addons/field_rations/initSettings.inc.sqf index 16e2d4eb2d6..173d5aec161 100644 --- a/addons/field_rations/initSettings.inc.sqf +++ b/addons/field_rations/initSettings.inc.sqf @@ -45,6 +45,15 @@ true ] call CBA_fnc_addSetting; +[ + QXGVAR(nearDepletedConsequence), + "LIST", + [LSTRING(NearDepletedConsequence_DisplayName), LSTRING(NearDepletedConsequence_Description)], + LSTRING(DisplayName), + [[0, 1], [LSTRING(NearDepletedConsequence_Pain), LSTRING(NearDepletedConsequence_Unconsciousness)], 1], + true +] call CBA_fnc_addSetting; + [ QXGVAR(waterSourceActions), "LIST", diff --git a/addons/field_rations/stringtable.xml b/addons/field_rations/stringtable.xml index 2b443ccc3c0..180dcd80b42 100644 --- a/addons/field_rations/stringtable.xml +++ b/addons/field_rations/stringtable.xml @@ -115,6 +115,21 @@ Tiempo sin agua Susuz Kalma Süresi + + Consequence of extreme thirst/hunger + Folge von extremen Durst/Hunger + Conseguenze di sete/fame estrema + + + Pain + Schmerzen + Dolore + + + Fainting + Ohnmacht + Svenimenti + How long should a person be able to go without water (hours). 一個單位脫水之前能支撐多久(單位為小時)。 From 17c1ef3c03aabeb3c829c15124ab5d71102d3c3c Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 11 Aug 2024 19:27:57 +0200 Subject: [PATCH 5/8] Condense condition for consequence --- addons/field_rations/functions/fnc_handleEffects.sqf | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/field_rations/functions/fnc_handleEffects.sqf b/addons/field_rations/functions/fnc_handleEffects.sqf index 980454cac7f..d84608ac22b 100644 --- a/addons/field_rations/functions/fnc_handleEffects.sqf +++ b/addons/field_rations/functions/fnc_handleEffects.sqf @@ -30,13 +30,11 @@ if !(_player call EFUNC(common,isAwake)) exitWith {}; // Trigger high thirst/hunger consequence if ( GETEGVAR(medical,enabled,false) && - {(_thirst > 85 || {_hunger > 85})} + {(_thirst > 85 || {_hunger > 85})} && + {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]} ) exitWith { if (XGVAR(nearDepletedConsequence) == 1) then { // Set unit unconscious with a 45s cooldown - if ( - (CBA_missionTime - XGVAR(lastUnconEvent)) > 45 && - {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]} - ) then { + if (CBA_missionTime - XGVAR(lastUnconEvent) > 45) then { [_player, true, 5, true] call EFUNC(medical,setUnconscious); XGVAR(lastUnconEvent) = CBA_missionTime; }; From 207fb4dc820cc4e32d24242fd6566af2c87379f4 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 11 Aug 2024 19:31:25 +0200 Subject: [PATCH 6/8] Medical injured sound "moan" when thirst/hunger > 70 --- addons/field_rations/functions/fnc_handleEffects.sqf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/field_rations/functions/fnc_handleEffects.sqf b/addons/field_rations/functions/fnc_handleEffects.sqf index d84608ac22b..f86ff3f3f33 100644 --- a/addons/field_rations/functions/fnc_handleEffects.sqf +++ b/addons/field_rations/functions/fnc_handleEffects.sqf @@ -27,6 +27,15 @@ if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith { // Exit if unit is not awake, below are animation based consequences if !(_player call EFUNC(common,isAwake)) exitWith {}; +// Make unit moan from high hunger/thirst +if ( + GETEGVAR(medical,enabled,false) && + {(_thirst > 70) || {_hunger > 70}} && + {random 1 < linearConversion [70, 100, _thirst max _hunger, 0.05, 0.2, true]} +) then { + [ACE_Player, "moan", round (linearConversion [70, 100, _thirst max _hunger, 0, 1, true])] call EFUNC(medical_feedback,playInjuredSound); +}; + // Trigger high thirst/hunger consequence if ( GETEGVAR(medical,enabled,false) && From 604088f8a6b00f319628d609411877a8d17406e3 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 11 Aug 2024 20:49:43 +0200 Subject: [PATCH 7/8] Reduce threshold for more intense moaning --- addons/field_rations/functions/fnc_handleEffects.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/field_rations/functions/fnc_handleEffects.sqf b/addons/field_rations/functions/fnc_handleEffects.sqf index f86ff3f3f33..6fb6468b919 100644 --- a/addons/field_rations/functions/fnc_handleEffects.sqf +++ b/addons/field_rations/functions/fnc_handleEffects.sqf @@ -33,7 +33,7 @@ if ( {(_thirst > 70) || {_hunger > 70}} && {random 1 < linearConversion [70, 100, _thirst max _hunger, 0.05, 0.2, true]} ) then { - [ACE_Player, "moan", round (linearConversion [70, 100, _thirst max _hunger, 0, 1, true])] call EFUNC(medical_feedback,playInjuredSound); + [ACE_Player, "moan", round (linearConversion [70, 90, _thirst max _hunger, 0, 2, true])] call EFUNC(medical_feedback,playInjuredSound); }; // Trigger high thirst/hunger consequence From 8d2fb3c904bce30a92ba056f337e8277b5fee038 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 2 Sep 2024 13:51:29 +0200 Subject: [PATCH 8/8] Fix refilling action from inside a vehicle --- addons/field_rations/functions/fnc_refillItem.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/field_rations/functions/fnc_refillItem.sqf b/addons/field_rations/functions/fnc_refillItem.sqf index 91542e60b42..7e34ea1228e 100644 --- a/addons/field_rations/functions/fnc_refillItem.sqf +++ b/addons/field_rations/functions/fnc_refillItem.sqf @@ -78,5 +78,6 @@ private _fnc_condition = { _fnc_onSuccess, _fnc_onFailure, LLSTRING(Refilling), - _fnc_condition + _fnc_condition, + ["isNotInside"] ] call EFUNC(common,progressBar);