2015-02-04 19:16:19 +00:00
|
|
|
/*
|
|
|
|
* Author: Nic547
|
|
|
|
* Attaches a Captive to the _unit
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: _unit-Player <OBJECT>
|
|
|
|
* 1: target <OBJECT>
|
|
|
|
* 2: _state <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* The return value <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
2015-02-06 23:03:56 +00:00
|
|
|
* [player, bob, true] call ACE_captives_fnc_doEscorteCaptive;
|
2015-02-04 19:16:19 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
PARAMS_3(_unit,_target,_state);
|
|
|
|
|
|
|
|
if (_state) then {
|
2015-02-06 05:11:28 +00:00
|
|
|
if (_unit getVariable [QGVAR(isEscorting), false]) exitWith {};
|
2015-02-04 19:16:19 +00:00
|
|
|
|
2015-04-25 21:03:21 +00:00
|
|
|
[_unit, _target, false] call EFUNC(common,claim);
|
2015-02-06 05:11:28 +00:00
|
|
|
_unit setVariable [QGVAR(isEscorting), true, true];
|
2015-02-04 19:16:19 +00:00
|
|
|
|
2015-02-06 05:11:28 +00:00
|
|
|
_target attachTo [_unit, [0, 1, 0]];
|
2015-02-04 19:16:19 +00:00
|
|
|
|
2015-02-06 05:11:28 +00:00
|
|
|
_unit setVariable [QGVAR(escortedUnit), _target, true];
|
2015-02-04 19:16:19 +00:00
|
|
|
|
2015-02-06 05:11:28 +00:00
|
|
|
//Add Actionmenu to release captive
|
2015-05-28 19:59:04 +00:00
|
|
|
_actionID = _unit addAction [format ["<t color='#FF0000'>%1</t>", localize LSTRING(StopEscorting)],
|
2015-02-06 05:11:28 +00:00
|
|
|
{[(_this select 0), ((_this select 0) getVariable [QGVAR(escortedUnit), objNull]), false] call FUNC(doEscortCaptive);},
|
|
|
|
nil, 20, false, true, "", QUOTE(!isNull (GETVAR(_target,QGVAR(escortedUnit),objNull)))];
|
2015-02-04 19:16:19 +00:00
|
|
|
|
2015-04-25 21:03:21 +00:00
|
|
|
[{
|
2015-02-06 09:38:27 +00:00
|
|
|
EXPLODE_3_PVT((_this select 0),_unit,_target,_actionID);
|
|
|
|
if (_unit getVariable [QGVAR(isEscorting), false]) then {
|
2015-02-06 05:11:28 +00:00
|
|
|
if (!alive _target || {!alive _unit} || {!canStand _target} || {!canStand _unit} || {_target getVariable ["ACE_isUnconscious", false]} || {_unit getVariable ["ACE_isUnconscious", false]} || {!isNull (attachedTo _unit)}) then {
|
|
|
|
_unit setVariable [QGVAR(isEscorting), false, true];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-02-06 09:38:27 +00:00
|
|
|
if (!(_unit getVariable [QGVAR(isEscorting), false])) then {
|
|
|
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
2015-04-25 21:03:21 +00:00
|
|
|
[objNull, _target, false] call EFUNC(common,claim);
|
2015-02-06 09:38:27 +00:00
|
|
|
detach _target;
|
|
|
|
_unit removeAction _actionID;
|
|
|
|
_unit setVariable [QGVAR(escortedUnit), objNull, true];
|
|
|
|
};
|
2015-04-25 21:03:21 +00:00
|
|
|
}, 0, [_unit, _target, _actionID]] call CBA_fnc_addPerFrameHandler;
|
2015-02-06 09:38:27 +00:00
|
|
|
|
2015-02-04 19:16:19 +00:00
|
|
|
} else {
|
2015-02-06 05:11:28 +00:00
|
|
|
_unit setVariable [QGVAR(isEscorting), false, true];
|
|
|
|
_unit setVariable [QGVAR(escortedUnit), objNull, true];
|
2015-02-04 19:16:19 +00:00
|
|
|
};
|