Skip to content

Commit

Permalink
updated search pattern to one discussed in PR acemod#9728
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdatiger committed Jul 19, 2024
1 parent fbca983 commit 04c4bd4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions addons/frag/functions/fnc_frago.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,30 @@ if ((_atlPos select 2) < 0.5) then {
_lastPos vectorAdd [0, 0, 0.5];
};

private _objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange];
// Add unique crews in faster way
// Post 2.18 change - uncomment line 41, and remove lines 43, 50-55, 64-66
// private _targets = [_posAGL, _fragRange, _fragRange, 0, false, _fragRange] nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], false, true, true];
private _objects = _posAGL nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange];
if (_objects isEqualTo []) exitWith {
TRACE_2("No nearby targets",_posAGL,_fragRange);
0
};

// grab crews and add them in so that targets stay approx. sorted by distance
private _targets = [];
{
{
_objects pushBackUnique _x;
} forEach (crew _x);
private _crew = crew _x;
_crew pushBackUnique _x;
_targets append _crew;
} forEach _objects;
TRACE_2("",_fragRange,count _objects);
TRACE_2("",_fragRange,count _targets);

private _fragCount = 0;

private _fragArcs = [];
_fragArcs set [360, 0];

private _doRandom = true;
if (_objects isNotEqualTo []) then {
if (_targets isNotEqualTo []) then {
if (GVAR(reflectionsEnabled)) then {
[_lastPos, _shellType] call FUNC(doReflections);
};
Expand Down Expand Up @@ -119,7 +127,7 @@ if (_objects isNotEqualTo []) then {
};
};
if (_fragCount > _maxFrags) exitWith {};
} forEach _objects;
} forEach _targets;
TRACE_1("targeted",_fragCount);
if (_fragCount > _maxFrags) exitWith {};
private _randomCount = ceil ((_maxFrags - _fragCount) * 0.35);
Expand Down

0 comments on commit 04c4bd4

Please sign in to comment.