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}; InterpolateTo[] = {"Unconscious",0.01};
}; };
class ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { 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"; actions = "CivilStandActions";
file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\sur\non\AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"; file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\sur\non\AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon";
ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1}; ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1};

View File

@ -18,5 +18,12 @@
PARAMS_2(_unit,_newSurrenderState); PARAMS_2(_unit,_newSurrenderState);
//TODO: any other conditions?? private "_returnValue";
(!((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _newSurrenderState))
_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,7 +30,12 @@ if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) then {
if (_state) then { if (_state) then {
_unit setVariable [QGVAR(isSurrendering), true, true]; _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) // fix anim on mission start (should work on dedicated servers)
[{ [{
PARAMS_1(_unit); PARAMS_1(_unit);
@ -38,37 +43,42 @@ if (_state) then {
[_unit] call EFUNC(common,fixLoweredRifleAnimation); [_unit] call EFUNC(common,fixLoweredRifleAnimation);
[_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); [_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 //Adds an animation changed eh
//Only change variables and captivity when they reach that state //Should handle changes in animation
//fixes vaulting to break animation _animChangedEHID = _unit addEventHandler ["AnimChanged", {
[{ PARAMS_2(_unit,_newAnimation);
PARAMS_2(_args,_pfID); if (_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") then {
EXPLODE_2_PVT(_args,_unit,_maxTime); ERROR("Surrender animation failed");
systemChat "You Stop Surrendering";
if (time > _maxTime) exitWith { [_unit, false] call FUNC(surrender);
[_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;
}; };
[_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); }];
}; _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID];
}, 0, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler;
}, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute);
} else { } else {
_unit setVariable [QGVAR(isSurrendering), false, true]; _unit setVariable [QGVAR(isSurrendering), false, true];
[_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus);
if ((vehicle _unit) == _unit) then { _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
//Break out of hands up animation loop (doAnimation handles Unconscious prioity) _unit removeEventHandler ["AnimChanged", _animChangedEHID];
[_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
}; //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 { if (_unit == ACE_player) then {
//only re-enable HUD if not handcuffed //only re-enable HUD if not handcuffed