Change AnimChange EH

This commit is contained in:
PabstMirror 2015-02-15 18:19:01 -06:00
parent a0c2a00777
commit e0d1d08913
3 changed files with 34 additions and 23 deletions

View File

@ -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;
};
};

View File

@ -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];

View File

@ -4,7 +4,7 @@
*
* Arguments:
* 0: Unit <OBJECT>
* 1: State <BOOL>
* 1: True to surrender, false to un-surrender <BOOL>
*
* 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;
};
};