Overworked the module settings (WIP)

This commit is contained in:
ulteq 2015-04-12 11:48:21 +02:00
parent 05f14d6242
commit c532742a5b
5 changed files with 100 additions and 25 deletions

View File

@ -1,37 +1,72 @@
class CfgVehicles {
class Module_F;
class GVAR(Module): Module_F {
author = "Ruthberg";
category = "ACE";
displayName = "Advanced Ballistics";
scope = 2;
isGlobal = 1;
displayName = "Advanced Ballistics [ACE]";
icon = QUOTE(PATHTOF(UI\Icon_Module_Wind_ca.paa));
category = "ACE";
function = QUOTE(DFUNC(initModuleSettings));
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
author = "Ruthberg";
class Arguments {
class enabled {
displayName = "Advanced Ballistics";
description = "Enable Advanced Ballistics?";
description = "Enables advanced ballistics";
typeName = "BOOL";
defaultValue = 1;
};
class alwaysSimulateForSnipers {
displayName = "Always Enabled For Snipers";
description = "Always enables advanced ballistics when high power optics are used";
typeName = "BOOL";
defaultValue = 1;
};
class disabledInFullAutoMode {
displayName = "Disabled In FullAuto Mode";
description = "Disables the advanced ballistics during full auto fire";
typeName = "BOOL";
defaultValue = 0;
};
class enableAmmoTemperatureSimulation {
displayName = "Enable Ammo Temperature";
class onlyActiveForLocalPlayers {
displayName = "Disabled For Non Local Players";
description = "Disables the advanced ballistics for bullets coming from other players (enable this if you encounter frame drops during heavy firefights in multiplayer)";
typeName = "BOOL";
defaultValue = 1;
};
/* // 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 ammoTemperatureEnabled {
displayName = "Enable Ammo Temperature Simulation";
description = "Muzzle velocity varies with ammo temperature";
typeName = "BOOL";
defaultValue = 1;
};
class enableBarrelLengthSimulation {
displayName = "Enable Barrel Length";
class barrelLengthInfluenceEnabled {
displayName = "Enable Barrel Length Simulation";
description = "Muzzle velocity varies with barrel length";
typeName = "BOOL";
defaultValue = 1;
};
class enableBulletTraceEffect {
displayName = "Enable Bullet Trace";
description = "Enables the bullet trace effect";
class bulletTraceEnabled {
displayName = "Enable Bullet Trace Effect";
description = "Enables a bullet trace effect to high caliber bullets (only visible when looking through high power optics)";
typeName = "BOOL";
defaultValue = 1;
};
class simulationRadius {
displayName = "Simulation Radius";
description = "Defines the radius (in meters) in which advanced ballistics are applied";
typeName = "NUMBER";
defaultValue = 3000;
};
};
};
};

View File

@ -2,13 +2,16 @@
#include "initKeybinds.sqf"
// AB is disabled by default
GVAR(enabled) = false;
GVAR(enabled) = true;
//GVAR(VehicleGunnerEnabled) = true; // TODO: We currently do not have firedEHs on vehicles
GVAR(AmmoTemperatureEnabled) = true;
GVAR(BarrelLengthInfluenceEnabled) = true;
GVAR(BulletTraceEnabled) = true;
//GVAR(vehicleGunnerEnabled) = true; // TODO: We currently do not have firedEHs on vehicles
GVAR(ammoTemperatureEnabled) = true;
GVAR(barrelLengthInfluenceEnabled) = true;
GVAR(bulletTraceEnabled) = true;
GVAR(onlyActiveForLocalPlayers) = false;
GVAR(disabledInFullAutoMode) = false;
GVAR(alwaysSimulateForSnipers) = true;
GVAR(simulationRadius) = 3000;
GVAR(bulletDatabase) = [];
GVAR(bulletDatabaseStartTime) = [];

View File

@ -13,5 +13,6 @@ PREP(calculateWindSpeed);
PREP(displayProtractor);
PREP(handleFired);
PREP(initializeTerrainExtension);
PREP(initModuleSettings);
ADDON = true;

View File

@ -28,20 +28,22 @@ _ammo = _this select 4;
_magazine = _this select 5;
_bullet = _this select 6;
_abort = false;
if (!hasInterface) exitWith {};
if (!alive _bullet) exitWith {};
if (!GVAR(enabled)) exitWith {};
if (!([_unit] call EFUNC(common,isPlayer))) exitWith {};
if (underwater _unit) exitWith {};
if (!(_ammo isKindOf "BulletBase")) exitWith {};
if (_unit distanceSqr ACE_player > 9000000) exitWith {};
if (GVAR(ONLY_ACTIVE_FOR_LOCAL_PLAYER) && _unit != ACE_player) exitWith {};
//if (!GVAR(VehicleGunnerEnabled) && !(_unit isKindOf "Man")) exitWith {};
if (GVAR(DISABLED_IN_FULL_AUTO_MODE) && getNumber(configFile >> "cfgWeapons" >> _weapon >> _mode >> "autoFire") == 1) exitWith {};
if (_unit distanceSqr ACE_player > GVAR(simulationRadius)) exitWith {};
if (GVAR(onlyActiveForLocalPlayers) && _unit != ACE_player) then { _abort = true; };
//if (!GVAR(vehicleGunnerEnabled) && !(_unit isKindOf "Man")) then { _abort = true; }; // TODO: We currently do not have firedEHs on vehicles
if (GVAR(disabledInFullAutoMode) && getNumber(configFile >> "cfgWeapons" >> _weapon >> _mode >> "autoFire") == 1) then { _abort = true; };
// Decide whether normal winddeflection is good enough
_abort = !(local _unit);
if (_abort) then {
systemChat format["%1, %2, %3", getNumber(configFile >> "cfgWeapons" >> _weapon >> _mode >> "autoFire"), _abort, GVAR(disabledInFullAutoMode)];
if (_abort && alwaysSimulateForSnipers) then {
// The shooter is non local
if (currentWeapon _unit == primaryWeapon _unit && count primaryWeaponItems _unit > 2) then {
_opticsName = (primaryWeaponItems _unit) select 2;
@ -53,6 +55,8 @@ if (_abort) exitWith {
[_bullet, getNumber(configFile >> "cfgAmmo" >> _ammo >> "airFriction")] call EFUNC(winddeflection,updateTrajectoryPFH);
};
systemChat "AB";
_airFriction = getNumber(configFile >> "cfgAmmo" >> _ammo >> "airFriction");
_muzzleVelocity = getNumber(configFile >> "cfgMagazines" >> _magazine >> "initSpeed");
_muzzleVelocityCoef = getNumber(configFile >> "cfgWeapons" >> _weapon >> "initSpeed");

View File

@ -0,0 +1,32 @@
/*
* Author: Glowbal, Ruthberg
* Module for adjusting the advanced ballistics settings
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* None <NIL>
*
* Public: No
*/
#include "script_component.hpp"
private ["_logic", "_units", "_activated"];
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
if !(_activated) exitWith {};
[_logic, QGVAR(enabled), "enabled"] call EFUNC(common,readSettingFromModule);
[_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(onlyActiveForLocalPlayers), "onlyActiveForLocalPlayers"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(disabledInFullAutoMode), "disabledInFullAutoMode"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(alwaysSimulateForSnipers), "alwaysSimulateForSnipers"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(simulationRadius), "simulationRadius"] call EFUNC(common,readSettingFromModule);