More Refactoring

This commit is contained in:
PabstMirror 2015-02-05 16:39:45 -06:00
parent 435b3b8b86
commit 122a38a6aa
23 changed files with 71 additions and 67 deletions

View File

@ -2,21 +2,21 @@ class CfgVehicles {
class Man; class Man;
class CAManBase: Man { class CAManBase: Man {
class ACE_Actions { class ACE_Actions {
class ACE_SetCaptive { class ACE_ApplyHandcuffs {
displayName = "$STR_ACE_Captives_SetCaptive"; displayName = "$STR_ACE_Captives_SetCaptive";
distance = 4; distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canTakeCaptive)); condition = QUOTE([ARR_2(_player, _target)] call FUNC(canApplyHandcuffs));
statement = QUOTE([ARR_2(_player, _target)] call FUNC(doTakeCaptive)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(doApplyHandcuffs));
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_RemoveHandcuffs {
displayName = "$STR_ACE_Captives_ReleaseCaptive"; displayName = "$STR_ACE_Captives_ReleaseCaptive";
distance = 4; distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canReleaseCaptive)); condition = QUOTE([ARR_2(_player, _target)] call FUNC(canRemoveHandcuffs));
statement = QUOTE([ARR_2(_player, _target)] call FUNC(doReleaseCaptive)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(doRemoveHandcuffs));
exceptions[] = {"ACE_Interaction_isNotEscorting"}; exceptions[] = {"ACE_Interaction_isNotEscorting"};
showDisabled = 0; showDisabled = 0;
priority = 2.4; priority = 2.4;
@ -27,7 +27,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_EscortCaptive"; displayName = "$STR_ACE_Captives_EscortCaptive";
distance = 4; distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canEscortCaptive)); condition = QUOTE([ARR_2(_player, _target)] call FUNC(canEscortCaptive));
statement = QUOTE([ARR_2(_target, true)] call FUNC(doEscortCaptive)); statement = QUOTE([ARR_3(_target, _target, true)] call FUNC(doEscortCaptive));
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));

View File

@ -1,12 +1,9 @@
#include "script_component.hpp" #include "script_component.hpp"
[missionNamespace, "playerChanged", {_this call ACE_Captives_fnc_handlePlayerChanged}] call ACE_Core_fnc_addCustomEventhandler; ["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler); ["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler);
["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); ["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler);
["SetCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler); ["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler);
//TODO: Medical Integration Events??? //TODO: Medical Integration Events???

View File

@ -2,18 +2,18 @@
ADDON = false; ADDON = false;
PREP(canApplyHandcuffs);
PREP(canEscortCaptive); PREP(canEscortCaptive);
PREP(canFriskPerson); PREP(canFriskPerson);
PREP(canLoadCaptive); PREP(canLoadCaptive);
PREP(canReleaseCaptive); PREP(canRemoveHandcuffs);
PREP(canStopEscorting); PREP(canStopEscorting);
PREP(canTakeCaptive);
PREP(canUnloadCaptive); PREP(canUnloadCaptive);
PREP(doApplyHandcuffs);
PREP(doEscortCaptive); PREP(doEscortCaptive);
PREP(doFriskPerson); PREP(doFriskPerson);
PREP(doLoadCaptive); PREP(doLoadCaptive);
PREP(doReleaseCaptive); PREP(doRemoveHandcuffs);
PREP(doTakeCaptive);
PREP(doUnloadCaptive); PREP(doUnloadCaptive);
PREP(handleGetIn); PREP(handleGetIn);
PREP(handleGetOut); PREP(handleGetOut);
@ -22,7 +22,7 @@ PREP(handleKnockedOut);
PREP(handlePlayerChanged); PREP(handlePlayerChanged);
PREP(handleUnitInitPost); PREP(handleUnitInitPost);
PREP(handleWokeUp); PREP(handleWokeUp);
PREP(setCaptive); PREP(setHandcuffed);
PREP(surrender); PREP(surrender);
PREP(vehicleCaptiveMoveIn); PREP(vehicleCaptiveMoveIn);
PREP(vehicleCaptiveMoveOut); PREP(vehicleCaptiveMoveOut);

View File

@ -17,15 +17,13 @@ class CfgPatches {
#include "CfgVehicles.hpp" #include "CfgVehicles.hpp"
#include "CfgWeapons.hpp" #include "CfgWeapons.hpp"
#define GVARFIX(var1) getVariable [ARR_2(QUOTE(GVAR(var1)), false)]
class ACE_canInteractConditions { class ACE_canInteractConditions {
class GVAR(isNotEscorting) { class GVAR(isNotEscorting) {
condition = QUOTE(!(GETVAR(player,QGVAR(isEscorting),false))); condition = QUOTE(!(GETVAR(player,QGVAR(isEscorting),false)));
}; };
class GVAR(isNotCaptive) { class GVAR(isNotHandcuffed) {
condition = QUOTE(!(GETVAR(player,QGVAR(isCaptive),false))); condition = QUOTE(!(GETVAR(player,QGVAR(isHandcuffed),false)));
}; };
class GVAR(isNotSurrendering) { class GVAR(isNotSurrendering) {
condition = QUOTE(!(GETVAR(player,QGVAR(isSurrender),false))); condition = QUOTE(!(GETVAR(player,QGVAR(isSurrender),false)));

View File

@ -1,6 +1,6 @@
/* /*
* Author: PabstMirror * Author: PabstMirror
* Checks the conditions for being able to take a unit captive * Checks the conditions for being able to apply handcuffs
* *
* Arguments: * Arguments:
* 0: caller (player) <OBJECT> * 0: caller (player) <OBJECT>
@ -18,6 +18,8 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
//Player has cableTie, target is alive and not already handcuffed
("ACE_CableTie" in (items _unit)) && ("ACE_CableTie" in (items _unit)) &&
{alive _target} && {alive _target} &&
{!(_target getVariable [QGVAR(isCaptive), false])} {!(_target getVariable [QGVAR(isHandcuffed), false])}

View File

@ -18,7 +18,7 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
(_target getVariable [QGVAR(isCaptive), false]) && (_target getVariable [QGVAR(isHandcuffed), false]) &&
{isNull (attachedTo _target)} && {isNull (attachedTo _target)} &&
{alive _target} && {alive _target} &&
{!(_target getVariable [QGVAR(ACE_isUnconscious), false])} {!(_target getVariable [QGVAR(ACE_isUnconscious), false])}

View File

@ -18,6 +18,6 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
_target getVariable [QGVAR(isCaptive), false] _target getVariable [QGVAR(isHandcuffed), false]
|| {_target getVariable ["ACE_isSearchable", false]} || {_target getVariable ["ACE_isSearchable", false]}
|| {_target getVariable ["ACE_isUnconscious", false]} || {_target getVariable ["ACE_isUnconscious", false]}

View File

@ -23,7 +23,7 @@ PARAMS_3(_unit,_target,_vehicle);
if (isNull _target) then { if (isNull _target) then {
_objects = attachedObjects _unit; _objects = attachedObjects _unit;
_objects = [_objects, {_this getVariable [QGVAR(isCaptive), false]}] call EFUNC(common,filter); _objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter);
_target = _objects select 0; _target = _objects select 0;
}; };

View File

@ -1,6 +1,6 @@
/* /*
* Author: PabstMirror * Author: PabstMirror
* Checks the conditions for being able to release a captive * Checks the conditions for being able to remove handcuffs
* *
* Arguments: * Arguments:
* 0: caller (player) <OBJECT> * 0: caller (player) <OBJECT>
@ -18,6 +18,6 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
//Unit is captive and not being escorted //Unit is handcuffed and not currently being escorted
_target getVariable [QGVAR(isCaptive), false] && _target getVariable [QGVAR(isHandcuffed), false] &&
{isNull (attachedTo _target)} {isNull (attachedTo _target)}

View File

@ -33,7 +33,7 @@ if (isNull _target) exitWith {
_isAttached = _target in (attachedObjects _unit); _isAttached = _target in (attachedObjects _unit);
if (_isAttached && (!(_target getVariable [QGVAR(isCaptive), false]))) exitWith { if (_isAttached && (!(_target getVariable [QGVAR(isHandcuffed), false]))) exitWith {
ERROR("Attached But Not Captive"); ERROR("Attached But Not Captive");
false false
}; };

View File

@ -23,6 +23,6 @@ PARAMS_2(_unit,_vehicle);
_cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway. _cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway.
_cargo = [_cargo, {_this getVariable [QGVAR(isCaptive), false]}] call EFUNC(common,filter); _cargo = [_cargo, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter);
count _cargo > 0 count _cargo > 0

View File

@ -1,6 +1,6 @@
/* /*
* Author: PabstMirror * Author: PabstMirror
* Checks the conditions for being able to take a unit captive * Checks the conditions for being able to apply handcuffs
* *
* Arguments: * Arguments:
* 0: caller (player) <OBJECT> * 0: caller (player) <OBJECT>
@ -18,5 +18,5 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
_unit removeItem 'ACE_CableTie'; _unit removeItem "ACE_CableTie";
["SetCaptive", [_target], [_target, true]] call EFUNC(common,targetEvent); ["SetHandcuffed", [_target], [_target, true]] call EFUNC(common,targetEvent);

View File

@ -19,7 +19,7 @@
PARAMS_3(_unit,_target,_state); PARAMS_3(_unit,_target,_state);
if !("ACE_Handcuffed" in ([_target] call ACE_Core_fnc_getCaptivityStatus)) exitWith { if !("ACE_Handcuffed" in ([_target] call EFUNC(common,getCaptivityStatus))) exitWith {
[localize "STR_ACE_Captives_NoCaptive"] call EFUNC(common,displayTextStructured); [localize "STR_ACE_Captives_NoCaptive"] call EFUNC(common,displayTextStructured);
}; };

View File

@ -21,14 +21,16 @@ PARAMS_3(_unit,_target,_vehicle);
if (isNull _target) then { if (isNull _target) then {
_objects = attachedObjects _unit; _objects = attachedObjects _unit;
_objects = [_objects, {_this getVariable [QGVAR(isCaptive), false]}] call EFUNC(common,filter); _objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter);
_target = _objects select 0; if ((count _objects) > 0) then {_target = _objects select 0;};
}; };
if (isNull _target) exitWith {};
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; if ((count _objects) > 0) then {_vehicle = _objects select 0;};
}; };
if (isNull _vehicle) exitWith {};
if ((!isNil "_target") && {!isNil "_vehicle"}) then { if ((!isNil "_target") && {!isNil "_vehicle"}) then {
_unit setVariable [QGVAR(isEscorting), false, true]; _unit setVariable [QGVAR(isEscorting), false, true];

View File

@ -18,4 +18,4 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
["SetCaptive", [_target], [_target, false]] call EFUNC(common,targetEvent); ["SetHandcuffed", [_target], [_target, false]] call EFUNC(common,targetEvent);

View File

@ -22,7 +22,7 @@ private ["_cargo", "_target"];
_cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway. _cargo = crew _vehicle; // Can also unload from driver, gunner, commander, turret positions. They shouldn't be there anyway.
_cargo = [_cargo, {_this getVariable [QGVAR(isCaptive), false]}] call EFUNC(common,filter); _cargo = [_cargo, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter);
if ((count _cargo) > 0) then { if ((count _cargo) > 0) then {
_target = _cargo select 0; _target = _cargo select 0;

View File

@ -19,8 +19,7 @@
PARAMS_3(_vehicle,_dontcare,_unit); PARAMS_3(_vehicle,_dontcare,_unit);
if ((local _unit)&&(_unit getVariable [QGVAR(isCaptive), false])) then { if ((local _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}) then {
private ["_cargoIndex"]; private ["_cargoIndex"];
_cargoIndex = _unit getVariable ["ACE_Captives_CargoIndex", -1]; _cargoIndex = _unit getVariable ["ACE_Captives_CargoIndex", -1];

View File

@ -17,8 +17,8 @@
PARAMS_1(_oldUnit); PARAMS_1(_oldUnit);
if (_oldUnit getVariable [QGVAR(isCaptive), false]) then { if (_oldUnit getVariable [QGVAR(isHandcuffed), false]) then {
_oldUnit setVariable [QGVAR(isCaptive), false, true]; _oldUnit setVariable [QGVAR(isHandcuffed), false, true];
}; };
if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { if (_oldUnit getVariable [QGVAR(isEscorting), false]) then {

View File

@ -18,7 +18,7 @@
PARAMS_2(_unit,_oldUnit); PARAMS_2(_unit,_oldUnit);
if (_unit getVariable [QGVAR(isCaptive), false]) then { if (_unit getVariable [QGVAR(isHandcuffed), false]) then {
showHUD false; showHUD false;
} else { } else {
showHUD true; showHUD true;

View File

@ -17,13 +17,13 @@
PARAMS_1(_unit); PARAMS_1(_unit);
// prevent players from throwing grenades // prevent players from throwing grenades (added to all units)
[_unit, "Throw", {(_this select 1) getVariable [QGVAR(isCaptive), false]}, {}] call EFUNC(common,addActionEventhandler); [_unit, "Throw", {(_this select 1) getVariable [QGVAR(isHandcuffed), false]}, {}] call EFUNC(common,addActionEventhandler);
if (local _unit) then { if (local _unit) then {
// reset status on mission start // reset status on mission start
if (_unit getVariable [QGVAR(isCaptive), false]) then { if (_unit getVariable [QGVAR(isHandcuffed), false]) then {
_unit setVariable [QGVAR(isCaptive), false]; _unit setVariable [QGVAR(isHandcuffed), false];
[_unit, true] call FUNC(setCaptive); [_unit, true] call FUNC(setHandcuffed);
}; };
}; };

View File

@ -17,7 +17,7 @@
PARAMS_1(_unit); PARAMS_1(_unit);
if (_unit getVariable [QGVAR(isCaptive), 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", 0] call EFUNC(common,doAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon", 0] call EFUNC(common,doAnimation);
}; };

View File

@ -1,6 +1,6 @@
/* /*
* Author: Nic547, commy2 * Author: Nic547, commy2
* Makes a civilian unable to move. * Handcuffs a unit
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
@ -18,18 +18,26 @@
PARAMS_2(_unit,_state); PARAMS_2(_unit,_state);
if (!local _unit) exitWith {[[_unit, _state, true], _fnc_scriptName, _unit] call ACE_Core_fnc_execRemoteFnc}; systemChat format ["set %1", _this];
if (!local _unit) exitWith {
ERROR("setHandcuffed unit not local");
};
systemChat format ["set %1 %2 ", _state, (_unit getVariable [QGVAR(isHandcuffed), false])];
if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) exitWith {
ERROR("new state equals current");
};
if (_state) then { if (_state) then {
if (_unit getVariable [QGVAR(isCaptive), false]) exitWith {}; _unit setVariable [QGVAR(isHandcuffed), true, true];
_unit setVariable [QGVAR(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, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus);
if (_this getVariable [QGVAR(isCaptive), false] && {vehicle _this == _this}) then { if (_this getVariable [QGVAR(isHandcuffed), 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);
}; };
@ -41,10 +49,8 @@ if (_state) then {
showHUD false; showHUD false;
}; };
} else { } else {
if !(_unit getVariable [QGVAR(isCaptive), false]) exitWith {}; _unit setVariable [QGVAR(isHandcuffed), false, true];
[_unit, "ACE_Handcuffed", false] call EFUNC(common,setCaptivityStatus);
_unit setVariable [QGVAR(isCaptive), false, true];
[_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);
}; };

View File

@ -24,7 +24,7 @@ if (_state) then {
if (_unit getVariable [QGVAR(isSurrender), false]) exitWith {}; if (_unit getVariable [QGVAR(isSurrender), false]) exitWith {};
_unit setVariable [QGVAR(isSurrender), true, true]; _unit setVariable [QGVAR(isSurrender), true, true];
[_unit, "ACE_Surrendered", true] call ACE_Core_fnc_setCaptivityStatus; [_unit, "ACE_Surrendered", true] call EFUNC(common,setCaptivityStatus);
_unit spawn { _unit spawn {
// fix for lowered rifle animation glitch // fix for lowered rifle animation glitch
@ -49,7 +49,7 @@ if (_state) then {
_this playMoveNow "unconscious"; _this playMoveNow "unconscious";
}; };
[_this, "ACE_Surrendered", false] call ACE_Core_fnc_setCaptivityStatus; [_this, "ACE_Surrendered", false] call EFUNC(common,setCaptivityStatus);
if (isPlayer _this) then {showHUD true}; if (isPlayer _this) then {showHUD true};
}; };