From 8b78d848745fc66e1a12055352024f8d05dc66a9 Mon Sep 17 00:00:00 2001 From: Tim Beswick Date: Fri, 14 Jul 2017 15:29:33 +0100 Subject: [PATCH 1/2] Workaround for laser max range. Made laser hud seeker use ammo values. --- addons/hellfire/functions/fnc_showHud.sqf | 5 ++++- addons/laser/functions/fnc_seekerFindLaserSpot.sqf | 6 +++--- addons/laser/functions/fnc_shootRay.sqf | 7 +++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/addons/hellfire/functions/fnc_showHud.sqf b/addons/hellfire/functions/fnc_showHud.sqf index c79780c3feb..380a31b0817 100644 --- a/addons/hellfire/functions/fnc_showHud.sqf +++ b/addons/hellfire/functions/fnc_showHud.sqf @@ -91,9 +91,12 @@ GVAR(pfID) = [{ private _ctrlIcon = (uiNamespace getVariable [QGVAR(display), displayNull]) displayCtrl IDC_LASERICON; // Do Laser Scan: + private _ammo = getText (configFile >> "CfgMagazines" >> _vehicle currentMagazineTurret _turretPath >> "ammo"); private _laserSource = AGLtoASL (_vehicle modelToWorld (_vehicle selectionPosition _seekerSource)); private _laserCode = _vehicle getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE]; - private _laserResult = [_laserSource, vectorDir _vehicle, 70, 5000, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], _laserCode, _vehicle] call EFUNC(laser,seekerFindLaserSpot); + private _seekerAngle = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_missileguidance" >> "seekerAngle"); + private _seekerMaxRange = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_missileguidance" >> "seekerMaxRange"); + private _laserResult = [_laserSource, vectorDir _vehicle, _seekerAngle, _seekerMaxRange, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], _laserCode, _vehicle] call EFUNC(laser,seekerFindLaserSpot); private _foundTargetPos = _laserResult select 0; private _haveLock = !isNil "_foundTargetPos"; diff --git a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf index 460add1c742..3c144b0eae5 100644 --- a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf +++ b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf @@ -25,15 +25,15 @@ BEGIN_COUNTER(seekerFindLaserSpot); -params ["_posASL", "_dir", "_seekerFov", "_seekerMaxDistnace", "_seekerWavelengths", "_seekerCode", ["_ignoreObj1", objNull]]; +params ["_posASL", "_dir", "_seekerFov", "_seekerMaxDistance", "_seekerWavelengths", "_seekerCode", ["_ignoreObj1", objNull]]; _dir = vectorNormalized _dir; _seekerWavelengths params ["_seekerWavelengthMin", "_seekerWavelengthMax"]; private _seekerCos = cos _seekerFov; -private _seekerMaxDistSq = _seekerMaxDistnace ^ 2; +private _seekerMaxDistSq = _seekerMaxDistance ^ 2; -TRACE_6("",_posASL,_dir,_seekerFov,_seekerMaxDistnace,_seekerWavelengths,_seekerCode); +TRACE_6("",_posASL,_dir,_seekerFov,_seekerMaxDistance,_seekerWavelengths,_seekerCode); private _spots = []; private _finalPos = nil; diff --git a/addons/laser/functions/fnc_shootRay.sqf b/addons/laser/functions/fnc_shootRay.sqf index ceae27fe77c..9f810044f79 100644 --- a/addons/laser/functions/fnc_shootRay.sqf +++ b/addons/laser/functions/fnc_shootRay.sqf @@ -28,6 +28,13 @@ private _resultPos = nil; private _farPoint = _posASL vectorAdd (_dir vectorMultiply 10000); private _intersects = lineIntersectsSurfaces [_posASL, _farPoint, _ignoreVehicle1, _ignoreVehicle2]; +// workaround for lineIntersectsSurfaces using a hardcoded max distance of 5000m. New max distance 15000m +if (_intersects isEqualTo []) then { + _intersects = lineIntersectsSurfaces [_posASL vectorAdd (_dir vectorMultiply 5000), _farPoint vectorAdd (_dir vectorMultiply 5000), _ignoreVehicle1, _ignoreVehicle2]; +}; +if (_intersects isEqualTo []) then { + _intersects = lineIntersectsSurfaces [_posASL vectorAdd (_dir vectorMultiply 10000), _farPoint vectorAdd (_dir vectorMultiply 10000), _ignoreVehicle1, _ignoreVehicle2]; +}; if (!(_intersects isEqualTo [])) then { (_intersects select 0) params ["_intersectPosASL", "", "_intersectObject"]; From de74e2858d86d1453307137342858bb07f078234 Mon Sep 17 00:00:00 2001 From: Tim Beswick Date: Fri, 14 Jul 2017 16:47:56 +0100 Subject: [PATCH 2/2] Nested ifs for optimization of check --- addons/laser/functions/fnc_shootRay.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/laser/functions/fnc_shootRay.sqf b/addons/laser/functions/fnc_shootRay.sqf index 9f810044f79..88844c5c957 100644 --- a/addons/laser/functions/fnc_shootRay.sqf +++ b/addons/laser/functions/fnc_shootRay.sqf @@ -31,9 +31,9 @@ private _intersects = lineIntersectsSurfaces [_posASL, _farPoint, _ignoreVehicle // workaround for lineIntersectsSurfaces using a hardcoded max distance of 5000m. New max distance 15000m if (_intersects isEqualTo []) then { _intersects = lineIntersectsSurfaces [_posASL vectorAdd (_dir vectorMultiply 5000), _farPoint vectorAdd (_dir vectorMultiply 5000), _ignoreVehicle1, _ignoreVehicle2]; -}; -if (_intersects isEqualTo []) then { - _intersects = lineIntersectsSurfaces [_posASL vectorAdd (_dir vectorMultiply 10000), _farPoint vectorAdd (_dir vectorMultiply 10000), _ignoreVehicle1, _ignoreVehicle2]; + if (_intersects isEqualTo []) then { + _intersects = lineIntersectsSurfaces [_posASL vectorAdd (_dir vectorMultiply 10000), _farPoint vectorAdd (_dir vectorMultiply 10000), _ignoreVehicle1, _ignoreVehicle2]; + }; }; if (!(_intersects isEqualTo [])) then {