Skip to content

Commit

Permalink
Advanced Ballistics - Optimized abort conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ulteq committed Nov 23, 2017
1 parent 5ee1df4 commit 8137d36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
9 changes: 3 additions & 6 deletions addons/advanced_ballistics/functions/fnc_handleFirePFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
{
_x params ["_bullet","_caliber","_bulletTraceVisible","_index"];

private _bulletVelocity = velocity _bullet;

private _bulletSpeed = vectorMagnitude _bulletVelocity;

if (!alive _bullet || _bulletSpeed < 100) then {
if (!alive _bullet) then {
GVAR(allBullets) deleteAt (GVAR(allBullets) find _x);
} else {
private _bulletVelocity = velocity _bullet;
private _bulletPosition = getPosASL _bullet;

if (_bulletTraceVisible && _bulletSpeed > 500) then {
if (_bulletTraceVisible && {vectorMagnitude _bulletVelocity > 500}) then {
drop ["\A3\data_f\ParticleEffects\Universal\Refract","","Billboard",1,0.1,getPos _bullet,[0,0,0],0,1.275,1,0,[0.02*_caliber,0.01*_caliber],[[0,0,0,0.65],[0,0,0,0.2]],[1,0],0,0,"","",""];
};

Expand Down
16 changes: 6 additions & 10 deletions addons/advanced_ballistics/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,24 @@
//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);

private _abort = false;

if (!(_ammo isKindOf "BulletBase")) exitWith {};
if (!alive _projectile) exitWith {};
if (_unit distance ACE_player > GVAR(simulationRadius)) exitWith {};
if (underwater _unit) exitWith {};
if (!GVAR(simulateForEveryone) && !(local _unit)) then {
// The shooter is non local
_abort = true;
if (GVAR(simulateForSnipers)) then {

private _abort = GVAR(disabledInFullAutoMode) && {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
_abort = !GVAR(simulateForGroupMembers) || {group ACE_player != group _unit};
if (_abort && GVAR(simulateForSnipers)) then {
if (currentWeapon _unit == primaryWeapon _unit && count primaryWeaponItems _unit > 2) then {
private _opticsName = (primaryWeaponItems _unit) select 2;
private _opticType = getNumber(configFile >> "CfgWeapons" >> _opticsName >> "ItemInfo" >> "opticType");
_abort = _opticType != 2; // We only abort if the non local shooter is not a sniper
};
};
if (GVAR(simulateForGroupMembers) && _abort) then {
_abort = (group ACE_player) != (group _unit);
};
};
//if (!GVAR(vehicleGunnerEnabled) && !(_unit isKindOf "Man")) then { _abort = true; }; // We currently do not have firedEHs on vehicles
if (GVAR(disabledInFullAutoMode) && getNumber(configFile >> "CfgWeapons" >> _weapon >> _mode >> "autoFire") == 1) then { _abort = true; };

// Get Weapon and Ammo Configurations
private _AmmoCacheEntry = uiNamespace getVariable format[QGVAR(%1), _ammo];
Expand Down

0 comments on commit 8137d36

Please sign in to comment.