From af2b9a280a254eb17823c1d24cf05c3a5cff9fcc Mon Sep 17 00:00:00 2001 From: Brandon Danyluk Date: Tue, 13 Apr 2021 20:31:10 -0600 Subject: [PATCH] multiple changes --- addons/gbu/CfgAmmo.hpp | 4 ++-- .../functions/fnc_attackProfile_WIRE.sqf | 13 +------------ .../missileguidance/functions/fnc_guidancePFH.sqf | 4 ++-- .../functions/fnc_seekerType_Optic.sqf | 4 +--- .../functions/fnc_seekerType_SALH.sqf | 11 +++++++++-- addons/missileguidance/todo.txt | 11 +++++++---- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/addons/gbu/CfgAmmo.hpp b/addons/gbu/CfgAmmo.hpp index 7cb1f89786..58472c608a 100644 --- a/addons/gbu/CfgAmmo.hpp +++ b/addons/gbu/CfgAmmo.hpp @@ -68,8 +68,8 @@ class CfgAmmo { seekerMaxRange = 4000; // Range from the missile which the seeker can visually search // Attack profile type selection - defaultAttackProfile = "LIN"; - attackProfiles[] = {"LIN"}; + defaultAttackProfile = "DIR"; + attackProfiles[] = {"DIR"}; }; }; }; diff --git a/addons/missileguidance/functions/fnc_attackProfile_WIRE.sqf b/addons/missileguidance/functions/fnc_attackProfile_WIRE.sqf index 4f0324597f..a17cb8a493 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_WIRE.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_WIRE.sqf @@ -48,16 +48,5 @@ if (_seekerTargetPos isEqualTo [0, 0, 0] || { _distanceToProjectile < _seekerMin _projectilePos vectorAdd (_projectile vectorModelToWorld [0, 50, 0]) }; -private _relativeCorrection = _projectile vectorWorldToModel (_projectilePos vectorDiff _seekerTargetPos); -_relativeCorrection = _relativeCorrection vectorDiff _crosshairOffset; +_seekerTargetPos vectorAdd (_shooterDir vectorMultiply 30); -private _magnitude = vectorMagnitude [_relativeCorrection select 0, 0, _relativeCorrection select 2]; -private _fovImpulse = 1 min (_magnitude / _maxCorrectableDistance); // the simulated impulse for the missile being close to the center of the crosshair - -// Adjust the impulse due to near-zero values creating wobbly missiles? -private _correction = _fovImpulse; - - -_relativeCorrection = (vectorNormalized _relativeCorrection) vectorMultiply _correction; -private _returnPos = _projectilePos vectorDiff (_projectile vectorModelToWorld _relativeCorrection); -_returnPos vectorAdd (_shooterDir vectorMultiply _distanceAheadOfMissile) diff --git a/addons/missileguidance/functions/fnc_guidancePFH.sqf b/addons/missileguidance/functions/fnc_guidancePFH.sqf index 585750451c..7457c6eec9 100644 --- a/addons/missileguidance/functions/fnc_guidancePFH.sqf +++ b/addons/missileguidance/functions/fnc_guidancePFH.sqf @@ -34,10 +34,10 @@ private _timestep = diag_deltaTime * accTime; _flightParams params ["_pitchRate", "_yawRate", "_isBangBangGuidance"]; // Run seeker function: -private _seekerTargetPos = [[0,0,0], _args, _seekerStateParams, _lastKnownPosState] call FUNC(doSeekerSearch); +private _seekerTargetPos = [[0,0,0], _args, _seekerStateParams, _lastKnownPosState, _timestep] call FUNC(doSeekerSearch); // Run attack profile function: _seekerTargetPos = AGLtoASL ASLToAGL _seekerTargetPos; -private _profileAdjustedTargetPos = [_seekerTargetPos, _args, _attackProfileStateParams] call FUNC(doAttackProfile); +private _profileAdjustedTargetPos = [_seekerTargetPos, _args, _attackProfileStateParams, _timestep] call FUNC(doAttackProfile); private _projectilePos = getPosASLVisual _projectile; _targetData set [1, _projectilePos vectorFromTo _profileAdjustedTargetPos]; diff --git a/addons/missileguidance/functions/fnc_seekerType_Optic.sqf b/addons/missileguidance/functions/fnc_seekerType_Optic.sqf index 0b1967412d..33bad1a86d 100644 --- a/addons/missileguidance/functions/fnc_seekerType_Optic.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_Optic.sqf @@ -25,7 +25,7 @@ _seekerParams params ["_seekerAngle", "", "_seekerMaxRange"]; if (isNil "_target") exitWith {[0,0,0]}; -private _foundTargetPos = aimPos _target; +private _foundTargetPos = _target modelToWorldVisualWorld getCenterOfMass _target; // @TODO: This is seeker LOS and angle checks for LOAL only; LOBL does not need visual private _angleOkay = [_projectile, _foundTargetPos, _seekerAngle] call FUNC(checkSeekerAngle); @@ -40,9 +40,7 @@ TRACE_2("", _angleOkay, _losOkay); if (!_angleOkay || !_losOkay) exitWith {[0,0,0]}; TRACE_2("", _target, _foundTargetPos); -private _projectileSpeed = (vectorMagnitude velocity _projectile); private _distanceToTarget = (getPosASL _projectile) vectorDistance _foundTargetPos; -private _eta = _distanceToTarget / _projectileSpeed; _targetData set [0, (getPosASL _projectile) vectorFromTo _foundTargetPos]; _targetData set [2, _distanceToTarget]; diff --git a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf index 3d6b489582..da2d298f53 100644 --- a/addons/missileguidance/functions/fnc_seekerType_SALH.sqf +++ b/addons/missileguidance/functions/fnc_seekerType_SALH.sqf @@ -18,11 +18,11 @@ */ #define MAX_AVERAGES 15 -params ["", "_args"]; +params ["", "_args", "", "", "_timestep"]; _args params ["_firedEH", "_launchParams", "", "_seekerParams", "", "_targetData"]; _firedEH params ["","","","","","","_projectile"]; _launchParams params ["","","","","","_laserParams"]; -_seekerParams params ["_seekerAngle", "", "_seekerMaxRange", "", ["_lastPositions", []], ["_lastPositionIndex", 0]]; +_seekerParams params ["_seekerAngle", "", "_seekerMaxRange", "", ["_lastPositions", []], ["_lastPositionIndex", 0], ["_lastPositionSum", [0, 0, 0]]]; _laserParams params ["_code", "_wavelengthMin", "_wavelengthMax"]; private _laserResult = [(getPosASL _projectile), (velocity _projectile), _seekerAngle, _seekerMaxRange, [_wavelengthMin, _wavelengthMax], _code, _projectile] call EFUNC(laser,seekerFindLaserSpot); @@ -45,14 +45,21 @@ if (_foundTargetPos isNotEqualTo [0, 0, 0]) then { _seekerParams set [5, _lastPositionIndex + 1]; }; +private _aproximateVelocity = [0, 0, 0]; _positionSum = _positionSum vectorAdd _foundTargetPos; if (MAX_AVERAGES == count _lastPositions) then { _positionSum = _positionSum vectorMultiply (1 / (1 + count _lastPositions)); + if (_timestep != 0) then { + _aproximateVelocity = (_positionSum vectorDiff _lastPositionSum) vectorMultiply (1 / _timestep); + }; } else { _positionSum = _positionSum vectorMultiply (1 / count _lastPositions); }; +_seekerParams set [6, _positionSum]; + _targetData set [0, (getPosASL _projectile) vectorFromTo _positionSum]; +_targetData set [3, _aproximateVelocity]; TRACE_3("laser target found",_foundTargetPos,_positionSum,count _lastPositions); diff --git a/addons/missileguidance/todo.txt b/addons/missileguidance/todo.txt index 627c29fcc2..2c2b970bfc 100644 --- a/addons/missileguidance/todo.txt +++ b/addons/missileguidance/todo.txt @@ -37,10 +37,12 @@ Seeker Types: Navigation Types: X GBU-12 - LOS Guidance X NLAW - LOS Guidance - X Dragon - LOS Guidance - X Metis - LOS Guidance - X HOT - LOS Guidance - Vikhr - LOS Guidance + + X Dragon - NA + + Metis - Wire/Beam Guidance + HOT - Wire/Beam Guidance + Vikhr - Wire/Beam Guidance X DAGR - APN X AGM-65 - APN @@ -64,6 +66,7 @@ Navigation State Machine: Navigation Types: X Augmented Pro-Nav X Zero Effort Miss + Wire/Beam Guided General To-Do: Add more weapons