Only launch if we are above a threshold angle

This commit is contained in:
Brandon Danyluk 2021-05-18 02:37:34 -06:00
parent a25cf7031b
commit f825d6ff92
2 changed files with 10 additions and 4 deletions

View File

@ -152,13 +152,17 @@ if (_idleLaunchers isNotEqualTo []) then {
} else {
private _directionToTarget = (getPosASLVisual _launcher) vectorFromTo (getPosASLVisual _target);
private _turretDirection = _launcher weaponDirection currentWeapon _launcher;
private _localDirection = _launcher vectorWorldToModelVisual _turretDirection;
private _elevation = 90 - ((_localDirection#1) atan2 (_localDirection#2));
private _angle = acos (_turretDirection vectorCos _directionToTarget);
if (_angle <= LAUNCH_ACCEPTABLE_ANGLE) then {
if (_angle <= LAUNCH_ACCEPTABLE_ANGLE && _elevation >= LAUNCH_ACCEPTABLE_ELEVATION) then {
_launcher setVariable [QGVAR(launchState), LAUNCH_STATE_FIRING];
};
#ifdef DRAW_TRACKING_INFO
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [0, 0, 1, 1], getPos _launcher, 0.75, 0.75, 0, format ["TRACKING: %1", _angle], 1, 0.025, "TahomaB"];
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [0, 0, 1, 1], getPos _launcher, 0.75, 0.75, 0, format ["TRACKING: %1 %2", _angle, _elevation], 1, 0.025, "TahomaB"];
drawLine3D [getPos _launcher, getPos _target, [0, 0, 1, 1]];
#endif
};

View File

@ -4,7 +4,7 @@
// #define DRAW_TRACKING_INFO
// #define DEBUG_MODE_FULL
#define DISABLE_COMPILE_CACHE
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_IRON_DOME
@ -21,9 +21,11 @@
#define LAUNCH_STATE_COOLDOWN 3
// How long it takes to recycle a target
#define RECYCLE_TIME 5
#define RECYCLE_TIME 2
// how many error degrees the launcher has to be pointing toward the target
#define LAUNCH_ACCEPTABLE_ANGLE 10
// How many degrees up this needs to point for a valid firing solution
#define LAUNCH_ACCEPTABLE_ELEVATION 5
// How fast the launcher launches
#define TIME_BETWEEN_LAUNCHES 1
// how many seconds does a launcher have to wait before re-engaging the same target