From dec34b4b30613e662a5d3d96e09b051076a35835 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 15 Feb 2015 14:55:17 -0600 Subject: [PATCH 01/12] Surrender Fixes Remove XEH GetIn and use vehicleChanged Event Handle Zeus (showHUD) Attempt to handle failed animation change --- addons/captives/CfgEventHandlers.hpp | 10 ----- addons/captives/XEH_postInit.sqf | 3 ++ addons/captives/XEH_preInit.sqf | 3 +- addons/captives/functions/fnc_handleGetIn.sqf | 24 ------------ .../functions/fnc_handleKnockedOut.sqf | 25 ++++++++++++- .../functions/fnc_handlePlayerChanged.sqf | 8 +++- .../functions/fnc_handleVehicleChanged.sqf | 30 +++++++++++++++ .../fnc_handleZeusDisplayChanged.sqf | 31 ++++++++++++++++ .../captives/functions/fnc_setHandcuffed.sqf | 3 ++ addons/captives/functions/fnc_surrender.sqf | 37 ++++++++++--------- 10 files changed, 120 insertions(+), 54 deletions(-) delete mode 100644 addons/captives/functions/fnc_handleGetIn.sqf create mode 100644 addons/captives/functions/fnc_handleVehicleChanged.sqf create mode 100644 addons/captives/functions/fnc_handleZeusDisplayChanged.sqf diff --git a/addons/captives/CfgEventHandlers.hpp b/addons/captives/CfgEventHandlers.hpp index 722750f915..8829d0f275 100644 --- a/addons/captives/CfgEventHandlers.hpp +++ b/addons/captives/CfgEventHandlers.hpp @@ -10,15 +10,6 @@ class Extended_PostInit_EventHandlers { }; }; -//release escorted captive when entering a vehicle -class Extended_GetIn_EventHandlers { - class All { - class GVAR(AutoDetachCaptive) { - getIn = QUOTE(_this call FUNC(handleGetIn)); - }; - }; -}; - //reset captive animation after leaving vehicle class Extended_GetOut_EventHandlers { class All { @@ -45,4 +36,3 @@ class Extended_InitPost_EventHandlers { }; }; }; - diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index 9d1a242d4d..9c124630ee 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -21,6 +21,9 @@ if (isServer) then { }]; }; +["playerVehicleChanged", {_this call FUNC(handleVehicleChanged)}] call EFUNC(common,addEventHandler); +["zeusDisplayChanged", {_this call FUNC(handleZeusDisplayChanged)}] call EFUNC(common,addEventHandler); + //TODO: Medical Integration Events??? // [_unit, "knockedOut", { diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index 75ee77e9bc..f6ec44225f 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -16,12 +16,13 @@ PREP(doFriskPerson); PREP(doLoadCaptive); PREP(doRemoveHandcuffs); PREP(doUnloadCaptive); -PREP(handleGetIn); PREP(handleGetOut); PREP(handleKilled); PREP(handleKnockedOut); PREP(handlePlayerChanged); PREP(handleUnitInitPost); +PREP(handleVehicleChanged); +PREP(handleZeusDisplayChanged); PREP(handleWokeUp); PREP(moduleSurrender); PREP(setHandcuffed); diff --git a/addons/captives/functions/fnc_handleGetIn.sqf b/addons/captives/functions/fnc_handleGetIn.sqf deleted file mode 100644 index 54133e2362..0000000000 --- a/addons/captives/functions/fnc_handleGetIn.sqf +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Author: commy2 - * Handles when a unit gets in to a vehicle. Release escorted captive when entering a vehicle - * - * Arguments: - * 0: _vehicle - * 2: dunno - * 1: _unit - * - * Return Value: - * The return value - * - * Example: - * [car2, x, player] call ACE_captives_fnc_handleGetIn - * - * Public: No - */ -#include "script_component.hpp" - -PARAMS_3(_vehicle,_dontcare,_unit); - -if ((local _unit) && (_unit getVariable [QGVAR(isEscorting), false])) then { - _unit setVariable [QGVAR(isEscorting), false, true]; -}; diff --git a/addons/captives/functions/fnc_handleKnockedOut.sqf b/addons/captives/functions/fnc_handleKnockedOut.sqf index 3257d544ca..aba01b194f 100644 --- a/addons/captives/functions/fnc_handleKnockedOut.sqf +++ b/addons/captives/functions/fnc_handleKnockedOut.sqf @@ -1,2 +1,25 @@ -// by commy2 +/* + * Author: 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(surrender); +}; diff --git a/addons/captives/functions/fnc_handlePlayerChanged.sqf b/addons/captives/functions/fnc_handlePlayerChanged.sqf index 13e284ef80..21fd1e1ec3 100644 --- a/addons/captives/functions/fnc_handlePlayerChanged.sqf +++ b/addons/captives/functions/fnc_handlePlayerChanged.sqf @@ -18,10 +18,16 @@ PARAMS_2(_newUnit,_oldUnit); +//set showHUD based on new unit status: if ((_newUnit getVariable [QGVAR(isHandcuffed), false]) || {_newUnit getVariable [QGVAR(isSurrendering), false]}) then { TRACE_1("Player Change (showHUD false)",_newUnit); - showHUD false; + showHUD false; } else { TRACE_1("Player Change (showHUD true)",_newUnit); showHUD true; }; + +//If old player was escorting, stop +if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { + _oldUnit setVariable [QGVAR(isEscorting), false, true]; +}; diff --git a/addons/captives/functions/fnc_handleVehicleChanged.sqf b/addons/captives/functions/fnc_handleVehicleChanged.sqf new file mode 100644 index 0000000000..74f966ecc3 --- /dev/null +++ b/addons/captives/functions/fnc_handleVehicleChanged.sqf @@ -0,0 +1,30 @@ +/* + * Author: commy2 + * Handles when a player's vehicle changes (supports scripted vehicle changes) + * + * Arguments: + * 0: unit + * 1: newVehicle + * + * Return Value: + * Nothing + * + * Example: + * [player, car] call ACE_captives_fnc_handleVehicleChanged + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_vehicle); + +//When moved into a vehicle (action or scripted) +if ((vehicle _unit) != _unit) then { + if (_unit getVariable [QGVAR(isEscorting), false]) then { + _unit setVariable [QGVAR(isEscorting), false, true]; + }; + + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + [_unit, false] call FUNC(surrender); + }; +}; diff --git a/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf new file mode 100644 index 0000000000..e328d410fa --- /dev/null +++ b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf @@ -0,0 +1,31 @@ +/* + * Author: PabstMirror + * Handles handles ZeusDisplayChanged event + * Need to reset showHUD after closing zeus + * + * Arguments: + * 0: Unit + * 1: Display is now open + * + * Return Value: + * Nothing + * + * Example: + * [bob1, false] call ACE_captives_fnc_handleZeusDisplayChanged + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_zeusIsOpen); + +//set showHUD based on unit status: +if (!_zeusIsOpen) then { + if ((_unit getVariable [QGVAR(isHandcuffed), false]) || {_unit getVariable [QGVAR(isSurrendering), false]}) then { + TRACE_1("Player Change (showHUD false)",_newUnit); + showHUD false; + } else { + TRACE_1("Player Change (showHUD true)",_newUnit); + showHUD true; + }; +}; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 912b00662f..06906167e9 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -30,6 +30,9 @@ if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) then { if (_state) then { _unit setVariable [QGVAR(isHandcuffed), true, true]; + if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop + [_unit, _false] call FUNC(surrender); + }; [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); _unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true]; diff --git a/addons/captives/functions/fnc_surrender.sqf b/addons/captives/functions/fnc_surrender.sqf index 1f0e232926..25d5e6a008 100644 --- a/addons/captives/functions/fnc_surrender.sqf +++ b/addons/captives/functions/fnc_surrender.sqf @@ -30,12 +30,7 @@ if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) then { if (_state) then { _unit setVariable [QGVAR(isSurrendering), true, true]; - [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); - - if (_unit == ACE_player) then { - showHUD false; - }; - + // fix anim on mission start (should work on dedicated servers) [{ PARAMS_1(_unit); @@ -45,19 +40,27 @@ if (_state) then { }; }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); - //PFEH - (TODO: move to event system?) + //Start up a pfeh to make sure the unit actualy goes into the animation + //Only change variables and captivity when they reach that state + //fixes vaulting to break animation [{ - EXPLODE_1_PVT((_this select 0),_unit); - if (_unit getVariable [QGVAR(isSurrendering), false]) then { - //If unit dies, gets knocked out, or is handcuffed then end surrender - if ((!alive _unit) || {_unit getVariable ["ACE_isUnconscious", false]} || {_unit getVariable [QGVAR(isHandcuffed), false]}) then { - [_unit, false] call FUNC(surrender); - [(_this select 1)] call CBA_fnc_removePerFrameHandler; - }; - } else { - [(_this select 1)] call cba_fnc_removePerFrameHandler; + PARAMS_2(_args,_pfID); + EXPLODE_2_PVT(_args,_unit,_maxTime); + + if (time > _maxTime) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + _unit setVariable [QGVAR(isSurrendering), false, true]; + ERROR("Surrender animation failed"); }; - }, 0.0, [_unit]] call CBA_fnc_addPerFrameHandler; + if ((animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon") exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + + if (_unit == ACE_player) then { + showHUD false; + }; + [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); + }; + }, 0, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler; } else { _unit setVariable [QGVAR(isSurrendering), false, true]; [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); From 3c65c422b1ab81db92640ee90a2c52f63fc67b02 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 15 Feb 2015 16:42:00 -0600 Subject: [PATCH 02/12] More Surrender Fixes Increase "drop hands" animation speed (now just 1/2 of normal) Use "AnimChanged" EH to watch for animation breaks while surrendering Only "crack" the hands up animation if we are in the right animation state --- addons/captives/CfgMoves.hpp | 2 +- .../captives/functions/fnc_canSurrender.sqf | 11 +++- addons/captives/functions/fnc_surrender.sqf | 62 +++++++++++-------- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/addons/captives/CfgMoves.hpp b/addons/captives/CfgMoves.hpp index 6e67f3615b..d60fab5a33 100644 --- a/addons/captives/CfgMoves.hpp +++ b/addons/captives/CfgMoves.hpp @@ -72,7 +72,7 @@ class CfgMovesMaleSdr: CfgMovesBasic { InterpolateTo[] = {"Unconscious",0.01}; }; class ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { - speed = 0.333; //for gameplay reasons, slow this down + speed = 0.5; //for gameplay reasons, slow this down actions = "CivilStandActions"; file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\sur\non\AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"; ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1}; diff --git a/addons/captives/functions/fnc_canSurrender.sqf b/addons/captives/functions/fnc_canSurrender.sqf index 238087c62b..4c16e8ccd0 100644 --- a/addons/captives/functions/fnc_canSurrender.sqf +++ b/addons/captives/functions/fnc_canSurrender.sqf @@ -18,5 +18,12 @@ PARAMS_2(_unit,_newSurrenderState); -//TODO: any other conditions?? -(!((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _newSurrenderState)) +private "_returnValue"; + +_returnValue = if (_newSurrenderState) then { + !(_unit getVariable [QGVAR(isSurrendering), false]); //Not currently surrendering +} else { + (_unit getVariable [QGVAR(isSurrendering), false]); //isSurrendering and on the hands up animation - // && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}; +}; + +_returnValue diff --git a/addons/captives/functions/fnc_surrender.sqf b/addons/captives/functions/fnc_surrender.sqf index 25d5e6a008..f2103d2c1c 100644 --- a/addons/captives/functions/fnc_surrender.sqf +++ b/addons/captives/functions/fnc_surrender.sqf @@ -30,7 +30,12 @@ if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) then { if (_state) then { _unit setVariable [QGVAR(isSurrendering), true, true]; - + [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); + + if (_unit == ACE_player) then { + showHUD false; + }; + // fix anim on mission start (should work on dedicated servers) [{ PARAMS_1(_unit); @@ -38,37 +43,42 @@ if (_state) then { [_unit] call EFUNC(common,fixLoweredRifleAnimation); [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); }; - }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); - //Start up a pfeh to make sure the unit actualy goes into the animation - //Only change variables and captivity when they reach that state - //fixes vaulting to break animation - [{ - PARAMS_2(_args,_pfID); - EXPLODE_2_PVT(_args,_unit,_maxTime); - - if (time > _maxTime) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - _unit setVariable [QGVAR(isSurrendering), false, true]; - ERROR("Surrender animation failed"); - }; - if ((animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon") exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - - if (_unit == ACE_player) then { - showHUD false; + //Adds an animation changed eh + //Should handle changes in animation + _animChangedEHID = _unit addEventHandler ["AnimChanged", { + PARAMS_2(_unit,_newAnimation); + if (_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") then { + ERROR("Surrender animation failed"); + systemChat "You Stop Surrendering"; + [_unit, false] call FUNC(surrender); }; - [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); - }; - }, 0, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler; + }]; + _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; + + }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); } else { _unit setVariable [QGVAR(isSurrendering), false, true]; [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); - if ((vehicle _unit) == _unit) then { - //Break out of hands up animation loop (doAnimation handles Unconscious prioity) - [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); - }; + _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; + _unit removeEventHandler ["AnimChanged", _animChangedEHID]; + + //spin up a PFEH, to watching animationState for the next 10 seconds to make sure we don't enter + [{ + PARAMS_2(_args,_pfID); + EXPLODE_2_PVT(_args,_unit,_maxTime); + //If maxtime or they re-surrendered, exit loop + if ((time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]}) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + }; + //Only break animation if they are actualy the "hands up" animation (because we are using switchmove) + if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + //Break out of hands up animation loop (doAnimation handles Unconscious prioity) + [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + }; + }, 0.05, [_unit, (time + 15)]] call CBA_fnc_addPerFrameHandler; if (_unit == ACE_player) then { //only re-enable HUD if not handcuffed From a0c2a00777052312583df4bac9e7c6954bf6d006 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 15 Feb 2015 16:45:13 -0600 Subject: [PATCH 03/12] Cleanup --- addons/captives/functions/fnc_canSurrender.sqf | 2 +- addons/captives/functions/fnc_handleKnockedOut.sqf | 2 +- addons/captives/functions/fnc_surrender.sqf | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/captives/functions/fnc_canSurrender.sqf b/addons/captives/functions/fnc_canSurrender.sqf index 4c16e8ccd0..3ee687cfc1 100644 --- a/addons/captives/functions/fnc_canSurrender.sqf +++ b/addons/captives/functions/fnc_canSurrender.sqf @@ -23,7 +23,7 @@ private "_returnValue"; _returnValue = if (_newSurrenderState) then { !(_unit getVariable [QGVAR(isSurrendering), false]); //Not currently surrendering } else { - (_unit getVariable [QGVAR(isSurrendering), false]); //isSurrendering and on the hands up animation - // && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}; + (_unit getVariable [QGVAR(isSurrendering), false]); //is Surrendering }; _returnValue diff --git a/addons/captives/functions/fnc_handleKnockedOut.sqf b/addons/captives/functions/fnc_handleKnockedOut.sqf index aba01b194f..fadf63e971 100644 --- a/addons/captives/functions/fnc_handleKnockedOut.sqf +++ b/addons/captives/functions/fnc_handleKnockedOut.sqf @@ -1,5 +1,5 @@ /* - * Author: PabstMirror + * Author: commy2, PabstMirror * Handles when a unit gets knocked out. Ends surrendering. * * Arguments: diff --git a/addons/captives/functions/fnc_surrender.sqf b/addons/captives/functions/fnc_surrender.sqf index f2103d2c1c..adffc4d2aa 100644 --- a/addons/captives/functions/fnc_surrender.sqf +++ b/addons/captives/functions/fnc_surrender.sqf @@ -50,7 +50,6 @@ if (_state) then { PARAMS_2(_unit,_newAnimation); if (_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") then { ERROR("Surrender animation failed"); - systemChat "You Stop Surrendering"; [_unit, false] call FUNC(surrender); }; }]; From e0d1d08913061204d303135bdc4a7dcf6200eb7a Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 15 Feb 2015 18:19:01 -0600 Subject: [PATCH 04/12] Change AnimChange EH --- .../fnc_handleZeusDisplayChanged.sqf | 4 +- .../captives/functions/fnc_setHandcuffed.sqf | 2 +- addons/captives/functions/fnc_surrender.sqf | 51 +++++++++++-------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf index e328d410fa..2299fa7031 100644 --- a/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf +++ b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf @@ -22,10 +22,10 @@ PARAMS_2(_unit,_zeusIsOpen); //set showHUD based on unit status: if (!_zeusIsOpen) then { if ((_unit getVariable [QGVAR(isHandcuffed), false]) || {_unit getVariable [QGVAR(isSurrendering), false]}) then { - TRACE_1("Player Change (showHUD false)",_newUnit); + TRACE_1("Player Change (showHUD false)",_unit); showHUD false; } else { - TRACE_1("Player Change (showHUD true)",_newUnit); + TRACE_1("Player Change (showHUD true)",_unit); showHUD true; }; }; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 06906167e9..0d404f6c6e 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -31,7 +31,7 @@ if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) then { if (_state) then { _unit setVariable [QGVAR(isHandcuffed), true, true]; if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop - [_unit, _false] call FUNC(surrender); + [_unit, false] call FUNC(surrender); }; [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); _unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true]; diff --git a/addons/captives/functions/fnc_surrender.sqf b/addons/captives/functions/fnc_surrender.sqf index adffc4d2aa..e1e4c19c11 100644 --- a/addons/captives/functions/fnc_surrender.sqf +++ b/addons/captives/functions/fnc_surrender.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Unit - * 1: State + * 1: True to surrender, false to un-surrender * * Return Value: * Nothing @@ -45,12 +45,16 @@ if (_state) then { }; //Adds an animation changed eh - //Should handle changes in animation + //If we get a change in animation before we've "locked" in the hands up animationState, then stop surrendering _animChangedEHID = _unit addEventHandler ["AnimChanged", { PARAMS_2(_unit,_newAnimation); + if (_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") then { - ERROR("Surrender animation failed"); - [_unit, false] call FUNC(surrender); + if ((animationState _unit != "ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon") && (animationState _unit != "ACE_AmovPercMstpSsurWnonDnon")) then { + ERROR("Surrender animation failed"); + systemChat "Debug: Surrender animation failed"; + [_unit, false] call FUNC(surrender); + }; }; }]; _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; @@ -62,22 +66,7 @@ if (_state) then { _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; _unit removeEventHandler ["AnimChanged", _animChangedEHID]; - - //spin up a PFEH, to watching animationState for the next 10 seconds to make sure we don't enter - [{ - PARAMS_2(_args,_pfID); - EXPLODE_2_PVT(_args,_unit,_maxTime); - //If maxtime or they re-surrendered, exit loop - if ((time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]}) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - }; - //Only break animation if they are actualy the "hands up" animation (because we are using switchmove) - if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - //Break out of hands up animation loop (doAnimation handles Unconscious prioity) - [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); - }; - }, 0.05, [_unit, (time + 15)]] call CBA_fnc_addPerFrameHandler; + _unit setVariable [QGVAR(surrenderAnimEHID), -1]; if (_unit == ACE_player) then { //only re-enable HUD if not handcuffed @@ -85,4 +74,26 @@ if (_state) then { showHUD true; }; }; + + //if we are in "hands up" animationState, crack it now + if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) then { + [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + } else { + //spin up a PFEH, to watching animationState for the next 20 seconds to make sure we don't enter + //Handles long animation chains + [{ + PARAMS_2(_args,_pfID); + EXPLODE_2_PVT(_args,_unit,_maxTime); + //If maxtime or they re-surrendered, exit loop + if ((time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]}) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + }; + //Only break animation if they are actualy the "hands up" animation (because we are using switchmove) + if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + //Break out of hands up animation loop (doAnimation handles Unconscious prioity) + [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + }; + }, 0.05, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler; + }; }; From eee4b256cd3f5285640283517b70873ab28bebfa Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 16 Feb 2015 18:03:09 -0600 Subject: [PATCH 05/12] More Changes and add EH --- addons/captives/CfgVehicles.hpp | 6 +- addons/captives/XEH_postInit.sqf | 10 +-- addons/captives/XEH_preInit.sqf | 2 +- .../functions/fnc_handleKnockedOut.sqf | 2 +- .../functions/fnc_handleUnitInitPost.sqf | 2 +- .../functions/fnc_handleVehicleChanged.sqf | 2 +- .../functions/fnc_moduleSurrender.sqf | 11 +++- .../captives/functions/fnc_setHandcuffed.sqf | 34 +++++++--- ...c_surrender.sqf => fnc_setSurrendered.sqf} | 64 ++++++++++--------- 9 files changed, 79 insertions(+), 54 deletions(-) rename addons/captives/functions/{fnc_surrender.sqf => fnc_setSurrendered.sqf} (56%) diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index d292402bcf..75b1a85803 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -81,8 +81,8 @@ class CfgVehicles { }; class ACE_StartSurrenderingSelf { displayName = "$STR_ACE_Captives_StartSurrendering"; - condition = QUOTE([ARR_2(_player, true)] call FUNC(canSurrender)); - statement = QUOTE([ARR_2(_player, true)] call FUNC(surrender)); + condition = QUOTE([ARR_2(_player, true)] call FUNC(setSurrendered)); + statement = QUOTE([ARR_2(_player, true)] call FUNC(setSurrendered)); exceptions[] = {}; showDisabled = 0; priority = 0; @@ -90,7 +90,7 @@ class CfgVehicles { class ACE_StopSurrenderingSelf { displayName = "$STR_ACE_Captives_StopSurrendering"; condition = QUOTE([ARR_2(_player, false)] call FUNC(canSurrender)); - statement = QUOTE([ARR_2(_player, false)] call FUNC(surrender)); + statement = QUOTE([ARR_2(_player, false)] call FUNC(setSurrender)); exceptions[] = {QGVAR(isNotSurrendering)}; showDisabled = 0; priority = 0; diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index 9c124630ee..da92307815 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -1,9 +1,5 @@ #include "script_component.hpp" -["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); -["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler); -["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); -["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler); //Handles when someone starts escorting and then disconnects, leaving the captive attached //This is normaly handled by the PFEH in doEscortCaptive, but that won't be running if they DC @@ -23,6 +19,12 @@ if (isServer) then { ["playerVehicleChanged", {_this call FUNC(handleVehicleChanged)}] call EFUNC(common,addEventHandler); ["zeusDisplayChanged", {_this call FUNC(handleZeusDisplayChanged)}] call EFUNC(common,addEventHandler); +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); +["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler); +["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); + +["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler); +["SetSurrendered", {_this call FUNC(setSurrendered)}] call EFUNC(common,addEventHandler); //TODO: Medical Integration Events??? diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index f6ec44225f..728f5fff69 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -26,7 +26,7 @@ PREP(handleZeusDisplayChanged); PREP(handleWokeUp); PREP(moduleSurrender); PREP(setHandcuffed); -PREP(surrender); +PREP(setSurrendered); PREP(vehicleCaptiveMoveIn); PREP(vehicleCaptiveMoveOut); diff --git a/addons/captives/functions/fnc_handleKnockedOut.sqf b/addons/captives/functions/fnc_handleKnockedOut.sqf index fadf63e971..1cd969807d 100644 --- a/addons/captives/functions/fnc_handleKnockedOut.sqf +++ b/addons/captives/functions/fnc_handleKnockedOut.sqf @@ -21,5 +21,5 @@ PARAMS_1(_unit); if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop - [_unit, _false] call FUNC(surrender); + [_unit, false] call FUNC(setSurrendered); }; diff --git a/addons/captives/functions/fnc_handleUnitInitPost.sqf b/addons/captives/functions/fnc_handleUnitInitPost.sqf index 1a5a8f2ecd..a8b601300a 100644 --- a/addons/captives/functions/fnc_handleUnitInitPost.sqf +++ b/addons/captives/functions/fnc_handleUnitInitPost.sqf @@ -29,6 +29,6 @@ if (local _unit) then { if (_unit getVariable [QGVAR(isSurrendering), false]) then { _unit setVariable [QGVAR(isSurrendering), false]; - [_unit, true] call FUNC(surrender); + [_unit, true] call FUNC(setSurrendered); }; }; diff --git a/addons/captives/functions/fnc_handleVehicleChanged.sqf b/addons/captives/functions/fnc_handleVehicleChanged.sqf index 74f966ecc3..a5cd7004a4 100644 --- a/addons/captives/functions/fnc_handleVehicleChanged.sqf +++ b/addons/captives/functions/fnc_handleVehicleChanged.sqf @@ -25,6 +25,6 @@ if ((vehicle _unit) != _unit) then { }; if (_unit getVariable [QGVAR(isSurrendering), false]) then { - [_unit, false] call FUNC(surrender); + [_unit, false] call FUNC(setSurrender); }; }; diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf index 5cbf43aacc..d2e3fc9f5e 100644 --- a/addons/captives/functions/fnc_moduleSurrender.sqf +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -28,7 +28,14 @@ if (local _logic) then { _mouseOverObject = _bisMouseOver select 1; if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then { systemChat format ["Debug - module surrendering %1", (name _mouseOverObject)]; - [_mouseOverObject, true] call FUNC(surrender); + [_mouseOverObject, true] call FUNC(setSurrendered); + + if (!(_mouseOverObject getVariable [GVAR(), false])) then { + ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, true]] call EFUNC(common,targetEvent); + } else { + ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, false]] call EFUNC(common,targetEvent); + }; + } else { systemChat format ["Only use on dismounted inf"]; }; @@ -38,7 +45,7 @@ if (local _logic) then { } else {//an editor module { systemChat format ["Debug - module surrendering %1", (name _x)]; - [_x, true] call FUNC(surrender); + [_x, true] call FUNC(setSurrendered); } forEach _units; }; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 0d404f6c6e..cec1a007e7 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -18,22 +18,23 @@ PARAMS_2(_unit,_state); -// We only want this function to work on local machines -if (!local _unit) exitwith { - [_this, QUOTE(FUNC(setHandcuffed)), _unit] call EFUNC(common,execRemoteFnc); - TRACE_2("running setHandcuffed on remote unit",_unit,_state); -}; -if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) then { - LOG("setHandcuffed: current state same as new"); +if (!local _unit) exitwith { + ERROR("running setHandcuffed on remote unit"); +}; +if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith { + ERROR("setHandcuffed: current state same as new"); }; if (_state) then { _unit setVariable [QGVAR(isHandcuffed), true, true]; - if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop - [_unit, false] call FUNC(surrender); - }; [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); + + if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop + [_unit, false] call FUNC(setSurrendered); + }; + + //Set unit cargoIndex (will be -1 if dismounted) _unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true]; if (_unit == ACE_player) then { @@ -46,6 +47,19 @@ if (_state) then { if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { [_unit] call EFUNC(common,fixLoweredRifleAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + + //Adds an animation changed eh + //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 { + ERROR("Handcuff animation interrupted"); + systemChat format ["debug %2: new %1", _newAnimation, time]; + [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + }; + }]; + _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; + }; }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); } else { diff --git a/addons/captives/functions/fnc_surrender.sqf b/addons/captives/functions/fnc_setSurrendered.sqf similarity index 56% rename from addons/captives/functions/fnc_surrender.sqf rename to addons/captives/functions/fnc_setSurrendered.sqf index e1e4c19c11..e49c6e9453 100644 --- a/addons/captives/functions/fnc_surrender.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -10,7 +10,7 @@ * Nothing * * Example: - * [Pierre, true] call ACE_captives_fnc_surrender; + * [Pierre, true] call ACE_captives_fnc_setSurrendered; * * Public: No */ @@ -18,52 +18,52 @@ PARAMS_2(_unit,_state); -// We only want this function to work on local machines + if (!local _unit) exitwith { - [_this, QUOTE(FUNC(surrender)), _unit] call EFUNC(common,execRemoteFnc); - TRACE_2("running surrender on remote unit",_unit,_state); + ERROR("running surrender on remote unit"); }; -if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) then { - LOG("Surrender: current state same as new"); +if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) exitWith { + ERROR("Surrender: current state same as new"); }; if (_state) then { + if ((vehicle _unit) != _unit) exitWith {ERROR("Cannot surrender while mounted");}; + if (_unit getVariable [QGVAR(isHandcuffed), false]) exitWith {ERROR("Cannot surrender while handcuffed");}; + _unit setVariable [QGVAR(isSurrendering), true, true]; + [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); if (_unit == ACE_player) then { showHUD false; }; + [_unit] call EFUNC(common,fixLoweredRifleAnimation); + [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); + // fix anim on mission start (should work on dedicated servers) [{ PARAMS_1(_unit); - if (_unit getVariable [QGVAR(isSurrendering), false] && {vehicle _unit == _unit}) then { - [_unit] call EFUNC(common,fixLoweredRifleAnimation); - [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); - }; - - //Adds an animation changed eh - //If we get a change in animation before we've "locked" in the hands up animationState, then stop surrendering - _animChangedEHID = _unit addEventHandler ["AnimChanged", { - PARAMS_2(_unit,_newAnimation); - - if (_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") then { - if ((animationState _unit != "ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon") && (animationState _unit != "ACE_AmovPercMstpSsurWnonDnon")) then { - ERROR("Surrender animation failed"); - systemChat "Debug: Surrender animation failed"; - [_unit, false] call FUNC(surrender); + if (_unit getVariable [QGVAR(isSurrendering), false] && {(vehicle _unit) == _unit}) then { + //Adds an animation changed eh + //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 { + ERROR("Surrender animation interrupted"); + systemChat format ["debug %2: new %1", _newAnimation, time]; + [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); }; - }; - }]; - _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; - + }]; + _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; + }; }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); } else { _unit setVariable [QGVAR(isSurrendering), false, true]; [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); + //remove AnimChanged EH _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; _unit removeEventHandler ["AnimChanged", _animChangedEHID]; _unit setVariable [QGVAR(surrenderAnimEHID), -1]; @@ -75,25 +75,27 @@ if (_state) then { }; }; + if (_unit getVariable ["ACE_isUnconscious", false]) exitWith {}; //don't touch animations if unconscious + //if we are in "hands up" animationState, crack it now if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) then { [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); } else { - //spin up a PFEH, to watching animationState for the next 20 seconds to make sure we don't enter + //spin up a PFEH, to watching animationState for the next 20 seconds to make sure we don't enter "hands up" //Handles long animation chains [{ PARAMS_2(_args,_pfID); EXPLODE_2_PVT(_args,_unit,_maxTime); - //If maxtime or they re-surrendered, exit loop - if ((time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]}) exitWith { + //If waited long enough or they re-surrendered or they are unconscious, exit loop + if ((time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]} || {_unit getVariable ["ACE_isUnconscious", false]}) exitWith { [_pfID] call CBA_fnc_removePerFrameHandler; }; - //Only break animation if they are actualy the "hands up" animation (because we are using switchmove) + //Only break animation if they are actualy the "hands up" animation (because we are using switchmove there won't be an transition) if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) exitWith { [_pfID] call CBA_fnc_removePerFrameHandler; - //Break out of hands up animation loop (doAnimation handles Unconscious prioity) + //Break out of hands up animation loop [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); }; - }, 0.05, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler; + }, 0, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler; }; }; From dc82e50d72cafb9744e692f2576ef937d33bd85a Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 16 Feb 2015 18:30:35 -0600 Subject: [PATCH 06/12] fix --- addons/captives/CfgVehicles.hpp | 2 +- addons/captives/XEH_postInit.sqf | 1 + addons/captives/XEH_preInit.sqf | 2 +- addons/captives/functions/fnc_moduleSurrender.sqf | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index 75b1a85803..47bd557efc 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -81,7 +81,7 @@ class CfgVehicles { }; class ACE_StartSurrenderingSelf { displayName = "$STR_ACE_Captives_StartSurrendering"; - condition = QUOTE([ARR_2(_player, true)] call FUNC(setSurrendered)); + condition = QUOTE([ARR_2(_player, true)] call FUNC(canSurrender)); statement = QUOTE([ARR_2(_player, true)] call FUNC(setSurrendered)); exceptions[] = {}; showDisabled = 0; diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index da92307815..ac86d71915 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -3,6 +3,7 @@ //Handles when someone starts escorting and then disconnects, leaving the captive attached //This is normaly handled by the PFEH in doEscortCaptive, but that won't be running if they DC + if (isServer) then { addMissionEventHandler ["HandleDisconnect", { PARAMS_1(_disconnectedPlayer); diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index 728f5fff69..d23d8759f8 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -22,8 +22,8 @@ PREP(handleKnockedOut); PREP(handlePlayerChanged); PREP(handleUnitInitPost); PREP(handleVehicleChanged); -PREP(handleZeusDisplayChanged); PREP(handleWokeUp); +PREP(handleZeusDisplayChanged); PREP(moduleSurrender); PREP(setHandcuffed); PREP(setSurrendered); diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf index d2e3fc9f5e..a33c56fc09 100644 --- a/addons/captives/functions/fnc_moduleSurrender.sqf +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -29,13 +29,13 @@ if (local _logic) then { if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then { systemChat format ["Debug - module surrendering %1", (name _mouseOverObject)]; [_mouseOverObject, true] call FUNC(setSurrendered); - - if (!(_mouseOverObject getVariable [GVAR(), false])) then { + + if (!(_mouseOverObject getVariable [QGVAR(isSurrendering), false])) then { ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, true]] call EFUNC(common,targetEvent); } else { ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, false]] call EFUNC(common,targetEvent); }; - + } else { systemChat format ["Only use on dismounted inf"]; }; From 9cdf06383dc8f5f6dda5b9c846d785eb65dac650 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 16 Feb 2015 19:20:55 -0600 Subject: [PATCH 07/12] Back to getIn --- addons/captives/CfgEventHandlers.hpp | 11 ++++++++--- addons/captives/CfgVehicles.hpp | 2 +- addons/captives/XEH_preInit.sqf | 2 +- ...dleVehicleChanged.sqf => fnc_handleGetIn.sqf} | 16 ++++++++-------- .../captives/functions/fnc_moduleSurrender.sqf | 3 +-- 5 files changed, 19 insertions(+), 15 deletions(-) rename addons/captives/functions/{fnc_handleVehicleChanged.sqf => fnc_handleGetIn.sqf} (55%) diff --git a/addons/captives/CfgEventHandlers.hpp b/addons/captives/CfgEventHandlers.hpp index 8829d0f275..0ce09280a7 100644 --- a/addons/captives/CfgEventHandlers.hpp +++ b/addons/captives/CfgEventHandlers.hpp @@ -9,7 +9,14 @@ class Extended_PostInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; - +//release escorted captive when entering a vehicle +class Extended_GetIn_EventHandlers { + class All { + class GVAR(AutoDetachCaptive) { + getIn = QUOTE(_this call FUNC(handleGetIn)); + }; + }; +}; //reset captive animation after leaving vehicle class Extended_GetOut_EventHandlers { class All { @@ -18,7 +25,6 @@ class Extended_GetOut_EventHandlers { }; }; }; - //reset captivity and escorting status when getting killed class Extended_Killed_EventHandlers { class CAManBase { @@ -27,7 +33,6 @@ class Extended_Killed_EventHandlers { }; }; }; - //mission start class Extended_InitPost_EventHandlers { class CAManBase { diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index 47bd557efc..31b0ac713f 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -90,7 +90,7 @@ class CfgVehicles { class ACE_StopSurrenderingSelf { displayName = "$STR_ACE_Captives_StopSurrendering"; condition = QUOTE([ARR_2(_player, false)] call FUNC(canSurrender)); - statement = QUOTE([ARR_2(_player, false)] call FUNC(setSurrender)); + statement = QUOTE([ARR_2(_player, false)] call FUNC(setSurrendered)); exceptions[] = {QGVAR(isNotSurrendering)}; showDisabled = 0; priority = 0; diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index d23d8759f8..34c9bca910 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -16,12 +16,12 @@ PREP(doFriskPerson); PREP(doLoadCaptive); PREP(doRemoveHandcuffs); PREP(doUnloadCaptive); +PREP(handleGetIn); PREP(handleGetOut); PREP(handleKilled); PREP(handleKnockedOut); PREP(handlePlayerChanged); PREP(handleUnitInitPost); -PREP(handleVehicleChanged); PREP(handleWokeUp); PREP(handleZeusDisplayChanged); PREP(moduleSurrender); diff --git a/addons/captives/functions/fnc_handleVehicleChanged.sqf b/addons/captives/functions/fnc_handleGetIn.sqf similarity index 55% rename from addons/captives/functions/fnc_handleVehicleChanged.sqf rename to addons/captives/functions/fnc_handleGetIn.sqf index a5cd7004a4..cf7d2c7271 100644 --- a/addons/captives/functions/fnc_handleVehicleChanged.sqf +++ b/addons/captives/functions/fnc_handleGetIn.sqf @@ -1,25 +1,25 @@ /* * Author: commy2 - * Handles when a player's vehicle changes (supports scripted vehicle changes) + * Handles when a unit gets in to a vehicle. Release escorted captive when entering a vehicle * * Arguments: - * 0: unit - * 1: newVehicle + * 0: _vehicle + * 2: dunno + * 1: _unit * * Return Value: - * Nothing + * The return value * * Example: - * [player, car] call ACE_captives_fnc_handleVehicleChanged + * [car2, x, player] call ACE_captives_fnc_handleGetIn * * Public: No */ #include "script_component.hpp" -PARAMS_2(_unit,_vehicle); +PARAMS_3(_vehicle,_dontcare,_unit); -//When moved into a vehicle (action or scripted) -if ((vehicle _unit) != _unit) then { +if (local _unit) then { if (_unit getVariable [QGVAR(isEscorting), false]) then { _unit setVariable [QGVAR(isEscorting), false, true]; }; diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf index a33c56fc09..9311c7a1b9 100644 --- a/addons/captives/functions/fnc_moduleSurrender.sqf +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -28,8 +28,7 @@ if (local _logic) then { _mouseOverObject = _bisMouseOver select 1; if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then { systemChat format ["Debug - module surrendering %1", (name _mouseOverObject)]; - [_mouseOverObject, true] call FUNC(setSurrendered); - + if (!(_mouseOverObject getVariable [QGVAR(isSurrendering), false])) then { ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, true]] call EFUNC(common,targetEvent); } else { From 37216d51449665287dde4e9c3bdb702895887f2b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 17 Feb 2015 17:05:07 -0600 Subject: [PATCH 08/12] Remove HandCuff animEH --- addons/captives/functions/fnc_setHandcuffed.sqf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index cec1a007e7..0deb68dc8b 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -58,13 +58,19 @@ if (_state) then { [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); }; }]; - _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; + _unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID]; }; }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); } else { _unit setVariable [QGVAR(isHandcuffed), false, true]; [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); + + //remove AnimChanged EH + _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1]; + _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) [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); From 85c568a061c4d9ac215fd4d2b2457f8b229dda7b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 24 Feb 2015 10:27:53 -0600 Subject: [PATCH 09/12] Comments --- addons/captives/functions/fnc_handleZeusDisplayChanged.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf index 2299fa7031..84b90e78c2 100644 --- a/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf +++ b/addons/captives/functions/fnc_handleZeusDisplayChanged.sqf @@ -1,6 +1,6 @@ /* * Author: PabstMirror - * Handles handles ZeusDisplayChanged event + * Handles ZeusDisplayChanged event * Need to reset showHUD after closing zeus * * Arguments: From 5364980997d49662a57126c17f002d8e590f5b58 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 24 Feb 2015 11:36:49 -0600 Subject: [PATCH 10/12] Zeus Module Hints --- .../functions/fnc_moduleSurrender.sqf | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf index 9311c7a1b9..07e7c1b9ad 100644 --- a/addons/captives/functions/fnc_moduleSurrender.sqf +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -27,24 +27,25 @@ if (local _logic) then { if ((count _bisMouseOver) == 2) then {//check what mouse was over before the module was placed _mouseOverObject = _bisMouseOver select 1; if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then { - systemChat format ["Debug - module surrendering %1", (name _mouseOverObject)]; - - if (!(_mouseOverObject getVariable [QGVAR(isSurrendering), false])) then { - ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, true]] call EFUNC(common,targetEvent); + TRACE_2("Debug - module surrendering %1",_mouseOverObject,(name _mouseOverObject)); + if (alive _mouseOverObject) then { + if (!(_mouseOverObject getVariable [QGVAR(isSurrendering), false])) then { + ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, true]] call EFUNC(common,targetEvent); + } else { + ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, false]] call EFUNC(common,targetEvent); + }; } else { - ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, false]] call EFUNC(common,targetEvent); + ["STR_ACE_Captives_Zeus_OnlyAlive"] call EFUNC(commmon,displayTextStructured); }; - } else { - systemChat format ["Only use on dismounted inf"]; + ["STR_ACE_Captives_Zeus_OnlyInfentry"] call EFUNC(commmon,displayTextStructured); }; } else { - systemChat format ["Nothing under mouse"]; + ["STR_ACE_Captives_Zeus_NothingSelected"] call EFUNC(commmon,displayTextStructured); }; } else {//an editor module { - systemChat format ["Debug - module surrendering %1", (name _x)]; - [_x, true] call FUNC(setSurrendered); + ["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent); } forEach _units; }; From ae3de331c465b5a3590c5b226ec80c82db6f6dff Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 24 Feb 2015 11:51:37 -0600 Subject: [PATCH 11/12] Module At Mission Start (Issue #148) --- addons/captives/functions/fnc_moduleSurrender.sqf | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf index 07e7c1b9ad..1c10779220 100644 --- a/addons/captives/functions/fnc_moduleSurrender.sqf +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -43,10 +43,15 @@ if (local _logic) then { } else { ["STR_ACE_Captives_Zeus_NothingSelected"] call EFUNC(commmon,displayTextStructured); }; - } else {//an editor module - { - ["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent); - } forEach _units; + } else { + //an editor module + //Modules run before postInit can instal the event handler, so we need to wait a little bit + [{ + PARAMS_1(_units); + { + ["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent); + } forEach _units; + }, [_units], 0.05, 0.05]call EFUNC(common,waitAndExecute); }; deleteVehicle _logic; From 80ac6d83deba2fd2d8327f7e7191665b326890e7 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 24 Feb 2015 12:44:54 -0600 Subject: [PATCH 12/12] Zeus Module Messages --- addons/captives/functions/fnc_moduleSurrender.sqf | 6 +++--- addons/captives/stringtable.xml | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf index 1c10779220..1a335131a8 100644 --- a/addons/captives/functions/fnc_moduleSurrender.sqf +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -35,13 +35,13 @@ if (local _logic) then { ["SetSurrendered", [_mouseOverObject], [_mouseOverObject, false]] call EFUNC(common,targetEvent); }; } else { - ["STR_ACE_Captives_Zeus_OnlyAlive"] call EFUNC(commmon,displayTextStructured); + ["STR_ACE_Captives_Zeus_OnlyAlive"] call EFUNC(common,displayTextStructured); }; } else { - ["STR_ACE_Captives_Zeus_OnlyInfentry"] call EFUNC(commmon,displayTextStructured); + ["STR_ACE_Captives_Zeus_OnlyInfentry"] call EFUNC(common,displayTextStructured); }; } else { - ["STR_ACE_Captives_Zeus_NothingSelected"] call EFUNC(commmon,displayTextStructured); + ["STR_ACE_Captives_Zeus_NothingSelected"] call EFUNC(common,displayTextStructured); }; } else { //an editor module diff --git a/addons/captives/stringtable.xml b/addons/captives/stringtable.xml index 7d8096b3e6..f03f30a113 100644 --- a/addons/captives/stringtable.xml +++ b/addons/captives/stringtable.xml @@ -1,5 +1,5 @@  - + @@ -136,5 +136,14 @@ Stop Surrendering + + Only use on alive units + + + Only use on dismounted inf + + + Nothing under mouse + \ No newline at end of file