diff --git a/addons/javelin/functions/fnc_onOpticDraw.sqf b/addons/javelin/functions/fnc_onOpticDraw.sqf index e9d3e304ad..85877f1f16 100644 --- a/addons/javelin/functions/fnc_onOpticDraw.sqf +++ b/addons/javelin/functions/fnc_onOpticDraw.sqf @@ -4,7 +4,7 @@ TRACE_1("enter", _this); #define __TRACKINTERVAL 0 // how frequent the check should be. #define __LOCKONTIME 3 // Lock on won't occur sooner -#define __LOCKONTIMERANDOM 2 // Deviation in lock on time + #define __OffsetX ((ctrlPosition __JavelinIGUITargetingLineV) select 0) - 0.5 #define __OffsetY ((ctrlPosition __JavelinIGUITargetingLineH) select 1) - 0.5 @@ -39,6 +39,7 @@ _currentTarget = _args select 1; _runTime = _args select 2; _lockTime = _args select 3; _soundTime = _args select 4; +_randomLockInterval = _args select 5; // Find a target within the optic range _newTarget = objNull; @@ -135,7 +136,7 @@ if (isNull _newTarget) then { playSound "ACE_Javelin_Locking"; } else { - if(diag_tickTime - _lockTime > __LOCKONTIME + (random __LOCKONTIMERANDOM)) then { + if(diag_tickTime - _lockTime > __LOCKONTIME + _randomLockInterval) then { TRACE_2("LOCKED!", _currentTarget, _lockTime); __JavelinIGUISeek ctrlSetTextColor __ColorGreen; diff --git a/addons/javelin/functions/fnc_onOpticLoad.sqf b/addons/javelin/functions/fnc_onOpticLoad.sqf index a12d0ef176..d38e1c3305 100644 --- a/addons/javelin/functions/fnc_onOpticLoad.sqf +++ b/addons/javelin/functions/fnc_onOpticLoad.sqf @@ -2,6 +2,8 @@ #include "script_component.hpp" TRACE_1("enter", _this); +#define __LOCKONTIMERANDOM 2 // Deviation in lock on time + if((count _this) > 0) then { uiNameSpace setVariable ['ACE_RscOptics_javelin',_this select 0]; }; @@ -22,10 +24,13 @@ uiNameSpace setVariable [QGVAR(arguments), objNull, // currentTargetObject 0, // Run Time 0, // Lock Time - 0 // Sound timer + 0, // Sound timer + (random __LOCKONTIMERANDOM) // random lock time addition ] ]; + + _pfh_handle = uiNamespace getVariable ["ACE_RscOptics_javelin_PFH", nil]; if(isNil "_pfh_handle") then { _pfh_handle = [FUNC(onOpticDraw), 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf index 421748a681..41ea877739 100644 --- a/addons/laser/functions/fnc_seekerFindLaserSpot.sqf +++ b/addons/laser/functions/fnc_seekerFindLaserSpot.sqf @@ -4,8 +4,10 @@ * * Arguments: * 0: Position of seeker (ASL) <position> - * 1: Seeker wavelength sensitivity range, [1550,1550] is common eye safe. <array> - * 2: Seeker laser code. <number> + * 1: Direction vector (will be normalized) <vector> + * 2: Seeker FOV in degrees <number> + * 3: Seeker wavelength sensitivity range, [1550,1550] is common eye safe. <array> + * 4: Seeker laser code. <number> * * Return value: * Array, [Strongest compatible laser spot ASL pos, owner object] Nil array values if nothing found. @@ -17,9 +19,14 @@ private ["_pos", "_seekerWavelengths", "_seekerCode", "_spots", "_buckets", "_ex "_emitterWavelength", "_laserCode", "_divergence", "_laser", "_laserPos", "_laserDir", "_res", "_bucketPos", "_bucketList", "_c", "_forEachIndex", "_index", "_testPos", "_finalBuckets", "_largest", "_largestIndex", "_finalBucket", "_owners", "_avgX", "_avgY", "_avgZ", "_count", "_maxOwner", "_maxOwnerIndex", "_finalOwner"]; -_pos = _this select 0; -_seekerWavelengths = _this select 1; -_seekerCode = _this select 2; +_pos = _this select 0; +_dir = vectorNormalized (_this select 1); +_seekerFov = _this select 2; +_seekerWavelengths = _this select 3; +_seekerCode = _this select 4; + + +_seekerCos = cos _seekerFov; _spots = []; _buckets = []; @@ -57,8 +64,13 @@ _finalOwner = nil; _laserPos = _laser select 0; _laserDir = _laser select 1; _res = [_laserPos, _laserDir, _divergence] call FUNC(shootCone); - { - _spots pushBack [_x select 0, _owner]; + { + _testPoint = _x select 0; + _testPointVector = vectorNormalized (_testPoint vectorDiff _pos); + _testDotProduct = _dir vectorDotProduct _testPointVector; + if(_testDotProduct > _seekerCos) then { + _spots pushBack [_testPoint, _owner]; + }; } forEach (_res select 2); }; } forEach (GVAR(laserEmitters) select 1); diff --git a/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf b/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf index d85cb01fcd..e8bc1a16f5 100644 --- a/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf +++ b/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf @@ -11,39 +11,20 @@ * Return value: * Boolean */ - -//#define DEBUG_MODE_FULL + #include "script_component.hpp" -private["_seeker", "_targetPos", "_seekerMaxAngle", "_vectorTo", "_sensorPos", "_vertOk", "_horzOk", "_dir", "_headingPitch"]; +private["_seeker", "_targetPos", "_seekerMaxAngle", "_sensorPos", "_testPointVector", "_testDotProduct"]; _seeker = _this select 0; _targetPos = _this select 1; _seekerMaxAngle = _this select 2; -_vertOk = false; -_horzOk = false; - _sensorPos = getPosASL _seeker; -_vectorTo = _sensorPos vectorFromTo _targetPos; -_headingPitch = (vectorDir _seeker) call CBA_fnc_vect2polar; -_polarTo = _vectorTo call CBA_fnc_vect2polar; +_testPointVector = vectorNormalized (_targetPos vectorDiff _sensorPos); +_testDotProduct = (vectorNormalized (velocity _seeker)) vectorDotProduct _testPointVector; -_dir = _polarTo select 1; -_dir = _dir - (_headingPitch select 1); - -if (_dir < 0) then {_dir = _dir + 360}; -if (_dir > 360) then {_dir = _dir - 360}; - _vertOk = false; - _horzOk = false; -if(_dir < _angleFov || {_dir > (360-_angleFov)}) then { - _horzOk = true; -}; -if(abs((abs(_polarTo select 2))-(abs(_headingPitch select 2))) < _angleFov) then { - _vertOk = true; -}; - -if(!_vertOk || !_horzOk ) exitWith { +if(_testDotProduct < (cos _seekerMaxAngle)) exitWith { false }; diff --git a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf index 828550aeeb..b6ed8d65a4 100644 --- a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf @@ -6,15 +6,15 @@ _seekerTargetPos = _this select 0; _launchParams = _this select 1; _seekerParams = _launchParams select 3; +_angleFov = _seekerParams select 0; -_laserResult = [(getPosASL _projectile), [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot); +_laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot); _foundTargetPos = _laserResult select 0; TRACE_1("Search", _laserResult); if(!isNil "_foundTargetPos") then { - _angleFov = _seekerParams select 0; - _canSeeTarget = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle); + //_canSeeTarget = [_projectile, _foundTargetPos, _angleFov] call FUNC(checkSeekerAngle); // If we got here, it was an invalid target, just return a spot 5m in front of the missile if(!_canSeeTarget) then {