Yardage 450 - Minor performance tweak (#5767)

* Utilize 'params' / 'selectMin' / 'selectMax'
This commit is contained in:
ulteq 2017-11-14 14:41:36 +01:00 committed by jonpas
parent 827718f748
commit 64c9c7d522
2 changed files with 6 additions and 13 deletions

View File

@ -32,23 +32,16 @@ GVAR(distanceIndex) = -1;
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
private _result = [eyePos ACE_player, ACE_player weaponDirection (currentWeapon ACE_player), ACE_player] call EFUNC(laser,shootRay);
private _distance = _result select 1;
_distance = _distance - 1 + (random 2);
([eyePos ACE_player, ACE_player weaponDirection (currentWeapon ACE_player), ACE_player] call EFUNC(laser,shootRay)) params ["", "_distance"];
GVAR(distanceIndex) = (GVAR(distanceIndex) + 1) % METERING_POINT_NUMBER;
GVAR(distances) set [GVAR(distanceIndex), _distance];
GVAR(distances) set [GVAR(distanceIndex), _distance - 1 + (random 2)];
if (count GVAR(distances) == METERING_POINT_NUMBER) then {
private _min = MAX_DISTANCE;
private _max = MIN_DISTANCE;
{
_min = _x min _min;
_max = _max max _x;
} forEach GVAR(distances);
private _min = selectMin GVAR(distances);
private _max = selectMax GVAR(distances);
if (abs(_max - _min) < 5) then {
if (_max - _min < 5) then {
private _range = (_min + _max) / 2;
if (_range >= MIN_DISTANCE && _range <= MAX_DISTANCE) then {
GVAR(targetAcquired) = true;

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* call ace_yardage450_fnc_acquireTarget
* call ace_yardage450_fnc_turnOn
*
* Public: No
*/