From 3778747a0363e5a85c39e61a0d35e92a38da7ba3 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:43:59 +0200 Subject: [PATCH] Artillerytables - Fix `Low` shots & bad params (#10325) * Fix direct fire not showing in tables * Fix parameters * Update simulate.rs --- addons/artillerytables/functions/fnc_adjustFire.sqf | 2 +- extension/src/artillery/simulate.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/artillerytables/functions/fnc_adjustFire.sqf b/addons/artillerytables/functions/fnc_adjustFire.sqf index 96c884880da..1e07c5ca212 100644 --- a/addons/artillerytables/functions/fnc_adjustFire.sqf +++ b/addons/artillerytables/functions/fnc_adjustFire.sqf @@ -36,6 +36,6 @@ params ["_gunPos", "_targetPos", "_adjustEast", "_adjustNorth", "_adjustUp", "_m private _resultPos = [_adjustEast + _targetPos select 0, _adjustNorth + _targetPos select 1, _adjustUp + _targetPos select 2]; -private _returns = ["_gunPos", "_resultPos", "_muzzleVelocity", "_highAngle", "_airFriction", "_temperature", "_airDensity", "_windDir", "_windSpeed"] call FUNC(calculateSolution); +private _returns = [_gunPos, _resultPos, _muzzleVelocity, _highAngle, _airFriction, _temperature, _airDensity, _windDir, _windSpeed] call FUNC(calculateSolution); _returns diff --git a/extension/src/artillery/simulate.rs b/extension/src/artillery/simulate.rs index b776a831cfe..2201d4d2ec9 100644 --- a/extension/src/artillery/simulate.rs +++ b/extension/src/artillery/simulate.rs @@ -71,8 +71,13 @@ pub fn find_solution( return (-1.0, -1.0, -1.0); } let radicand = radicand.sqrt(); - let angle_root = + let mut angle_root = (muzzle_velocity.mul_add(*muzzle_velocity, radicand) / (GRAVITY * range_to_hit)).atan(); + if angle_root > max_elev || angle_root < min_elev { + angle_root = (muzzle_velocity.mul_add(*muzzle_velocity, -radicand) + / (GRAVITY * range_to_hit)) + .atan(); + } if angle_root > max_elev || angle_root < min_elev { return (-1.0, -1.0, -1.0); }