Scopes - Take rail base angle into account

* Removes fixed angular offsets from the zero angle calculation
This commit is contained in:
ulteq 2017-11-12 12:12:49 +01:00
parent 6b68ff426f
commit 224e2cb777
8 changed files with 46 additions and 4 deletions

View File

@ -255,6 +255,7 @@ class CfgWeapons {
class pdw2000_base_F: Rifle_Short_Base_F {
ACE_RailHeightAboveBore = 3.08883;
ACE_RailBaseAngle = 0.019366;
};
class arifle_AKS_base_F: Rifle_Base_F {
@ -307,12 +308,15 @@ class CfgWeapons {
class SMG_01_Base: Rifle_Short_Base_F {
ACE_RailHeightAboveBore = 4.85355;
ACE_RailBaseAngle = 0.0250956;
};
class SMG_02_base_F: Rifle_Short_Base_F {
ACE_RailHeightAboveBore = 4.41831;
ACE_RailBaseAngle = 0.0217724;
};
class SMG_05_base_F: Rifle_Short_Base_F {
ACE_RailHeightAboveBore = 4.05169;
ACE_RailBaseAngle = 0.019366;
};
class Tavor_base_F: Rifle_Base_F {};
@ -369,6 +373,7 @@ class CfgWeapons {
};
class srifle_DMR_04_F: DMR_04_base_F {
ACE_RailHeightAboveBore = 2.38022;
ACE_RailBaseAngle = 0.019366;
};
class srifle_DMR_05_blk_F: DMR_05_base_F {
ACE_RailHeightAboveBore = 3.91334;

View File

@ -5,6 +5,7 @@ PREP(applyScopeAdjustment);
PREP(calculateZeroAngleCorrection);
PREP(canAdjustZero);
PREP(firedEH);
PREP(getBaseAngle);
PREP(getBoreHeight);
PREP(getCurrentZeroRange);
PREP(getOptics);

View File

@ -13,6 +13,7 @@ GVAR(Optics) = ["", "", ""];
GVAR(Guns) = ["", "", ""];
GVAR(canAdjustElevation) = [false, false, false];
GVAR(canAdjustWindage) = [false, false, false];
GVAR(baseAngle) = [0, 0, 0];
GVAR(boreHeight) = [0, 0, 0];
GVAR(scopeAdjust) = [[[0,0],0,[0,0],0], [[0,0],0,[0,0],0], [[0,0],0,[0,0],0]];

View File

@ -32,6 +32,7 @@ _zeroing = _zeroing vectorMultiply MRAD_TO_DEG(1);
if (GVAR(correctZeroing)) then {
private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false];
private _baseAngle = GVAR(baseAngle) select _weaponIndex;
private _boreHeight = GVAR(boreHeight) select _weaponIndex;
private _oldZeroRange = currentZeroing _unit;
private _newZeroRange = [_unit] call FUNC(getCurrentZeroRange);
@ -39,7 +40,7 @@ if (GVAR(correctZeroing)) then {
if (isNil "_zeroCorrection") then {
_zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection);
};
_zeroing = _zeroing vectorAdd [0, 0, _zeroCorrection];
_zeroing = _zeroing vectorAdd [0, 0, _zeroCorrection - _baseAngle];
};
if (_zeroing isEqualTo [0, 0, 0]) exitWith {};

View File

@ -0,0 +1,31 @@
/*
* Author: Ruthberg
* Gets the base angle of the rail on the weapon with the given weapon index
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon index <NUMBER>
*
* Return Value:
* base angle <NUMBER>
*
* Example:
* [player, 0] call ace_scopes_fnc_getBaseAngle
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_player", "_weaponIndex"];
if (_weaponIndex < 0 || {_weaponIndex > 2}) exitWith { 0 };
private _weaponClass = [primaryWeapon _player, secondaryWeapon _player, handgunWeapon _player] select _weaponIndex;
private _baseAngle = DEFAULT_RAIL_BASE_ANGLE;
private _weaponConfig = configFile >> "CfgWeapons" >> _weaponClass;
if (isNumber (_weaponConfig >> "ACE_RailBaseAngle")) then {
_baseAngle = getNumber(_weaponConfig >> "ACE_RailBaseAngle");
};
_baseAngle

View File

@ -10,7 +10,7 @@
* bore height <NUMBER>
*
* Example:
* [player] call ace_scopes_fnc_getBoreHeight
* [player, 0] call ace_scopes_fnc_getBoreHeight
*
* Public: Yes
*/

View File

@ -69,9 +69,10 @@ private _newGuns = [primaryWeapon _player, secondaryWeapon _player, handgunWeapo
_adjustment set [_forEachIndex, [0, 0, 0]];
_updateAdjustment = true;
};
GVAR(baseAngle) set [_x, [_player, _x] call FUNC(getBaseAngle)];
GVAR(boreHeight) set [_x, [_player, _x] call FUNC(getBoreHeight)];
if ((_newOptics select _x) == "") then {
// Check if the weapon comes with an integrated optic
private _weaponConfig = configFile >> "CfgWeapons" >> (_newGuns select _x);

View File

@ -14,6 +14,8 @@
#define MINOR_INCREMENT false
#define MAJOR_INCREMENT true
#define DEFAULT_RAIL_BASE_ANGLE 0.0086
#ifdef DEBUG_ENABLED_SCOPES
#define DEBUG_MODE_FULL
#endif