From aed2222b8159dbfbea00526169fd8fa85870ee6b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 22 Jun 2024 22:34:34 -0500 Subject: [PATCH] Artillery Tables - Support for ammo that has native `airFriction` (#10059) * Artillery Tables - Support for ammo that has native `airFriction` * fix comment Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/artillerytables/functions/fnc_rangeTableOpen.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * replace if block with select const Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- .../artillerytables/functions/fnc_firedEH.sqf | 3 +- .../functions/fnc_rangeTableOpen.sqf | 11 +++++- .../framework/artillery-tables-framework.md | 38 +++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 docs/wiki/framework/artillery-tables-framework.md diff --git a/addons/artillerytables/functions/fnc_firedEH.sqf b/addons/artillerytables/functions/fnc_firedEH.sqf index f735c4c9615..5aa46c69690 100644 --- a/addons/artillerytables/functions/fnc_firedEH.sqf +++ b/addons/artillerytables/functions/fnc_firedEH.sqf @@ -35,7 +35,7 @@ if (isNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(airFriction))) _airFriction = getNumber (configFile >> "CfgMagazines" >> _magazine >> QGVAR(airFriction)); }; TRACE_1("",_airFriction); -if (_airFriction >= 0) exitWith {}; // 0 disables everything, >0 makes no sense +if (_airFriction == 0) exitWith {}; // 0 disables everything BEGIN_COUNTER(adjustmentsCalc); @@ -60,6 +60,7 @@ if (_newMuzzleVelocityCoefficent != 1) then { _projectile setVelocity _bulletVelocity; }; +if (_airFriction > 0) exitWith {}; // positive value indicates it has vanilla airFriction, so we can just exit [{ params ["_projectile", "_kFactor", "_time"]; diff --git a/addons/artillerytables/functions/fnc_rangeTableOpen.sqf b/addons/artillerytables/functions/fnc_rangeTableOpen.sqf index 327a2903a05..508b8c894ce 100644 --- a/addons/artillerytables/functions/fnc_rangeTableOpen.sqf +++ b/addons/artillerytables/functions/fnc_rangeTableOpen.sqf @@ -41,8 +41,15 @@ _mags = _mags apply { private _initSpeed = getNumber (_magCfg >> _x >> "initSpeed"); _magParamsArray pushBackUnique _initSpeed; private _airFriction = 0; - if (_advCorrection) then { - _airFriction = if (isNumber (_magCfg >> _x >> QGVAR(airFriction))) then { getNumber (_magCfg >> _x >> QGVAR(airFriction)) } else { DEFAULT_AIR_FRICTION }; + private _magAirFriction = getNumber (_magCfg >> _x >> QGVAR(airFriction)); + if (_magAirFriction <= 0) then { + if (_advCorrection) then { + _airFriction = [DEFAULT_AIR_FRICTION, _magAirFriction] select (isNumber (_magCfg >> _x >> QGVAR(airFriction))); + }; + } else { + // positive value, use ammo's airFriction (regardless of setting) + private _ammo = getText (_magCfg >> _x >> "ammo"); + _airFriction = getNumber (configFile >> "CfgAmmo" >> _ammo >> "airFriction"); }; _magParamsArray pushBackUnique _airFriction; [getText (_magCfg >> _x >> "displayNameShort"), getText (_magCfg >> _x >> "displayName"), _initSpeed, _airFriction] diff --git a/docs/wiki/framework/artillery-tables-framework.md b/docs/wiki/framework/artillery-tables-framework.md new file mode 100644 index 00000000000..be2adb33317 --- /dev/null +++ b/docs/wiki/framework/artillery-tables-framework.md @@ -0,0 +1,38 @@ +--- +layout: wiki +title: Artillery Tables +description: Explains the configs for artillery tables. +group: framework +parent: wiki +mod: ace +version: + major: 3 + minor: 13 + patch: 0 +--- + +## 1. Magazine Configs + +```cpp +class CfgMagazines { + class yourMag { + ace_artillerytables_airFriction = -0.00006; // default value + // drag coefficent (when Air Resistance setting is enabled) + // can set to 0 to disable all muzzle effects and airFriction + // can set to +1 to use the ammo's native airFriction (not common, as most artillery ammo will have none) +``` + +## 2. Vehicle Configs + +```cpp +class CfgVehicles { + class yourVic { + ace_artillerytables_showRangetable = 1; // [0 disabled, 1 enabled] falls back to artilleryScanner + // Show rangetable for this vehicle + + ace_artillerytables_showGunLaying = 1; // [0 disabled, 1 enabled, 2 enabled w/ alt elevationMode] falls back to artilleryScanner + // Shows gun laying info (elev/azimuth) + + ace_artillerytables_applyCorrections = 1; // [0 disabled, 1 enabled] falls back to artilleryScanner + // Apply advanced corrections (when setting enabled) +```