Skip to content

Commit

Permalink
General - Optimize tracer status with getShotInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Mar 3, 2024
1 parent 64538f2 commit d6c9b99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
5 changes: 1 addition & 4 deletions addons/advanced_ballistics/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
9 changes: 2 additions & 7 deletions addons/nightvision/functions/fnc_onFiredPlayer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
15 changes: 4 additions & 11 deletions addons/winddeflection/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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")];

0 comments on commit d6c9b99

Please sign in to comment.