diff --git a/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf b/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf index 11e39b848c..8f5176d360 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_JDAM.sqf @@ -17,10 +17,10 @@ * * Public: No */ -params ["_seekerTargetPos", "_args", "_attackProfileStateParams"]; +params ["_seekerTargetPos", "_args", "_attackProfileStateParams", "_timestep"]; _args params ["_firedEH", "", "_flightParams", "", "", "_targetData"]; _firedEH params ["_shooter","","","","","","_projectile"]; -_attackProfileStateParams params ["_gpsData", "_initialProjectileHeight", "_terminal"]; +_attackProfileStateParams params ["_gpsData", "_initialProjectileHeight", "_terminal", "_lastAngleToTarget"]; _gpsData params ["", "_impactAngle", "_attackDirection"]; _targetData params ["_directionToTarget", "", "_distanceToTarget"]; _flightParams params ["_pitchRate", "_yawRate"]; @@ -35,23 +35,43 @@ if (_attackDirection < 0) then { private _targetPos = _seekerTargetPos; if !(_terminal) then { - _targetPos set [2, (_seekerTargetPos select 2) + 500]; - private _timeToGo = ((getPosASL _projectile) distance _targetPos) / vectorMagnitude velocity _projectile; + _targetPos = [ + _targetPos#0, + _targetPos#1, + (_seekerTargetPos select 2) + 500 + ]; - private _pitchTime = 0.5 * _pitchRate * _timeToGo; + private _projectilePos = getPosASLVisual _projectile; + private _timeToGo = (_projectilePos distance _targetPos) / vectorMagnitude velocity _projectile; - private _atMinRotationAngle = _pitchTime <= _impactAngle; + private _currentPitchTowardTarget = ((_projectilePos vectorFromTo _seekerTargetPos) call CBA_fnc_vect2polar) select 2; + private _closingRate = if (_timestep != 0) then { + (_currentPitchTowardTarget - _lastAngleToTarget) / _timestep; + } else { + 0 + }; + _attackProfileStateParams set [3, _currentPitchTowardTarget]; + + private _pitchTime = _pitchRate * _timeToGo; + + private _projectileElevation = ((vectorDir _projectile) call CBA_fnc_vect2polar) select 2; + private _neededPitch = (_impactAngle + _projectileElevation + _closingRate); + private _pitchOverETA = _timeToGo - ((_impactAngle + _projectileElevation) / _pitchRate); + + // TODO: look into PID controller and custom navigation type to ride the line? Same as SACLOS really + + private _atMinRotationAngle = _pitchTime <= _neededPitch; _attackProfileStateParams set [2, _atMinRotationAngle]; if (GVAR(debug_drawGuidanceInfo)) then { - _attackProfileName = format ["JDAM [%1]", _pitchTime]; + _attackProfileName = format ["JDAM [Pitch Available - %1 Needed Pitch - %2 ETP - %3]", _pitchTime, _neededPitch, _pitchOverETA]; }; }; if (GVAR(debug_drawGuidanceInfo)) then { private _desiredAngle = [5000, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect; - private _projectilePosAGL = ASLtoAGL _seekerTargetPos; - drawLine3D [_projectilePosAGL, _projectilePosAGL vectorAdd _desiredAngle, [1, 0, 0, 1]]; + private _targetPosAGL = ASLtoAGL _seekerTargetPos; + drawLine3D [_targetPosAGL, _targetPosAGL vectorAdd _desiredAngle, [1, 1, 1, 1]]; }; _targetPos; diff --git a/addons/missileguidance/functions/fnc_gps_attackOnFired.sqf b/addons/missileguidance/functions/fnc_gps_attackOnFired.sqf index fd633c324d..fc1af427c6 100644 --- a/addons/missileguidance/functions/fnc_gps_attackOnFired.sqf +++ b/addons/missileguidance/functions/fnc_gps_attackOnFired.sqf @@ -21,3 +21,4 @@ _firedEH params ["_shooter","","","","_ammo","","_projectile"]; _attackProfileStateParams set [0, [] call FUNC(gps_getAttackData)]; _attackProfileStateParams set [1, (getPosASL _projectile) select 2]; _attackProfileStateParams set [2, false]; +_attackProfileStateParams set [3, 0]; diff --git a/addons/missileguidance/functions/fnc_guidancePFH.sqf b/addons/missileguidance/functions/fnc_guidancePFH.sqf index a040a53fb7..9da0f0de57 100644 --- a/addons/missileguidance/functions/fnc_guidancePFH.sqf +++ b/addons/missileguidance/functions/fnc_guidancePFH.sqf @@ -70,7 +70,7 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua if (GVAR(debug_drawGuidanceInfo)) then { private _projectilePosAGL = ASLToAGL _projectilePos; - drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _projectilePosAGL vectorAdd [0, 0, 1], 0.75, 0.75, 0, str _commandedAcceleration, 1, 0.025, "TahomaB"]; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _projectilePosAGL vectorAdd [0, 0, 1], 0.75, 0.75, 0, format ["cmdPitch: %1 cmdYaw %2", _commandedAcceleration#2, _commandedAcceleration#0], 1, 0.025, "TahomaB"]; drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,1,0,1], _projectilePosAGL vectorAdd [0, 0, 2], 0.75, 0.75, 0, _navigationType, 1, 0.025, "TahomaB"]; drawLine3D [_projectilePosAGL, _projectilePosAGL vectorAdd _commandedAcceleration, [1, 0, 1, 1]]; }; @@ -104,8 +104,8 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua } else { _clampedYaw / abs _clampedYaw }; - _clampedPitch = _pitchSign * 50; - _clampedYaw = _yawSign * 50; + _clampedPitch = _pitchSign * _pitchRate; + _clampedYaw = _yawSign * _yawRate; }; TRACE_9("pitch/yaw/roll",_pitch,_yaw,_roll,_yawChange,_pitchChange,_pitchRate,_yawRate,_clampedPitch,_clampedYaw); @@ -163,8 +163,6 @@ if ((_pitchRate != 0 || {_yawRate != 0}) && {_profileAdjustedTargetPos isNotEqua _projectile setVectorDirAndUp [_dir, _up]; - systemChat str [_pitch, _yaw]; - //[_projectile, _pitch, _yaw, 0] call FUNC(changeMissileDirection); _guidanceParameters set [0, _yaw];