diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index ac86d71915..7b06770fd3 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -27,12 +27,5 @@ if (isServer) then { ["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler); ["SetSurrendered", {_this call FUNC(setSurrendered)}] call EFUNC(common,addEventHandler); -//TODO: Medical Integration Events??? - -// [_unit, "knockedOut", { -// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleKnockedOut}; -// }] call ACE_Core_fnc_addCustomEventhandler; - -// [_unit, "wokeUp", { -// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleWokeUp}; -// }] call ACE_Core_fnc_addCustomEventhandler; +//Medical Integration Events??? +["medical_onUnconscious", {_this call ACE_Captives_fnc_handleOnUnconscious}] call EFUNC(common,addEventHandler); diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index 34c9bca910..c09f81e51b 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -19,10 +19,9 @@ PREP(doUnloadCaptive); PREP(handleGetIn); PREP(handleGetOut); PREP(handleKilled); -PREP(handleKnockedOut); +PREP(handleOnUnconscious); PREP(handlePlayerChanged); PREP(handleUnitInitPost); -PREP(handleWokeUp); PREP(handleZeusDisplayChanged); PREP(moduleSurrender); PREP(setHandcuffed); diff --git a/addons/captives/functions/fnc_doEscortCaptive.sqf b/addons/captives/functions/fnc_doEscortCaptive.sqf index 299aa81631..08f44a1437 100644 --- a/addons/captives/functions/fnc_doEscortCaptive.sqf +++ b/addons/captives/functions/fnc_doEscortCaptive.sqf @@ -51,7 +51,7 @@ if (_state) then { _unit setVariable [QGVAR(escortedUnit), objNull, true]; }; }; - [_escortFnc, 0.2, [_unit, _target, _actionID]] call CBA_fnc_addPerFrameHandler; + [_escortFnc, 0, [_unit, _target, _actionID]] call CBA_fnc_addPerFrameHandler; } else { _unit setVariable [QGVAR(isEscorting), false, true]; diff --git a/addons/captives/functions/fnc_handleKnockedOut.sqf b/addons/captives/functions/fnc_handleKnockedOut.sqf deleted file mode 100644 index 1cd969807d..0000000000 --- a/addons/captives/functions/fnc_handleKnockedOut.sqf +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Author: commy2, PabstMirror - * Handles when a unit gets knocked out. Ends surrendering. - * - * Arguments: - * 0: Unit - * - * Return Value: - * Nothing - * - * Example: - * [bob, true] call ACE_captives_fnc_handleKnockedOut - * - * Public: No - */ -#include "script_component.hpp" - - -//ToDo: Waiting on medical integration - -PARAMS_1(_unit); - -if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop - [_unit, false] call FUNC(setSurrendered); -}; diff --git a/addons/captives/functions/fnc_handleOnUnconscious.sqf b/addons/captives/functions/fnc_handleOnUnconscious.sqf new file mode 100644 index 0000000000..9b73d34485 --- /dev/null +++ b/addons/captives/functions/fnc_handleOnUnconscious.sqf @@ -0,0 +1,36 @@ +/* + * Author: commy2, PabstMirror + * Handles the "medical_onUnconscious" event + * + * Arguments: + * 0: Unit + * 0: Is Unconsisisiouses + * + * Return Value: + * Nothing + * + * Example: + * [bob, true] call ACE_captives_fnc_handleOnUnconscious + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_isUnconc); + +if (!local _unit) exitWith {}; + +systemChat format ["med: %1", _this]; + +if (_isUnconc) then { + //Knocked out: If surrendering, stop + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + [_unit, false] call FUNC(setSurrendered); + }; +} else { + //Woke up: if handcuffed, goto animation + if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { + [_unit] call EFUNC(common,fixLoweredRifleAnimation); + [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + }; +}; diff --git a/addons/captives/functions/fnc_handleWokeUp.sqf b/addons/captives/functions/fnc_handleWokeUp.sqf deleted file mode 100644 index 9bf2e1a2bc..0000000000 --- a/addons/captives/functions/fnc_handleWokeUp.sqf +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Author: commy2 - * TODO - * - * Arguments: - * 0: _unit - * - * Return Value: - * The return value - * - * Example: - * [bob] call ACE_captives_fnc_handleWokeUp - * - * Public: No - */ -#include "script_component.hpp" - -PARAMS_1(_unit); - -if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { - [_unit] call EFUNC(common,fixLoweredRifleAnimation); - [_unit, "ACE_AmovPercMstpScapWnonDnon", 0] call EFUNC(common,doAnimation); -}; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 0deb68dc8b..5917532874 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -52,7 +52,7 @@ if (_state) then { //If we get a change in animation then redo the animation (handles people vaulting to break the animation chain) _animChangedEHID = _unit addEventHandler ["AnimChanged", { PARAMS_2(_unit,_newAnimation); - if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && (_newAnimation != "Unconscious")) then { + if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { ERROR("Handcuff animation interrupted"); systemChat format ["debug %2: new %1", _newAnimation, time]; [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); @@ -71,8 +71,8 @@ if (_state) then { _unit removeEventHandler ["AnimChanged", _animChangedEHID]; _unit setVariable [QGVAR(handcuffAnimEHID), -1]; - if ((vehicle _unit) == _unit) then { - //Break out of hands up animation loop (doAnimation handles Unconscious prioity) + if (((vehicle _unit) == _unit) && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { + //Break out of hands up animation loop [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); }; diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index e49c6e9453..3a7436abc7 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -50,7 +50,7 @@ if (_state) then { //If we get a change in animation then redo the animation (handles people vaulting to break the animation chain) _animChangedEHID = _unit addEventHandler ["AnimChanged", { PARAMS_2(_unit,_newAnimation); - if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && (_newAnimation != "Unconscious")) then { + if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { ERROR("Surrender animation interrupted"); systemChat format ["debug %2: new %1", _newAnimation, time]; [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index dbb0d115c3..890f4d2787 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -25,7 +25,7 @@ if !(!(isNull _unit) && {(_unit isKindOf "CaManBase") && ([_unit] call EFUNC(com // We only want this function to work on local machines if (!local _unit) exitwith { - [[_unit], QUOTE(DFUNC(setUnconsciousState)), _unit, false] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + [[_unit], QUOTE(DFUNC(setUnconscious)), _unit, false] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ }; // Get rid of the object we are carrying, before we go unconscious. @@ -64,22 +64,21 @@ _unit setUnitPos "DOWN"; // So the AI does not get stuck, we are moving the unit to a temp group on its own. [_unit, true, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide); -_captiveSwitch = [_unit, true] call EFUNC(common,setCaptiveSwitch); +[_unit, QGVAR(unconscious), true] call EFUNC(common,setCaptivityStatus); [_unit, [_unit] call EFUNC(common,getDeathAnim), 1, true] call EFUNC(common,doAnimation); _startingTime = time; _minWaitingTime = (round(random(10)+5)); [{ - private ["_unit", "_vehicleOfUnit","_lockSwitch","_minWaitingTime", "_oldAnimation", "_captiveSwitch", "_hasMovedOut"]; + private ["_unit", "_vehicleOfUnit","_minWaitingTime", "_oldAnimation", "_captiveSwitch", "_hasMovedOut"]; _args = _this select 0; _unit = _args select 0; _oldAnimation = _args select 1; - _captiveSwitch = _args select 2; - _originalPos = _args select 3; - _startingTime = _args select 4; - _minWaitingTime = _args select 5; - _hasMovedOut = _args select 6; + _originalPos = _args select 2; + _startingTime = _args select 3; + _minWaitingTime = _args select 4; + _hasMovedOut = _args select 5; // Since the unit is no longer alive, get rid of this PFH. if (!alive _unit) exitwith { // EXIT PFH @@ -104,10 +103,8 @@ _minWaitingTime = (round(random(10)+5)); }; if (!_hasMovedOut) then { // Reset the unit back to the previous captive state. - if (_captiveSwitch) then { - [_unit, false] call EFUNC(common,setCaptiveSwitch); - }; - + [_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus); + // Swhich the unit back to its original group [_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide); @@ -137,6 +134,6 @@ _minWaitingTime = (round(random(10)+5)); [_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call EFUNC(common,doAnimation); // Reset animations if unit starts doing wierd things. }; -}, 0.1, [_unit,_animState, _captiveSwitch, _originalPos, _startingTime, _minWaitingTime, false] ] call CBA_fnc_addPerFrameHandler; +}, 0.1, [_unit,_animState, _originalPos, _startingTime, _minWaitingTime, false] ] call CBA_fnc_addPerFrameHandler; ["medical_onUnconscious", [_unit], [_unit, true]] call EFUNC(common,targetEvent);