mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Moves the bore height calculation into FUNC(inventoryCheck)
This commit is contained in:
@ -10,8 +10,10 @@
|
|||||||
if (!hasInterface) exitWith {};
|
if (!hasInterface) exitWith {};
|
||||||
|
|
||||||
GVAR(Optics) = ["", "", ""];
|
GVAR(Optics) = ["", "", ""];
|
||||||
|
GVAR(Guns) = ["", "", ""];
|
||||||
GVAR(canAdjustElevation) = [false, false, false];
|
GVAR(canAdjustElevation) = [false, false, false];
|
||||||
GVAR(canAdjustWindage) = [false, false, false];
|
GVAR(canAdjustWindage) = [false, false, false];
|
||||||
|
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]];
|
GVAR(scopeAdjust) = [[[0,0],0,[0,0],0], [[0,0],0,[0,0],0], [[0,0],0,[0,0],0]];
|
||||||
|
|
||||||
// Check inventory when it changes
|
// Check inventory when it changes
|
||||||
|
@ -28,37 +28,8 @@ TRACE_1("Adjusting With",_zeroing);
|
|||||||
_zeroing = _zeroing vectorMultiply 0.05625;
|
_zeroing = _zeroing vectorMultiply 0.05625;
|
||||||
|
|
||||||
if (_ammo isKindOf "BulletBase") then {
|
if (_ammo isKindOf "BulletBase") then {
|
||||||
private _railHeightAboveBore = 0;
|
|
||||||
private _scopeHeightAboveRail = 0;
|
|
||||||
// Determine rail height above bore
|
|
||||||
private _weaponConfig = configFile >> "CfgWeapons" >> _weapon;
|
|
||||||
if (isNumber (_weaponConfig >> "ACE_RailHeightAboveBore")) then {
|
|
||||||
_railHeightAboveBore = getNumber(_weaponConfig >> "ACE_RailHeightAboveBore");
|
|
||||||
} else {
|
|
||||||
switch (_weaponIndex) do {
|
|
||||||
case 0: { _railHeightAboveBore = 2.0; }; // Rifle
|
|
||||||
case 2: { _railHeightAboveBore = 0.7; }; // Pistol
|
|
||||||
};
|
|
||||||
};
|
|
||||||
// Determine scope height above rail
|
|
||||||
private _optic = GVAR(Optics) select _weaponIndex;
|
|
||||||
private _opticConfig = configFile >> "CfgWeapons" >> _optic;
|
|
||||||
if (isNumber (_opticConfig >> "ACE_ScopeHeightAboveRail")) then {
|
|
||||||
_scopeHeightAboveRail = getNumber(_opticConfig >> "ACE_ScopeHeightAboveRail");
|
|
||||||
} else {
|
|
||||||
switch (getNumber(_opticConfig >> "ItemInfo" >> "opticType")) do {
|
|
||||||
case 1: { _scopeHeightAboveRail = 3.0; }; // RCO or similar
|
|
||||||
case 2: { _scopeHeightAboveRail = 4.0; }; // High power scope
|
|
||||||
default {
|
|
||||||
switch (_weaponIndex) do {
|
|
||||||
case 0: { _scopeHeightAboveRail = 0.5; }; // Rifle iron sights
|
|
||||||
case 2: { _scopeHeightAboveRail = 0.3; }; // Pistol iron sights
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false];
|
private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false];
|
||||||
private _boreHeight = _railHeightAboveBore + _scopeHeightAboveRail;
|
private _boreHeight = GVAR(boreHeight) select _weaponIndex;
|
||||||
private _oldZeroRange = currentZeroing _unit;
|
private _oldZeroRange = currentZeroing _unit;
|
||||||
private _newZeroRange = [_unit] call FUNC(getCurrentZeroRange);
|
private _newZeroRange = [_unit] call FUNC(getCurrentZeroRange);
|
||||||
private _zeroCorrection = missionNamespace getVariable format[QGVAR(%1_%2_%3_%4_%5_%6_%7), _oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics];
|
private _zeroCorrection = missionNamespace getVariable format[QGVAR(%1_%2_%3_%4_%5_%6_%7), _oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics];
|
||||||
|
@ -26,6 +26,41 @@ if (isNil "_adjustment") then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private _newOptics = [_player] call FUNC(getOptics);
|
private _newOptics = [_player] call FUNC(getOptics);
|
||||||
|
private _newGuns = [primaryWeapon _player, secondaryWeapon _player, handgunWeapon _player];
|
||||||
|
|
||||||
|
{
|
||||||
|
if ((_newOptics select _x) != (GVAR(Optics) select _x) || (_newGuns select _x != GVAR(Guns) select _x)) then {
|
||||||
|
// Determine rail height above bore
|
||||||
|
private _railHeightAboveBore = 0;
|
||||||
|
private _weaponConfig = configFile >> "CfgWeapons" >> (_newGuns select _x);
|
||||||
|
if (isNumber (_weaponConfig >> "ACE_RailHeightAboveBore")) then {
|
||||||
|
_railHeightAboveBore = getNumber(_weaponConfig >> "ACE_RailHeightAboveBore");
|
||||||
|
} else {
|
||||||
|
switch (_x) do {
|
||||||
|
case 0: { _railHeightAboveBore = 2.0; }; // Rifle
|
||||||
|
case 2: { _railHeightAboveBore = 0.7; }; // Pistol
|
||||||
|
};
|
||||||
|
};
|
||||||
|
// Determine scope height above rail
|
||||||
|
private _scopeHeightAboveRail = 0;
|
||||||
|
private _opticConfig = configFile >> "CfgWeapons" >> (_newOptics select _x);
|
||||||
|
if (isNumber (_opticConfig >> "ACE_ScopeHeightAboveRail")) then {
|
||||||
|
_scopeHeightAboveRail = getNumber(_opticConfig >> "ACE_ScopeHeightAboveRail");
|
||||||
|
} else {
|
||||||
|
switch (getNumber(_opticConfig >> "ItemInfo" >> "opticType")) do {
|
||||||
|
case 1: { _scopeHeightAboveRail = 3.0; }; // RCO or similar
|
||||||
|
case 2: { _scopeHeightAboveRail = 4.0; }; // High power scope
|
||||||
|
default {
|
||||||
|
switch (_x) do {
|
||||||
|
case 0: { _scopeHeightAboveRail = 0.5; }; // Rifle iron sights
|
||||||
|
case 2: { _scopeHeightAboveRail = 0.3; }; // Pistol iron sights
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
GVAR(boreHeight) set [_x, _railHeightAboveBore + _scopeHeightAboveRail];
|
||||||
|
}
|
||||||
|
} forEach [0, 1, 2];
|
||||||
|
|
||||||
{
|
{
|
||||||
if (_newOptics select _forEachIndex != _x) then {
|
if (_newOptics select _forEachIndex != _x) then {
|
||||||
@ -68,11 +103,12 @@ private _newOptics = [_player] call FUNC(getOptics);
|
|||||||
(GVAR(scopeAdjust) select _forEachIndex) set [3, _horizontalIncrement];
|
(GVAR(scopeAdjust) select _forEachIndex) set [3, _horizontalIncrement];
|
||||||
GVAR(canAdjustElevation) set [_forEachIndex, (_verticalIncrement > 0) && !(_maxVertical isEqualTo [0, 0])];
|
GVAR(canAdjustElevation) set [_forEachIndex, (_verticalIncrement > 0) && !(_maxVertical isEqualTo [0, 0])];
|
||||||
GVAR(canAdjustWindage) set [_forEachIndex, (_horizontalIncrement > 0) && !(_maxHorizontal isEqualTo [0, 0])];
|
GVAR(canAdjustWindage) set [_forEachIndex, (_horizontalIncrement > 0) && !(_maxHorizontal isEqualTo [0, 0])];
|
||||||
// Does not work reliably
|
private _hideVanillaZeroing = (getNumber(_opticConfig >> "ItemInfo" >> "opticType") == 2 && {GVAR(canAdjustElevation) select _forEachIndex}) || {isNumber (_opticConfig >> "ACE_ScopeZeroRange")};
|
||||||
//private _hideVanillaZeroing = (getNumber(_opticConfig >> "ItemInfo" >> "opticType") == 2 && (GVAR(canAdjustElevation) select _forEachIndex)) || {isNumber (_opticConfig >> "ACE_ScopeZeroRange")};
|
["ace_scopes", true, "zeroing", !_hideVanillaZeroing] call EFUNC(ui,setElementVisibility);
|
||||||
//private _result = ["zeroing", !_hideVanillaZeroing, false] call EFUNC(ui,setAdvancedElement);
|
|
||||||
};
|
};
|
||||||
} forEach GVAR(Optics);
|
} forEach GVAR(Optics);
|
||||||
|
|
||||||
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
||||||
GVAR(Optics) = _newOptics;
|
GVAR(Optics) = _newOptics;
|
||||||
|
GVAR(Guns) = _newGuns;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user