More Changes and add EH

This commit is contained in:
PabstMirror 2015-02-16 18:03:09 -06:00
parent e0d1d08913
commit eee4b256cd
9 changed files with 79 additions and 54 deletions

View File

@ -81,8 +81,8 @@ class CfgVehicles {
}; };
class ACE_StartSurrenderingSelf { class ACE_StartSurrenderingSelf {
displayName = "$STR_ACE_Captives_StartSurrendering"; displayName = "$STR_ACE_Captives_StartSurrendering";
condition = QUOTE([ARR_2(_player, true)] call FUNC(canSurrender)); condition = QUOTE([ARR_2(_player, true)] call FUNC(setSurrendered));
statement = QUOTE([ARR_2(_player, true)] call FUNC(surrender)); statement = QUOTE([ARR_2(_player, true)] call FUNC(setSurrendered));
exceptions[] = {}; exceptions[] = {};
showDisabled = 0; showDisabled = 0;
priority = 0; priority = 0;
@ -90,7 +90,7 @@ class CfgVehicles {
class ACE_StopSurrenderingSelf { class ACE_StopSurrenderingSelf {
displayName = "$STR_ACE_Captives_StopSurrendering"; displayName = "$STR_ACE_Captives_StopSurrendering";
condition = QUOTE([ARR_2(_player, false)] call FUNC(canSurrender)); condition = QUOTE([ARR_2(_player, false)] call FUNC(canSurrender));
statement = QUOTE([ARR_2(_player, false)] call FUNC(surrender)); statement = QUOTE([ARR_2(_player, false)] call FUNC(setSurrender));
exceptions[] = {QGVAR(isNotSurrendering)}; exceptions[] = {QGVAR(isNotSurrendering)};
showDisabled = 0; showDisabled = 0;
priority = 0; priority = 0;

View File

@ -1,9 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler);
["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler);
["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler);
//Handles when someone starts escorting and then disconnects, leaving the captive attached //Handles when someone starts escorting and then disconnects, leaving the captive attached
//This is normaly handled by the PFEH in doEscortCaptive, but that won't be running if they DC //This is normaly handled by the PFEH in doEscortCaptive, but that won't be running if they DC
@ -23,6 +19,12 @@ if (isServer) then {
["playerVehicleChanged", {_this call FUNC(handleVehicleChanged)}] call EFUNC(common,addEventHandler); ["playerVehicleChanged", {_this call FUNC(handleVehicleChanged)}] call EFUNC(common,addEventHandler);
["zeusDisplayChanged", {_this call FUNC(handleZeusDisplayChanged)}] call EFUNC(common,addEventHandler); ["zeusDisplayChanged", {_this call FUNC(handleZeusDisplayChanged)}] call EFUNC(common,addEventHandler);
["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler);
["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler);
["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler);
["SetSurrendered", {_this call FUNC(setSurrendered)}] call EFUNC(common,addEventHandler);
//TODO: Medical Integration Events??? //TODO: Medical Integration Events???

View File

@ -26,7 +26,7 @@ PREP(handleZeusDisplayChanged);
PREP(handleWokeUp); PREP(handleWokeUp);
PREP(moduleSurrender); PREP(moduleSurrender);
PREP(setHandcuffed); PREP(setHandcuffed);
PREP(surrender); PREP(setSurrendered);
PREP(vehicleCaptiveMoveIn); PREP(vehicleCaptiveMoveIn);
PREP(vehicleCaptiveMoveOut); PREP(vehicleCaptiveMoveOut);

View File

@ -21,5 +21,5 @@
PARAMS_1(_unit); PARAMS_1(_unit);
if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop
[_unit, _false] call FUNC(surrender); [_unit, false] call FUNC(setSurrendered);
}; };

View File

@ -29,6 +29,6 @@ if (local _unit) then {
if (_unit getVariable [QGVAR(isSurrendering), false]) then { if (_unit getVariable [QGVAR(isSurrendering), false]) then {
_unit setVariable [QGVAR(isSurrendering), false]; _unit setVariable [QGVAR(isSurrendering), false];
[_unit, true] call FUNC(surrender); [_unit, true] call FUNC(setSurrendered);
}; };
}; };

View File

@ -25,6 +25,6 @@ if ((vehicle _unit) != _unit) then {
}; };
if (_unit getVariable [QGVAR(isSurrendering), false]) then { if (_unit getVariable [QGVAR(isSurrendering), false]) then {
[_unit, false] call FUNC(surrender); [_unit, false] call FUNC(setSurrender);
}; };
}; };

View File

@ -28,7 +28,14 @@ if (local _logic) then {
_mouseOverObject = _bisMouseOver select 1; _mouseOverObject = _bisMouseOver select 1;
if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then { if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then {
systemChat format ["Debug - module surrendering %1", (name _mouseOverObject)]; systemChat format ["Debug - module surrendering %1", (name _mouseOverObject)];
[_mouseOverObject, true] call FUNC(surrender); [_mouseOverObject, true] call FUNC(setSurrendered);
if (!(_mouseOverObject getVariable [GVAR(), false])) then {
["SetSurrendered", [_mouseOverObject], [_mouseOverObject, true]] call EFUNC(common,targetEvent);
} else {
["SetSurrendered", [_mouseOverObject], [_mouseOverObject, false]] call EFUNC(common,targetEvent);
};
} else { } else {
systemChat format ["Only use on dismounted inf"]; systemChat format ["Only use on dismounted inf"];
}; };
@ -38,7 +45,7 @@ if (local _logic) then {
} else {//an editor module } else {//an editor module
{ {
systemChat format ["Debug - module surrendering %1", (name _x)]; systemChat format ["Debug - module surrendering %1", (name _x)];
[_x, true] call FUNC(surrender); [_x, true] call FUNC(setSurrendered);
} forEach _units; } forEach _units;
}; };

View File

@ -18,22 +18,23 @@
PARAMS_2(_unit,_state); PARAMS_2(_unit,_state);
// We only want this function to work on local machines
if (!local _unit) exitwith {
[_this, QUOTE(FUNC(setHandcuffed)), _unit] call EFUNC(common,execRemoteFnc);
TRACE_2("running setHandcuffed on remote unit",_unit,_state);
};
if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) then { if (!local _unit) exitwith {
LOG("setHandcuffed: current state same as new"); ERROR("running setHandcuffed on remote unit");
};
if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith {
ERROR("setHandcuffed: current state same as new");
}; };
if (_state) then { if (_state) then {
_unit setVariable [QGVAR(isHandcuffed), true, true]; _unit setVariable [QGVAR(isHandcuffed), true, true];
if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop
[_unit, false] call FUNC(surrender);
};
[_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus);
if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop
[_unit, false] call FUNC(setSurrendered);
};
//Set unit cargoIndex (will be -1 if dismounted)
_unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true]; _unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true];
if (_unit == ACE_player) then { if (_unit == ACE_player) then {
@ -46,6 +47,19 @@ if (_state) then {
if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then {
[_unit] call EFUNC(common,fixLoweredRifleAnimation); [_unit] call EFUNC(common,fixLoweredRifleAnimation);
[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation);
//Adds an animation changed eh
//If we get a change in animation then redo the animation (handles people vaulting to break the animation chain)
_animChangedEHID = _unit addEventHandler ["AnimChanged", {
PARAMS_2(_unit,_newAnimation);
if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && (_newAnimation != "Unconscious")) then {
ERROR("Handcuff animation interrupted");
systemChat format ["debug %2: new %1", _newAnimation, time];
[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation);
};
}];
_unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID];
}; };
}, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute);
} else { } else {

View File

@ -10,7 +10,7 @@
* Nothing * Nothing
* *
* Example: * Example:
* [Pierre, true] call ACE_captives_fnc_surrender; * [Pierre, true] call ACE_captives_fnc_setSurrendered;
* *
* Public: No * Public: No
*/ */
@ -18,52 +18,52 @@
PARAMS_2(_unit,_state); PARAMS_2(_unit,_state);
// We only want this function to work on local machines
if (!local _unit) exitwith { if (!local _unit) exitwith {
[_this, QUOTE(FUNC(surrender)), _unit] call EFUNC(common,execRemoteFnc); ERROR("running surrender on remote unit");
TRACE_2("running surrender on remote unit",_unit,_state);
}; };
if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) then { if ((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _state) exitWith {
LOG("Surrender: current state same as new"); ERROR("Surrender: current state same as new");
}; };
if (_state) then { if (_state) then {
if ((vehicle _unit) != _unit) exitWith {ERROR("Cannot surrender while mounted");};
if (_unit getVariable [QGVAR(isHandcuffed), false]) exitWith {ERROR("Cannot surrender while handcuffed");};
_unit setVariable [QGVAR(isSurrendering), true, true]; _unit setVariable [QGVAR(isSurrendering), true, true];
[_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus);
if (_unit == ACE_player) then { if (_unit == ACE_player) then {
showHUD false; showHUD false;
}; };
[_unit] call EFUNC(common,fixLoweredRifleAnimation);
[_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation);
// 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);
if (_unit getVariable [QGVAR(isSurrendering), false] && {vehicle _unit == _unit}) then { if (_unit getVariable [QGVAR(isSurrendering), false] && {(vehicle _unit) == _unit}) then {
[_unit] call EFUNC(common,fixLoweredRifleAnimation); //Adds an animation changed eh
[_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); //If we get a change in animation then redo the animation (handles people vaulting to break the animation chain)
}; _animChangedEHID = _unit addEventHandler ["AnimChanged", {
PARAMS_2(_unit,_newAnimation);
//Adds an animation changed eh if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && (_newAnimation != "Unconscious")) then {
//If we get a change in animation before we've "locked" in the hands up animationState, then stop surrendering ERROR("Surrender animation interrupted");
_animChangedEHID = _unit addEventHandler ["AnimChanged", { systemChat format ["debug %2: new %1", _newAnimation, time];
PARAMS_2(_unit,_newAnimation); [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation);
if (_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") then {
if ((animationState _unit != "ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon") && (animationState _unit != "ACE_AmovPercMstpSsurWnonDnon")) then {
ERROR("Surrender animation failed");
systemChat "Debug: Surrender animation failed";
[_unit, false] call FUNC(surrender);
}; };
}; }];
}]; _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID];
_unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; };
}, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); }, [_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);
//remove AnimChanged EH
_animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
_unit removeEventHandler ["AnimChanged", _animChangedEHID]; _unit removeEventHandler ["AnimChanged", _animChangedEHID];
_unit setVariable [QGVAR(surrenderAnimEHID), -1]; _unit setVariable [QGVAR(surrenderAnimEHID), -1];
@ -75,25 +75,27 @@ if (_state) then {
}; };
}; };
if (_unit getVariable ["ACE_isUnconscious", false]) exitWith {}; //don't touch animations if unconscious
//if we are in "hands up" animationState, crack it now //if we are in "hands up" animationState, crack it now
if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) then { if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) then {
[_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
} else { } else {
//spin up a PFEH, to watching animationState for the next 20 seconds to make sure we don't enter //spin up a PFEH, to watching animationState for the next 20 seconds to make sure we don't enter "hands up"
//Handles long animation chains //Handles long animation chains
[{ [{
PARAMS_2(_args,_pfID); PARAMS_2(_args,_pfID);
EXPLODE_2_PVT(_args,_unit,_maxTime); EXPLODE_2_PVT(_args,_unit,_maxTime);
//If maxtime or they re-surrendered, exit loop //If waited long enough or they re-surrendered or they are unconscious, exit loop
if ((time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]}) exitWith { if ((time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]} || {_unit getVariable ["ACE_isUnconscious", false]}) exitWith {
[_pfID] call CBA_fnc_removePerFrameHandler; [_pfID] call CBA_fnc_removePerFrameHandler;
}; };
//Only break animation if they are actualy the "hands up" animation (because we are using switchmove) //Only break animation if they are actualy the "hands up" animation (because we are using switchmove there won't be an transition)
if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) exitWith { if (((vehicle _unit) == _unit) && {(animationState _unit) == "ACE_AmovPercMstpSsurWnonDnon"}) exitWith {
[_pfID] call CBA_fnc_removePerFrameHandler; [_pfID] call CBA_fnc_removePerFrameHandler;
//Break out of hands up animation loop (doAnimation handles Unconscious prioity) //Break out of hands up animation loop
[_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
}; };
}, 0.05, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler; }, 0, [_unit, (time + 20)]] call CBA_fnc_addPerFrameHandler;
}; };
}; };