diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index 8758788b2a..dd4f6361d7 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -1,84 +1,84 @@ class CfgVehicles { - class Man; - class CAManBase: Man { - class ACE_Actions { - class ACE_SetCaptive { - displayName = "$STR_ACE_Captives_SetCaptive"; - distance = 4; - condition = QUOTE(('ACE_CableTie' in (items _player)) && {alive _target} && {!(_target getVariable ['ACE_isCaptive', false])}); - statement = QUOTE(_player removeItem 'ACE_CableTie'; [ARR_2(_target, true)] call FUNC(setCaptive);); - showDisabled = 0; - priority = 2.4; - icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); - hotkey = "C"; - }; - class ACE_ReleaseCaptive { - displayName = "$STR_ACE_Captives_ReleaseCaptive"; - distance = 4; - condition = QUOTE(_target getVariable ['ACE_isCaptive', false] && {isNull (attachedTo _target)}); - statement = QUOTE([ARR_2(_target, false)] call FUNC(setCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; - showDisabled = 0; - priority = 2.4; - icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); - hotkey = "R"; - }; - class ACE_EscortCaptive { - displayName = "$STR_ACE_Captives_EscortCaptive"; - distance = 4; - condition = QUOTE((_target getVariable ['ACE_isCaptive', false]) && {isNull (attachedTo _target)} && {alive _target} && {!(_target getVariable ['ACE_isUnconscious', false])}); - statement = QUOTE([ARR_2(_target, true)] call FUNC(escortCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; - showDisabled = 0; - icon = QUOTE(PATHTOF(UI\captive_ca.paa)); - priority = 2.3; - hotkey = "E"; - }; - class ACE_StopEscorting { - displayName = "$STR_ACE_Captives_StopEscorting"; - distance = 4; - condition = QUOTE((_target getVariable ['ACE_isCaptive', false]) && {_target in (attachedObjects _player)}); - statement = QUOTE([ARR_2(_target, false)] call FUNC(escortCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; - showDisabled = 0; - icon = QUOTE(PATHTOF(UI\captive_ca.paa)); - priority = 2.3; - hotkey = "E"; - }; - class ACE_LoadCaptive { - displayName = "$STR_ACE_Captives_LoadCaptive"; - distance = 4; - condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive)); - statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(loadCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; - showDisabled = 0; - icon = QUOTE(PATHTOF(UI\captive_ca.paa)); - priority = 2.2; - hotkey = "L"; - }; - class ACE_FriskPerson { - displayName = "$STR_ACE_Captives_FriskPerson"; - distance = 2; - condition = QUOTE([ARR_2(_player, _target)] call FUNC(canFriskPerson)); - statement = QUOTE([ARR_2(_player, _target)] call FUNC(openFriskMenu)); - showDisabled = 0; - //icon = ""; //@todo - priority = 3; - hotkey = "F"; - }; - }; + class Man; + class CAManBase: Man { + class ACE_Actions { + class ACE_SetCaptive { + displayName = "$STR_ACE_Captives_SetCaptive"; + distance = 4; + condition = QUOTE(('ACE_CableTie' in (items _player)) && {alive _target} && {!(_target getVariable ['ACE_isCaptive', false])}); + statement = QUOTE(_player removeItem 'ACE_CableTie'; [ARR_3(QGVAR(SetCaptive), [_target], [ARR_2(_target, true)])] call EFUNC(common,targetEvent);); + showDisabled = 0; + priority = 2.4; + icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); + hotkey = "C"; + }; + class ACE_ReleaseCaptive { + displayName = "$STR_ACE_Captives_ReleaseCaptive"; + distance = 4; + condition = QUOTE(_target getVariable ['ACE_isCaptive', false] && {isNull (attachedTo _target)}); + statement = QUOTE([ARR_2(_target, false)] call FUNC(setCaptive)); + exceptions[] = {"ACE_Interaction_isNotEscorting"}; + showDisabled = 0; + priority = 2.4; + icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); + hotkey = "R"; + }; + class ACE_EscortCaptive { + displayName = "$STR_ACE_Captives_EscortCaptive"; + distance = 4; + condition = QUOTE((_target getVariable ['ACE_isCaptive', false]) && {isNull (attachedTo _target)} && {alive _target} && {!(_target getVariable ['ACE_isUnconscious', false])}); + statement = QUOTE([ARR_2(_target, true)] call FUNC(escortCaptive)); + exceptions[] = {"ACE_Interaction_isNotEscorting"}; + showDisabled = 0; + icon = QUOTE(PATHTOF(UI\captive_ca.paa)); + priority = 2.3; + hotkey = "E"; + }; + class ACE_StopEscorting { + displayName = "$STR_ACE_Captives_StopEscorting"; + distance = 4; + condition = QUOTE((_target getVariable ['ACE_isCaptive', false]) && {_target in (attachedObjects _player)}); + statement = QUOTE([ARR_2(_target, false)] call FUNC(escortCaptive)); + exceptions[] = {"ACE_Interaction_isNotEscorting"}; + showDisabled = 0; + icon = QUOTE(PATHTOF(UI\captive_ca.paa)); + priority = 2.3; + hotkey = "E"; + }; + class ACE_LoadCaptive { + displayName = "$STR_ACE_Captives_LoadCaptive"; + distance = 4; + condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive)); + statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(loadCaptive)); + exceptions[] = {"ACE_Interaction_isNotEscorting"}; + showDisabled = 0; + icon = QUOTE(PATHTOF(UI\captive_ca.paa)); + priority = 2.2; + hotkey = "L"; + }; + class ACE_FriskPerson { + displayName = "$STR_ACE_Captives_FriskPerson"; + distance = 2; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canFriskPerson)); + statement = QUOTE([ARR_2(_player, _target)] call FUNC(openFriskMenu)); + showDisabled = 0; + //icon = ""; //@todo + priority = 3; + hotkey = "F"; + }; + }; - class ACE_SelfActions { - class ACE_StopEscortingSelf { - displayName = "$STR_ACE_Captives_StopEscorting"; - condition = QUOTE(((_player getVariable ['ACE_escortedUnit', objNull]) getVariable ['ACE_isCaptive', false]) && {(_player getVariable ['ACE_escortedUnit', objNull]) in attachedObjects _player}); - statement = QUOTE([ARR_2((_player getVariable ['ACE_escortedUnit', objNull]), false)] call FUNC(_escortCaptive);); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; - showDisabled = 0; - priority = 2.3; - hotkey = "C"; - }; - /*class ACE_LoadCaptiveSelf { + class ACE_SelfActions { + class ACE_StopEscortingSelf { + displayName = "$STR_ACE_Captives_StopEscorting"; + condition = QUOTE(((_player getVariable ['ACE_escortedUnit', objNull]) getVariable ['ACE_isCaptive', false]) && {(_player getVariable ['ACE_escortedUnit', objNull]) in attachedObjects _player}); + statement = QUOTE([ARR_2((_player getVariable ['ACE_escortedUnit', objNull]), false)] call FUNC(_escortCaptive);); + exceptions[] = {"ACE_Interaction_isNotEscorting"}; + showDisabled = 0; + priority = 2.3; + hotkey = "C"; + }; + /*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"; @@ -86,72 +86,72 @@ class CfgVehicles { showDisabled = 0; priority = 2.2; hotkey = "K"; - };*/ - }; - }; - - #define MACRO_LOADUNLOADCAPTIVE \ - class ACE_Actions { \ - class ACE_LoadCaptive { \ - displayName = "$STR_ACE_Captives_LoadCaptive"; \ - distance = 4; \ - condition = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(canLoadCaptive)); \ - statement = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(loadCaptive)); \ - exceptions[] = {"ACE_Interaction_isNotEscorting"}; \ - showDisabled = 0; \ - priority = 1.2; \ - hotkey = "L"; \ - }; \ - class ACE_UnloadCaptive { \ - displayName = "$STR_ACE_Captives_UnloadCaptive"; \ - distance = 4; \ - condition = QUOTE([ARR_2(_player, _target)] call FUNC(canUnloadCaptive)); \ - statement = QUOTE([ARR_2(_player, _target)] call FUNC(unloadCaptive)); \ - showDisabled = 0; \ - priority = 1.2; \ - hotkey = "C"; \ - }; \ + };*/ + }; }; - class LandVehicle; - class Car: LandVehicle { - MACRO_LOADUNLOADCAPTIVE - }; - class Tank: LandVehicle { - MACRO_LOADUNLOADCAPTIVE - }; +#define MACRO_LOADUNLOADCAPTIVE \ + class ACE_Actions { \ + class ACE_LoadCaptive { \ + displayName = "$STR_ACE_Captives_LoadCaptive"; \ + distance = 4; \ + condition = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(canLoadCaptive)); \ + statement = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(loadCaptive)); \ + exceptions[] = {"ACE_Interaction_isNotEscorting"}; \ + showDisabled = 0; \ + priority = 1.2; \ + hotkey = "L"; \ + }; \ + class ACE_UnloadCaptive { \ + displayName = "$STR_ACE_Captives_UnloadCaptive"; \ + distance = 4; \ + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canUnloadCaptive)); \ + statement = QUOTE([ARR_2(_player, _target)] call FUNC(unloadCaptive)); \ + showDisabled = 0; \ + priority = 1.2; \ + hotkey = "C"; \ + }; \ + }; - class Air; - class Helicopter: Air { - MACRO_LOADUNLOADCAPTIVE - }; - class Plane: Air { - MACRO_LOADUNLOADCAPTIVE - }; - - class Ship; - class Ship_F: Ship { - MACRO_LOADUNLOADCAPTIVE - }; - - class StaticWeapon: LandVehicle { - MACRO_LOADUNLOADCAPTIVE - }; - - class StaticMortar; - class Mortar_01_base_F: StaticMortar { - MACRO_LOADUNLOADCAPTIVE - }; - - #define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ - name = #ITEM; \ - count = COUNT; \ - }; - - class Box_NATO_Support_F; - class ACE_Box_Misc: Box_NATO_Support_F { - class TransportItems { - MACRO_ADDITEM(ACE_CableTie,12) + class LandVehicle; + class Car: LandVehicle { + MACRO_LOADUNLOADCAPTIVE + }; + class Tank: LandVehicle { + MACRO_LOADUNLOADCAPTIVE + }; + + class Air; + class Helicopter: Air { + MACRO_LOADUNLOADCAPTIVE + }; + class Plane: Air { + MACRO_LOADUNLOADCAPTIVE + }; + + class Ship; + class Ship_F: Ship { + MACRO_LOADUNLOADCAPTIVE + }; + + class StaticWeapon: LandVehicle { + MACRO_LOADUNLOADCAPTIVE + }; + + class StaticMortar; + class Mortar_01_base_F: StaticMortar { + MACRO_LOADUNLOADCAPTIVE + }; + +#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ + name = #ITEM; \ + count = COUNT; \ + }; + + class Box_NATO_Support_F; + class ACE_Box_Misc: Box_NATO_Support_F { + class TransportItems { + MACRO_ADDITEM(ACE_CableTie,12) + }; }; - }; }; diff --git a/addons/captives/XEH_postInitClient.sqf b/addons/captives/XEH_postInitClient.sqf index a08c5d4239..a461b36aeb 100644 --- a/addons/captives/XEH_postInitClient.sqf +++ b/addons/captives/XEH_postInitClient.sqf @@ -1,3 +1,9 @@ // by commy2 [missionNamespace, "playerChanged", {_this call ACE_Captives_fnc_handlePlayerChanged}] call ACE_Core_fnc_addCustomEventhandler; + + + +[QGVAR(MoveIn), {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler); +[QGVAR(MoveOut), {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); +[QGVAR(SetCaptive), {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); diff --git a/addons/captives/functions/fnc_loadCaptive.sqf b/addons/captives/functions/fnc_loadCaptive.sqf index f2b1a9a0c1..2648255c3b 100644 --- a/addons/captives/functions/fnc_loadCaptive.sqf +++ b/addons/captives/functions/fnc_loadCaptive.sqf @@ -20,17 +20,17 @@ PARAMS_1(_unit,_target,_vehicle); if (isNull _target) then { - // _objects = attachedObjects _unit; - // _objects = [_objects, {_this getVariable ["ACE_isCaptive", false]}] call EFUNC(common,filter); - // _target = _objects select 0; + _objects = attachedObjects _unit; + _objects = [_objects, {_this getVariable ["ACE_isCaptive", false]}] call EFUNC(common,filter); + _target = _objects select 0; }; if (isNull _vehicle) then { - _objects = nearestObjects [_unit, ["Car_F", "Tank_F", "Helicopter_F", "Boat_F", "Plane_F"], 10]; - _vehicle = _objects select 0; + _objects = nearestObjects [_unit, ["Car_F", "Tank_F", "Helicopter_F", "Boat_F", "Plane_F"], 10]; + _vehicle = _objects select 0; }; -if (!isNil "_target" && {!isNil "_vehicle"}) then { - _unit setVariable ["ACE_isEscorting", false]; - [[_target, _vehicle], "{(_this select 0) moveInCargo (_this select 1); (_this select 0) assignAsCargo (_this select 1); (_this select 0) setVariable ['ACE_Captives_CargoIndex', (_this select 1) getCargoIndex (_this select 0), true];}", _target] call ACE_Core_fnc_execRemoteFnc; +if ((!isNil "_target") && {!isNil "_vehicle"}) then { + _unit setVariable ["ACE_isEscorting", false]; + [QGVAR(MoveIn), [_target], [_target, _vehicle]] call EFUNC(common,targetEvent); }; diff --git a/addons/captives/functions/fnc_setCaptive.sqf b/addons/captives/functions/fnc_setCaptive.sqf index 38ce997a88..b4c047dd1b 100644 --- a/addons/captives/functions/fnc_setCaptive.sqf +++ b/addons/captives/functions/fnc_setCaptive.sqf @@ -21,39 +21,39 @@ PARAMS_2(_unit,_state); if (!local _unit) exitWith {[[_unit, _state, true], _fnc_scriptName, _unit] call ACE_Core_fnc_execRemoteFnc}; if (_state) then { - if (_unit getVariable ["ACE_isCaptive", false]) exitWith {}; + if (_unit getVariable ["ACE_isCaptive", false]) exitWith {}; - _unit setVariable ["ACE_isCaptive", true, true]; + _unit setVariable ["ACE_isCaptive", true, true]; - // fix anim on mission start (should work on dedicated servers) - _unit spawn { - [_this, "ACE_Handcuffed", true] call ACE_Core_fnc_setCaptivityStatus; + // fix anim on mission start (should work on dedicated servers) + _unit spawn { + [_this, "ACE_Handcuffed", true] call ACE_Core_fnc_setCaptivityStatus; - if (_this getVariable ["ACE_isCaptive", false] && {vehicle _this == _this}) then { - [_this] call EFUNC(common,fixLoweredRifleAnimation); - [_this, "ACE_AmovPercMstpScapWnonDnon", 0] spawn EFUNC(common,doAnimation); + if (_this getVariable ["ACE_isCaptive", false] && {vehicle _this == _this}) then { + [_this] call EFUNC(common,fixLoweredRifleAnimation); + [_this, "ACE_AmovPercMstpScapWnonDnon", 0] spawn EFUNC(common,doAnimation); + }; }; - }; - _unit setVariable ["ACE_Captives_CargoIndex", vehicle _unit getCargoIndex _unit, true]; + _unit setVariable ["ACE_Captives_CargoIndex", vehicle _unit getCargoIndex _unit, true]; - if (_unit == ACE_player) then { - showHUD false; - }; + if (_unit == ACE_player) then { + showHUD false; + }; } else { - if !(_unit getVariable ["ACE_isCaptive", false]) exitWith {}; + if !(_unit getVariable ["ACE_isCaptive", false]) exitWith {}; - _unit setVariable ["ACE_isCaptive", false, true]; - [_unit, "ACE_Handcuffed", false] call ACE_Core_fnc_setCaptivityStatus; - if (vehicle _unit == _unit) then { - [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); - }; + _unit setVariable ["ACE_isCaptive", false, true]; + [_unit, "ACE_Handcuffed", false] call ACE_Core_fnc_setCaptivityStatus; + if (vehicle _unit == _unit) then { + [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + }; - if (_unit getVariable ["ACE_Captives_CargoIndex", -1] != -1) then { - _unit setVariable ["ACE_Captives_CargoIndex", -1, true]; - }; + if (_unit getVariable ["ACE_Captives_CargoIndex", -1] != -1) then { + _unit setVariable ["ACE_Captives_CargoIndex", -1, true]; + }; - if (_unit == ACE_player) then { - showHUD true; - }; + if (_unit == ACE_player) then { + showHUD true; + }; }; diff --git a/addons/captives/functions/fnc_unloadCaptive.sqf b/addons/captives/functions/fnc_unloadCaptive.sqf index e6eb4b24a5..2ede9de480 100644 --- a/addons/captives/functions/fnc_unloadCaptive.sqf +++ b/addons/captives/functions/fnc_unloadCaptive.sqf @@ -24,12 +24,9 @@ _cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turr _cargo = [_cargo, {_this getVariable ["ACE_isCaptive", false]}] call EFUNC(common,filter); -if (count _cargo > 0) then { +if ((count _cargo) > 0) then { _target = _cargo select 0; - - _target setVariable ["ACE_Captives_CargoIndex", -1, true]; - - moveOut _target; - [_target, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); - [_target, "{unassignVehicle _this}", _target] call ACE_Core_fnc_execRemoteFnc; + [QGVAR(MoveOut), [_target], [_target]] call EFUNC(common,targetEvent); +} else { + ERROR("No captive to unload"); }; diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf new file mode 100644 index 0000000000..1eb1c2ef2b --- /dev/null +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf @@ -0,0 +1,28 @@ +/* + * Author: PabstMirror + * Loads a captive into a vehicle + * + * Arguments: + * 0: The Captive + * 1: The Vehicle + * + * Return Value: + * Nothing + * + * Example: + * TODO + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_target,_vehicle); + +private ["_cargoIndex"]; + +_target moveInCargo _vehicle; +_target assignAsCargo _vehicle; +_cargoIndex = _vehicle getCargoIndex _target; +_target setVariable ["ACE_Captives_CargoIndex", _cargoIndex, true]; + +TRACE_3("moveinEH",_target,_vehicle,_cargoIndex); diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf new file mode 100644 index 0000000000..0a10572909 --- /dev/null +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf @@ -0,0 +1,24 @@ +/* + * Author: PabstMirror + * Unloads a captive from a vehicle. + * + * Arguments: + * 0: Captive Unit being unloaded + * + * Return Value: + * Nothing + * + * Example: + * TODO + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_unit); + +_unit setVariable ["ACE_Captives_CargoIndex", -1, true]; + +moveOut _unit; +[_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); +unassignVehicle _unit; \ No newline at end of file