remoteFncs -> events

This commit is contained in:
PabstMirror 2015-02-03 23:13:44 -06:00
parent 4156143ecf
commit 4c727fbff5
7 changed files with 238 additions and 183 deletions

View File

@ -1,84 +1,84 @@
class CfgVehicles { class CfgVehicles {
class Man; class Man;
class CAManBase: Man { class CAManBase: Man {
class ACE_Actions { class ACE_Actions {
class ACE_SetCaptive { class ACE_SetCaptive {
displayName = "$STR_ACE_Captives_SetCaptive"; displayName = "$STR_ACE_Captives_SetCaptive";
distance = 4; distance = 4;
condition = QUOTE(('ACE_CableTie' in (items _player)) && {alive _target} && {!(_target getVariable ['ACE_isCaptive', false])}); 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);); statement = QUOTE(_player removeItem 'ACE_CableTie'; [ARR_3(QGVAR(SetCaptive), [_target], [ARR_2(_target, true)])] call EFUNC(common,targetEvent););
showDisabled = 0; showDisabled = 0;
priority = 2.4; priority = 2.4;
icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); icon = QUOTE(PATHTOF(UI\handcuff_ca.paa));
hotkey = "C"; hotkey = "C";
}; };
class ACE_ReleaseCaptive { class ACE_ReleaseCaptive {
displayName = "$STR_ACE_Captives_ReleaseCaptive"; displayName = "$STR_ACE_Captives_ReleaseCaptive";
distance = 4; distance = 4;
condition = QUOTE(_target getVariable ['ACE_isCaptive', false] && {isNull (attachedTo _target)}); condition = QUOTE(_target getVariable ['ACE_isCaptive', false] && {isNull (attachedTo _target)});
statement = QUOTE([ARR_2(_target, false)] call FUNC(setCaptive)); statement = QUOTE([ARR_2(_target, false)] call FUNC(setCaptive));
exceptions[] = {"ACE_Interaction_isNotEscorting"}; exceptions[] = {"ACE_Interaction_isNotEscorting"};
showDisabled = 0; showDisabled = 0;
priority = 2.4; priority = 2.4;
icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); icon = QUOTE(PATHTOF(UI\handcuff_ca.paa));
hotkey = "R"; hotkey = "R";
}; };
class ACE_EscortCaptive { class ACE_EscortCaptive {
displayName = "$STR_ACE_Captives_EscortCaptive"; displayName = "$STR_ACE_Captives_EscortCaptive";
distance = 4; distance = 4;
condition = QUOTE((_target getVariable ['ACE_isCaptive', false]) && {isNull (attachedTo _target)} && {alive _target} && {!(_target getVariable ['ACE_isUnconscious', false])}); 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)); statement = QUOTE([ARR_2(_target, true)] call FUNC(escortCaptive));
exceptions[] = {"ACE_Interaction_isNotEscorting"}; exceptions[] = {"ACE_Interaction_isNotEscorting"};
showDisabled = 0; showDisabled = 0;
icon = QUOTE(PATHTOF(UI\captive_ca.paa)); icon = QUOTE(PATHTOF(UI\captive_ca.paa));
priority = 2.3; priority = 2.3;
hotkey = "E"; hotkey = "E";
}; };
class ACE_StopEscorting { class ACE_StopEscorting {
displayName = "$STR_ACE_Captives_StopEscorting"; displayName = "$STR_ACE_Captives_StopEscorting";
distance = 4; distance = 4;
condition = QUOTE((_target getVariable ['ACE_isCaptive', false]) && {_target in (attachedObjects _player)}); condition = QUOTE((_target getVariable ['ACE_isCaptive', false]) && {_target in (attachedObjects _player)});
statement = QUOTE([ARR_2(_target, false)] call FUNC(escortCaptive)); statement = QUOTE([ARR_2(_target, false)] call FUNC(escortCaptive));
exceptions[] = {"ACE_Interaction_isNotEscorting"}; exceptions[] = {"ACE_Interaction_isNotEscorting"};
showDisabled = 0; showDisabled = 0;
icon = QUOTE(PATHTOF(UI\captive_ca.paa)); icon = QUOTE(PATHTOF(UI\captive_ca.paa));
priority = 2.3; priority = 2.3;
hotkey = "E"; hotkey = "E";
}; };
class ACE_LoadCaptive { class ACE_LoadCaptive {
displayName = "$STR_ACE_Captives_LoadCaptive"; displayName = "$STR_ACE_Captives_LoadCaptive";
distance = 4; distance = 4;
condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive)); condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive));
statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(loadCaptive)); statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(loadCaptive));
exceptions[] = {"ACE_Interaction_isNotEscorting"}; exceptions[] = {"ACE_Interaction_isNotEscorting"};
showDisabled = 0; showDisabled = 0;
icon = QUOTE(PATHTOF(UI\captive_ca.paa)); icon = QUOTE(PATHTOF(UI\captive_ca.paa));
priority = 2.2; priority = 2.2;
hotkey = "L"; hotkey = "L";
}; };
class ACE_FriskPerson { class ACE_FriskPerson {
displayName = "$STR_ACE_Captives_FriskPerson"; displayName = "$STR_ACE_Captives_FriskPerson";
distance = 2; distance = 2;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canFriskPerson)); condition = QUOTE([ARR_2(_player, _target)] call FUNC(canFriskPerson));
statement = QUOTE([ARR_2(_player, _target)] call FUNC(openFriskMenu)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(openFriskMenu));
showDisabled = 0; showDisabled = 0;
//icon = ""; //@todo //icon = ""; //@todo
priority = 3; priority = 3;
hotkey = "F"; hotkey = "F";
}; };
}; };
class ACE_SelfActions { class ACE_SelfActions {
class ACE_StopEscortingSelf { class ACE_StopEscortingSelf {
displayName = "$STR_ACE_Captives_StopEscorting"; displayName = "$STR_ACE_Captives_StopEscorting";
condition = QUOTE(((_player getVariable ['ACE_escortedUnit', objNull]) getVariable ['ACE_isCaptive', false]) && {(_player getVariable ['ACE_escortedUnit', objNull]) in attachedObjects _player}); 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);); statement = QUOTE([ARR_2((_player getVariable ['ACE_escortedUnit', objNull]), false)] call FUNC(_escortCaptive););
exceptions[] = {"ACE_Interaction_isNotEscorting"}; exceptions[] = {"ACE_Interaction_isNotEscorting"};
showDisabled = 0; showDisabled = 0;
priority = 2.3; priority = 2.3;
hotkey = "C"; hotkey = "C";
}; };
/*class ACE_LoadCaptiveSelf { /*class ACE_LoadCaptiveSelf {
displayName = "$STR_ACE_Captives_LoadCaptive"; displayName = "$STR_ACE_Captives_LoadCaptive";
condition = "[_player, objNull, objNull] call ACE_Captives_fnc_canLoadCaptiveIntoVehicle"; condition = "[_player, objNull, objNull] call ACE_Captives_fnc_canLoadCaptiveIntoVehicle";
statement = "[_player, objNull, objNull] call ACE_Captives_fnc_loadCaptiveIntoVehicle"; statement = "[_player, objNull, objNull] call ACE_Captives_fnc_loadCaptiveIntoVehicle";
@ -86,72 +86,72 @@ class CfgVehicles {
showDisabled = 0; showDisabled = 0;
priority = 2.2; priority = 2.2;
hotkey = "K"; 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; #define MACRO_LOADUNLOADCAPTIVE \
class Car: LandVehicle { class ACE_Actions { \
MACRO_LOADUNLOADCAPTIVE class ACE_LoadCaptive { \
}; displayName = "$STR_ACE_Captives_LoadCaptive"; \
class Tank: LandVehicle { distance = 4; \
MACRO_LOADUNLOADCAPTIVE 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 LandVehicle;
class Helicopter: Air { class Car: LandVehicle {
MACRO_LOADUNLOADCAPTIVE MACRO_LOADUNLOADCAPTIVE
}; };
class Plane: Air { class Tank: LandVehicle {
MACRO_LOADUNLOADCAPTIVE MACRO_LOADUNLOADCAPTIVE
}; };
class Ship; class Air;
class Ship_F: Ship { class Helicopter: Air {
MACRO_LOADUNLOADCAPTIVE MACRO_LOADUNLOADCAPTIVE
}; };
class Plane: Air {
class StaticWeapon: LandVehicle { MACRO_LOADUNLOADCAPTIVE
MACRO_LOADUNLOADCAPTIVE };
};
class Ship;
class StaticMortar; class Ship_F: Ship {
class Mortar_01_base_F: StaticMortar { MACRO_LOADUNLOADCAPTIVE
MACRO_LOADUNLOADCAPTIVE };
};
class StaticWeapon: LandVehicle {
#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \ MACRO_LOADUNLOADCAPTIVE
name = #ITEM; \ };
count = COUNT; \
}; class StaticMortar;
class Mortar_01_base_F: StaticMortar {
class Box_NATO_Support_F; MACRO_LOADUNLOADCAPTIVE
class ACE_Box_Misc: Box_NATO_Support_F { };
class TransportItems {
MACRO_ADDITEM(ACE_CableTie,12) #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)
};
}; };
};
}; };

View File

@ -1,3 +1,9 @@
// by commy2 // by commy2
[missionNamespace, "playerChanged", {_this call ACE_Captives_fnc_handlePlayerChanged}] call ACE_Core_fnc_addCustomEventhandler; [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);

View File

@ -20,17 +20,17 @@
PARAMS_1(_unit,_target,_vehicle); PARAMS_1(_unit,_target,_vehicle);
if (isNull _target) then { if (isNull _target) then {
// _objects = attachedObjects _unit; _objects = attachedObjects _unit;
// _objects = [_objects, {_this getVariable ["ACE_isCaptive", false]}] call EFUNC(common,filter); _objects = [_objects, {_this getVariable ["ACE_isCaptive", false]}] call EFUNC(common,filter);
// _target = _objects select 0; _target = _objects select 0;
}; };
if (isNull _vehicle) then { if (isNull _vehicle) then {
_objects = nearestObjects [_unit, ["Car_F", "Tank_F", "Helicopter_F", "Boat_F", "Plane_F"], 10]; _objects = nearestObjects [_unit, ["Car_F", "Tank_F", "Helicopter_F", "Boat_F", "Plane_F"], 10];
_vehicle = _objects select 0; _vehicle = _objects select 0;
}; };
if (!isNil "_target" && {!isNil "_vehicle"}) then { if ((!isNil "_target") && {!isNil "_vehicle"}) then {
_unit setVariable ["ACE_isEscorting", false]; _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; [QGVAR(MoveIn), [_target], [_target, _vehicle]] call EFUNC(common,targetEvent);
}; };

View File

@ -21,39 +21,39 @@ PARAMS_2(_unit,_state);
if (!local _unit) exitWith {[[_unit, _state, true], _fnc_scriptName, _unit] call ACE_Core_fnc_execRemoteFnc}; if (!local _unit) exitWith {[[_unit, _state, true], _fnc_scriptName, _unit] call ACE_Core_fnc_execRemoteFnc};
if (_state) then { 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) // fix anim on mission start (should work on dedicated servers)
_unit spawn { _unit spawn {
[_this, "ACE_Handcuffed", true] call ACE_Core_fnc_setCaptivityStatus; [_this, "ACE_Handcuffed", true] call ACE_Core_fnc_setCaptivityStatus;
if (_this getVariable ["ACE_isCaptive", false] && {vehicle _this == _this}) then { if (_this getVariable ["ACE_isCaptive", false] && {vehicle _this == _this}) then {
[_this] call EFUNC(common,fixLoweredRifleAnimation); [_this] call EFUNC(common,fixLoweredRifleAnimation);
[_this, "ACE_AmovPercMstpScapWnonDnon", 0] spawn EFUNC(common,doAnimation); [_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 { if (_unit == ACE_player) then {
showHUD false; showHUD false;
}; };
} else { } else {
if !(_unit getVariable ["ACE_isCaptive", false]) exitWith {}; if !(_unit getVariable ["ACE_isCaptive", false]) exitWith {};
_unit setVariable ["ACE_isCaptive", false, true]; _unit setVariable ["ACE_isCaptive", false, true];
[_unit, "ACE_Handcuffed", false] call ACE_Core_fnc_setCaptivityStatus; [_unit, "ACE_Handcuffed", false] call ACE_Core_fnc_setCaptivityStatus;
if (vehicle _unit == _unit) then { if (vehicle _unit == _unit) then {
[_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
}; };
if (_unit getVariable ["ACE_Captives_CargoIndex", -1] != -1) then { if (_unit getVariable ["ACE_Captives_CargoIndex", -1] != -1) then {
_unit setVariable ["ACE_Captives_CargoIndex", -1, true]; _unit setVariable ["ACE_Captives_CargoIndex", -1, true];
}; };
if (_unit == ACE_player) then { if (_unit == ACE_player) then {
showHUD true; showHUD true;
}; };
}; };

View File

@ -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); _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 = _cargo select 0;
[QGVAR(MoveOut), [_target], [_target]] call EFUNC(common,targetEvent);
_target setVariable ["ACE_Captives_CargoIndex", -1, true]; } else {
ERROR("No captive to unload");
moveOut _target;
[_target, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation);
[_target, "{unassignVehicle _this}", _target] call ACE_Core_fnc_execRemoteFnc;
}; };

View File

@ -0,0 +1,28 @@
/*
* Author: PabstMirror
* Loads a captive into a vehicle
*
* Arguments:
* 0: The Captive <OBJECT>
* 1: The Vehicle <OBJECT>
*
* 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);

View File

@ -0,0 +1,24 @@
/*
* Author: PabstMirror
* Unloads a captive from a vehicle.
*
* Arguments:
* 0: Captive Unit being unloaded <OBJECT>
*
* 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;