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

Medical Status - Remove status effects upon death/featureCamera #9301

Merged
merged 7 commits into from
Aug 18, 2023
Merged
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
1 change: 1 addition & 0 deletions addons/medical_status/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ PREP(isBeingDragged);
PREP(isInStableCondition);
PREP(setCardiacArrestState);
PREP(setDead);
PREP(setStatusEffects);
PREP(setUnconsciousState);
PREP(updateWoundBloodLoss);
15 changes: 15 additions & 0 deletions addons/medical_status/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 3 additions & 0 deletions addons/medical_status/functions/fnc_handleKilled.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
30 changes: 30 additions & 0 deletions addons/medical_status/functions/fnc_setStatusEffects.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
* 1: Status effects value <BOOL>
* 2: Skip setHidden <BOOL> (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);
10 changes: 2 additions & 8 deletions addons/medical_status/functions/fnc_setUnconsciousState.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved

if (_active) then {
// Don't bother setting this if not used
Expand Down