mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
AI - Fix units not being removed from the garrison unitMove list consistently (#6651)
* Fix units not being removed from the garrison unitMove list consistently Not sure how I missed that. * fix whitespace * Fix typo in unGarrison check dedmen saw nothing :D
This commit is contained in:
parent
25f36d9340
commit
8580cb250a
@ -26,6 +26,7 @@ params [["_startingPos",[0,0,0], [[]], 3], ["_buildingTypes", ["Building"], [[]]
|
|||||||
TRACE_6("fnc_garrison: Start",_startingPos,_buldingTypes,count _unitsArray,_fillingRadius,_fillingTYpe,_topDownFilling);
|
TRACE_6("fnc_garrison: Start",_startingPos,_buldingTypes,count _unitsArray,_fillingRadius,_fillingTYpe,_topDownFilling);
|
||||||
|
|
||||||
_unitsArray = _unitsArray select {alive _x && {!isPlayer _x}};
|
_unitsArray = _unitsArray select {alive _x && {!isPlayer _x}};
|
||||||
|
private _currentUnitMoveList = missionNameSpace getVariable [QGVAR(garrison_unitMoveList), []];
|
||||||
|
|
||||||
if (_startingPos isEqualTo [0,0,0]) exitWith {
|
if (_startingPos isEqualTo [0,0,0]) exitWith {
|
||||||
TRACE_1("fnc_garrison: StartingPos error",_startingPos);
|
TRACE_1("fnc_garrison: StartingPos error",_startingPos);
|
||||||
@ -145,6 +146,8 @@ switch (_fillingType) do {
|
|||||||
_unit setPosATL _pos;
|
_unit setPosATL _pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_currentUnitMoveList deleteAt (_currentUnitMoveList findIf {_x select 0 == _unit});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_unitMoveList pushBack [_unit,[_pos, AGLToASL _pos] select (_posSurface)];
|
_unitMoveList pushBack [_unit,[_pos, AGLToASL _pos] select (_posSurface)];
|
||||||
};
|
};
|
||||||
@ -192,6 +195,8 @@ switch (_fillingType) do {
|
|||||||
_unit setPosATL _pos;
|
_unit setPosATL _pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_currentUnitMoveList deleteAt (_currentUnitMoveList findIf {_x select 0 == _unit});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_unitMoveList pushBack [_unit,[_pos, AGLToASL _pos] select (_posSurface)];
|
_unitMoveList pushBack [_unit,[_pos, AGLToASL _pos] select (_posSurface)];
|
||||||
};
|
};
|
||||||
@ -237,6 +242,8 @@ switch (_fillingType) do {
|
|||||||
_unit setPosATL _pos;
|
_unit setPosATL _pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_currentUnitMoveList deleteAt (_currentUnitMoveList findIf {_x select 0 == _unit});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_unitMoveList pushBack [_unit,[_pos, AGLToASL _pos] select (_posSurface)];
|
_unitMoveList pushBack [_unit,[_pos, AGLToASL _pos] select (_posSurface)];
|
||||||
};
|
};
|
||||||
|
@ -85,9 +85,9 @@ if (isNil QGVAR(garrison_moveUnitPFH)) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Check if unit is alive or even existing
|
// Check if unit is alive or even existing
|
||||||
if (!alive _unit) then {
|
if (!alive _unit || {_unit getVariable [QGVAR(garrisoned), false]}) then {
|
||||||
_unitMoveList deleteAt (_unitMoveList find _x);
|
_unitMoveList deleteAt (_unitMoveList find _x);
|
||||||
LOG(format [ARR_2("garrisonMove PFH: unit dead or deleted | %1 units left", count _unitMoveList)]);
|
LOG(format [ARR_2("garrisonMove PFH: unit dead, deleted or garrisoned via TP | %1 units left", count _unitMoveList)]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
private _unitPos = getPos _unit;
|
private _unitPos = getPos _unit;
|
||||||
|
@ -21,27 +21,31 @@ params [["_units", [], [[]]]];
|
|||||||
_units = _units select {local _x};
|
_units = _units select {local _x};
|
||||||
|
|
||||||
{
|
{
|
||||||
if (!isPlayer _x && {local _x}) then {
|
private _unit = _x;
|
||||||
_x enableAI "PATH";
|
if (!isPlayer _unit && {local _unit}) then {
|
||||||
_x enableAI "FSM";
|
_unit enableAI "PATH";
|
||||||
|
_unit enableAI "FSM";
|
||||||
|
|
||||||
private _leader = leader _x;
|
private _leader = leader _unit;
|
||||||
|
|
||||||
TRACE_3("fnc_ungarrison: unit and leader",_x , _leader, (_leader == _x));
|
TRACE_3("fnc_ungarrison: unit and leader",_unit , _leader, (_leader == _unit));
|
||||||
|
|
||||||
_x setVariable [QGVAR(garrisonned), false, true];
|
_unit setVariable [QGVAR(garrisonned), false, true];
|
||||||
|
|
||||||
if (_leader != _x) then {
|
private _unitMoveList = missionNameSpace getVariable [QGVAR(garrison_unitMoveList), []];
|
||||||
doStop _x;
|
_unitMoveList deleteAt (_unitMoveList findIf {_x select 0 == _unit});
|
||||||
_x doFollow _leader;
|
|
||||||
|
if (_leader != _unit) then {
|
||||||
|
doStop _unit;
|
||||||
|
_unit doFollow _leader;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_x doMove ((nearestBuilding (getPos _x)) buildingExit 0);
|
_unit doMove ((nearestBuilding (getPos _unit)) buildingExit 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
if ({(_x getVariable [QGVAR(garrisonned), false]) && !isPlayer _x} count (units _x) == 0) then {
|
if ((units _unit) findif {(_x getVariable [QGVAR(garrisonned), false]) && !isPlayer _x} == -1) then {
|
||||||
LOG("fnc_ungarrison: enableAttack true");
|
LOG("fnc_ungarrison: enableAttack true");
|
||||||
(group _x) enableAttack true;
|
(group _unit) enableAttack true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} foreach _units;
|
} foreach _units;
|
||||||
|
Loading…
Reference in New Issue
Block a user