Skip to content

Commit

Permalink
Captives - Fix adding duplicate animEH
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Oct 23, 2015
1 parent 5d7a8af commit ef681e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 6 additions & 5 deletions addons/captives/functions/fnc_setHandcuffed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ if (_state) 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)
private "_animChangedEHID";

local _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
if (_animChangedEHID != -1) then {
TRACE_1("removing animChanged EH",_animChangedEHID);
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
};
_animChangedEHID = _unit addEventHandler ["AnimChanged", {
params ["_unit", "_newAnimation"];
TRACE_2("AnimChanged",_unit,_newAnimation);
Expand All @@ -67,7 +70,6 @@ if (_state) then {
[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation);
};
} else {

_turretPath = [];
{
_x params ["_xUnit", "", "", "_xTurretPath"];
Expand All @@ -90,8 +92,7 @@ if (_state) then {
[_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus);

//remove AnimChanged EH
private "_animChangedEHID";
_animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
local _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
TRACE_1("removing animChanged EH",_animChangedEHID);
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
_unit setVariable [QGVAR(handcuffAnimEHID), -1];
Expand Down
9 changes: 6 additions & 3 deletions addons/captives/functions/fnc_setSurrendered.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ if (_state) then {
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)
private "_animChangedEHID";
local _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
if (_animChangedEHID != -1) then {
TRACE_1("removing animChanged EH",_animChangedEHID);
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
};
_animChangedEHID = _unit addEventHandler ["AnimChanged", {
params ["_unit", "_newAnimation"];
if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
Expand All @@ -64,8 +68,7 @@ if (_state) then {
[_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus);

//remove AnimChanged EH
private "_animChangedEHID";
_animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
local _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
_unit setVariable [QGVAR(surrenderAnimEHID), -1];

Expand Down

0 comments on commit ef681e4

Please sign in to comment.