mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Close #3950
This commit is contained in:
parent
618d14555a
commit
8042b888d4
@ -55,3 +55,11 @@ class Extended_Respawn_EventHandlers {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Extended_Local_EventHandlers {
|
||||||
|
class CAManBase {
|
||||||
|
class ADDON {
|
||||||
|
local = QUOTE(call FUNC(handleLocal));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -16,6 +16,7 @@ PREP(doUnloadCaptive);
|
|||||||
PREP(findEmptyNonFFVCargoSeat);
|
PREP(findEmptyNonFFVCargoSeat);
|
||||||
PREP(handleGetIn);
|
PREP(handleGetIn);
|
||||||
PREP(handleGetOut);
|
PREP(handleGetOut);
|
||||||
|
PREP(handleLocal);
|
||||||
PREP(handleOnUnconscious);
|
PREP(handleOnUnconscious);
|
||||||
PREP(handlePlayerChanged);
|
PREP(handlePlayerChanged);
|
||||||
PREP(handleRespawn);
|
PREP(handleRespawn);
|
||||||
|
61
addons/captives/functions/fnc_handleLocal.sqf
Normal file
61
addons/captives/functions/fnc_handleLocal.sqf
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Author: esteldunedain
|
||||||
|
* Called when a unit switched locality
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: The Unit <OBJECT>
|
||||||
|
* 1: Is local <BOOL>
|
||||||
|
*
|
||||||
|
* ReturnValue:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_unit", "_local"];
|
||||||
|
|
||||||
|
// Make sure that if the unit is captive it has a AnimChanged EH running ONLY on the machine that owns it
|
||||||
|
if (_local) then {
|
||||||
|
// If the unit is not handcuffed there's nothing to do
|
||||||
|
if !(_unit getVariable [QGVAR(isHandcuffed), false]) exitWith {};
|
||||||
|
// If the unit already has an AnimChanged EH here then there's nothing to do either
|
||||||
|
if (_unit getVariable [QGVAR(handcuffAnimEHID), -1] != -1) exitWith {};
|
||||||
|
|
||||||
|
// Otherwise, restart the AnimChanged EH in the new machine
|
||||||
|
_animChangedEHID = _unit addEventHandler ["AnimChanged", {
|
||||||
|
params ["_unit", "_newAnimation"];
|
||||||
|
TRACE_2("AnimChanged",_unit,_newAnimation);
|
||||||
|
if (_unit == (vehicle _unit)) then {
|
||||||
|
if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
|
||||||
|
TRACE_1("Handcuff animation interrupted",_newAnimation);
|
||||||
|
[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
_turretPath = [];
|
||||||
|
{
|
||||||
|
_x params ["_xUnit", "", "", "_xTurretPath"];
|
||||||
|
if (_unit == _xUnit) exitWith {_turretPath = _xTurretPath};
|
||||||
|
} forEach (fullCrew (vehicle _unit));
|
||||||
|
TRACE_1("turret Path",_turretPath);
|
||||||
|
if (_turretPath isEqualTo []) exitWith {};
|
||||||
|
|
||||||
|
TRACE_1("Handcuff (FFV) animation interrupted",_newAnimation);
|
||||||
|
[_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation);
|
||||||
|
[_unit, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation);
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
TRACE_2("Adding animChangedEH",_unit,_animChangedEHID);
|
||||||
|
_unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID];
|
||||||
|
} else {
|
||||||
|
private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
|
||||||
|
// If the unit didn't have an AnimChanged EH here, do nothing
|
||||||
|
if (_animChangedEHID == -1) exitWith {};
|
||||||
|
|
||||||
|
// If the unit had a AnimChanged EH in the old machine then remove it
|
||||||
|
TRACE_1("removing animChanged EH",_animChangedEHID);
|
||||||
|
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
||||||
|
_unit setVariable [QGVAR(handcuffAnimEHID), -1];
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user