Skip to content

Commit

Permalink
Advanced Ballistics - Fix _maxRange in handleFired (acemod#8552)
Browse files Browse the repository at this point in the history
* AdvBallistics - Fix _maxRange in `handleFired`

* Adding 30% more to range just to be safe
  • Loading branch information
PabstMirror authored and AndreasBrostrom committed Dec 3, 2021
1 parent cbebe8a commit 549a5c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/advanced_ballistics/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ if (_abort) then {
private _maxRange = uiNamespace getVariable format[QGVAR(maxRange_%1), _ammo];
if (isNil "_maxRange") then {
private _airFriction = getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction");
private _maxRange = if (_airFriction < 0) then {
private _vanillaInitialSpeed = getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
_maxRange = if (_airFriction < 0) then {
private _maxTime = ((_vanillaInitialSpeed - BULLET_TRACE_MIN_VELOCITY) / (BULLET_TRACE_MIN_VELOCITY * -_airFriction * _vanillaInitialSpeed)) max getNumber(configFile >> "CfgAmmo" >> _ammo >> "tracerEndTime");
-ln(1 - _airFriction * _vanillaInitialSpeed * _maxTime) / _airFriction
} else {
_vanillaInitialSpeed * getNumber(configFile >> "CfgAmmo" >> _ammo >> "tracerEndTime")
};
_maxRange = _maxRange * 1.3; // Adding 30% more to range just to be safe
uiNamespace setVariable [format[QGVAR(maxRange_%1), _ammo], _maxRange];
};
if (ACE_player distance _unit > _maxRange && {ACE_player distance ((getPosASL _unit) vectorAdd ((vectorNormalized _bulletVelocity) vectorMultiply _maxRange)) > _maxRange}) exitWith {};
Expand Down

0 comments on commit 549a5c5

Please sign in to comment.