diff --git a/addons/medical_status/XEH_PREP.hpp b/addons/medical_status/XEH_PREP.hpp index 811c49c103..34a6346ab2 100644 --- a/addons/medical_status/XEH_PREP.hpp +++ b/addons/medical_status/XEH_PREP.hpp @@ -14,5 +14,6 @@ PREP(isBeingDragged); PREP(isInStableCondition); PREP(setCardiacArrestState); PREP(setDead); +PREP(setStatusEffects); PREP(setUnconsciousState); PREP(updateWoundBloodLoss); diff --git a/addons/medical_status/XEH_postInit.sqf b/addons/medical_status/XEH_postInit.sqf index 9b7d186b46..803c67dd1b 100644 --- a/addons/medical_status/XEH_postInit.sqf +++ b/addons/medical_status/XEH_postInit.sqf @@ -2,3 +2,18 @@ // Handle pain changes on injury [QEGVAR(medical,injured), LINKFUNC(adjustPainLevel)] call CBA_fnc_addEventHandler; + +// Handle comms status effects for spectator +// Separate from medical_feedback as these affect unit behavior rather than what the player sees +["featureCamera", { + params ["_unit", "_newCamera"]; + + if (_unit isNotEqualTo ACE_player) exitWith {}; + + if (_newCamera == "") then { // switched back to player view + private _status = IS_UNCONSCIOUS(_unit); + [_unit, _status] call FUNC(setStatusEffects); + } else { + [_unit, false, true] call FUNC(setStatusEffects); + }; +}] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/medical_status/functions/fnc_handleKilled.sqf b/addons/medical_status/functions/fnc_handleKilled.sqf index f2b253cf3e..29e5e42cec 100644 --- a/addons/medical_status/functions/fnc_handleKilled.sqf +++ b/addons/medical_status/functions/fnc_handleKilled.sqf @@ -53,4 +53,7 @@ if (_unit == player) then { ["unconscious", false] call EFUNC(common,setDisableUserInputStatus); }; +// Remove status effects before respawn, in case mission is using spectator +[_unit, false] call FUNC(setStatusEffects); + ["ace_killed", [_unit, _causeOfDeath, _killer, _instigator]] call CBA_fnc_globalEvent; diff --git a/addons/medical_status/functions/fnc_setStatusEffects.sqf b/addons/medical_status/functions/fnc_setStatusEffects.sqf new file mode 100644 index 0000000000..9d93354de3 --- /dev/null +++ b/addons/medical_status/functions/fnc_setStatusEffects.sqf @@ -0,0 +1,30 @@ +#include "script_component.hpp" +/* + * Author: LinkIsGrim + * Sets status effects for a unit. + * For Internal Use: Called by FUNC(setUnconsciousState), FUNC(handleKilled), and on featureCamera changes. + * + * Arguments: + * 0: The unit + * 1: Status effects value + * 2: Skip setHidden (default: false) + * + * Return Value: + * None + * + * Public: No + */ + +params ["_unit", "_set", ["_skipSetHidden", false]]; +TRACE_3("setStatusEffect",_unit,_set,_skipSetHidden); + +// Block radio on unconsciousness for compatibility with captive module +[_unit, "blockRadio", "ace_unconscious", _set] call EFUNC(common,statusEffect_set); + +// Block speaking on unconsciousness +[_unit, "blockSpeaking", "ace_unconscious", _set] call EFUNC(common,statusEffect_set); + +if (_skipSetHidden) exitWith {}; + +// Stop AI firing at unconscious units in most situations (global effect) +[_unit, "setHidden", "ace_unconscious", _set] call EFUNC(common,statusEffect_set); diff --git a/addons/medical_status/functions/fnc_setUnconsciousState.sqf b/addons/medical_status/functions/fnc_setUnconsciousState.sqf index 214005f8d4..ccc9a8938f 100644 --- a/addons/medical_status/functions/fnc_setUnconsciousState.sqf +++ b/addons/medical_status/functions/fnc_setUnconsciousState.sqf @@ -28,14 +28,8 @@ _unit setVariable [VAR_UNCON, _active, true]; // Toggle unit ragdoll state [_unit, _active] call EFUNC(medical_engine,setUnconsciousAnim); -// Stop AI firing at unconscious units in most situations (global effect) -[_unit, "setHidden", "ace_unconscious", _active] call EFUNC(common,statusEffect_set); - -// Block radio on unconsciousness for compatibility with captive module -[_unit, "blockRadio", "ace_unconscious", _active] call EFUNC(common,statusEffect_set); - -// Block speaking on unconsciousness -[_unit, "blockSpeaking", "ace_unconscious", _active] call EFUNC(common,statusEffect_set); +// Handle hiding from AI and talking blocks. +[_unit, _active] call FUNC(setStatusEffects); if (_active) then { // Don't bother setting this if not used