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

Improve unconscious volume handling #6455

Merged
merged 5 commits into from Jul 20, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 27 additions & 6 deletions addons/medical_feedback/XEH_postInit.sqf
Expand Up @@ -21,21 +21,42 @@ GVAR(heartBeatEffectRunning) = false;
["ace_unconscious", {
params ["_unit", "_unconscious"];

if (local _unit) then {
_unit setVariable ["tf_voiceVolume", [1, 0] select _unconscious, true];
_unit setVariable ["tf_unable_to_use_radio", _unconscious, true];
_unit setVariable ["acre_sys_core_isDisabled", _unconscious, true];
};

if (_unit != ACE_player) exitWith {};

// Toggle unconscious player's ability to talk in radio addons
_unit setVariable ["tf_voiceVolume", [1, 0] select _unconscious, true];
_unit setVariable ["tf_unable_to_use_radio", _unconscious]; // Only used locally
_unit setVariable ["acre_sys_core_isDisabled", _unconscious, true];

// Greatly reduce player's hearing ability while unconscious (affects radio addons)
[QUOTE(ADDON), VOL_UNCONSCIOUS, _unconscious] call EFUNC(common,setHearingCapability);

[_unconscious, 1] call FUNC(effectUnconscious);
["unconscious", _unconscious] call EFUNC(common,setDisableUserInputStatus);
}] call CBA_fnc_addEventHandler;

// Reset volume upon death for spectators
[QEGVAR(medical,death), {
params ["_unit"];

if (_unit != ACE_player) exitWith {};

_unit setVariable ["tf_voiceVolume", 1, true];
_unit setVariable ["tf_unable_to_use_radio", false];
_unit setVariable ["acre_sys_core_isDisabled", false, true];
[QUOTE(ADDON), 1, false] call EFUNC(common,setHearingCapability);
}] call CBA_fnc_addEventHandler;

// Update effects to match new unit's current status (this also handles respawn)
["unit", {
params ["_new", "_old"];

private _status = _new getVariable ["ace_unconscious", false];

_new setVariable ["tf_voiceVolume", [1, 0] select _status, true];
_new setVariable ["tf_unable_to_use_radio", _status];
_new setVariable ["acre_sys_core_isDisabled", _status, true];
[QUOTE(ADDON), VOL_UNCONSCIOUS, _status] call EFUNC(common,setHearingCapability);
[_status, 0] call FUNC(effectUnconscious);
["unconscious", _status] call EFUNC(common,setDisableUserInputStatus);
}] call CBA_fnc_addPlayerEventHandler;
2 changes: 2 additions & 0 deletions addons/medical_feedback/script_component.hpp
Expand Up @@ -34,3 +34,5 @@
#define SND_HEARBEAT_FAST (selectRandom ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"])
#define SND_HEARBEAT_NORMAL (selectRandom ["ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"])
#define SND_HEARBEAT_SLOW (selectRandom ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"])

#define VOL_UNCONSCIOUS 0.25
5 changes: 2 additions & 3 deletions addons/medical_statemachine/Statemachine.hpp
Expand Up @@ -107,8 +107,7 @@ class ACE_Medical_StateMachine {
};
};
class Dead {
// TODO: this needs to be handled by a function instead of inline scripts
// Probably also needs additional logic to deal with edge cases
onStateEntered = "_this setDamage 1"; // killing a unit also exits the state machine for this unit
// When the unit is killed it's no longer handled by the statemachine
onStateEntered = QFUNC(enteredStateDeath);
};
};
1 change: 1 addition & 0 deletions addons/medical_statemachine/XEH_PREP.hpp
@@ -1,6 +1,7 @@
PREP(conditionCardiacArrestTimer);
PREP(conditionExecutionDeath);
PREP(enteredStateCardiacArrest);
PREP(enteredStateDeath);
PREP(enteredStateFatalInjury);
PREP(handleStateDefault);
PREP(handleStateInjured);
Expand Down
22 changes: 22 additions & 0 deletions addons/medical_statemachine/functions/fnc_enteredStateDeath.sqf
@@ -0,0 +1,22 @@
#include "script_component.hpp"
/*
* Author: SilentSpike
* Handles a unit reaching the point of death.
*
* Arguments:
* 0: The Unit <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/

params ["_unit"];

// TODO: Probably also needs additional logic to deal with edge cases

// Send a local event before death
[QEGVAR(medical,death), [_unit]] call CBA_fnc_localEvent;

_unit setDamage 1;