tweak navigation to allow for <200m shots

This commit is contained in:
Brandon Danyluk 2021-12-13 17:15:00 -07:00
parent becc9d24ff
commit fd5b8a27f1
4 changed files with 32 additions and 29 deletions

View File

@ -16,43 +16,36 @@
* *
* Public: No * Public: No
*/ */
#define CHECK_DISTANCE 25 #define CHECK_DISTANCE 10
params ["_origin", "_direction", "_designateInput", "_seekerTargetPos", ["_ignoreObject", objNull]]; #define SEEKER_BIAS 50
params ["_origin", "_direction", "_designateInput", "_seekerTargetPos", "_seeker", ["_ignoreObject", objNull]];
scopeName "main"; scopeName "main";
private _nearObjects = []; private _nearObjects = [];
if (cursorObject isKindOf "AllVehicles") then { private _desiredObject = objNull;
private _intersectionsToCursorTarget = lineIntersectsSurfaces [_origin, aimPos cursorObject, _ignoreObject, cursorObject, true, 1];
if (_intersectionsToCursorTarget isEqualTo []) then {
_nearObjects pushBack cursorObject;
};
};
private _intersections = lineIntersectsSurfaces [_origin, _origin vectorAdd (_direction vectorMultiply 5000), _ignoreObject, objNull, true, 1, "FIRE", "VIEW", true]; private _intersections = lineIntersectsSurfaces [_origin, _origin vectorAdd (_direction vectorMultiply 5000), _ignoreObject, objNull, true, 1, "FIRE", "VIEW", true];
if (_intersections isNotEqualTo []) then { if (_intersections isNotEqualTo []) then {
(_intersections#0) params ["_intersectPos", "", "_object"]; (_intersections#0) params ["_intersectPos", "", "_object"];
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLtoAGL _intersectPos, 0.75, 0.75, 0, "", 1, 0.025, "TahomaB"];
if (_designateInput == 1) then { if (_designateInput == 1) then {
_seekerTargetPos = _intersectPos; _seekerTargetPos = _intersectPos;
}; };
_nearObjects = (ASLtoAGL _seekerTargetPos) nearObjects ["AllVehicles", 5]; _nearObjects = (ASLtoAGL _seekerTargetPos) nearObjects ["AllVehicles", CHECK_DISTANCE];
if (_designateInput == 1 && { !isNull _object }) then { if (_designateInput == 1 && { !isNull _object } && { _object isKindOf "Building" }) then {
_nearObjects pushBack _object; _nearObjects pushBack _object;
if (isNull _desiredObject) then {
_desiredObject = _object;
};
}; };
}; };
if (_nearObjects isNotEqualTo []) then { if (_nearObjects isNotEqualTo []) then {
// I want to prefer the designated position on the object moreso than the bounds of the object // I want to prefer the designated position on the object moreso than the bounds of the object
private _averagePosition = _seekerTargetPos vectorMultiply 15; private _averagePosition = _seekerTargetPos vectorMultiply SEEKER_BIAS;
private _averagePositionCounter = 15; private _averagePositionCounter = SEEKER_BIAS;
private _highestMagnitude = 0;
private _closestDistance = 1e10;
private _bestScore = 0; private _bestScore = 0;
private _bestObject = objNull; private _bestObject = objNull;
@ -61,13 +54,14 @@ if (_nearObjects isNotEqualTo []) then {
private _tiMagnitude = (vectorMagnitude getVehicleTIPars _x) / 1.74; // 1.74 = sqrt(3) = max magnitude of [1, 1, 1] private _tiMagnitude = (vectorMagnitude getVehicleTIPars _x) / 1.74; // 1.74 = sqrt(3) = max magnitude of [1, 1, 1]
private _distance = (getPosASLVisual _x) vectorDistanceSqr _seekerTargetPos; private _distance = (getPosASLVisual _x) vectorDistanceSqr _seekerTargetPos;
if (_distance <= CHECK_DISTANCE * CHECK_DISTANCE) then { private _score = 4 * _tiMagnitude + (_distance / (CHECK_DISTANCE * CHECK_DISTANCE));
private _score = 8 * _tiMagnitude + (_distance / (CHECK_DISTANCE * CHECK_DISTANCE)); if (_desiredObject isEqualTo _x) then {
_score = _score * 2;
};
if (_score > _bestScore) then { if (_score > _bestScore) then {
_bestScore = _score; _bestScore = _score;
_bestObject = _x; _bestObject = _x;
}; };
};
} forEach _nearObjects; } forEach _nearObjects;
private _boundingBox = 0 boundingBoxReal _bestObject; private _boundingBox = 0 boundingBoxReal _bestObject;

View File

@ -55,7 +55,7 @@ if (cameraView isEqualTo "GUNNER") then {
if (_currentAmmo != 0 && { _designating == 1 || _targetPosition isNotEqualTo [0, 0, 0] }) then { if (_currentAmmo != 0 && { _designating == 1 || _targetPosition isNotEqualTo [0, 0, 0] }) then {
private _viewASL = AGLtoASL positionCameraToWorld [0,0,0]; private _viewASL = AGLtoASL positionCameraToWorld [0,0,0];
private _viewDir = _viewASL vectorFromTo (AGLtoASL positionCameraToWorld [0,0,1]); private _viewDir = _viewASL vectorFromTo (AGLtoASL positionCameraToWorld [0,0,1]);
_targetPosition = [_viewASL, _viewDir, _designating, _targetPosition, _currentShooter] call FUNC(getTargetPosition); _targetPosition = [_viewASL, _viewDir, _designating, _targetPosition, _currentShooter, _currentShooter] call FUNC(getTargetPosition);
GVAR(arguments) set [1, _targetPosition]; GVAR(arguments) set [1, _targetPosition];
}; };

View File

@ -14,6 +14,7 @@
* *
* Public: No * Public: No
*/ */
#define ARM_TIME 0.5
params ["_args", "_timestep", "", "_profileAdjustedTargetPos", "", "_navigationParams"]; params ["_args", "_timestep", "", "_profileAdjustedTargetPos", "", "_navigationParams"];
_args params ["_firedEH", "_launchParams", "_flightParams", "_seekerParams", "_stateParams", "_targetData", "_navigationStateData"]; _args params ["_firedEH", "_launchParams", "_flightParams", "_seekerParams", "_stateParams", "_targetData", "_navigationStateData"];
_firedEH params ["_shooter","","","","_ammo","","_projectile"]; _firedEH params ["_shooter","","","","_ammo","","_projectile"];
@ -95,8 +96,15 @@ switch (_stage) do {
default {}; default {};
}; };
(_directionToTarget call CBA_fnc_vect2polar) params ["", "", "_elevationToTarget"]; private _distance = _launchPos vectorDistance _profileAdjustedTargetPos;
if (_stage >= STAGE_LAUNCH && { _profileAdjustedTargetPos isNotEqualTo [0, 0, 0] } && { -_elevationToTarget >= 30 }) then {
private _los = _projectilePos vectorFromTo _profileAdjustedTargetPos;
// subtract 500 so we dont get a perfect top-attack angle
private _ttgo = ((_projectilePos distance2D _profileAdjustedTargetPos) - 500) / (vectorMagnitude velocity _projectile);
private _angleToTarget = acos ((vectorDir _projectile) vectorCos _los);
private _atMinRotationAngle = _angleToTarget >= (_pitchRate * _ttgo);
if (_met >= ARM_TIME && { _stage >= STAGE_LAUNCH } && { _profileAdjustedTargetPos isNotEqualTo [0, 0, 0] } && { _atMinRotationAngle }) then {
_navigationParams set [0, STAGE_TERMINAL]; _navigationParams set [0, STAGE_TERMINAL];
}; };

View File

@ -17,7 +17,8 @@
*/ */
params ["", "_args", "_seekerStateParams", "", "_timestep"]; params ["", "_args", "_seekerStateParams", "", "_timestep"];
_args params ["_firedEH", "", "", "", "", "_targetData"]; _args params ["_firedEH", "", "", "_seekerParams", "", "_targetData"];
_seekerParams params ["_seekerAngle", "", "_seekerMaxRange", "_seekerMinRange"];
_firedEH params ["","","","","","","_projectile"]; _firedEH params ["","","","","","","_projectile"];
(GVAR(projectileHashMap) get hashValue _projectile) params ["_cameraNamespace", "_preTarget"]; (GVAR(projectileHashMap) get hashValue _projectile) params ["_cameraNamespace", "_preTarget"];
@ -36,7 +37,7 @@ if (_seekerTargetPos isEqualTo [0, 0, 0]) then {
}; };
if ((_seekerTargetPos isNotEqualTo [0, 0, 0]) || { (_designateInput == 1) }) then { if ((_seekerTargetPos isNotEqualTo [0, 0, 0]) || { (_designateInput == 1) }) then {
_seekerTargetPos = [_cameraPos, vectorNormalized _logicPos, _designateInput, _seekerTargetPos] call FUNC(getTargetPosition); _seekerTargetPos = [_cameraPos, vectorNormalized _logicPos, _designateInput, _seekerTargetPos, _projectile] call FUNC(getTargetPosition);
}; };
_cameraNamespace setVariable [QGVAR(seekerTargetPos), _seekerTargetPos]; _cameraNamespace setVariable [QGVAR(seekerTargetPos), _seekerTargetPos];