Skip to content

Commit 2e98288

Browse files
authored
Improvements to groupFlank and groupSuppress performance (#463)
* Improvements to groupFlank and groupSuppress performance Adds a check count to further limit terrainIntersect checks being run. * Update fnc_doGroupFlank.sqf Fixed unit stance was reversed! Suppressing units should crouch-- moving units should be standing!
1 parent 11847a1 commit 2e98288

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

addons/main/functions/GroupAction/fnc_doGroupFlank.sqf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ private _leaderAlone = ( ( _units - crew _leader) findIf { _x distanceSqr _leade
4040

4141
[_posList, true] call CBA_fnc_shuffle;
4242
private _index = -1;
43+
private _checkCount = 3;
44+
4345
{
4446
private _unit = _x;
4547
private _suppressed = (getSuppression _unit) > 0.5;
4648
private _activeTeam = (_forEachIndex % 2) isEqualTo _teamAlpha;
4749

4850
// stance
4951
private _unitPos = call {
50-
if (_leaderAlone && {_unit isEqualTo _leader}) exitWith {"DOWN"};
52+
if (_suppressed) exitWith {"DOWN"};
53+
if (_unit isEqualTo _leader) exitWith {["MIDDLE", "DOWN"] select _leaderAlone};
5154
private _crouched = (stance _unit) isEqualTo "CROUCH";
52-
if (_suppressed) exitWith {["UP", "DOWN"] select _crouched};
53-
if (_crouched && _activeTeam) exitWith {"UP"};
55+
if (_crouched && !_activeTeam) exitWith {"UP"};
5456
"MIDDLE"
5557
};
5658
_unit setUnitPos _unitPos;
@@ -61,8 +63,9 @@ private _index = -1;
6163
_unit setVariable [QGVAR(currentTask), "Group Flank", GVAR(debug_functions)];
6264

6365
// check suppress position
64-
if (_activeTeam && _index isEqualTo -1) then {
66+
if (_activeTeam && _checkCount > 0 && _index isEqualTo -1) then {
6567
_index = [_x, _posList] call FUNC(checkVisibilityList);
68+
_checkCount = _checkCount - 1;
6669
};
6770

6871
// suppress

addons/main/functions/GroupAction/fnc_doGroupSuppress.sqf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ _vehicles = _vehicles select { canFire _x };
2929
// infantry
3030
[_posList, true] call CBA_fnc_shuffle;
3131
private _index = -1;
32+
private _checkCount = 3;
3233

3334
{
3435
// find target
35-
if (_index isEqualTo -1)then {_index = [_x, _posList] call FUNC(checkVisibilityList);};
36+
if (_index isEqualTo -1 && _checkCount > 0) then {
37+
_index = [_x, _posList] call FUNC(checkVisibilityList);
38+
_checkCount = _checkCount - 1;
39+
};
3640

3741
// found good target
3842
if (_index isNotEqualTo -1) then {
@@ -65,7 +69,7 @@ private _index = -1;
6569
private _vehicle = _x;
6670

6771
// find target
68-
if (_index isEqualTo -1)then {_index = [_vehicle, _posList] call FUNC(checkVisibilityList);};
72+
if (_index isEqualTo -1) then {_index = [_vehicle, _posList] call FUNC(checkVisibilityList);};
6973

7074
// execute suppression
7175
if (_index isNotEqualTo -1) then {

0 commit comments

Comments
 (0)