Skip to content

Commit

Permalink
Merge pull request #1657 from Vdauphin/fix-ied-overlaping
Browse files Browse the repository at this point in the history
FIX: IED overlap sometimes
  • Loading branch information
Vdauphin authored Oct 6, 2024
2 parents 1b04d4b + dd7bf29 commit 2ffd62c
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/ied/initArea.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,38 @@ params [
private _pos = getPos _city;
private _array = _city getVariable ["ieds", []];

private _cities = (values btc_city_all) - [_city];
_cities = _cities inAreaArray [_city, _area * 2, _area * 2];
private _blackListCities = _cities select {
_x getVariable ["ieds", []] isNotEqualTo []
};
private _blackListPos = [];
{
_blackListPos append ((_x getVariable "ieds") apply {_x select 0});
} forEach _blackListCities;
_blackListPos = _blackListPos inAreaArray [_city, _area, _area];

private _blackListRoads = [];
{
for "_i" from 1 to _n do {
private _sel_pos = [_pos, _area] call btc_fnc_randomize_pos;
private _dir = random 360;

private _roads = _sel_pos nearRoads 50;
if (_roads isEqualTo []) then {
_sel_pos = [_sel_pos, 0, 100, 1, false] call btc_fnc_findsafepos;
} else {
private _arr = (selectRandom _roads) call btc_ied_fnc_randomRoadPos;
_roads = _roads - _blackListRoads;
if (_roads isNotEqualTo []) then {
private _road = selectRandom _roads;
_blackListRoads pushBack _road;
private _arr = _road call btc_ied_fnc_randomRoadPos;
_sel_pos = _arr select 0;
_dir = _arr select 1;
};
if (
_roads isEqualTo [] ||
{_blackListPos inAreaArray [_sel_pos, 3, 3] isNotEqualTo []}
) then {
_sel_pos = [_sel_pos, 0, 100, 1, false] call btc_fnc_findsafepos;
};

_array pushBack [_sel_pos, selectRandom btc_model_ieds, _dir, _x];

Expand Down

0 comments on commit 2ffd62c

Please sign in to comment.