From 48912be73cd1610f4fb41fc37db485f3facfbde5 Mon Sep 17 00:00:00 2001 From: Salluci <69561145+Salluci@users.noreply.github.com> Date: Sat, 25 Sep 2021 13:16:15 -0300 Subject: [PATCH] Captives - Disallow ACRE/TFAR radio usage on surrender/handcuff (#8388) * Block radio on captive/surrendered/unconscious via status effect * missing semicolon * Don't broadcast setVar if radio addon doesn't exist Co-authored-by: PabstMirror --- addons/captives/functions/fnc_setHandcuffed.sqf | 2 ++ addons/captives/functions/fnc_setSurrendered.sqf | 2 ++ addons/common/XEH_postInit.sqf | 15 +++++++++++++++ addons/common/functions/fnc_setVolume.sqf | 4 ---- .../functions/fnc_setUnconsciousState.sqf | 3 +++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index ae70b7961f5..c0065438afb 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -42,6 +42,7 @@ if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith if (_state) then { _unit setVariable [QGVAR(isHandcuffed), true, true]; [_unit, "setCaptive", QGVAR(Handcuffed), true] call EFUNC(common,statusEffect_set); + [_unit, "blockRadio", QGVAR(Handcuffed), true] call EFUNC(common,statusEffect_set); if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop [_unit, false] call FUNC(setSurrendered); @@ -82,6 +83,7 @@ if (_state) then { } else { _unit setVariable [QGVAR(isHandcuffed), false, true]; [_unit, "setCaptive", QGVAR(Handcuffed), false] call EFUNC(common,statusEffect_set); + [_unit, "blockRadio", QGVAR(Handcuffed), false] call EFUNC(common,statusEffect_set); //remove AnimChanged EH private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1]; diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index a9b4ef85a7e..331a5ab2313 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -45,6 +45,7 @@ if (_state) then { _unit setVariable [QGVAR(isSurrendering), true, true]; [_unit, "setCaptive", QGVAR(Surrendered), true] call EFUNC(common,statusEffect_set); + [_unit, "blockRadio", QGVAR(Surrendered), true] call EFUNC(common,statusEffect_set); if (_unit == ACE_player) then { ["captive", [false, false, false, false, false, false, false, false, false, true]] call EFUNC(common,showHud); @@ -71,6 +72,7 @@ if (_state) then { } else { _unit setVariable [QGVAR(isSurrendering), false, true]; [_unit, "setCaptive", QGVAR(Surrendered), false] call EFUNC(common,statusEffect_set); + [_unit, "blockRadio", QGVAR(Surrendered), false] call EFUNC(common,statusEffect_set); //remove AnimChanged EH private _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 1791b30dbf5..baedcd79638 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -26,6 +26,7 @@ ["blockEngine", false, ["ACE_Refuel"]] call FUNC(statusEffect_addType); ["blockThrow", false, ["ACE_Attach", "ACE_concertina_wire", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_rearm", "ACE_refuel", "ACE_Sandbag", "ACE_Trenches", "ACE_tripod"]] call FUNC(statusEffect_addType); ["setHidden", true, ["ace_unconscious"]] call FUNC(statusEffect_addType); +["blockRadio", false, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered), "ace_unconscious"]] call FUNC(statusEffect_addType); [QGVAR(forceWalk), { params ["_object", "_set"]; @@ -71,6 +72,20 @@ }; }] call CBA_fnc_addEventHandler; +[QGVAR(blockRadio), { + params ["_object", "_set"]; + TRACE_2("blockRadio EH",_object,_set); + if (_object isEqualTo ACE_Player && {_set > 0}) then { + call FUNC(endRadioTransmission); + }; + if (isClass (configFile >> "CfgPatches" >> "task_force_radio")) then { + _object setVariable ["tf_unable_to_use_radio", _set > 0, true]; + }; + if (isClass (configFile >> "CfgPatches" >> "acre_main")) then { + _object setVariable ["acre_sys_core_isDisabled", _set > 0, true]; + }; +}] call CBA_fnc_addEventHandler; + [QGVAR(blockDamage), { //Name reversed from `allowDamage` because we want NOR logic params ["_object", "_set"]; if ((_object isKindOf "CAManBase") && {(["ace_medical"] call FUNC(isModLoaded))}) then { diff --git a/addons/common/functions/fnc_setVolume.sqf b/addons/common/functions/fnc_setVolume.sqf index 01de0b2802c..b4d0423d0e1 100644 --- a/addons/common/functions/fnc_setVolume.sqf +++ b/addons/common/functions/fnc_setVolume.sqf @@ -33,11 +33,9 @@ if (_setVolume) then { // TFAR _unit setVariable ["tf_voiceVolume", NORMAL_LEVEL, true]; _unit setVariable ["tf_globalVolume", NORMAL_LEVEL]; - _unit setVariable ["tf_unable_to_use_radio", false]; // ACRE2 if (!isNil "acre_api_fnc_setGlobalVolume") then { [NORMAL_LEVEL^0.33] call acre_api_fnc_setGlobalVolume; }; - _unit setVariable ["acre_sys_core_isDisabled", false, true]; } else { // Vanilla Game @@ -46,9 +44,7 @@ if (_setVolume) then { // TFAR _unit setVariable ["tf_voiceVolume", NO_SOUND, true]; _unit setVariable ["tf_globalVolume", MUTED_LEVEL]; - _unit setVariable ["tf_unable_to_use_radio", true]; // ACRE2 if (!isNil "acre_api_fnc_setGlobalVolume") then { [MUTED_LEVEL^0.33] call acre_api_fnc_setGlobalVolume; }; - _unit setVariable ["acre_sys_core_isDisabled", true, true]; }; diff --git a/addons/medical_status/functions/fnc_setUnconsciousState.sqf b/addons/medical_status/functions/fnc_setUnconsciousState.sqf index 6508e2fb1c4..0a10a29a5d4 100644 --- a/addons/medical_status/functions/fnc_setUnconsciousState.sqf +++ b/addons/medical_status/functions/fnc_setUnconsciousState.sqf @@ -31,6 +31,9 @@ _unit setVariable [VAR_UNCON, _active, true]; // 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); + if (_active) then { // Don't bother setting this if not used if (EGVAR(medical,spontaneousWakeUpChance) > 0) then {