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 - Improve and add setting for hunger/thirst consequence #10675

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 23 additions & 8 deletions addons/field_rations/functions/fnc_handleEffects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,31 @@ 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)
// Make unit moan from high hunger/thirst
if (
GETEGVAR(medical,enabled,false) &&
{(_thirst > 85 || {_hunger > 85}) && {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]}}
) exitWith {
if (_player getVariable [QGVAR(nextUnconsciousTime), CBA_missionTime] > CBA_missionTime) exitWith {};

_player setVariable [QGVAR(nextUnconsciousTime), CBA_missionTime + 15];
GETEGVAR(medical,enabled,false) &&
{(_thirst > CONSEQ_THRESHOLD_LIGHT) || {_hunger > CONSEQ_THRESHOLD_LIGHT}} &&
{random 1 < linearConversion [CONSEQ_THRESHOLD_LIGHT, 100, (_thirst max _hunger), 0.05, 0.2, true]}
) then {
[ACE_Player, "moan", round (linearConversion [CONSEQ_THRESHOLD_LIGHT, 90, (_thirst max _hunger), 0, 2, true])] call EFUNC(medical_feedback,playInjuredSound);
};

[_player, true, 5, true] call EFUNC(medical,setUnconscious);
// Trigger high thirst/hunger consequence (chance based on how high thirst/hunger are)
if (
GETEGVAR(medical,enabled,false) &&
{(_thirst > CONSEQ_THRESHOLD_SEVERE || {_hunger > CONSEQ_THRESHOLD_SEVERE}) &&
{random 1 < linearConversion [CONSEQ_THRESHOLD_SEVERE, 100, _thirst max _hunger, 0.05, 0.1, true]}}
) exitWith {
if (XGVAR(nearDepletedConsequence) == 1) then { // Set unit unconscious with a 45s cooldown
if (_player getVariable [QGVAR(nextUnconsciousTime), CBA_missionTime] >= CBA_missionTime) then {
mrschick marked this conversation as resolved.
Show resolved Hide resolved
_player setVariable [QGVAR(nextUnconsciousTime), CBA_missionTime + 45];
[_player, true, 5, true] call EFUNC(medical,setUnconscious);
};
} else { // Add pain
if (ACE_Player getVariable [QEGVAR(medical,pain), 0] < 0.1) then {
[ACE_Player, 0.1] call EFUNC(medical,adjustPainLevel);
};
};
};

// Make unit fall if moving fast
Expand Down
9 changes: 9 additions & 0 deletions addons/field_rations/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
true
] call CBA_fnc_addSetting;

[
QXGVAR(nearDepletedConsequence),
"LIST",
LSTRING(NearDepletedConsequence_DisplayName),
LSTRING(DisplayName),
[[0, 1], [LSTRING(NearDepletedConsequence_Pain), LSTRING(NearDepletedConsequence_Unconsciousness)], 1],
true
] call CBA_fnc_addSetting;

[
QXGVAR(waterSourceActions),
"LIST",
Expand Down
4 changes: 4 additions & 0 deletions addons/field_rations/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#define DRINK_FROM_SOURCE_QUENCHED 10
#define DRINK_FROM_SOURCE_TIME 10

// Threshold for high hunger/thirst consequences
#define CONSEQ_THRESHOLD_LIGHT 75
#define CONSEQ_THRESHOLD_SEVERE 85

#define IDC_COLORED_HUD_THIRST 6740
#define IDC_COLORED_HUD_HUNGER 6750
#define IDC_DRAINING_HUD_THIRST_GROUP 7740
Expand Down
15 changes: 15 additions & 0 deletions addons/field_rations/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,21 @@
<Turkish>Hayatta kalma</Turkish>
<Hungarian>Túlélés</Hungarian>
</Key>
<Key ID="STR_ACE_Field_Rations_NearDepletedConsequence_DisplayName">
<English>Consequence of extreme thirst/hunger (over 85%)</English>
<German>Folge von extremen Durst/Hunger (über 85%)</German>
<Italian>Conseguenze di sete/fame estrema (oltre 85%)</Italian>
</Key>
<Key ID="STR_ACE_Field_Rations_NearDepletedConsequence_Pain">
<English>Pain</English>
<German>Schmerzen</German>
<Italian>Dolore</Italian>
</Key>
<Key ID="STR_ACE_Field_Rations_NearDepletedConsequence_Unconsciousness">
<English>Fainting</English>
<German>Ohnmacht</German>
<Italian>Svenimenti</Italian>
</Key>
<Key ID="STR_ACE_Field_Rations_NoWaterRemaining">
<English>There is no water left.</English>
<French>Il n'y a plus d'eau.</French>
Expand Down
Loading