From 98564fae683a212798f3c29542972cbefa40d20e Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 6 Feb 2015 15:54:26 -0600 Subject: [PATCH] Surrendering --- addons/captives/CfgMoves.hpp | 79 ++++++++----------- addons/captives/CfgVehicles.hpp | 25 +++--- addons/captives/XEH_preInit.sqf | 1 + addons/captives/config.cpp | 2 +- .../captives/functions/fnc_canSurrender.sqf | 22 ++++++ .../functions/fnc_handleUnitInitPost.sqf | 7 +- .../captives/functions/fnc_setHandcuffed.sqf | 1 - addons/captives/functions/fnc_surrender.sqf | 51 ++++++------ addons/captives/stringtable.xml | 12 ++- addons/interaction/XEH_clientInit.sqf | 4 +- 10 files changed, 121 insertions(+), 83 deletions(-) create mode 100644 addons/captives/functions/fnc_canSurrender.sqf diff --git a/addons/captives/CfgMoves.hpp b/addons/captives/CfgMoves.hpp index ab379de6ae..bb6b8669e0 100644 --- a/addons/captives/CfgMoves.hpp +++ b/addons/captives/CfgMoves.hpp @@ -1,7 +1,7 @@ class CfgMovesBasic { class Actions { class CivilStandActions; - class ACE_CivilStandCaptiveActions: CivilStandActions { + class ACE_CivilStandHandcuffedActions: CivilStandActions { turnL = ""; turnR = ""; stop = "ACE_AmovPercMstpScapWnonDnon"; @@ -11,6 +11,11 @@ class CfgMovesBasic { throwPrepare = ""; throwGrenade[] = {"","Gesture"}; }; + class ACE_CivilStandSurrenderActions: ACE_CivilStandHandcuffedActions { + stop = "ACE_AmovPercMstpScapWnonDnon"; + StopRelaxed = "ACE_AmovPercMstpScapWnonDnon"; + default = "ACE_AmovPercMstpScapWnonDnon"; + }; }; }; @@ -18,12 +23,14 @@ class CfgMovesMaleSdr: CfgMovesBasic { class StandBase; class States { class AmovPercMstpSnonWnonDnon: StandBase { - ConnectTo[] += {"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1}; + ConnectTo[] += {"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1,"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon",0.1}; }; class CutSceneAnimationBase; + + //Handcuffed Anims: class ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon: CutSceneAnimationBase { - actions = "ACE_CivilStandCaptiveActions"; + actions = "ACE_CivilStandHandcuffedActions"; file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_EaseIn"; speed = 1; looped = 0; @@ -31,7 +38,6 @@ class CfgMovesMaleSdr: CfgMovesBasic { ConnectTo[] = {"ACE_AmovPercMstpScapWnonDnon",0.1}; InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; }; - class ACE_AmovPercMstpScapWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon { file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_Ease"; speed = 0; @@ -39,52 +45,37 @@ class CfgMovesMaleSdr: CfgMovesBasic { InterpolateTo[] = {"Unconscious",0.01}; looped = 1; }; - class ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon { actions = "CivilStandActions"; file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\amovpercmstpsnonwnondnon_easeout"; ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1}; InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1}; }; + + //Surrender Anims: + class ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon: CutSceneAnimationBase { + actions = "ACE_CivilStandSurrenderActions"; + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\non\non\AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon"; + speed = 1; + looped = 0; + interpolationRestart = 2; + ConnectTo[] = {"ACE_AmovPercMstpSsurWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; + }; + class ACE_AmovPercMstpSsurWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\sur\non\AmovPercMstpSsurWnonDnon"; + speed = 0; + looped = 1; + ConnectTo[] = {"ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01}; + }; + class ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon: ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { + speed = 0.4; //for gameplay reasons, slow this down + actions = "CivilStandActions"; + file = "\A3\anims_f\Data\Anim\Sdr\mov\erc\stp\sur\non\AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"; + ConnectTo[] = {"AmovPercMstpSnonWnonDnon",0.1}; + InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon",0.1}; + }; }; }; -/* -player playMove "ACE_AmovPercMstpScapWnonDnon"; -player switchMove "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon"; - */ - -/*class CfgMovesBasic; -class CfgMovesMaleSdr: CfgMovesBasic { -class States { - class CutSceneAnimationBase; - class AmovPercMstpSnonWnonDnon_EaseIn: CutSceneAnimationBase { - head = "headDefault"; - static = 1; - disableWeapons = 0; - forceAim = 0; - InterpolateTo[] = {"AmovPercMstpSnonWnonDnon_EaseOut",0.02,"Unconscious",0.1}; - }; - class AmovPercMstpSnonWnonDnon_Ease: AmovPercMstpSnonWnonDnon_EaseIn { - looped = 1; - InterpolateTo[] = {"Unconscious",0.1}; - }; - class AmovPercMstpSnonWnonDnon_EaseOut: AmovPercMstpSnonWnonDnon_EaseIn { - InterpolateTo[] = {"AmovPercMstpSnonWnonDnon_EaseIn",0.02,"Unconscious",0.1}; - }; - - class AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon: CutSceneAnimationBase { - InterpolateTo[] = {"Unconscious",0.01,"AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon",0.1}; - }; - - class AmovPercMstpSsurWnonDnon: AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { - looped = 1; - InterpolateTo[] = {"Unconscious",0.01}; - }; - - class AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon: AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon { - InterpolateTo[] = {"Unconscious",0.01,"AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon",0.1}; - }; -}; -};*/ - diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index 65d574fab0..934e1215d2 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -78,16 +78,23 @@ class CfgVehicles { showDisabled = 0; priority = 2.3; hotkey = "C"; + }; + class ACE_StartSurrenderingSelf { + displayName = "$STR_ACE_Captives_StartSurrendering"; + condition = QUOTE([ARR_2(_player, true)] call FUNC(canSurrender)); + statement = QUOTE([ARR_2(_player, true)] call FUNC(surrender)); + exceptions[] = {}; + showDisabled = 0; + priority = 0; + }; + class ACE_StopSurrenderingSelf { + displayName = "$STR_ACE_Captives_StopSurrendering"; + condition = QUOTE([ARR_2(_player, false)] call FUNC(canSurrender)); + statement = QUOTE([ARR_2(_player, false)] call FUNC(surrender)); + exceptions[] = {QGVAR(isNotSurrendering)}; + showDisabled = 0; + priority = 0; }; - /*class ACE_LoadCaptiveSelf { - displayName = "$STR_ACE_Captives_LoadCaptive"; - condition = "[_player, objNull, objNull] call ACE_Captives_fnc_canLoadCaptiveIntoVehicle"; - statement = "[_player, objNull, objNull] call ACE_Captives_fnc_loadCaptiveIntoVehicle"; - exceptions[] = {QGVAR(isNotEscorting)}; - showDisabled = 0; - priority = 2.2; - hotkey = "K"; - };*/ }; }; diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index e894cd1c31..a98bf73443 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -8,6 +8,7 @@ PREP(canFriskPerson); PREP(canLoadCaptive); PREP(canRemoveHandcuffs); PREP(canStopEscorting); +PREP(canSurrender); PREP(canUnloadCaptive); PREP(doApplyHandcuffs); PREP(doEscortCaptive); diff --git a/addons/captives/config.cpp b/addons/captives/config.cpp index bceeda3b2b..c0a34e3222 100644 --- a/addons/captives/config.cpp +++ b/addons/captives/config.cpp @@ -26,6 +26,6 @@ class ACE_canInteractConditions { condition = QUOTE(!(GETVAR(player,QGVAR(isHandcuffed),false))); }; class GVAR(isNotSurrendering) { - condition = QUOTE(!(GETVAR(player,QGVAR(isSurrender),false))); + condition = QUOTE(!(GETVAR(player,QGVAR(isSurrendering),false))); }; }; diff --git a/addons/captives/functions/fnc_canSurrender.sqf b/addons/captives/functions/fnc_canSurrender.sqf new file mode 100644 index 0000000000..60dcd7c938 --- /dev/null +++ b/addons/captives/functions/fnc_canSurrender.sqf @@ -0,0 +1,22 @@ +/* + * Author: PabstMirror + * Checks the conditions for being able to surrender + * + * Arguments: + * 0: caller (player) + * 1: New Surrender State to test + * + * Return Value: + * The return value + * + * Example: + * [player, true] call ACE_captives_fnc_canSurrender; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_newSurrenderState); + +//TODO: any other conditions?? +(!((_unit getVariable [QGVAR(isSurrendering), false]) isEqualTo _newSurrenderState)) diff --git a/addons/captives/functions/fnc_handleUnitInitPost.sqf b/addons/captives/functions/fnc_handleUnitInitPost.sqf index d34eebeb4a..635d7b0439 100644 --- a/addons/captives/functions/fnc_handleUnitInitPost.sqf +++ b/addons/captives/functions/fnc_handleUnitInitPost.sqf @@ -18,7 +18,7 @@ PARAMS_1(_unit); // prevent players from throwing grenades (added to all units) -[_unit, "Throw", {(_this select 1) getVariable [QGVAR(isHandcuffed), false]}, {hint format ["%1 - debug throw prevented",time];}] call EFUNC(common,addActionEventhandler); +[_unit, "Throw", {((_this select 1) getVariable [QGVAR(isHandcuffed), false]) || {(_this select 1) getVariable [QGVAR(isSurrendering), false]}}, {}] call EFUNC(common,addActionEventhandler); if (local _unit) then { // reset status on mission start @@ -26,4 +26,9 @@ if (local _unit) then { _unit setVariable [QGVAR(isHandcuffed), false]; [_unit, true] call FUNC(setHandcuffed); }; + + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + _unit setVariable [QGVAR(isSurrendering), false]; + [_unit, true] call FUNC(surrender); + }; }; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 98a12168d3..1be72ca7c9 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -32,7 +32,6 @@ if (_state) then { [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); // fix anim on mission start (should work on dedicated servers) - _fixAnimationFnc = { PARAMS_1(_unit); if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { diff --git a/addons/captives/functions/fnc_surrender.sqf b/addons/captives/functions/fnc_surrender.sqf index 7c5adc08de..bb782d85da 100644 --- a/addons/captives/functions/fnc_surrender.sqf +++ b/addons/captives/functions/fnc_surrender.sqf @@ -1,6 +1,6 @@ /* - * Author: commy2 - * TODO + * Author: commy2 PabstMirror + * Lets a unit surrender * * Arguments: * 0: Unit @@ -18,39 +18,42 @@ PARAMS_2(_unit,_state); -if (!local _unit) exitWith {[_this, _fnc_scriptName, _unit] call ACE_Core_fnc_execRemoteFnc}; - if (_state) then { - if (_unit getVariable [QGVAR(isSurrender), false]) exitWith {}; - - _unit setVariable [QGVAR(isSurrender), true, true]; - [_unit, "ACE_Surrendered", true] call EFUNC(common,setCaptivityStatus); + if (_unit getVariable [QGVAR(isSurrendering), false]) exitWith {}; + _unit setVariable [QGVAR(isSurrendering), true, true]; + [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); + [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); private "_surrenderFnc"; _surrenderFnc = { EXPLODE_1_PVT((_this select 0),_unit); - if (_unit getVariable [QGVAR(isSurrender), false]) then { + + if (_unit getVariable [QGVAR(isSurrendering), false]) then { if ((!alive _unit) || {_unit getVariable ["ACE_isUnconscious", false]} || {_unit getVariable [QGVAR(isHandcuffed), false]}) then { - _unit setVariable [QGVAR(isSurrender), false, true]; - } else { - [_unit, "amovpercmstpsnonwnondnon_amovpercmstpssurwnondnon", 0] call EFUNC(common,doAnimation); + [_unit, false] call FUNC(surrender); + [(_this select 1)] call cba_fnc_removePerFrameHandler; }; - }; - - if (!(_unit getVariable [QGVAR(isSurrender), false])) then { + } else { [(_this select 1)] call cba_fnc_removePerFrameHandler; - - if !(_unit getVariable ["ACE_isUnconscious", false]) then { - [_unit, "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 1] call EFUNC(common,doAnimation); - } else { - [_unit, "unconscious", 1] call EFUNC(common,doAnimation); - }; - [_unit, "ACE_Surrendered", false] call EFUNC(common,setCaptivityStatus); - if (isPlayer _unit) then {showHUD true}; }; }; [_surrenderFnc, 0.0, [_unit]] call CBA_fnc_addPerFrameHandler; } else { - _unit setVariable [QGVAR(isSurrender), false, true]; + _unit setVariable [QGVAR(isSurrendering), false, true]; + + if !(_unit getVariable ["ACE_isUnconscious", false]) then { + //Break out of hands up animation loop + //don't want to step on animations from medical (TODO: testing medical integration) + [_unit, "ACE_AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + }; + + [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); + + if (_unit == ACE_player) then { + //only enable if not handcuffed + if (!(_unit getVariable [QGVAR(isHandcuffed), false])) then { + showHUD true; + }; + }; }; diff --git a/addons/captives/stringtable.xml b/addons/captives/stringtable.xml index eaf63b2d41..7d8096b3e6 100644 --- a/addons/captives/stringtable.xml +++ b/addons/captives/stringtable.xml @@ -1,5 +1,5 @@  - + @@ -71,6 +71,7 @@ Naložit zajatce Fogoly berakása Загрузить пленного + Embarcar Prisioneiro Unload Captive @@ -81,6 +82,7 @@ Vyložit zajatce Fogoly kivevése Выгрузить пленного + Desembarcar Prisioneiro Cable Tie @@ -115,6 +117,7 @@ Inventář prohledávané osoby Ekwipunek rewidowanej osoby Инвентарь обысканных лиц + Inventário da pessoa revistada Frisk person @@ -125,6 +128,13 @@ Rewiduj osobę Motozás Обыскать человека + Revistar + + + Surrender + + + Stop Surrendering \ No newline at end of file diff --git a/addons/interaction/XEH_clientInit.sqf b/addons/interaction/XEH_clientInit.sqf index 71be601ac7..1c314078a4 100644 --- a/addons/interaction/XEH_clientInit.sqf +++ b/addons/interaction/XEH_clientInit.sqf @@ -56,7 +56,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenuSelf", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming", "ACE_Common_notOnMap"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), QEGVAR(captives,isNotSurrendering), "ACE_Interaction_isNotSwimming", "ACE_Common_notOnMap"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(isNull (findDisplay 1713999)) exitWith {false}; @@ -74,7 +74,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenuSelf", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), QEGVAR(captives,isNotSurrendering), "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(!isNull (findDisplay 1713999) && {profileNamespace getVariable [QGVAR(AutoCloseMenu), 0] > 0}) exitWith {false};