Skip to content

Commit

Permalink
Advanced Ballistics - Removed all unnecessary settings
Browse files Browse the repository at this point in the history
* It just works automagically
  • Loading branch information
ulteq committed Nov 24, 2017
1 parent f7d91a8 commit b6f31b2
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 257 deletions.
37 changes: 0 additions & 37 deletions addons/advanced_ballistics/ACE_Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,6 @@ class ACE_Settings {
typeName = "BOOL";
value = 0;
};
class GVAR(simulateForSnipers) {
category = CSTRING(DisplayName);
displayName = CSTRING(simulateForSnipers_DisplayName);
description = CSTRING(simulateForSnipers_Description);
typeName = "BOOL";
value = 1;
};
class GVAR(simulateForGroupMembers) {
category = CSTRING(DisplayName);
displayName = CSTRING(simulateForGroupMembers_DisplayName);
description = CSTRING(simulateForGroupMembers_Description);
typeName = "BOOL";
value = 0;
};
class GVAR(simulateForEveryone) {
category = CSTRING(DisplayName);
displayName = CSTRING(simulateForEveryone_DisplayName);
description = CSTRING(simulateForEveryone_Description);
typeName = "BOOL";
value = 0;
};
class GVAR(disabledInFullAutoMode) {
category = CSTRING(DisplayName);
displayName = CSTRING(disabledInFullAutoMod_DisplayName);
description = CSTRING(disabledInFullAutoMod_Description);
typeName = "BOOL";
value = 0;
};
/* // TODO: We currently do not have firedEHs on vehicles
class GVAR(vehicleGunnerEnabled) {
category = CSTRING(DisplayName);
displayName = "Enabled For Vehicle Gunners";
description = "Enables advanced ballistics for vehicle gunners";
typeName = "BOOL";
value = 0;
};
*/
class GVAR(muzzleVelocityVariationEnabled) {
category = CSTRING(DisplayName);
displayName = CSTRING(muzzleVelocityVariationEnabled_DisplayName);
Expand Down
32 changes: 0 additions & 32 deletions addons/advanced_ballistics/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,6 @@ class CfgVehicles {
typeName = "BOOL";
defaultValue = 0;
};
class simulateForSnipers {
displayName = CSTRING(simulateForSnipers_DisplayName);
description = CSTRING(simulateForSnipers_Description);
typeName = "BOOL";
defaultValue = 1;
};
class simulateForGroupMembers {
displayName = CSTRING(simulateForGroupMembers_DisplayName);
description = CSTRING(simulateForGroupMembers_Description);
typeName = "BOOL";
defaultValue = 0;
};
class simulateForEveryone {
displayName = CSTRING(simulateForEveryone_DisplayName);
description = CSTRING(simulateForEveryone_Description);
typeName = "BOOL";
defaultValue = 0;
};
class disabledInFullAutoMode {
displayName = CSTRING(disabledInFullAutoMod_DisplayName);
description = CSTRING(disabledInFullAutoMod_Description);
typeName = "BOOL";
defaultValue = 0;
};
/* // TODO: We currently do not have firedEHs on vehicles
class vehicleGunnerEnabled {
displayName = "Enabled For Vehicle Gunners";
description = "Enables advanced ballistics for vehicle gunners";
typeName = "BOOL";
defaultValue = 0;
};
*/
class muzzleVelocityVariationEnabled {
displayName = CSTRING(muzzleVelocityVariation_DisplayName);
description = CSTRING(muzzleVelocityVariation_Description);
Expand Down
2 changes: 1 addition & 1 deletion addons/advanced_ballistics/functions/fnc_handleFirePFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
private _bulletVelocity = velocity _bullet;
private _bulletPosition = getPosASL _bullet;

if (_bulletTraceVisible && {vectorMagnitude _bulletVelocity > 500}) then {
if (_bulletTraceVisible && {vectorMagnitude _bulletVelocity > BULLET_TRACE_MIN_VELOCITY}) 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
52 changes: 31 additions & 21 deletions addons/advanced_ballistics/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,38 @@ if (!(_ammo isKindOf "BulletBase")) exitWith {};
if (!alive _projectile) 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
_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 _abort = !local _unit;
if (_abort) then {
private _bulletVelocity = velocity _projectile;
private _muzzleVelocity = vectorMagnitude _bulletVelocity;

private _maxRange = uiNamespace getVariable format[QGVAR(maxRange_%1), _ammo];
if (isNil "_maxRange") then {
private _airFriction = getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction");
private _maxTime = ((_muzzleVelocity - BULLET_TRACE_MIN_VELOCITY) / (BULLET_TRACE_MIN_VELOCITY * -_airFriction * _muzzleVelocity)) max getNumber(configFile >> "CfgAmmo" >> _ammo >> "tracerEndTime");
private _maxRange = if (_airFriction < 0) then {
-ln(1 - _airFriction * _muzzleVelocity * _maxTime) / _airFriction
} else {
_muzzleVelocity * _maxTime
};
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 {};

private _ammoCount = _unit ammo _muzzle;
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 (GVAR(bulletTraceEnabled) && {_muzzleVelocity > BULLET_TRACE_MIN_VELOCITY} && {cameraView == "GUNNER"}) then {
if (currentWeapon ACE_player == binocular ACE_player) exitWith { _abort = false };
if (currentWeapon ACE_player == primaryWeapon ACE_player && {count primaryWeaponItems ACE_player > 2}) then {
private _opticsName = (primaryWeaponItems ACE_player) 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 (_opticType == 2) exitWith { _abort = false };
};
};
};
//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")];
Expand All @@ -69,6 +77,8 @@ _WeaponCacheEntry params ["_barrelTwist", "_twistDirection", "_barrelLength"];
private _temperature = nil; // We need the variable in this scope. So we need to init it here.

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));
Expand All @@ -91,7 +101,7 @@ _bulletVelocity = (vectorNormalized _bulletVelocity) vectorMultiply _muzzleVeloc
_projectile setVelocity _bulletVelocity;

private _bulletTraceVisible = false;
if (GVAR(bulletTraceEnabled) && cameraView == "GUNNER") then {
if (GVAR(bulletTraceEnabled) && {_muzzleVelocity > BULLET_TRACE_MIN_VELOCITY} && {cameraView == "GUNNER"}) then {
if (currentWeapon ACE_player == binocular ACE_player) then {
_bulletTraceVisible = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ if !(_activated) exitWith {};
[_logic, QGVAR(ammoTemperatureEnabled), "ammoTemperatureEnabled"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(barrelLengthInfluenceEnabled), "barrelLengthInfluenceEnabled"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(bulletTraceEnabled), "bulletTraceEnabled"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(simulateForEveryone), "simulateForEveryone"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(disabledInFullAutoMode), "disabledInFullAutoMode"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(simulateForSnipers), "simulateForSnipers"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(simulateForGroupMembers), "simulateForGroupMembers"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(simulationInterval), "simulationInterval"] call EFUNC(common,readSettingFromModule);

GVAR(simulationInterval) = 0 max GVAR(simulationInterval) min 0.2;
2 changes: 2 additions & 0 deletions addons/advanced_ballistics/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@
// Standard deviation of the default muzzle velocity variation (0.3%)
#define DEFAULT_MUZZLE_VELOCITY_VARIATION_SD 0.003

#define BULLET_TRACE_MIN_VELOCITY 500

#define EXTENSION_REQUIRED_VERSION "1.0"
Loading

0 comments on commit b6f31b2

Please sign in to comment.