Skip to content

Commit 04437a3

Browse files
Medical - Make unconsciousness hide UI (#11365)
* Hide hud when uncon * Add player check * Add ui hideHud event * Re-enable hud on unit change * Feex * Fade AF stamina bar on keybind * adv fatigue - use existing event handler --------- Co-authored-by: PabstMirror <pabstmirror@gmail.com>
1 parent 26de87f commit 04437a3

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

addons/advanced_fatigue/XEH_postInit.sqf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ call FUNC(renderDebugLines);
1111
["loadout", {GVAR(inertia) = [ACE_player] call FUNC(getWeaponInertia)}, false] call CBA_fnc_addPlayerEventHandler;
1212
["unit", {GVAR(inertia) = [ACE_player] call FUNC(getWeaponInertia)}, true] call CBA_fnc_addPlayerEventHandler;
1313

14+
GVAR(uiHidden) = false; // internal var to track if ui is hidden, based on EGVAR(ui,hideHud) var but set from event handler for compatilbity
1415
["CBA_settingsInitialized", {
1516
if (!GVAR(enabled)) exitWith {};
1617

17-
[QEGVAR(ui,hideHud), LINKFUNC(updateStaminaBar)] call CBA_fnc_addEventHandler;
18+
[QEGVAR(ui,hideHud), {
19+
params ["_hide"];
20+
GVAR(uiHidden) = _hide;
21+
call FUNC(updateStaminaBar);
22+
}] call CBA_fnc_addEventHandler;
1823

1924
["baseline", {
2025
private _fatigue = ACE_player getVariable [QGVAR(aimFatigue), 0];

addons/advanced_fatigue/functions/fnc_updateStaminaBar.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Public: No
1616
*/
1717

18-
GVAR(enableStaminaBarRealized) = GVAR(enabled) && GVAR(enableStaminaBar) && {!(missionNamespace getVariable [QEGVAR(ui,hideHud), false])};
18+
GVAR(enableStaminaBarRealized) = GVAR(enabled) && GVAR(enableStaminaBar) && {!GVAR(uiHidden)};
1919
TRACE_1("updateStaminaBar",GVAR(enableStaminaBarRealized));
2020

2121
private _staminaBarContainer = uiNamespace getVariable [QGVAR(staminaBarContainer), controlNull];

addons/medical_status/XEH_postInit.sqf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
[QGVAR(addInventoryActions), _unit] call CBA_fnc_globalEvent;
2222
}, true] call CBA_fnc_addClassEventHandler;
2323

24+
if (!hasInterface) exitWith {};
2425

2526
// Handle comms status effects for spectator
2627
// Separate from medical_feedback as these affect unit behavior rather than what the player sees
@@ -36,3 +37,15 @@
3637
[_unit, false, true] call FUNC(setStatusEffects);
3738
};
3839
}] call CBA_fnc_addPlayerEventHandler;
40+
41+
// Hide hud when knocked unconscious
42+
["unit", {
43+
params ["_unit"];
44+
45+
private _hudMask = [];
46+
private _isUnconscious = IS_UNCONSCIOUS(_unit);
47+
if (_isUnconscious) then { _hudMask resize [10, false] };
48+
49+
[QEGVAR(ui,hideHud), [_isUnconscious]] call CBA_fnc_localEvent;
50+
[QGVAR(unconscious), _hudMask] call EFUNC(common,showHud);
51+
}] call CBA_fnc_addPlayerEventHandler;

addons/medical_status/functions/fnc_setUnconsciousState.sqf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ if (_active isEqualTo IS_UNCONSCIOUS(_unit) || {!alive _unit}) exitWith { TRACE_
2525

2626
_unit setVariable [VAR_UNCON, _active, true];
2727

28+
// Hide hud when knocked unconscious
29+
private _hudMask = [];
30+
2831
// Toggle unit ragdoll state
2932
[_unit, _active] call EFUNC(medical_engine,setUnconsciousAnim);
3033

3134
// Handle hiding from AI and talking blocks.
3235
[_unit, _active] call FUNC(setStatusEffects);
3336

3437
if (_active) then {
38+
_hudMask resize [10, false];
39+
3540
// Don't bother setting this if not used
3641
if (EGVAR(medical,spontaneousWakeUpChance) > 0) then {
3742
private _lastWakeUpCheck = _unit getVariable [QEGVAR(medical,lastWakeUpCheck), 0]; // could be set higher from ace_medical_fnc_setUnconscious
@@ -83,6 +88,11 @@ if (_active) then {
8388
};
8489
};
8590

91+
if (_unit == ace_player) then {
92+
[QEGVAR(ui,hideHud), [_active]] call CBA_fnc_localEvent;
93+
[QGVAR(unconscious), _hudMask] call EFUNC(common,showHud);
94+
};
95+
8696
// This event doesn't correspond to unconscious in statemachine
8797
// It's for any time a unit changes consciousness (including cardiac arrest)
8898
["ace_unconscious", [_unit, _active]] call CBA_fnc_globalEvent;

0 commit comments

Comments
 (0)