From fde9658b217447f724d9ba3f9b56587abaef54a4 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 8 Apr 2019 16:24:51 -0500 Subject: [PATCH 1/4] Medical Fedback - fix heart rate effect and limit setVar for acre/tfar --- addons/medical_feedback/XEH_postInit.sqf | 34 ++++++++++++------- .../functions/fnc_effectHeartBeat.sqf | 6 ++-- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/addons/medical_feedback/XEH_postInit.sqf b/addons/medical_feedback/XEH_postInit.sqf index 0dac59dd282..267b1bdab43 100644 --- a/addons/medical_feedback/XEH_postInit.sqf +++ b/addons/medical_feedback/XEH_postInit.sqf @@ -24,10 +24,13 @@ GVAR(heartBeatEffectRunning) = false; 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]; - + if (["tfar_core"] call EFUNC(common,isModLoaded)) then { + _unit setVariable ["tf_voiceVolume", [1, 0] select _unconscious, true]; + _unit setVariable ["tf_unable_to_use_radio", _unconscious]; // Only used locally + }; + if (["acre_sys_core"] call EFUNC(common,isModLoaded)) then { + _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); @@ -40,22 +43,29 @@ GVAR(heartBeatEffectRunning) = false; 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]; + if (["tfar_core"] call EFUNC(common,isModLoaded)) then { + _unit setVariable ["tf_voiceVolume", 1, true]; + _unit setVariable ["tf_unable_to_use_radio", false]; + }; + if (["acre_sys_core"] call EFUNC(common,isModLoaded)) then { + _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"]; + params ["_new"]; 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]; + if (["tfar_core"] call EFUNC(common,isModLoaded)) then { + _new setVariable ["tf_voiceVolume", [1, 0] select _status, true]; + _new setVariable ["tf_unable_to_use_radio", _status]; + }; + if (["acre_sys_core"] call EFUNC(common,isModLoaded)) then { + _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); diff --git a/addons/medical_feedback/functions/fnc_effectHeartBeat.sqf b/addons/medical_feedback/functions/fnc_effectHeartBeat.sqf index ad8a2d7c738..1c5c9ef9683 100644 --- a/addons/medical_feedback/functions/fnc_effectHeartBeat.sqf +++ b/addons/medical_feedback/functions/fnc_effectHeartBeat.sqf @@ -4,18 +4,18 @@ * Handles the hear beat sound. * * Arguments: - * 0: Heart rate + * None * * Return Value: * None * * Example: - * [120] call ace_medical_feedback_fnc_effectHeartBeat + * [] call ace_medical_feedback_fnc_effectHeartBeat * * Public: No */ -params ["_heartRate"]; +private _heartRate = GET_HEART_RATE(ACE_player); if (_heartRate == 0) exitWith { TRACE_1("Ending heart beat effect - zero",_heartRate); From 6d0061e800c67d120baf509b232bdfb2aac5efaf Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Tue, 9 Apr 2019 00:23:12 -0500 Subject: [PATCH 2/4] Apply suggestions from code review Co-Authored-By: PabstMirror --- addons/medical_feedback/XEH_postInit.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/medical_feedback/XEH_postInit.sqf b/addons/medical_feedback/XEH_postInit.sqf index 267b1bdab43..34c1f6c3ad6 100644 --- a/addons/medical_feedback/XEH_postInit.sqf +++ b/addons/medical_feedback/XEH_postInit.sqf @@ -28,7 +28,7 @@ GVAR(heartBeatEffectRunning) = false; _unit setVariable ["tf_voiceVolume", [1, 0] select _unconscious, true]; _unit setVariable ["tf_unable_to_use_radio", _unconscious]; // Only used locally }; - if (["acre_sys_core"] call EFUNC(common,isModLoaded)) then { + if (["acre_main"] call EFUNC(common,isModLoaded)) then { _unit setVariable ["acre_sys_core_isDisabled", _unconscious, true]; }; // Greatly reduce player's hearing ability while unconscious (affects radio addons) @@ -63,7 +63,7 @@ GVAR(heartBeatEffectRunning) = false; _new setVariable ["tf_voiceVolume", [1, 0] select _status, true]; _new setVariable ["tf_unable_to_use_radio", _status]; }; - if (["acre_sys_core"] call EFUNC(common,isModLoaded)) then { + if (["acre_main"] call EFUNC(common,isModLoaded)) then { _new setVariable ["acre_sys_core_isDisabled", _status, true]; }; [QUOTE(ADDON), VOL_UNCONSCIOUS, _status] call EFUNC(common,setHearingCapability); From 286d8a4232ae3a21a9a4d766f7f06a36c1cfeb61 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 9 Apr 2019 00:23:43 -0500 Subject: [PATCH 3/4] Update XEH_postInit.sqf --- addons/medical_feedback/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical_feedback/XEH_postInit.sqf b/addons/medical_feedback/XEH_postInit.sqf index 34c1f6c3ad6..c3c1ec0a088 100644 --- a/addons/medical_feedback/XEH_postInit.sqf +++ b/addons/medical_feedback/XEH_postInit.sqf @@ -47,7 +47,7 @@ GVAR(heartBeatEffectRunning) = false; _unit setVariable ["tf_voiceVolume", 1, true]; _unit setVariable ["tf_unable_to_use_radio", false]; }; - if (["acre_sys_core"] call EFUNC(common,isModLoaded)) then { + if (["acre_main"] call EFUNC(common,isModLoaded)) then { _unit setVariable ["acre_sys_core_isDisabled", false, true]; }; [QUOTE(ADDON), 1, false] call EFUNC(common,setHearingCapability); From 357335a22217e923f7ed85d5bfd8843304590d02 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 9 Apr 2019 09:06:55 -0500 Subject: [PATCH 4/4] use "task_force_radio" --- addons/medical_feedback/XEH_postInit.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/medical_feedback/XEH_postInit.sqf b/addons/medical_feedback/XEH_postInit.sqf index c3c1ec0a088..6b339f19935 100644 --- a/addons/medical_feedback/XEH_postInit.sqf +++ b/addons/medical_feedback/XEH_postInit.sqf @@ -24,7 +24,7 @@ GVAR(heartBeatEffectRunning) = false; if (_unit != ACE_player) exitWith {}; // Toggle unconscious player's ability to talk in radio addons - if (["tfar_core"] call EFUNC(common,isModLoaded)) then { + if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { _unit setVariable ["tf_voiceVolume", [1, 0] select _unconscious, true]; _unit setVariable ["tf_unable_to_use_radio", _unconscious]; // Only used locally }; @@ -43,7 +43,7 @@ GVAR(heartBeatEffectRunning) = false; params ["_unit"]; if (_unit != ACE_player) exitWith {}; - if (["tfar_core"] call EFUNC(common,isModLoaded)) then { + if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { _unit setVariable ["tf_voiceVolume", 1, true]; _unit setVariable ["tf_unable_to_use_radio", false]; }; @@ -59,7 +59,7 @@ GVAR(heartBeatEffectRunning) = false; private _status = _new getVariable ["ace_unconscious", false]; - if (["tfar_core"] call EFUNC(common,isModLoaded)) then { + if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { _new setVariable ["tf_voiceVolume", [1, 0] select _status, true]; _new setVariable ["tf_unable_to_use_radio", _status]; };