Skip to content

Commit a00ca9b

Browse files
mrschickjohnb432
andauthored
Field Rations - Improve and add setting for needs consequence (#10675)
Co-authored-by: johnb432 <[email protected]>
1 parent 9635d54 commit a00ca9b

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

addons/field_rations/functions/fnc_handleEffects.sqf

+23-8
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,31 @@ if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith {
2727
// Exit if unit is not awake, below are animation based consequences
2828
if !(_player call EFUNC(common,isAwake)) exitWith {};
2929

30-
// Set unit unconscious (chance based on how high thirst/hunger are)
30+
// Make unit moan from high hunger/thirst
3131
if (
32-
GETEGVAR(medical,enabled,false) &&
33-
{(_thirst > 85 || {_hunger > 85}) && {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]}}
34-
) exitWith {
35-
if (_player getVariable [QGVAR(nextUnconsciousTime), CBA_missionTime] > CBA_missionTime) exitWith {};
36-
37-
_player setVariable [QGVAR(nextUnconsciousTime), CBA_missionTime + 15];
32+
GETEGVAR(medical,enabled,false) &&
33+
{(_thirst > CONSEQ_THRESHOLD_LIGHT) || {_hunger > CONSEQ_THRESHOLD_LIGHT}} &&
34+
{random 1 < linearConversion [CONSEQ_THRESHOLD_LIGHT, 100, (_thirst max _hunger), 0.05, 0.2, true]}
35+
) then {
36+
[ACE_Player, "moan", round (linearConversion [CONSEQ_THRESHOLD_LIGHT, 90, (_thirst max _hunger), 0, 2, true])] call EFUNC(medical_feedback,playInjuredSound);
37+
};
3838

39-
[_player, true, 5, true] call EFUNC(medical,setUnconscious);
39+
// Trigger high thirst/hunger consequence (chance based on how high thirst/hunger are)
40+
if (
41+
GETEGVAR(medical,enabled,false) &&
42+
{(_thirst > CONSEQ_THRESHOLD_SEVERE || {_hunger > CONSEQ_THRESHOLD_SEVERE}) &&
43+
{random 1 < linearConversion [CONSEQ_THRESHOLD_SEVERE, 100, _thirst max _hunger, 0.05, 0.1, true]}}
44+
) exitWith {
45+
if (XGVAR(nearDepletedConsequence) == 1) then { // Set unit unconscious with a 45s cooldown
46+
if (_player getVariable [QGVAR(nextUnconsciousTime), CBA_missionTime] >= CBA_missionTime) then {
47+
_player setVariable [QGVAR(nextUnconsciousTime), CBA_missionTime + 45];
48+
[_player, true, 5, true] call EFUNC(medical,setUnconscious);
49+
};
50+
} else { // Add pain
51+
if (ACE_Player getVariable [QEGVAR(medical,pain), 0] < 0.1) then {
52+
[ACE_Player, 0.1] call EFUNC(medical,adjustPainLevel);
53+
};
54+
};
4055
};
4156

4257
// Make unit fall if moving fast

addons/field_rations/initSettings.inc.sqf

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
true
4646
] call CBA_fnc_addSetting;
4747

48+
[
49+
QXGVAR(nearDepletedConsequence),
50+
"LIST",
51+
LSTRING(NearDepletedConsequence_DisplayName),
52+
LSTRING(DisplayName),
53+
[[0, 1], [LSTRING(NearDepletedConsequence_Pain), LSTRING(NearDepletedConsequence_Unconsciousness)], 1],
54+
true
55+
] call CBA_fnc_addSetting;
56+
4857
[
4958
QXGVAR(waterSourceActions),
5059
"LIST",

addons/field_rations/script_component.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#define DRINK_FROM_SOURCE_QUENCHED 10
2828
#define DRINK_FROM_SOURCE_TIME 10
2929

30+
// Threshold for high hunger/thirst consequences
31+
#define CONSEQ_THRESHOLD_LIGHT 75
32+
#define CONSEQ_THRESHOLD_SEVERE 85
33+
3034
#define IDC_COLORED_HUD_THIRST 6740
3135
#define IDC_COLORED_HUD_HUNGER 6750
3236
#define IDC_DRAINING_HUD_THIRST_GROUP 7740

addons/field_rations/stringtable.xml

+15
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,21 @@
879879
<Turkish>Hayatta kalma</Turkish>
880880
<Hungarian>Túlélés</Hungarian>
881881
</Key>
882+
<Key ID="STR_ACE_Field_Rations_NearDepletedConsequence_DisplayName">
883+
<English>Consequence of extreme thirst/hunger (over 85%)</English>
884+
<German>Folge von extremen Durst/Hunger (über 85%)</German>
885+
<Italian>Conseguenze di sete/fame estrema (oltre 85%)</Italian>
886+
</Key>
887+
<Key ID="STR_ACE_Field_Rations_NearDepletedConsequence_Pain">
888+
<English>Pain</English>
889+
<German>Schmerzen</German>
890+
<Italian>Dolore</Italian>
891+
</Key>
892+
<Key ID="STR_ACE_Field_Rations_NearDepletedConsequence_Unconsciousness">
893+
<English>Fainting</English>
894+
<German>Ohnmacht</German>
895+
<Italian>Svenimenti</Italian>
896+
</Key>
882897
<Key ID="STR_ACE_Field_Rations_NoWaterRemaining">
883898
<English>There is no water left.</English>
884899
<French>Il n'y a plus d'eau.</French>

0 commit comments

Comments
 (0)