From 38c4b1dc8130e0ac5743b63c64fb37f7e848fd9b Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Fri, 19 Feb 2016 00:45:00 -0300 Subject: [PATCH 1/3] Add a diagnose script to detect incompatibilities between vanilla and ab initial velocities --- addons/advanced_ballistics/XEH_postInit.sqf | 4 ++ addons/advanced_ballistics/XEH_preInit.sqf | 1 + .../functions/fnc_diagnoseWeapons.sqf | 59 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf diff --git a/addons/advanced_ballistics/XEH_postInit.sqf b/addons/advanced_ballistics/XEH_postInit.sqf index 20c0622eac..498006d83e 100644 --- a/addons/advanced_ballistics/XEH_postInit.sqf +++ b/addons/advanced_ballistics/XEH_postInit.sqf @@ -36,3 +36,7 @@ if (!hasInterface) exitWith {}; [] call FUNC(updateTrajectoryPFH); }] call EFUNC(common,addEventHandler); + +#ifdef DEBUG_MODE_FULL + call FUNC(diagnoseWeapons); +#endif \ No newline at end of file diff --git a/addons/advanced_ballistics/XEH_preInit.sqf b/addons/advanced_ballistics/XEH_preInit.sqf index f722d9c573..1404f08bc0 100644 --- a/addons/advanced_ballistics/XEH_preInit.sqf +++ b/addons/advanced_ballistics/XEH_preInit.sqf @@ -7,6 +7,7 @@ PREP(calculateAtmosphericCorrection); PREP(calculateBarrelLengthVelocityShift); PREP(calculateRetardation); PREP(calculateStabilityFactor); +PREP(diagnoseWeapons); PREP(displayProtractor); PREP(handleFired); PREP(initializeTerrainExtension); diff --git a/addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf b/addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf new file mode 100644 index 0000000000..4d344e8bfe --- /dev/null +++ b/addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf @@ -0,0 +1,59 @@ +/* + * Author: esteldunedain + * + * This function diagnoses all primary weapons to find cases in which the initial + * velocity of shots with and without AB significantly mismatch + * + * Arguments: + * None. Parameters inherited from EFUNC(common,firedEH) + * + * Return Value: + * None + * + * Public: No + */ +#define DEBUG_MODE_FULL +#include "script_component.hpp" + +private _cfgWeapons = configFile >> "CfgWeapons"; +for "_i" from 0 to (count _cfgWeapons)-1 do { + private _weaponConfig = _cfgWeapons select _i; + if (isClass _weaponConfig) then { + private _weapon = configName _weaponConfig; + private _weaponType = getNumber (_weaponConfig >> "Type"); + if (_weaponType == 1) then { + // The weapon is a primary weapon + + private _weaponInitSpeed = getNumber (_weaponConfig >> "initSpeed"); + private _magazines = getArray (_weaponConfig >> "magazines"); + { + private _magazine = _x; + private _magazineInitSpeed = getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed"); + private _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo"); + + // Vanilla initial speed -------------------------- + private _vanillaInitialSpeed = _magazineInitSpeed; + if (_weaponInitSpeed > 0) then { + _vanillaInitialSpeed = _weaponInitSpeed; + } else { + if (_weaponInitSpeed < 0) then { + _vanillaInitialSpeed = _vanillaInitialSpeed * (-_weaponInitSpeed); + }; + }; + // -------------------------------------------------- + + // AB initial speed -------------------------------- + // Get Weapon and Ammo Configurations + private _AmmoCacheEntry = _ammo call FUNC(readAmmoDataFromConfig); + private _WeaponCacheEntry = _weapon call FUNC(readWeaponDataFromConfig); + _AmmoCacheEntry params ["_airFriction", "_caliber", "_bulletLength", "_bulletMass", "_transonicStabilityCoef", "_dragModel", "_ballisticCoefficients", "_velocityBoundaries", "_atmosphereModel", "_ammoTempMuzzleVelocityShifts", "_muzzleVelocityTable", "_barrelLengthTable"]; + _WeaponCacheEntry params ["_barrelTwist", "_twistDirection", "_barrelLength"]; + + private _barrelVelocityShift = [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, _vanillaInitialSpeed] call FUNC(calculateBarrelLengthVelocityShift); + private _abInitialSpeed = _vanillaInitialSpeed + _barrelVelocityShift; + // -------------------------------------------------- + diag_log text format ["ABDiagnose,%1,%2,%3,%4,%5,%6,%7",_weapon,_magazine,_ammo,_magazineInitSpeed,_weaponInitSpeed,_vanillaInitialSpeed,_abInitialSpeed]; + } forEach _magazines; + }; + }; +}; From eac26fc2394942a379c3fb8b1a6e38a34053624e Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Fri, 19 Feb 2016 00:46:31 -0300 Subject: [PATCH 2/3] Fix subsonic ammo from RHS that incorrectly inherit barrel length coefficients from supersonic ammo. Fix #3320 --- optionals/compat_rhs_afrf3/CfgAmmo.hpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/optionals/compat_rhs_afrf3/CfgAmmo.hpp b/optionals/compat_rhs_afrf3/CfgAmmo.hpp index 2444da41cf..b462b2d749 100644 --- a/optionals/compat_rhs_afrf3/CfgAmmo.hpp +++ b/optionals/compat_rhs_afrf3/CfgAmmo.hpp @@ -112,11 +112,30 @@ class CfgAmmo { ACE_muzzleVelocities[]={298, 330, 350}; ACE_barrelLengths[]={96.52, 127.0, 228.6}; }; + class rhs_B_545x39_7U1_Ball: rhs_B_545x39_Ball { + // @todo: Provide _barrelLengths coefficients for this subsonic ammo + // In the meantime, prevent it inheriting from its supersonic parent + ACE_muzzleVelocities[]={}; + ACE_barrelLengths[]={}; + }; + class rhs_B_9x39_SP5: rhs_B_762x39_Ball { + // @todo: Provide _barrelLengths coefficients for this subsonic ammo + // In the meantime, prevent it inheriting from its supersonic parent + ACE_muzzleVelocities[]={}; + ACE_barrelLengths[]={}; + }; + class rhs_B_762x39_U_Ball: rhs_B_762x39_Ball { + // @todo: Provide _barrelLengths coefficients for this subsonic ammo + // In the meantime, prevent it inheriting from its supersonic parent + ACE_muzzleVelocities[]={}; + ACE_barrelLengths[]={}; + }; + class SubmunitionBase; class rhs_ammo_127x108mm_x5: SubmunitionBase { ACE_rearm_caliber=13; }; - + class GrenadeHand; class rhs_ammo_rgd5: GrenadeHand { ace_frag_enabled = 1; @@ -153,7 +172,7 @@ class CfgAmmo { class rhs_ammo_fakels: rhs_ammo_fakel {}; class rhs_ammo_zarya2: rhs_ammo_fakels {}; class rhs_ammo_plamyam: rhs_ammo_fakels {}; - + class RocketBase; class R_PG32V_F: RocketBase {}; class rhs_rpg26_rocket: R_PG32V_F {}; From 4f62e5600403d9a2307b22df3ff20f04eb4df9aa Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Sat, 20 Feb 2016 17:05:47 -0300 Subject: [PATCH 3/3] Unify the changes of #3130 and #3343 --- optionals/compat_rhs_afrf3/CfgAmmo.hpp | 37 +++++++++++--------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/optionals/compat_rhs_afrf3/CfgAmmo.hpp b/optionals/compat_rhs_afrf3/CfgAmmo.hpp index ec86457700..ead78866c1 100644 --- a/optionals/compat_rhs_afrf3/CfgAmmo.hpp +++ b/optionals/compat_rhs_afrf3/CfgAmmo.hpp @@ -14,12 +14,6 @@ class CfgAmmo { ACE_muzzleVelocities[]={780, 880, 920}; ACE_barrelLengths[]={254.0, 414.02, 508.0}; }; - class rhs_B_545x39_7U1_Ball: rhs_B_545x39_Ball { - //Subsonic - ToDo need full config for this bullet - ACE_ammoTempMuzzleVelocityShifts[]={-8.85,-8.49,-7.61667,-6.70667,-5.66,-4.26667,-2.54667,-0.51,1.98667,5.05667,8.73}; //Just Scaled Down Normal? - ACE_muzzleVelocities[] = {303}; - ACE_barrelLengths[] = {200}; - }; class rhs_B_545x39_Ball_Tracer_Green: rhs_B_545x39_Ball { ACE_caliber=5.588; ACE_bulletLength=21.59; @@ -81,12 +75,6 @@ class CfgAmmo { ACE_muzzleVelocities[]={650, 716, 750}; ACE_barrelLengths[]={254.0, 414.02, 508.0}; }; - class rhs_B_762x39_U_Ball: rhs_B_762x39_Ball { - //Subsonic - ToDo need full config for this bullet - ACE_ammoTempMuzzleVelocityShifts[]={-8.85,-8.49,-7.61667,-6.70667,-5.66,-4.26667,-2.54667,-0.51,1.98667,5.05667,8.73}; //Just Scaled Down Normal? - ACE_muzzleVelocities[] = {295}; - ACE_barrelLengths[] = {414}; - }; class rhs_B_762x39_Tracer: rhs_B_762x39_Ball { ACE_caliber=7.823; ACE_bulletLength=28.956; @@ -125,20 +113,25 @@ class CfgAmmo { ACE_barrelLengths[]={96.52, 127.0, 228.6}; }; class rhs_B_545x39_7U1_Ball: rhs_B_545x39_Ball { - // @todo: Provide _barrelLengths coefficients for this subsonic ammo + // @todo: Provide accurate coefficients for this subsonic ammo // In the meantime, prevent it inheriting from its supersonic parent - ACE_muzzleVelocities[]={}; - ACE_barrelLengths[]={}; - }; - class rhs_B_9x39_SP5: rhs_B_762x39_Ball { - // @todo: Provide _barrelLengths coefficients for this subsonic ammo - // In the meantime, prevent it inheriting from its supersonic parent - ACE_muzzleVelocities[]={}; - ACE_barrelLengths[]={}; + // ammoTempMuzzleVelocityShifts scaled down from normal + ACE_ammoTempMuzzleVelocityShifts[]={-8.85,-8.49,-7.61667,-6.70667,-5.66,-4.26667,-2.54667,-0.51,1.98667,5.05667,8.73}; + ACE_muzzleVelocities[] = {}; + ACE_barrelLengths[] = {}; }; class rhs_B_762x39_U_Ball: rhs_B_762x39_Ball { - // @todo: Provide _barrelLengths coefficients for this subsonic ammo + // @todo: Provide accurate coefficients for this subsonic ammo // In the meantime, prevent it inheriting from its supersonic parent + // ammoTempMuzzleVelocityShifts scaled down from normal + ACE_ammoTempMuzzleVelocityShifts[]={-8.85,-8.49,-7.61667,-6.70667,-5.66,-4.26667,-2.54667,-0.51,1.98667,5.05667,8.73}; //Just Scaled Down Normal? + ACE_muzzleVelocities[] = {}; + ACE_barrelLengths[] = {}; + }; + class rhs_B_9x39_SP5: rhs_B_762x39_Ball { + // @todo: Provide accurate coefficients for this subsonic ammo + // In the meantime, prevent it inheriting from its supersonic parent + ACE_ammoTempMuzzleVelocityShifts[]={}; ACE_muzzleVelocities[]={}; ACE_barrelLengths[]={}; };