Skip to content

Commit

Permalink
Laser seeker range improvements (#5365)
Browse files Browse the repository at this point in the history
* Workaround for laser max range. Made laser hud seeker use ammo values.

* Nested ifs for optimization of check
  • Loading branch information
tbeswick96 authored and PabstMirror committed Aug 3, 2017
1 parent 03b51a6 commit a0b5f9f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion addons/hellfire/functions/fnc_showHud.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
6 changes: 3 additions & 3 deletions addons/laser/functions/fnc_seekerFindLaserSpot.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions addons/laser/functions/fnc_shootRay.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down

0 comments on commit a0b5f9f

Please sign in to comment.