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
This commit is contained in:
PabstMirror 2015-02-15 16:42:00 -06:00
parent dec34b4b30
commit 3c65c422b1
3 changed files with 46 additions and 29 deletions

View File

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

View File

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

View File

@ -30,6 +30,11 @@ 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)
[{
@ -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];
//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);
};
if ((animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon") exitWith {
[_pfID] call CBA_fnc_removePerFrameHandler;
}];
_unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID];
if (_unit == ACE_player) then {
showHUD false;
};
[_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus);
};
}, 0, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler;
}, [_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 {
_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