tabs -> spaces

This commit is contained in:
Brandon Danyluk 2021-05-01 23:04:08 -06:00
parent f3bea7bb30
commit 89e64dfcdc
20 changed files with 290 additions and 290 deletions

View File

@ -26,11 +26,11 @@ _targetData params ["_directionToTarget", "", "_distanceToTarget"];
_flightParams params ["_pitchRate", "_yawRate"];
if (_impactAngle <= 0) then {
_impactAngle = 360; // immediate pitch over to attack
_impactAngle = 360; // immediate pitch over to attack
};
if (_attackDirection < 0) then {
_attackDirection = direction _projectile;
_attackDirection = direction _projectile;
};
private _projectilePos = getPosASLVisual _projectile;
@ -39,40 +39,40 @@ private _targetDir = _projectilePos vectorFromTo _seekerTargetPos;
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;
_targetPos = [
_targetPos#0,
_targetPos#1,
(_seekerTargetPos select 2) + 500
];
private _lineDir = [1, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect;
private _v = _projectilePos vectorDiff _seekerTargetPos;
private _d = _v vectorDotProduct _lineDir;
private _closestPoint = _seekerTargetPos vectorAdd (_lineDir vectorMultiply _d);
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 _timeToGo = (_projectilePos distance _closestPoint) / vectorMagnitude velocity _projectile;
private _projectileAngleFromTarget = acos ((vectorDir _projectile) vectorCos _targetDir);
private _availablePitch = _pitchRate * _timeToGo;
private _projectileAngleFromTarget = acos ((vectorDir _projectile) vectorCos _targetDir);
private _availablePitch = _pitchRate * _timeToGo;
private _neededPitch = _impactAngle + _projectilePitch;
private _neededPitch = _impactAngle + _projectilePitch;
private _atMinRotationAngle = _availablePitch <= _neededPitch;
_attackProfileStateParams set [2, (_atMinRotationAngle || (_neededPitch <= _projectileAngleFromTarget))];
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"];
};
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];
_attackProfileName = format ["JDAM [Pitch - %1 Impact Pitch - %2]", _projectilePitch, _impactAngle];
};
if (GVAR(debug_drawGuidanceInfo)) then {
private _desiredAngle = [5000, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect;
private _targetPosAGL = ASLtoAGL _seekerTargetPos;
drawLine3D [_targetPosAGL, _targetPosAGL vectorAdd _desiredAngle, [1, 1, 1, 1]];
private _desiredAngle = [5000, 180 + _attackDirection, _impactAngle] call CBA_fnc_polar2vect;
private _targetPosAGL = ASLtoAGL _seekerTargetPos;
drawLine3D [_targetPosAGL, _targetPosAGL vectorAdd _desiredAngle, [1, 1, 1, 1]];
};
_targetPos;

View File

@ -28,7 +28,7 @@ _stateParams params ["_lastRunTime", "_seekerStateParams", "_attackProfileStateP
_seekerParams params ["_seekerAngle", "_seekerAccuracy", "_seekerMaxRange", "_seekerMinRange"];
if (_seekerTargetPos isEqualTo [0, 0, 0]) exitWith {
_seekerTargetPos
_seekerTargetPos
};
private _projectilePos = getPosASLVisual _projectile;
@ -46,8 +46,8 @@ private _atMinRotationAngle = _angleToTarget >= (0.5 * _pitchRate * _timeToGo);
private _returnTargetPos = _seekerTargetPos;
if (!_atMinRotationAngle && _distanceToTarget2d >= 500 && _timeToGo >= 10) then {
// 10 degree pitch up
_returnTargetPos = _seekerTargetPos vectorAdd [0, 0, (_projectilePos distance _seekerTargetPos) * sin 10];
// 10 degree pitch up
_returnTargetPos = _seekerTargetPos vectorAdd [0, 0, (_projectilePos distance _seekerTargetPos) * sin 10];
};
_returnTargetPos

View File

@ -15,7 +15,7 @@
* Public: No
*/
if (GVAR(gps_mode) isEqualTo "pb") then {
[GVAR(gps_pbMode)] call FUNC(gps_saveAttackSettings);
[GVAR(gps_pbMode)] call FUNC(gps_saveAttackSettings);
};
closeDialog 0;

View File

@ -16,15 +16,15 @@
*/
if (GVAR(gps_mode) isEqualTo "too") then {
private _target = getPilotCameraTarget (vehicle ACE_PLAYER);
_target params ["_tracking", "_position", "_object"];
GVAR(gps_currentSettings) set [0, _position]
private _target = getPilotCameraTarget (vehicle ACE_PLAYER);
_target params ["_tracking", "_position", "_object"];
GVAR(gps_currentSettings) set [0, _position]
};
// create a copy of this array to make sure values are not overwritten
[
GVAR(gps_currentSettings)#0,
GVAR(gps_currentSettings)#1,
GVAR(gps_currentSettings)#2
GVAR(gps_currentSettings)#0,
GVAR(gps_currentSettings)#1,
GVAR(gps_currentSettings)#2
]

View File

@ -26,23 +26,23 @@ private _grid = [_position] call EFUNC(common,getMapGridFromPos);
_grid params ["_easting", "_northing"];
if (_angle < 0) then {
_angle = "";
_angle = "";
} else {
_angle = str _angle;
_angle = str _angle;
};
if (_heading < 0) then {
_heading = "";
_heading = "";
} else {
_heading = str _heading;
_heading = str _heading;
};
if (0 == parseNumber _easting) then {
_easting = "";
_easting = "";
};
if (0 == parseNumber _northing) then {
_northing = "";
_northing = "";
};
(_display displayCtrl GPS_UI_EASTING) ctrlSetText _easting;

View File

@ -18,39 +18,39 @@
params ["_mode", ["_onLoad", false]];
private _display = uiNamespace getVariable QGVAR(gpsAttackOptionDisplay);
{
// only TOO and PB modes modelled
if (_mode == GPS_UI_TOO) then {
// disable
ctrlEnable [_x, false];
} else {
// enable
ctrlEnable [_x, true];
};
{
// only TOO and PB modes modelled
if (_mode == GPS_UI_TOO) then {
// disable
ctrlEnable [_x, false];
} else {
// enable
ctrlEnable [_x, true];
};
} forEach CONTROLS_DISABLED_IN_TOO;
private _backgroundColour = [
GUI_BCG_RGB_R call BIS_fnc_parseNumber,
GUI_BCG_RGB_G call BIS_fnc_parseNumber,
GUI_BCG_RGB_B call BIS_fnc_parseNumber,
GUI_BCG_ALPHA call BIS_fnc_parseNumber
GUI_BCG_RGB_R call BIS_fnc_parseNumber,
GUI_BCG_RGB_G call BIS_fnc_parseNumber,
GUI_BCG_RGB_B call BIS_fnc_parseNumber,
GUI_BCG_ALPHA call BIS_fnc_parseNumber
];
private _selectedColour = [
0,
0,
0,
1
0,
0,
0,
1
];
ctrlSetFocus (_display displayCtrl _mode);
if (_mode == GPS_UI_TOO) then {
GVAR(gps_mode) = "too";
if !(_onLoad) then {
[GVAR(gps_pbMode)] call FUNC(gps_saveAttackSettings);
};
GVAR(gps_mode) = "too";
if !(_onLoad) then {
[GVAR(gps_pbMode)] call FUNC(gps_saveAttackSettings);
};
} else {
GVAR(gps_mode) = "pb";
[GVAR(gps_pbMode)] call FUNC(gps_loadAttackSettings);
GVAR(gps_mode) = "pb";
[GVAR(gps_pbMode)] call FUNC(gps_loadAttackSettings);
};

View File

@ -15,39 +15,39 @@
* Public: No
*/
[{
params ["_display"];
uiNamespace setVariable [QGVAR(gpsAttackOptionDisplay), _display];
params ["_display"];
uiNamespace setVariable [QGVAR(gpsAttackOptionDisplay), _display];
private _mode = if (GVAR(gps_mode) isEqualTo "too") then {
GPS_UI_TOO
} else {
GPS_UI_PB
};
private _mode = if (GVAR(gps_mode) isEqualTo "too") then {
GPS_UI_TOO
} else {
GPS_UI_PB
};
[_mode, true] call FUNC(gps_modeSelect);
(_display displayCtrl GPS_UI_PB_MISSION) ctrlSetText format ["PP %1", GVAR(gps_pbMode) + 1];
[_mode, true] call FUNC(gps_modeSelect);
(_display displayCtrl GPS_UI_PB_MISSION) ctrlSetText format ["PP %1", GVAR(gps_pbMode) + 1];
// update current settings
GVAR(gps_uiPerFrameHandler) = [{
if (GVAR(gps_mode) isEqualTo "too") then {
// update coordinates based on TGP position
private _target = getPilotCameraTarget (vehicle ACE_PLAYER);
_target params ["_tracking", "_position", "_object"];
// update current settings
GVAR(gps_uiPerFrameHandler) = [{
if (GVAR(gps_mode) isEqualTo "too") then {
// update coordinates based on TGP position
private _target = getPilotCameraTarget (vehicle ACE_PLAYER);
_target params ["_tracking", "_position", "_object"];
if (_position isNotEqualTo [0, 0, 0]) then {
private _mapGrid = [_position] call EFUNC(common,getMapGridFromPos);
_mapGrid params ["_easting", "_northing"];
private _height = _position#2;
if (_position isNotEqualTo [0, 0, 0]) then {
private _mapGrid = [_position] call EFUNC(common,getMapGridFromPos);
_mapGrid params ["_easting", "_northing"];
private _height = _position#2;
private _display = uiNamespace getVariable QGVAR(gpsAttackOptionDisplay);
(_display displayCtrl GPS_UI_EASTING) ctrlSetText _easting;
(_display displayCtrl GPS_UI_NORTHING) ctrlSetText _northing;
(_display displayCtrl GPS_UI_HEIGHT) ctrlSetText str _height;
};
};
private _display = uiNamespace getVariable QGVAR(gpsAttackOptionDisplay);
(_display displayCtrl GPS_UI_EASTING) ctrlSetText _easting;
(_display displayCtrl GPS_UI_NORTHING) ctrlSetText _northing;
(_display displayCtrl GPS_UI_HEIGHT) ctrlSetText str _height;
};
};
// info is read from text boxes, so if boxes are update this will be updated
GVAR(gps_currentSettings) = [-1] call FUNC(gps_saveAttackSettings);
}] call CBA_fnc_addPerFrameHandler;
// info is read from text boxes, so if boxes are update this will be updated
GVAR(gps_currentSettings) = [-1] call FUNC(gps_saveAttackSettings);
}] call CBA_fnc_addPerFrameHandler;
}, _this] call CBA_fnc_execNextFrame;

View File

@ -20,15 +20,15 @@ private _display = uiNamespace getVariable QGVAR(gpsAttackOptionDisplay);
[GVAR(gps_pbMode)] call FUNC(gps_saveAttackSettings);
if (_direction > 0) then {
// right
GVAR(gps_pbMode) = (GVAR(gps_pbMode) + 1) % MAX_PB_MODES
// right
GVAR(gps_pbMode) = (GVAR(gps_pbMode) + 1) % MAX_PB_MODES
} else {
// left
GVAR(gps_pbMode) = (GVAR(gps_pbMode) - 1);
if (GVAR(gps_pbMode) < 0) then {
GVAR(gps_pbMode) = MAX_PB_MODES - 1;
};
GVAR(gps_pbMode) = GVAR(gps_pbMode) % MAX_PB_MODES;
// left
GVAR(gps_pbMode) = (GVAR(gps_pbMode) - 1);
if (GVAR(gps_pbMode) < 0) then {
GVAR(gps_pbMode) = MAX_PB_MODES - 1;
};
GVAR(gps_pbMode) = GVAR(gps_pbMode) % MAX_PB_MODES;
};
[GVAR(gps_pbMode)] call FUNC(gps_loadAttackSettings);

View File

@ -24,42 +24,42 @@ private _angle = ctrlText (_display displayCtrl GPS_UI_ANGLE);
private _heading = ctrlText (_display displayCtrl GPS_UI_HEADING);
if (_height isEqualTo "") then {
_height = 0
_height = 0
} else {
_height = parseNumber _height;
_height = parseNumber _height;
};
if (_angle isEqualTo "") then {
_angle = -1
_angle = -1
} else {
_angle = parseNumber _angle;
_angle = parseNumber _angle;
};
if (_heading isEqualTo "") then {
_heading = -1
_heading = -1
} else {
_heading = parseNumber _heading;
_heading = parseNumber _heading;
};
private _minGridCount = (count _easting) min (count _northing);
private _grid = (_easting select [0, _minGridCount]) + (_northing select [0, _minGridCount]);
private _position = if (_grid isEqualTo "") then {
[0, 0, 0]
[0, 0, 0]
} else {
[_grid, false] call EFUNC(common,getMapPosFromGrid);
[_grid, false] call EFUNC(common,getMapPosFromGrid);
};
_position set [2, _height];
TRACE_3("settings gps pos",_position,_angle,_heading);
private _settings = [
_position, // attack position
_angle, // impact angle
_heading // attack heading
_position, // attack position
_angle, // impact angle
_heading // attack heading
];
if (_mode != -1) then {
GVAR(gps_settings) set [_mode, _settings];
GVAR(gps_settings) set [_mode, _settings];
};
_settings

View File

@ -23,28 +23,28 @@ if (_vehicle getVariable [QGVAR(gps_actionsAdded), false]) exitWith {};
_vehicle setVariable [QGVAR(gps_actionsAdded), true];
private _condition = {
params ["_target", "_player"];
params ["_target", "_player"];
private _turretPath = if (ACE_player == (driver _target)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
private _hasJDAM = false;
private _hasJDAM = false;
{
private _magazines = getArray (configFile >> "CfgWeapons" >> _x >> "magazines");
{
private _ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo");
private _ammoAttackProfiles = getArray (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "attackProfiles");
_hasJDAM = "JDAM" in _ammoAttackProfiles;
private _magazines = getArray (configFile >> "CfgWeapons" >> _x >> "magazines");
{
private _ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo");
private _ammoAttackProfiles = getArray (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "attackProfiles");
_hasJDAM = "JDAM" in _ammoAttackProfiles;
if (_hasJDAM) exitWith { true };
} forEach _magazines;
if (_hasJDAM) exitWith { true };
} forEach _magazines;
if (_hasJDAM) exitWith { true };
} forEach (_target weaponsTurret _turretPath);
if (_hasJDAM) exitWith { true };
} forEach (_target weaponsTurret _turretPath);
_hasJDAM
_hasJDAM
};
private _statement = {
createDialog QGVAR(gpsAttackOptionsUI);
createDialog QGVAR(gpsAttackOptionsUI);
};
private _action = [QUOTE(ADDON), "JDAM settings", "", _statement, _condition] call EFUNC(interact_menu,createAction);

View File

@ -23,14 +23,14 @@ private _d = getNumber (_ammoConfig >> QUOTE(ADDON) >> "lineGainD");
private _correctionDistance = getNumber (_ammoConfig >> QUOTE(ADDON) >> "correctionDistance");
if (_correctionDistance == 0) then {
_correctionDistance = 1;
_correctionDistance = 1;
};
private _navigationParams = [
_p, _i, _d,
0,
0,
_correctionDistance
_p, _i, _d,
0,
0,
_correctionDistance
];
_navigationParams

View File

@ -32,9 +32,9 @@ _targetAcceleration = _targetAcceleration vectorDiff _targetAccelerationProjecte
// this is just due to how we measure our LOS delta, the vectors involved are _tiny_
private _losDelta = _attackProfileDirection vectorDiff _lastLineOfSight;
private _losRate = if (_timestep == 0) then {
0
0
} else {
1 * (vectorMagnitude _losDelta) / _timestep;
1 * (vectorMagnitude _losDelta) / _timestep;
};
private _lateralAcceleration = _navigationGain * _losRate;
@ -46,7 +46,7 @@ private _commandedAccelerationProjected = _attackProfileDirection vectorMultiply
_commandedAcceleration = _commandedAcceleration vectorDiff _commandedAccelerationProjected;
if (accTime > 0) then {
_navigationParams set [0, [_seekerTargetPos, _targetVelocity, _attackProfileDirection]];
_navigationParams set [0, [_seekerTargetPos, _targetVelocity, _attackProfileDirection]];
};
_commandedAcceleration

View File

@ -28,25 +28,25 @@ private _errorY = 1 min (_targetDistance#2 / _correctionDistance);
private _pX = _proportionalGain * _errorX;
private _dX = if (_timestep != 0) then {
_derivativeGain * (_errorX - _lastErrorX) / _timestep
_derivativeGain * (_errorX - _lastErrorX) / _timestep
} else {
0
0
};
private _pY = _proportionalGain * _errorY;
private _dY = if (_timestep != 0) then {
_derivativeGain * (_errorY - _lastErrorY) / _timestep
_derivativeGain * (_errorY - _lastErrorY) / _timestep
} else {
0
0
};
private _accelerationX = _pX + _dX;
private _accelerationY = _pY + _dY;
private _commandedAcceleration = [
_accelerationX,
0,
_accelerationY
_accelerationX,
0,
_accelerationY
];
_navigationParams set [3, _errorX];

View File

@ -28,9 +28,9 @@ _targetData params ["_targetDirection", "_attackProfileDirection", "", "_targetV
// this is just due to how we measure our LOS delta, the vectors involved are _tiny_
private _losDelta = _attackProfileDirection vectorDiff _lastLineOfSight;
private _losRate = if (_timestep == 0) then {
0
0
} else {
10 * (vectorMagnitude _losDelta) / _timestep;
10 * (vectorMagnitude _losDelta) / _timestep;
};
private _closingVelocity = _targetVelocity vectorDiff (velocity _projectile);
@ -42,7 +42,7 @@ private _commandedAccelerationProjected = _attackProfileDirection vectorMultiply
_commandedAcceleration = _commandedAcceleration vectorDiff _commandedAccelerationProjected;
if (accTime > 0) then {
_navigationParams set [0, [_attackProfileDirection]];
_navigationParams set [0, [_attackProfileDirection]];
};
_targetDirection

View File

@ -29,9 +29,9 @@ private _closingVelocity = _targetVelocity vectorDiff velocity _projectile;
// this is just due to how we measure our LOS delta, the vectors involved are _tiny_
private _losDelta = _attackProfileDirection vectorDiff _lastLineOfSight;
private _losRate = if (_timestep == 0) then {
0
0
} else {
1 * (vectorMagnitude _losDelta) / _timestep;
1 * (vectorMagnitude _losDelta) / _timestep;
};
private _lateralAcceleration = _navigationGain * _losRate;
@ -42,7 +42,7 @@ private _commandedAccelerationProjected = _attackProfileDirection vectorMultiply
_commandedAcceleration = _commandedAcceleration vectorDiff _commandedAccelerationProjected;
if (accTime > 0) then {
_navigationParams set [0, [_seekerTargetPos, _targetVelocity, _attackProfileDirection]];
_navigationParams set [0, [_seekerTargetPos, _targetVelocity, _attackProfileDirection]];
};
_commandedAcceleration

View File

@ -26,7 +26,7 @@ private _closingVelocity = _targetVelocity vectorDiff velocity _projectile;
private _timeToGo = _targetRange / vectorMagnitude _closingVelocity;
if (_timeToGo == 0) then {
_timeToGo = 0.001;
_timeToGo = 0.001;
};
private _zeroEffortMiss = _vectorToTarget vectorAdd (_closingVelocity vectorMultiply _timeToGo);
@ -36,6 +36,6 @@ private _zeroEffortMissNormal = _zeroEffortMiss vectorDiff _zeroEffortMissProjec
private _commandedAcceleration = _zeroEffortMissNormal vectorMultiply (_navigationGain / (_timeToGo * _timeToGo));
if (accTime > 0) then {
_navigationParams set [0, [_lineOfSight]];
_navigationParams set [0, [_lineOfSight]];
};
_commandedAcceleration

View File

@ -24,13 +24,13 @@ _seekerParams params ["_seekerAngle", "_seekerAccuracy", "_seekerMaxRange", "_se
private _ammoConfig = configOf _projectile;
private _navigationGain = getNumber (_ammoConfig >> QUOTE(ADDON) >> "navigationGain");
if (_navigationGain == 0) then {
_navigationGain = 3;
_navigationGain = 3;
};
private _navigationParams = [
[ // Last Missile Frame
[0, 0, 0] // Last line of sight
],
_navigationGain // navigation gain of missile. Set in the navigation onFired function
[ // Last Missile Frame
[0, 0, 0] // Last line of sight
],
_navigationGain // navigation gain of missile. Set in the navigation onFired function
];
_navigationParams

View File

@ -36,85 +36,85 @@ private _withinView = [_projectile, getPosASLVisual _trackingTarget, _seekerAngl
private _canSee = [_projectile, _trackingTarget, false] call FUNC(checkLos);
if (!_withinView || !_canSee) then {
_trackingTarget = objNull;
_trackingTarget = objNull;
};
if (isNull _trackingTarget) then {
// find any target within seeker range
private _potentialTargets = _projectile nearEntities ["Air", _seekerMaxRange];
private _bestAngle = 90;
{
private _withinView = [_projectile, getPosASLVisual _x, _seekerAngle] call FUNC(checkSeekerAngle);
private _canSee = [_projectile, _x, false] call FUNC(checkLos);
// find any target within seeker range
private _potentialTargets = _projectile nearEntities ["Air", _seekerMaxRange];
private _bestAngle = 90;
{
private _withinView = [_projectile, getPosASLVisual _x, _seekerAngle] call FUNC(checkSeekerAngle);
private _canSee = [_projectile, _x, false] call FUNC(checkLos);
if (_withinView && _canSee) then {
private _los = (getPosASLVisual _projectile) vectorFromTo (getPosASLVisual _x);
private _losAngle = (_los#2 atan2 _los#0);
if (_losAngle < _bestAngle) then {
_trackingTarget = _x;
_bestAngle = _losAngle;
};
};
} forEach _potentialTargets;
if (_withinView && _canSee) then {
private _los = (getPosASLVisual _projectile) vectorFromTo (getPosASLVisual _x);
private _losAngle = (_los#2 atan2 _los#0);
if (_losAngle < _bestAngle) then {
_trackingTarget = _x;
_bestAngle = _losAngle;
};
};
} forEach _potentialTargets;
};
if (TRACK_ON_PAUSE || {accTime > 0 && !isGamePaused}) then {
// If there are flares nearby, check if they will confuse missile
private _nearby = _trackingTarget nearObjects _flareDistanceFilter;
_nearby = _nearby select {
// 2 = IR blocking
private _blocking = configOf _x >> "weaponLockSystem";
private _isFlare = false;
if (isNumber _blocking) then {
_isFlare = (2 == getNumber _blocking);
};
// If there are flares nearby, check if they will confuse missile
private _nearby = _trackingTarget nearObjects _flareDistanceFilter;
_nearby = _nearby select {
// 2 = IR blocking
private _blocking = configOf _x >> "weaponLockSystem";
private _isFlare = false;
if (isNumber _blocking) then {
_isFlare = (2 == getNumber _blocking);
};
if (isText _blocking) then {
_isFlare = ("2" in getText _blocking);
};
if (isText _blocking) then {
_isFlare = ("2" in getText _blocking);
};
private _withinView = [_projectile, getPosASLVisual _x, _seekerAngle] call FUNC(checkSeekerAngle);
private _canSee = [_projectile, _x, false] call FUNC(checkLos);
private _withinView = [_projectile, getPosASLVisual _x, _seekerAngle] call FUNC(checkSeekerAngle);
private _canSee = [_projectile, _x, false] call FUNC(checkLos);
(_x isEqualTo _target && _trackingTarget isNotEqualTo _target) || { (_withinView && _canSee && _isFlare) }
};
(_x isEqualTo _target && _trackingTarget isNotEqualTo _target) || { (_withinView && _canSee && _isFlare) }
};
private _relativeTargetVelocity = _projectile vectorWorldToModelVisual velocity _trackingTarget;
_relativeTargetVelocity set [1, 0];
private _foundDecoy = false;
{
if (_trackingTarget isNotEqualTo _x) then {
private _considering = false;
private _relativeTargetVelocity = _projectile vectorWorldToModelVisual velocity _trackingTarget;
_relativeTargetVelocity set [1, 0];
private _foundDecoy = false;
{
if (_trackingTarget isNotEqualTo _x) then {
private _considering = false;
private _flareRelativeVelocity = _projectile vectorWorldToModelVisual velocity _x;
_flareRelativeVelocity set [1, 0];
private _angleBetweenVelocities = acos (_relativeTargetVelocity vectorCos _flareRelativeVelocity);
if !(_foundDecoy) then {
if (_angleBetweenVelocities <= _flareAngleFilter) then {
_considering = true;
if (_seekerAccuracy <= random 1) then {
_trackingTarget = _x;
_foundDecoy = true;
};
};
};
private _flareRelativeVelocity = _projectile vectorWorldToModelVisual velocity _x;
_flareRelativeVelocity set [1, 0];
private _angleBetweenVelocities = acos (_relativeTargetVelocity vectorCos _flareRelativeVelocity);
if !(_foundDecoy) then {
if (_angleBetweenVelocities <= _flareAngleFilter) then {
_considering = true;
if (_seekerAccuracy <= random 1) then {
_trackingTarget = _x;
_foundDecoy = true;
};
};
};
if (GVAR(debug_drawGuidanceInfo)) then {
private _flarePos = ASLToAGL getPosASLVisual _x;
private _colour = [1, 0, 0, 1];
if (_considering) then {
_colour = [0, 1, 0, 1];
};
if (_trackingTarget isEqualTo _x) then {
_colour = [0, 0, 1, 1];
};
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _flarePos, 0.75, 0.75, 0, format ["F %1", _angleBetweenVelocities], 1, 0.025, "TahomaB"];
};
};
} forEach _nearby;
if (GVAR(debug_drawGuidanceInfo)) then {
private _flarePos = ASLToAGL getPosASLVisual _x;
private _colour = [1, 0, 0, 1];
if (_considering) then {
_colour = [0, 1, 0, 1];
};
if (_trackingTarget isEqualTo _x) then {
_colour = [0, 0, 1, 1];
};
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _flarePos, 0.75, 0.75, 0, format ["F %1", _angleBetweenVelocities], 1, 0.025, "TahomaB"];
};
};
} forEach _nearby;
_seekerStateParams set [2, _trackingTarget];
_seekerStateParams set [2, _trackingTarget];
};
private _targetPosition = _trackingTarget modelToWorldVisualWorld getCenterOfMass _trackingTarget;

View File

@ -31,36 +31,36 @@ private _foundTargetPos = _laserResult select 0;
TRACE_1("Search", _laserResult);
if (isNil "_foundTargetPos") exitWith {
[0, 0, 0]
[0, 0, 0]
};
// average out any error from laser jump
private _positionSum = [0, 0, 0];
{
_positionSum = _positionSum vectorAdd _x;
_positionSum = _positionSum vectorAdd _x;
} forEach _lastPositions;
if (_foundTargetPos isNotEqualTo [0, 0, 0]) then {
_lastPositions set [_lastPositionIndex % MAX_AVERAGES, _foundTargetPos];
_seekerParams set [4, _lastPositions];
_seekerParams set [5, _lastPositionIndex + 1];
_lastPositions set [_lastPositionIndex % MAX_AVERAGES, _foundTargetPos];
_seekerParams set [4, _lastPositions];
_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));
_positionSum = _positionSum vectorMultiply (1 / (1 + count _lastPositions));
// if we are within a meter of the previous average, just use the previous average
if (_positionSum distanceSqr _lastPositionSum < MINIMUM_DISTANCE_UNTIL_NEW_POS * MINIMUM_DISTANCE_UNTIL_NEW_POS) then {
_positionSum = _lastPositionSum;
};
// if we are within a meter of the previous average, just use the previous average
if (_positionSum distanceSqr _lastPositionSum < MINIMUM_DISTANCE_UNTIL_NEW_POS * MINIMUM_DISTANCE_UNTIL_NEW_POS) then {
_positionSum = _lastPositionSum;
};
if (_timestep != 0) then {
_aproximateVelocity = (_positionSum vectorDiff _lastPositionSum) vectorMultiply (1 / _timestep);
};
if (_timestep != 0) then {
_aproximateVelocity = (_positionSum vectorDiff _lastPositionSum) vectorMultiply (1 / _timestep);
};
} else {
_positionSum = _positionSum vectorMultiply (1 / count _lastPositions);
_positionSum = _positionSum vectorMultiply (1 / count _lastPositions);
};
_seekerParams set [6, _positionSum];

View File

@ -28,8 +28,8 @@ TRACE_5("should filter target",_projectile,_target,_minimumSpeed,_minimumTime,_m
// helicopter blades will always produce a doppler shift due to their nature. Don't filter
if (_target isKindOf "Helicopter" && isEngineOn _target) exitWith {
TRACE_2("dont filter helicopters",_target isKindOf "Helicopter",isEngineOn _target);
false
TRACE_2("dont filter helicopters",_target isKindOf "Helicopter",isEngineOn _target);
false
};
private _lineOfSight = (getPosASLVisual _projectile) vectorFromTo (getPosASLVisual _target);
@ -39,8 +39,8 @@ private _closingSpeed = vectorMagnitude _closingVelocity;
// if relative target velocity is greather than threshold, we can easily see it. Don't filter
if (_closingSpeed > _minimumSpeed) exitWith {
TRACE_2("dont filter fast objects approaching",_closingSpeed,_minimumSpeed);
false
TRACE_2("dont filter fast objects approaching",_closingSpeed,_minimumSpeed);
false
};
private _projectilePos = getPosASLVisual _projectile;
@ -52,71 +52,71 @@ private _maskedByGround = false;
// Check for all surfaces until we reach our max range
for "_i" from 0 to _maximumTerrainCheck step MAX_LINE_DISTANCE do {
// determine if target is masked by ground
private _endPos = _checkPos vectorAdd _stepDistance;
private _groundHit = lineIntersectsSurfaces [_checkPos, _endPos, _projectile, _target];
// determine if target is masked by ground
private _endPos = _checkPos vectorAdd _stepDistance;
private _groundHit = lineIntersectsSurfaces [_checkPos, _endPos, _projectile, _target];
_maskedByGround = _groundHit isNotEqualTo [];
_maskedByGround = _groundHit isNotEqualTo [];
_checkPos = _endPos;
_checkPos = _endPos;
if (_maskedByGround || (_checkPos select 2) <= 0) then {
// for ease assume that we can't check underwater
if ((_checkPos select 2) < 0) then {
_checkPos set [2, 0];
};
break
};
if (_maskedByGround || (_checkPos select 2) <= 0) then {
// for ease assume that we can't check underwater
if ((_checkPos select 2) < 0) then {
_checkPos set [2, 0];
};
break
};
};
// looking at sky, target is clear as day. Check for chaff before filtering
if !(_maskedByGround) exitWith {
TRACE_1("dont filter stuff in the sky",_maskedByGround);
TRACE_1("dont filter stuff in the sky",_maskedByGround);
// If there is chaff nearby, check if they will confuse missile
private _nearby = _target nearObjects 50;
_nearby = _nearby select {
// 8 = radar blocking
private _blocking = configOf _x >> "weaponLockSystem";
private _isChaff = false;
if (isNumber _blocking) then {
_isChaff = (8 == getNumber _blocking);
};
// If there is chaff nearby, check if they will confuse missile
private _nearby = _target nearObjects 50;
_nearby = _nearby select {
// 8 = radar blocking
private _blocking = configOf _x >> "weaponLockSystem";
private _isChaff = false;
if (isNumber _blocking) then {
_isChaff = (8 == getNumber _blocking);
};
if (isText _blocking) then {
_isChaff = ("8" in getText _blocking);
};
if (isText _blocking) then {
_isChaff = ("8" in getText _blocking);
};
private _withinView = [_projectile, getPosASLVisual _x, _seekerAngle] call FUNC(checkSeekerAngle);
private _canSee = [_projectile, _x, false] call FUNC(checkLos);
private _withinView = [_projectile, getPosASLVisual _x, _seekerAngle] call FUNC(checkSeekerAngle);
private _canSee = [_projectile, _x, false] call FUNC(checkLos);
(_withinView && _canSee && _isChaff)
};
(_withinView && _canSee && _isChaff)
};
private _foundDecoy = false;
{
private _considering = false;
if !(_foundDecoy) then {
_considering = true;
if (0.95 <= random 1) then {
_foundDecoy = true;
};
};
private _foundDecoy = false;
{
private _considering = false;
if !(_foundDecoy) then {
_considering = true;
if (0.95 <= random 1) then {
_foundDecoy = true;
};
};
if (GVAR(debug_drawGuidanceInfo)) then {
private _chaffPos = ASLToAGL getPosASLVisual _x;
private _colour = [1, 0, 0, 1];
if (_considering) then {
_colour = [0, 1, 0, 1];
};
if (_foundDecoy) then {
_colour = [0, 0, 1, 1];
};
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _chaffPos, 0.75, 0.75, 0, "C", 1, 0.025, "TahomaB"];
};
} forEach _nearby;
if (GVAR(debug_drawGuidanceInfo)) then {
private _chaffPos = ASLToAGL getPosASLVisual _x;
private _colour = [1, 0, 0, 1];
if (_considering) then {
_colour = [0, 1, 0, 1];
};
if (_foundDecoy) then {
_colour = [0, 0, 1, 1];
};
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", _colour, _chaffPos, 0.75, 0.75, 0, "C", 1, 0.025, "TahomaB"];
};
} forEach _nearby;
_foundDecoy
_foundDecoy
};
private _distanceToTerrain = _checkPos vectorDistance _projectilePos;
@ -124,8 +124,8 @@ private _checkTime = _distanceToTerrain / 3e8;
// Time to ground is large enough to know if we are looking at a target, don't filter
if (_checkTime > _minimumTime) exitWith {
TRACE_2("dont filter targets that we can see in ground clutter",_checkTime,_minimumTime);
false
TRACE_2("dont filter targets that we can see in ground clutter",_checkTime,_minimumTime);
false
};
// filter out the target since we can't reasonably see it