Skip to content

Commit 5867dd4

Browse files
authored
Improvements to doSuppress performance (#464)
* Improvements to doSuppress performance Adds various tweaks to doSuppress performance. Various tweaks and revisions to when and how checks are performed in doSuppress. Tweaks default friendly check from 5 to 3 for better performance Removes suppressFor in brainEngage. Command has no effect. OBS: Contains debug information to be removed before release! L55+ * Update fnc_doSuppress.sqf Remove debug information
1 parent 2e98288 commit 5867dd4

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

addons/danger/functions/fnc_brainEngage.sqf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ if (
9393
_posASL = AGLToASL _posASL
9494
};
9595
_unit forceSpeed 1;
96-
_unit suppressFor 4;
9796
[_unit, _posASL vectorAdd [0, 0, 0.8], true] call EFUNC(main,doSuppress);
9897
_timeout + 3
9998
};

addons/main/functions/UnitAction/fnc_doSuppress.sqf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Arguments:
77
* 0: unit suppressing <OBJECT>
88
* 1: target position <ARRAY> (ASL position)
9+
* 2: do extended visibility checks <BOOLEAN>, default false
910
*
1011
* Return Value:
1112
* success
@@ -15,36 +16,35 @@
1516
*
1617
* Public: No
1718
*/
18-
params ["_unit", "_pos", ["_checkLOS", false]];
19+
params [["_unit", objNull], [ "_pos", [0, 0, 0], [[]]], ["_checkLOS", false, [false]]];
1920

2021
// no primary weapons exit? Player led groups do not auto-suppress
21-
private _eyePos = eyePos _unit;
22+
private _eyePos = getPosWorld _unit;
2223
if (
2324
(primaryWeapon _unit) isEqualTo ""
24-
|| (_eyePos distance2D _pos) < GVAR(minSuppressionRange)
25-
|| {(currentCommand _unit) isEqualTo "Suppress"}
26-
|| {terrainIntersectASL [_eyePos, _pos]}
27-
|| {GVAR(disablePlayerGroupSuppression) && {isPlayer (leader _unit)}}
25+
|| (currentCommand _unit) isEqualTo "Suppress"
26+
|| terrainIntersectASL [_eyePos, _pos]
27+
|| (isPlayer (leader _unit) && GVAR(disablePlayerGroupSuppression))
2828
|| {_checkLOS && {!([_unit, _pos, false] call FUNC(shouldSuppressPosition))}}
2929
) exitWith {false};
3030

3131
// max range pos
32-
private _distance = (_eyePos vectorDistance _pos) min 200;
33-
_pos = _eyePos vectorAdd ((_eyePos vectorFromTo _pos) vectorMultiply _distance);
32+
private _distance = _eyePos vectorDistance _pos;
33+
if (_distance > 200) then {_pos = _eyePos vectorAdd ((_eyePos vectorFromTo _pos) vectorMultiply 200);};
3434

3535
// adjust pos
36-
private _vis = lineIntersectsSurfaces [_eyePos, _pos, _unit, objNull, true, 1, "GEOM", "VIEW"];
36+
private _vis = lineIntersectsSurfaces [_eyePos, _pos, _unit, objNull, true, 1, "VIEW", "NONE"];
3737
if (_vis isNotEqualTo []) then {_pos = (_vis select 0) select 0;};
3838

3939
// final range check
40-
if ((_eyePos distance2D _pos) < GVAR(minSuppressionRange)) exitWith {false};
40+
if ((_eyePos vectorDistance _pos) < GVAR(minSuppressionRange)) exitWith {false};
4141

4242
// check for friendlies
43-
private _friendlies = [_unit, ASLToAGL _pos, GVAR(minFriendlySuppressionDistance)] call FUNC(findNearbyFriendlies);
43+
private _friendlies = if (_distance > 200) then {[]} else {[_unit, ASLToAGL _pos, GVAR(minFriendlySuppressionDistance)] call FUNC(findNearbyFriendlies);};
4444
if (_friendlies isNotEqualTo []) exitWith {false};
4545

4646
// Callout!
47-
if (RND(0.4)) then {
47+
if (RND(0.3)) then {
4848
[_unit, "Combat", "suppress"] call FUNC(doCallout);
4949
};
5050

addons/main/settings.inc.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ _curCat = LSTRING(Settings_SuppressionCat);
8989
"SLIDER",
9090
[LSTRING(Settings_minFriendlySuppressionDistance), LSTRING(Settings_minFriendlySuppressionDistance_ToolTip)],
9191
[COMPONENT_NAME, _curCat],
92-
[0, 50, 5, 0],
92+
[0, 50, 3, 0],
9393
1
9494
] call CBA_fnc_addSetting;
9595

0 commit comments

Comments
 (0)