Skip to content

Commit

Permalink
Captives - Disallow ACRE/TFAR radio usage on surrender/handcuff (#8388)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
LinkIsGrim and PabstMirror authored Sep 25, 2021
1 parent f9d064e commit 48912be
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions addons/captives/functions/fnc_setHandcuffed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions addons/captives/functions/fnc_setSurrendered.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
Expand Down
15 changes: 15 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions addons/common/functions/fnc_setVolume.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
};
3 changes: 3 additions & 0 deletions addons/medical_status/functions/fnc_setUnconsciousState.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 48912be

Please sign in to comment.