From d6c9b99a2f835d9bb2fc8697dcb96b4c2b0e0354 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 3 Mar 2024 00:46:03 -0600 Subject: [PATCH] General - Optimize tracer status with `getShotInfo` --- .../functions/fnc_handleFired.sqf | 5 +---- .../nightvision/functions/fnc_onFiredPlayer.sqf | 9 ++------- .../winddeflection/functions/fnc_handleFired.sqf | 15 ++++----------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/addons/advanced_ballistics/functions/fnc_handleFired.sqf b/addons/advanced_ballistics/functions/fnc_handleFired.sqf index b41fd7a7c0..3c1edb77c3 100644 --- a/addons/advanced_ballistics/functions/fnc_handleFired.sqf +++ b/addons/advanced_ballistics/functions/fnc_handleFired.sqf @@ -43,10 +43,7 @@ if (_abort) then { }; if (ACE_player distance _unit > _maxRange && {ACE_player distance ((getPosASL _unit) vectorAdd ((vectorNormalized _bulletVelocity) vectorMultiply _maxRange)) > _maxRange}) exitWith {}; - private _ammoCount = (_unit ammo _muzzle) + 1; - private _tracersEvery = getNumber(configFile >> "CfgMagazines" >> _magazine >> "tracersEvery"); - private _lastRoundsTracer = getNumber(configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer"); - if (_ammoCount <= _lastRoundsTracer || {_tracersEvery > 0 && {(_ammoCount - _lastRoundsTracer) % _tracersEvery == 0}}) exitWith { _abort = false }; + if (_projectile getShotInfo 4) exitWith { _abort = false }; // 4=shownTracer if (GVAR(bulletTraceEnabled) && {_muzzleVelocity > BULLET_TRACE_MIN_VELOCITY} && {cameraView == "GUNNER"}) then { if (currentWeapon ACE_player == binocular ACE_player) exitWith { _abort = false }; diff --git a/addons/nightvision/functions/fnc_onFiredPlayer.sqf b/addons/nightvision/functions/fnc_onFiredPlayer.sqf index 5bc7ff621e..add6bc8be5 100644 --- a/addons/nightvision/functions/fnc_onFiredPlayer.sqf +++ b/addons/nightvision/functions/fnc_onFiredPlayer.sqf @@ -38,16 +38,11 @@ private _visibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFi private _isTracer = call { if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "nvgOnly") > 0) exitWith {false}; - private _indexShot = (_unit ammo _weapon) + 1; - private _lastRoundsTracer = getNumber (configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer"); - if (_indexShot <= _lastRoundsTracer) exitWith {true}; - private _tracersEvery = getNumber (configFile >> "CfgMagazines" >> _magazine >> "tracersEvery"); - if (_tracersEvery == 0) exitWith {false}; - (_indexShot - _lastRoundsTracer) % _tracersEvery == 0 + _projectile getShotInfo 4 // 4=shownTracer }; TRACE_3("",_ammo,_visibleFire,_isTracer); -if ( _isTracer) then { +if (_isTracer) then { _visibleFire = _visibleFire + 2; }; diff --git a/addons/winddeflection/functions/fnc_handleFired.sqf b/addons/winddeflection/functions/fnc_handleFired.sqf index c1b93818f0..5463fd0ef6 100644 --- a/addons/winddeflection/functions/fnc_handleFired.sqf +++ b/addons/winddeflection/functions/fnc_handleFired.sqf @@ -18,18 +18,11 @@ //IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"]; TRACE_10("firedEH:",_unit,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile,_vehicle,_gunner,_turret); -if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false] && {_projectile isKindOf "BulletBase" && {_unit isKindOf "Man"}}) exitWith {false}; +if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false] && {_projectile isKindOf "BulletBase" && {_unit isKindOf "Man"}}) exitWith {}; -if (!((_projectile isKindOf "BulletBase") || {_projectile isKindOf "GrenadeBase"})) exitWith {false}; -if (_unit distance ACE_player > 2000) exitWith {false}; +if (!((_projectile isKindOf "BulletBase") || {_projectile isKindOf "GrenadeBase"})) exitWith {}; +if (_unit distance ACE_player > 2000) exitWith {}; -private _abort = false; -if (!local _unit && {_projectile isKindOf "BulletBase"}) then { - private _ammoCount = (_unit ammo _muzzle) + 1; - private _tracersEvery = getNumber(configFile >> "CfgMagazines" >> _magazine >> "tracersEvery"); - private _lastRoundsTracer = getNumber(configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer"); - _abort = _ammoCount > _lastRoundsTracer && {_tracersEvery == 0 || {(_ammoCount - _lastRoundsTracer) % _tracersEvery != 0}}; -}; -if (_abort) exitWith {false}; +if (!local _unit && {_projectile isKindOf "BulletBase"} && {!(_projectile getShotInfo 4)}) exitWith {}; // 4=shownTracer GVAR(trackedBullets) pushBack [_projectile, getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction")];