mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
better JDAM simulation
Attack heading and impact angle now are followed better
This commit is contained in:
parent
8142bb069b
commit
038c82a489
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Author: Brandon (TCVM)
|
||||
* Attack profile: JDAM
|
||||
* Glides until attack angle, and then dives in
|
||||
* Uses LINE navigation type to guide projectile onto target
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Seeker Target PosASL <ARRAY>
|
||||
@ -26,54 +26,34 @@ _targetData params ["_directionToTarget", "", "_distanceToTarget"];
|
||||
_flightParams params ["_pitchRate", "_yawRate"];
|
||||
|
||||
if (_impactAngle <= 0) then {
|
||||
_impactAngle = 360; // immediate pitch over to attack
|
||||
_impactAngle = 45; // immediate pitch over to attack
|
||||
};
|
||||
|
||||
if (_attackDirection < 0) then {
|
||||
_attackDirection = direction _projectile;
|
||||
_gpsData set [2, _attackDirection];
|
||||
};
|
||||
|
||||
private _projectilePos = getPosASLVisual _projectile;
|
||||
private _projectilePitch = ((vectorDir _projectile) call CBA_fnc_vect2polar) select 2;
|
||||
private _targetDir = _projectilePos vectorFromTo _seekerTargetPos;
|
||||
private _lineDir = [1, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect;
|
||||
|
||||
private _targetPos = _seekerTargetPos;
|
||||
if !(_terminal) then {
|
||||
_targetPos = [
|
||||
_targetPos#0,
|
||||
_targetPos#1,
|
||||
(_seekerTargetPos select 2) + 500
|
||||
];
|
||||
|
||||
private _lineDir = [1, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect;
|
||||
private _leadDistance = linearConversion [0, 1000, _projectilePos vectorDistance _seekerTargetPos, 5, 500, true];
|
||||
|
||||
private _v = _projectilePos vectorDiff _seekerTargetPos;
|
||||
private _d = _v vectorDotProduct _lineDir;
|
||||
private _closestPoint = _seekerTargetPos vectorAdd (_lineDir vectorMultiply _d);
|
||||
|
||||
private _timeToGo = (_projectilePos distance _closestPoint) / vectorMagnitude velocity _projectile;
|
||||
|
||||
private _projectileAngleFromTarget = acos ((vectorDir _projectile) vectorCos _targetDir);
|
||||
private _availablePitch = _pitchRate * _timeToGo;
|
||||
|
||||
private _neededPitch = _impactAngle + _projectilePitch;
|
||||
|
||||
private _atMinRotationAngle = _availablePitch <= _neededPitch;
|
||||
_attackProfileStateParams set [2, (_atMinRotationAngle || (_neededPitch <= _projectileAngleFromTarget))];
|
||||
|
||||
if (GVAR(debug_drawGuidanceInfo)) then {
|
||||
_attackProfileName = format ["JDAM [Pitch Available - %1 Needed Pitch - %2 TTP - %3]", _availablePitch, _neededPitch, (_availablePitch - _neededPitch) / _pitchRate];
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _closestPoint, 0.75, 0.75, 0, "P", 1, 0.025, "TahomaB"];
|
||||
};
|
||||
} else {
|
||||
_attackProfileName = format ["JDAM [Pitch - %1 Impact Pitch - %2]", _projectilePitch, _impactAngle];
|
||||
private _missilePosProjected = _seekerTargetPos vectorAdd (_lineDir vectorMultiply ((_projectilePos vectorDistance _seekerTargetPos) - _leadDistance));
|
||||
// don't climb
|
||||
if (_missilePosProjected#2 > _projectilePos#2) then {
|
||||
_missilePosProjected set [2, _projectilePos#2];
|
||||
};
|
||||
_targetData set [2, (_projectilePos vectorDistance _missilePosProjected)];
|
||||
|
||||
if (GVAR(debug_drawGuidanceInfo)) then {
|
||||
private _desiredAngle = [5000, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect;
|
||||
private _projectilePitch = ((vectorDir _projectile) call CBA_fnc_vect2polar) select 2;
|
||||
_attackProfileName = format ["JDAM [Pitch - %1 Impact Pitch - %2]", _projectilePitch, _impactAngle];
|
||||
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _missilePosProjected, 0.75, 0.75, 0, "P", 1, 0.025, "TahomaB"];
|
||||
private _desiredAngle = _lineDir vectorMultiply 5000;
|
||||
private _targetPosAGL = ASLtoAGL _seekerTargetPos;
|
||||
drawLine3D [_targetPosAGL, _targetPosAGL vectorAdd _desiredAngle, [1, 1, 1, 1]];
|
||||
};
|
||||
|
||||
_targetPos;
|
||||
_missilePosProjected
|
||||
|
||||
|
@ -21,10 +21,9 @@ _flightParams params ["_pitchRate", "_yawRate"];
|
||||
|
||||
_navigationParams params ["_proportionalGain", "", "_derivativeGain", "_lastErrorX", "_lastErrorY", "_correctionDistance"];
|
||||
private _targetDistance = _projectile vectorWorldToModelVisual (_targetDir vectorMultiply _distance);
|
||||
private _relativeDirection = _projectile vectorWorldToModelVisual _targetDir;
|
||||
|
||||
private _errorX = -1 max (1 min (_targetDistance#0 / _correctionDistance));
|
||||
private _errorY = -1 max (1 min (_targetDistance#2 / _correctionDistance));
|
||||
private _errorX = _targetDistance#0 / _correctionDistance;
|
||||
private _errorY = _targetDistance#2 / _correctionDistance;
|
||||
|
||||
private _pX = _proportionalGain * _errorX;
|
||||
private _dX = if (_timestep != 0) then {
|
||||
|
@ -7,7 +7,7 @@ class CfgAmmo {
|
||||
enabled = 1;
|
||||
|
||||
pitchRate = 15;
|
||||
yawRate = 5;
|
||||
yawRate = 20;
|
||||
|
||||
canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode
|
||||
|
||||
@ -18,8 +18,11 @@ class CfgAmmo {
|
||||
defaultSeekerLockMode = "LOBL";
|
||||
seekerLockModes[] = { "LOBL" };
|
||||
|
||||
defaultNavigationType = "ZeroEffortMiss";
|
||||
navigationTypes[] = { "ZeroEffortMiss" };
|
||||
defaultNavigationType = "LINE";
|
||||
navigationTypes[] = { "LINE" };
|
||||
|
||||
lineGainP = 50;
|
||||
lineGainD = 1;
|
||||
|
||||
seekLastTargetPos = 0; // seek last target position [if seeker loses LOS of target, continue to last known pos]
|
||||
seekerAngle = 60; // Angle from the shooter's view that can track the missile
|
||||
|
Loading…
x
Reference in New Issue
Block a user