diff --git a/addons/advanced_ballistics/ACE_Settings.hpp b/addons/advanced_ballistics/ACE_Settings.hpp index 2ea314915a7..9a5d9a9c3aa 100644 --- a/addons/advanced_ballistics/ACE_Settings.hpp +++ b/addons/advanced_ballistics/ACE_Settings.hpp @@ -79,12 +79,4 @@ class ACE_Settings { value = 0.05; sliderSettings[] = {0, 0.2, 0.05, 1}; }; - class GVAR(simulationRadius) { - category = CSTRING(DisplayName); - displayName = CSTRING(simulationRadius_DisplayName); - description = CSTRING(simulationRadius_Description); - typeName = "SCALAR"; - value = 3000; - sliderSettings[] = {0, 3000, 3000, 0}; - }; }; diff --git a/addons/advanced_ballistics/CfgVehicles.hpp b/addons/advanced_ballistics/CfgVehicles.hpp index 8f81b53001f..4ba1d8ac126 100644 --- a/addons/advanced_ballistics/CfgVehicles.hpp +++ b/addons/advanced_ballistics/CfgVehicles.hpp @@ -79,12 +79,6 @@ class CfgVehicles { typeName = "NUMBER"; defaultValue = 0.05; }; - class simulationRadius { - displayName = CSTRING(simulationRadius_DisplayName); - description = CSTRING(simulationRadius_Description); - typeName = "NUMBER"; - defaultValue = 3000; - }; }; class ModuleDescription { description = CSTRING(Description); diff --git a/addons/advanced_ballistics/functions/fnc_handleFired.sqf b/addons/advanced_ballistics/functions/fnc_handleFired.sqf index ec284759f5d..8c4fc28ec36 100644 --- a/addons/advanced_ballistics/functions/fnc_handleFired.sqf +++ b/addons/advanced_ballistics/functions/fnc_handleFired.sqf @@ -21,9 +21,19 @@ TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectil if (!(_ammo isKindOf "BulletBase")) exitWith {}; if (!alive _projectile) exitWith {}; -if (_unit distance ACE_player > GVAR(simulationRadius)) exitWith {}; if (underwater _unit) exitWith {}; +private _bulletVelocity = velocity _projectile; +private _muzzleVelocity = vectorMagnitude _bulletVelocity; +private _airFriction = getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction"); +private _timeToLive = getNumber(configFile >> "CfgAmmo" >> _ammo >> "timeToLive"); +private _maxRange = if (_airFriction < 0) then { + -ln(1 - _airFriction * _muzzleVelocity * _timeToLive) / _airFriction +} else { + _muzzleVelocity * _timeToLive +}; +if (_unit distance ACE_player > _maxRange) exitWith {}; + private _abort = GVAR(disabledInFullAutoMode) && {!local _unit && {getNumber(configFile >> "CfgWeapons" >> _weapon >> _mode >> "autoFire") == 1}}; if (!local _unit && {!_abort && !GVAR(simulateForEveryone)}) then { // The shooter is non local -> abort unless we match an exception rule @@ -37,6 +47,11 @@ if (!local _unit && {!_abort && !GVAR(simulateForEveryone)}) then { }; }; //if (!GVAR(vehicleGunnerEnabled) && !(_unit isKindOf "Man")) then { _abort = true; }; // We currently do not have firedEHs on vehicles +if (_abort) exitWith { + if (missionNamespace getVariable [QEGVAR(windDeflection,enabled), false]) then { + EGVAR(windDeflection,trackedBullets) pushBack [_projectile, getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction")]; + }; +}; // Get Weapon and Ammo Configurations private _AmmoCacheEntry = uiNamespace getVariable format[QGVAR(%1), _ammo]; @@ -55,9 +70,6 @@ private _temperature = nil; // We need the variable in this scope. So we need to private _ammoCount = _unit ammo _muzzle; -private _bulletVelocity = velocity _projectile; -private _muzzleVelocity = vectorMagnitude _bulletVelocity; - if (GVAR(barrelLengthInfluenceEnabled)) then { _muzzleVelocity = _muzzleVelocity + ([_barrelLength, _muzzleVelocityTable, _barrelLengthTable, _muzzleVelocity] call FUNC(calculateBarrelLengthVelocityShift)); }; @@ -78,12 +90,6 @@ if (GVAR(muzzleVelocityVariationEnabled)) then { _bulletVelocity = (vectorNormalized _bulletVelocity) vectorMultiply _muzzleVelocity; _projectile setVelocity _bulletVelocity; -if (_abort) exitWith { - if (missionNamespace getVariable [QEGVAR(windDeflection,enabled), false]) then { - EGVAR(windDeflection,trackedBullets) pushBack [_projectile, getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction")]; - }; -}; - private _bulletTraceVisible = false; if (GVAR(bulletTraceEnabled) && cameraView == "GUNNER") then { if (currentWeapon ACE_player == binocular ACE_player) then { diff --git a/addons/advanced_ballistics/functions/fnc_initModuleSettings.sqf b/addons/advanced_ballistics/functions/fnc_initModuleSettings.sqf index ce3c51add26..51e170f8203 100644 --- a/addons/advanced_ballistics/functions/fnc_initModuleSettings.sqf +++ b/addons/advanced_ballistics/functions/fnc_initModuleSettings.sqf @@ -31,6 +31,5 @@ if !(_activated) exitWith {}; [_logic, QGVAR(simulateForSnipers), "simulateForSnipers"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(simulateForGroupMembers), "simulateForGroupMembers"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(simulationInterval), "simulationInterval"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(simulationRadius), "simulationRadius"] call EFUNC(common,readSettingFromModule); GVAR(simulationInterval) = 0 max GVAR(simulationInterval) min 0.2;