2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2017-10-10 16:06:37 +00:00
|
|
|
/*
|
|
|
|
* Author: alganthe
|
|
|
|
* Used to un-garrison units.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Units to un-garrison <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [unit1, unit2, unit3] call ace_ai_fnc_unGarrison
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
params [["_units", [], [[]]]];
|
|
|
|
|
|
|
|
_units = _units select {local _x};
|
|
|
|
|
|
|
|
{
|
2018-10-24 17:55:12 +00:00
|
|
|
private _unit = _x;
|
|
|
|
if (!isPlayer _unit && {local _unit}) then {
|
|
|
|
_unit enableAI "PATH";
|
|
|
|
_unit enableAI "FSM";
|
2017-10-10 16:06:37 +00:00
|
|
|
|
2018-10-24 17:55:12 +00:00
|
|
|
private _leader = leader _unit;
|
2017-10-10 16:06:37 +00:00
|
|
|
|
2018-10-24 17:55:12 +00:00
|
|
|
TRACE_3("fnc_ungarrison: unit and leader",_unit , _leader, (_leader == _unit));
|
2017-10-10 16:06:37 +00:00
|
|
|
|
2018-10-24 17:55:12 +00:00
|
|
|
_unit setVariable [QGVAR(garrisonned), false, true];
|
2017-10-10 16:06:37 +00:00
|
|
|
|
2018-10-24 17:55:12 +00:00
|
|
|
private _unitMoveList = missionNameSpace getVariable [QGVAR(garrison_unitMoveList), []];
|
|
|
|
_unitMoveList deleteAt (_unitMoveList findIf {_x select 0 == _unit});
|
|
|
|
|
|
|
|
if (_leader != _unit) then {
|
|
|
|
doStop _unit;
|
|
|
|
_unit doFollow _leader;
|
2017-10-10 16:06:37 +00:00
|
|
|
|
|
|
|
} else {
|
2018-10-24 17:55:12 +00:00
|
|
|
_unit doMove ((nearestBuilding (getPos _unit)) buildingExit 0);
|
2017-10-10 16:06:37 +00:00
|
|
|
};
|
|
|
|
|
2018-10-24 17:55:12 +00:00
|
|
|
if ((units _unit) findif {(_x getVariable [QGVAR(garrisonned), false]) && !isPlayer _x} == -1) then {
|
2017-10-10 16:06:37 +00:00
|
|
|
LOG("fnc_ungarrison: enableAttack true");
|
2018-10-24 17:55:12 +00:00
|
|
|
(group _unit) enableAttack true;
|
2017-10-10 16:06:37 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} foreach _units;
|