Improve unconscious volume handling (#6455)

* Lower player hearing upon entering unconscious
* Fix potential for unconscious units to use radio
* Evaluate player's volume upon changing unit
* Reset player volume on death
* Remove unnecessary public variable
This commit is contained in:
SilentSpike 2018-07-20 22:23:48 +01:00 committed by GitHub
parent b8cd85135e
commit 3b5747423a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 9 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);
};
};

View File

@ -1,6 +1,7 @@
PREP(conditionCardiacArrestTimer);
PREP(conditionExecutionDeath);
PREP(enteredStateCardiacArrest);
PREP(enteredStateDeath);
PREP(enteredStateFatalInjury);
PREP(handleStateDefault);
PREP(handleStateInjured);

View File

@ -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;