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 - Various Usability Improvements #10171

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
10 changes: 6 additions & 4 deletions addons/field_rations/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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), {
Expand All @@ -15,7 +17,7 @@ if !(hasInterface) exitWith {};
};

// Compile water source actions
private _mainAction = [
GVAR(mainAction) = [
QGVAR(waterSource),
LLSTRING(WaterSource),
QPATHTOF(ui\icon_water_tap.paa),
Expand All @@ -38,7 +40,7 @@ if !(hasInterface) exitWith {};
[false, false, false, false, true]
] call EFUNC(interact_menu,createAction);

private _subActions = [
GVAR(subActions) = [
[
QGVAR(checkWater),
LLSTRING(CheckWater),
Expand Down Expand Up @@ -68,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),
Expand Down
32 changes: 24 additions & 8 deletions addons/field_rations/functions/fnc_addWaterSourceInteractions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};

Expand Down Expand Up @@ -49,13 +48,30 @@ 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);
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);
};
} 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];
Expand Down
4 changes: 3 additions & 1 deletion addons/field_rations/functions/fnc_checkWater.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ params ["_player", "_source"];
};
},
{},
LLSTRING(CheckingWater)
LLSTRING(CheckingWater),
{true},
["isNotInside"]
] call EFUNC(common,progressBar);
3 changes: 2 additions & 1 deletion addons/field_rations/functions/fnc_drinkFromSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ private _progressText = if (isNull _sourceConfig) then {
_fnc_onSuccess,
_fnc_onFailure,
_progressText,
_fnc_condition
_fnc_condition,
["isNotInside"]
] call EFUNC(common,progressBar);
25 changes: 22 additions & 3 deletions addons/field_rations/functions/fnc_handleEffects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +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]}}
{(_thirst > 70) || {_hunger > 70}} &&
{random 1 < linearConversion [70, 100, _thirst max _hunger, 0.05, 0.2, true]}
) then {
[ACE_Player, "moan", round (linearConversion [70, 90, _thirst max _hunger, 0, 2, true])] call EFUNC(medical_feedback,playInjuredSound);
};

// Trigger high thirst/hunger consequence
if (
GETEGVAR(medical,enabled,false) &&
{(_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);
if (XGVAR(nearDepletedConsequence) == 1) then { // Set unit unconscious with a 45s cooldown
if (CBA_missionTime - XGVAR(lastUnconEvent) > 45) 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
Expand Down
3 changes: 2 additions & 1 deletion addons/field_rations/functions/fnc_refillItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ private _fnc_condition = {
_fnc_onSuccess,
_fnc_onFailure,
LLSTRING(Refilling),
_fnc_condition
_fnc_condition,
["isNotInside"]
] call EFUNC(common,progressBar);
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(NearDepletedConsequence_Description)],
LSTRING(DisplayName),
[[0, 1], [LSTRING(NearDepletedConsequence_Pain), LSTRING(NearDepletedConsequence_Unconsciousness)], 1],
true
] call CBA_fnc_addSetting;

[
QXGVAR(waterSourceActions),
"LIST",
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 @@ -115,6 +115,21 @@
<Spanish>Tiempo sin agua</Spanish>
<Turkish>Susuz Kalma Süresi</Turkish>
</Key>
<Key ID="STR_ACE_Field_Rations_NearDepletedConsequence_DisplayName">
<English>Consequence of extreme thirst/hunger</English>
<German>Folge von extremen Durst/Hunger</German>
<Italian>Conseguenze di sete/fame estrema</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_TimeWithoutWater_Description">
<English>How long should a person be able to go without water (hours).</English>
<Chinese>一個單位脫水之前能支撐多久(單位為小時)。</Chinese>
Expand Down
Loading