Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Ballistics - Removed all unnecessary settings #5814

Merged
merged 1 commit into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 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 Expand Up @@ -79,12 +42,4 @@ class ACE_Settings {
value = 0.05;
sliderSettings[] = {0, 0.2, 0.05, 1};
};
class GVAR(simulationRadius) {
category = CSTRING(DisplayName);
displayName = CSTRING(simulationRadius_DisplayName);
description = CSTRING(simulationRadius_Description);
typeName = "SCALAR";
value = 3000;
sliderSettings[] = {0, 3000, 3000, 0};
};
};
38 changes: 0 additions & 38 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(muzzleVelocityVariationEnabled_DisplayName);
description = CSTRING(muzzleVelocityVariationEnabled_Description);
Expand Down Expand Up @@ -79,12 +47,6 @@ class CfgVehicles {
typeName = "NUMBER";
defaultValue = 0.05;
};
class simulationRadius {
displayName = CSTRING(simulationRadius_DisplayName);
description = CSTRING(simulationRadius_Description);
typeName = "NUMBER";
defaultValue = 3000;
};
};
class ModuleDescription {
description = CSTRING(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: 34 additions & 18 deletions addons/advanced_ballistics/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,45 @@ TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectil

if (!(_ammo isKindOf "BulletBase")) exitWith {};
if (!alive _projectile) exitWith {};
if (_unit distance ACE_player > GVAR(simulationRadius)) exitWith {};
if (underwater _unit) exitWith {};

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 _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) + 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 (GVAR(bulletTraceEnabled) && {_muzzleVelocity > BULLET_TRACE_MIN_VELOCITY} && {cameraView == "GUNNER"}) then {
if (currentWeapon ACE_player == binocular ACE_player) exitWith { _abort = false };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a civilian driving a tank could have cameraView gunner and currentWeapon ACE_player == binocular ACE_player (both "")
but I wouldn't worry about it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could check if the player is currently sitting in a vehicle. But then we would need extra code for the spotting scope.

An ideal solution would be to only display the bullet trace if the view is magnified at least 4 times.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can always refine this later, I wouldn't bother changing it for now

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")];
};
};

// Get Weapon and Ammo Configurations
private _AmmoCacheEntry = uiNamespace getVariable format[QGVAR(%1), _ammo];
Expand All @@ -54,7 +77,6 @@ _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;

Expand All @@ -78,14 +100,8 @@ if (GVAR(muzzleVelocityVariationEnabled)) then {
_bulletVelocity = (vectorNormalized _bulletVelocity) vectorMultiply _muzzleVelocity;
_projectile setVelocity _bulletVelocity;

if (_abort) exitWith {
if (missionNamespace getVariable [QEGVAR(windDeflection,enabled), false]) then {
EGVAR(windDeflection,trackedBullets) pushBack [_projectile, getNumber(configFile >> "CfgAmmo" >> _ammo >> "airFriction")];
};
};

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,11 +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);
[_logic, QGVAR(simulationRadius), "simulationRadius"] 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