From 1890c71c65529dcb53ca46b7ac906bc9c65bf689 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 6 Dec 2017 16:55:01 +0100 Subject: [PATCH 1/3] replace usage of setCaptive with camouflageCoef trait --- addons/common/XEH_postInit.sqf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 0bd088a2109..a5a28365596 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -38,7 +38,16 @@ [QGVAR(setCaptive), { params ["_object", "_set"]; TRACE_2("setCaptive EH",_object,_set); - _object setCaptive (_set > 0); + private _visibility = _object getUnitTrait "camouflageCoef"; + if (_set > 0) then { + if (_visibility != 0) then { + _object setVariable [QGVAR(oldVisibility), _visibility]; + _object setUnitTrait ["camouflageCoef", 0]; + }; + } else { + _visibility = _unit getVariable [QGVAR(oldVisibility), _visibility]; + _object setUnitTrait ["camouflageCoef", _visibility]; + }; }] call CBA_fnc_addEventHandler; [QGVAR(blockDamage), { //Name reversed from `allowDamage` because we want NOR logic params ["_object", "_set"]; From eba99f4707a3853aef7a0f5add3363509266b972 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 6 Dec 2017 17:22:07 +0100 Subject: [PATCH 2/3] only use for medical, keep setCaptive for captives --- addons/common/XEH_postInit.sqf | 13 ++++++++++++- addons/medical/functions/fnc_setUnconscious.sqf | 4 ++-- addons/medical/functions/fnc_unconsciousPFH.sqf | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index a5a28365596..d15fd21dbb1 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -21,23 +21,32 @@ [QGVAR(setStatusEffect), {_this call FUNC(statusEffect_set)}] call CBA_fnc_addEventHandler; ["forceWalk", false, ["ACE_SwitchUnits", "ACE_Attach", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_Sandbag", "ACE_refuel", "ACE_rearm", "ACE_dragging"]] call FUNC(statusEffect_addType); ["blockSprint", false, []] call FUNC(statusEffect_addType); -["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered), "ace_unconscious"]] call FUNC(statusEffect_addType); +["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered)]] call FUNC(statusEffect_addType); ["blockDamage", false, ["fixCollision", "ACE_cargo"]] call FUNC(statusEffect_addType); ["blockEngine", false, ["ACE_Refuel"]] call FUNC(statusEffect_addType); +["setHidden", true, ["ace_unconscious"]] call FUNC(statusEffect_addType); [QGVAR(forceWalk), { params ["_object", "_set"]; TRACE_2("forceWalk EH",_object,_set); _object forceWalk (_set > 0); }] call CBA_fnc_addEventHandler; + [QGVAR(blockSprint), { //Name reversed from `allowSprint` because we want NOR logic params ["_object", "_set"]; TRACE_2("blockSprint EH",_object,_set); _object allowSprint (_set == 0); }] call CBA_fnc_addEventHandler; + [QGVAR(setCaptive), { params ["_object", "_set"]; TRACE_2("setCaptive EH",_object,_set); + _object setCaptive (_set > 0); +}] call CBA_fnc_addEventHandler; + +[QGVAR(setHidden), { + params ["_object", "_set"]; + TRACE_2("setHidden EH",_object,_set); private _visibility = _object getUnitTrait "camouflageCoef"; if (_set > 0) then { if (_visibility != 0) then { @@ -49,6 +58,7 @@ _object setUnitTrait ["camouflageCoef", _visibility]; }; }] 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 { @@ -59,6 +69,7 @@ _object allowDamage (_set == 0); }; }] call CBA_fnc_addEventHandler; + [QGVAR(blockEngine), { params ["_vehicle", "_set"]; _vehicle setVariable [QGVAR(blockEngine), _set > 0, true]; diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index 7b7235d7ec7..61d831f5332 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -97,7 +97,7 @@ if (GVAR(moveUnitsFromGroupOnUnconscious)) then { }; // Delay Unconscious so the AI dont instant stop shooting on the unit #3121 if (GVAR(delayUnconCaptive) == 0) then { - [_unit, "setCaptive", "ace_unconscious", true] call EFUNC(common,statusEffect_set); + [_unit, "setHidden", "ace_unconscious", true] call EFUNC(common,statusEffect_set); } else { // when the Delay is so high that the unit can wake up and get uncon again we need to check if it is the correct wait that got executed private _counter = _unit getVariable [QGVAR(unconsciousCounter), 0]; @@ -106,7 +106,7 @@ if (GVAR(delayUnconCaptive) == 0) then { [{ params ["_unit", "_counter"]; if (_unit getVariable ["ACE_isUnconscious", false] && (_unit getVariable [QGVAR(unconsciousCounter), 0]) == _counter) then { - [_unit, "setCaptive", "ace_unconscious", true] call EFUNC(common,statusEffect_set); + [_unit, "setHidden", "ace_unconscious", true] call EFUNC(common,statusEffect_set); }; },[_unit, _counter], GVAR(delayUnconCaptive)] call CBA_fnc_waitAndExecute; }; diff --git a/addons/medical/functions/fnc_unconsciousPFH.sqf b/addons/medical/functions/fnc_unconsciousPFH.sqf index b9236883a38..2f9d1a5522a 100644 --- a/addons/medical/functions/fnc_unconsciousPFH.sqf +++ b/addons/medical/functions/fnc_unconsciousPFH.sqf @@ -36,7 +36,7 @@ if (!alive _unit) exitWith { if (GVAR(moveUnitsFromGroupOnUnconscious)) then { [_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide); }; - [_unit, "setCaptive", "ace_unconscious", false] call EFUNC(common,statusEffect_set); + [_unit, "setHidden", "ace_unconscious", false] call EFUNC(common,statusEffect_set); [_unit, false] call EFUNC(common,disableAI); //_unit setUnitPos _originalPos; @@ -104,7 +104,7 @@ if !(_unit getVariable ["ACE_isUnconscious",false]) exitWith { }; if (!_hasMovedOut) then { // Reset the unit back to the previous captive state. - [_unit, "setCaptive", "ace_unconscious", false] call EFUNC(common,statusEffect_set); + [_unit, "setHidden", "ace_unconscious", false] call EFUNC(common,statusEffect_set); // Swhich the unit back to its original group //Unconscious units shouldn't be put in another group #527: From 6a6b03eb57cee38b63a26370c1dad3ea49c709de Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 7 Dec 2017 12:45:59 -0600 Subject: [PATCH 3/3] Fix undefined var --- addons/common/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index b7dec0510a3..1958c0978c7 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -55,7 +55,7 @@ _object setUnitTrait ["camouflageCoef", 0]; }; } else { - _visibility = _unit getVariable [QGVAR(oldVisibility), _visibility]; + _visibility = _object getVariable [QGVAR(oldVisibility), _visibility]; _object setUnitTrait ["camouflageCoef", _visibility]; }; }] call CBA_fnc_addEventHandler;