Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yardage 450 - Minor performance tweak #5767

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions addons/yardage450/functions/fnc_acquireTarget.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);

if (abs(_max - _min) < 5) then {
private _min = selectMin GVAR(distances);
private _max = selectMax GVAR(distances);

if (_max - _min < 5) then {
private _range = (_min + _max) / 2;
if (_range >= MIN_DISTANCE && _range <= MAX_DISTANCE) then {
GVAR(targetAcquired) = true;
Expand Down
2 changes: 1 addition & 1 deletion addons/yardage450/functions/fnc_turnOn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* None
*
* Example:
* call ace_yardage450_fnc_acquireTarget
* call ace_yardage450_fnc_turnOn
*
* Public: No
*/
Expand Down