Merge pull request #3362 from acemod/delayedCaptivity

Delay captivity until 0.05s after settings are initialized
This commit is contained in:
PabstMirror 2016-02-20 10:34:18 -06:00
commit 84ba6f29f2
4 changed files with 32 additions and 0 deletions

View File

@ -34,3 +34,10 @@ if (!hasInterface) exitWith {};
["isNotEscorting", {!(GETVAR(_this select 0,GVAR(isEscorting),false))}] call EFUNC(common,addCanInteractWithCondition);
["isNotHandcuffed", {!(GETVAR(_this select 0,GVAR(isHandcuffed),false))}] call EFUNC(common,addCanInteractWithCondition);
["isNotSurrendering", {!(GETVAR(_this select 0,GVAR(isSurrendering),false))}] call EFUNC(common,addCanInteractWithCondition);
["SettingsInitialized", {
// Hold on a little bit longer to ensure anims will work
[{
GVAR(captivityEnabled) = true;
}, [], 0.05] call EFUNC(common,waitAndExecute);
}] call EFUNC(common,addEventHandler);

View File

@ -32,4 +32,6 @@ PREP(setSurrendered);
PREP(vehicleCaptiveMoveIn);
PREP(vehicleCaptiveMoveOut);
GVAR(captivityEnabled) = false;
ADDON = true;

View File

@ -22,6 +22,18 @@ TRACE_2("params",_unit,_state);
if (!local _unit) exitWith {
ERROR("running setHandcuffed on remote unit");
};
if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
// It's to soon to call this function, delay it
if (EGVAR(common,settingsInitFinished)) then {
// Settings are already initialized, but the small wait isn't over
[DFUNC(setHandCuffed), _this, 0.05] call EFUNC(common,waitAndExecute);
} else {
// Settings are not initialized yet
[DFUNC(setHandCuffed), _this] call EFUNC(common,runAfterSettingsInit);
};
};
if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith {
ERROR("setHandcuffed: current state same as new");
};

View File

@ -23,6 +23,17 @@ if (!local _unit) exitWith {
ERROR("running surrender on remote unit");
};
if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
// It's to soon to call this function, delay it
if (EGVAR(common,settingsInitFinished)) then {
// Settings are already initialized, but the small wait isn't over
[DFUNC(setSurrendered), _this, 0.05] call EFUNC(common,waitAndExecute);
} else {
// Settings are not initialized yet
[DFUNC(setSurrendered), _this] call EFUNC(common,runAfterSettingsInit);
};
};
if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) exitWith {
ERROR("Surrender: current state same as new");
};