2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2021-10-14 15:46:43 +00:00
|
|
|
/*
|
|
|
|
* Author: mharis001, Glowbal, PabstMirror
|
|
|
|
* Handles the effects/consequences of high thirst/hunger.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Player <OBJECT>
|
|
|
|
* 1: Thirst <NUMBER>
|
|
|
|
* 2: Hunger <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [_player, _thirst, _hunger] call ace_field_rations_fnc_handleEffects
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_player", "_thirst", "_hunger"];
|
|
|
|
|
|
|
|
// Kill unit with max thirst or hunger
|
|
|
|
if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith {
|
2024-05-31 20:07:50 +00:00
|
|
|
[_player, "Hunger/Thirst empty"] call EFUNC(common,setDead);
|
2021-10-14 15:46:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Exit if unit is not awake, below are animation based consequences
|
|
|
|
if !(_player call EFUNC(common,isAwake)) exitWith {};
|
|
|
|
|
2024-08-10 16:55:33 +00:00
|
|
|
// Trigger high thirst/hunger consequence
|
2024-06-18 00:07:38 +00:00
|
|
|
if (
|
|
|
|
GETEGVAR(medical,enabled,false) &&
|
2024-08-10 16:55:33 +00:00
|
|
|
{(_thirst > 85 || {_hunger > 85})}
|
2024-06-18 00:07:38 +00:00
|
|
|
) exitWith {
|
2024-08-10 16:55:33 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
};
|
2021-10-14 15:46:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Make unit fall if moving fast
|
2024-06-18 00:07:38 +00:00
|
|
|
if ((_thirst > 93 || {_hunger > 93}) && {speed _player > 1} && {isNull objectParent _player}) exitWith {
|
2021-10-14 15:46:43 +00:00
|
|
|
[_player, "down"] call EFUNC(common,doGesture);
|
|
|
|
};
|