Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchNearby Endless Loop #1544 #1545

Closed
wants to merge 7 commits into from
15 changes: 13 additions & 2 deletions addons/ai/fnc_searchNearby.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ if ((leader _group) distanceSqr _building > 250e3) exitwith {};

// Search while there are still available positions
private _positions = _building buildingPos -1;

// Create Limiters For Each Unit
mrzachhigginsofficial marked this conversation as resolved.
Show resolved Hide resolved
private _timeout = (count(_positions) * 15) min 120;
mrzachhigginsofficial marked this conversation as resolved.
Show resolved Hide resolved
private _timetag = "CBASearchTime";
(units _group) apply {_x setVariable [_timetag,time]};
mrzachhigginsofficial marked this conversation as resolved.
Show resolved Hide resolved

while {_positions isNotEqualTo []} do {
// Update units in case of death
private _units = (units _group) - [_leader];
Expand All @@ -59,13 +65,18 @@ if ((leader _group) distanceSqr _building > 250e3) exitwith {};

// Send all available units to the next available position
{
private _starttime = _x getVariable _timetag;

if (_positions isEqualTo []) exitWith {};
if (unitReady _x) then {
if (unitReady _x or (_starttime + _timeout) < time) then {
mrzachhigginsofficial marked this conversation as resolved.
Show resolved Hide resolved
private _pos = _positions deleteAt 0;
_x commandMove _pos;
_x setVariable [_timetag,time];
sleep 2;
};

sleep .25;
} forEach _units;
};
_group lockWP false;
};
};
mrzachhigginsofficial marked this conversation as resolved.
Show resolved Hide resolved