mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Allow using adjustment turrets on weapons with integrated scopes
This commit is contained in:
parent
429bffd039
commit
789a169b0e
@ -17,8 +17,10 @@
|
|||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
|
if (!GVAR(enabled)) exitWith { currentZeroing _unit };
|
||||||
|
|
||||||
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
||||||
if (_weaponIndex < 0) exitWith { 0 };
|
if (_weaponIndex < 0) exitWith { currentZeroing _unit };
|
||||||
|
|
||||||
private _optic = GVAR(Optics) select _weaponIndex;
|
private _optic = GVAR(Optics) select _weaponIndex;
|
||||||
private _opticConfig = configFile >> "CfgWeapons" >> _optic;
|
private _opticConfig = configFile >> "CfgWeapons" >> _optic;
|
||||||
|
@ -28,40 +28,6 @@ if (isNil "_adjustment") then {
|
|||||||
private _newOptics = [_player] call FUNC(getOptics);
|
private _newOptics = [_player] call FUNC(getOptics);
|
||||||
private _newGuns = [primaryWeapon _player, secondaryWeapon _player, handgunWeapon _player];
|
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 {
|
||||||
// The optic for this weapon changed, set adjustment to zero
|
// The optic for this weapon changed, set adjustment to zero
|
||||||
@ -103,11 +69,71 @@ private _newGuns = [primaryWeapon _player, secondaryWeapon _player, handgunWeapo
|
|||||||
(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])];
|
||||||
private _hideVanillaZeroing = (getNumber(_opticConfig >> "ItemInfo" >> "opticType") == 2 && {GVAR(canAdjustElevation) select _forEachIndex}) || {isNumber (_opticConfig >> "ACE_ScopeZeroRange")};
|
private _hideVanillaZeroing = (GVAR(enabled) && getNumber(_opticConfig >> "ItemInfo" >> "opticType") == 2 && {GVAR(canAdjustElevation) select _forEachIndex}) || {isNumber (_opticConfig >> "ACE_ScopeZeroRange")};
|
||||||
["ace_scopes", true, "zeroing", !_hideVanillaZeroing] call EFUNC(ui,setElementVisibility);
|
["ace_scopes", true, "zeroing", !_hideVanillaZeroing] call EFUNC(ui,setElementVisibility);
|
||||||
};
|
};
|
||||||
} forEach GVAR(Optics);
|
} forEach GVAR(Optics);
|
||||||
|
|
||||||
|
{
|
||||||
|
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];
|
||||||
|
|
||||||
|
if ((_newOptics select _x) == "") then {
|
||||||
|
// Check if the weapon comes with an integrated optic
|
||||||
|
private _verticalIncrement = 0;
|
||||||
|
if (isNumber (_weaponConfig >> "ACE_ScopeAdjust_VerticalIncrement")) then {
|
||||||
|
_verticalIncrement = getNumber (_weaponConfig >> "ACE_ScopeAdjust_VerticalIncrement");
|
||||||
|
};
|
||||||
|
private _horizontalIncrement = 0;
|
||||||
|
if (isNumber (_weaponConfig >> "ACE_ScopeAdjust_HorizontalIncrement")) then {
|
||||||
|
_horizontalIncrement = getNumber (_weaponConfig >> "ACE_ScopeAdjust_HorizontalIncrement");
|
||||||
|
};
|
||||||
|
private _maxVertical = [0, 0];
|
||||||
|
if (isArray (_weaponConfig >> "ACE_ScopeAdjust_Vertical")) then {
|
||||||
|
_maxVertical = getArray (_weaponConfig >> "ACE_ScopeAdjust_Vertical");
|
||||||
|
};
|
||||||
|
private _maxHorizontal = [0, 0];
|
||||||
|
if (isArray (_weaponConfig >> "ACE_ScopeAdjust_Horizontal")) then {
|
||||||
|
_maxHorizontal = getArray (_weaponConfig >> "ACE_ScopeAdjust_Horizontal");
|
||||||
|
};
|
||||||
|
(GVAR(scopeAdjust) select _x) set [0, _maxVertical];
|
||||||
|
(GVAR(scopeAdjust) select _x) set [1, _verticalIncrement];
|
||||||
|
(GVAR(scopeAdjust) select _x) set [2, _maxHorizontal];
|
||||||
|
(GVAR(scopeAdjust) select _x) set [3, _horizontalIncrement];
|
||||||
|
GVAR(canAdjustElevation) set [_x, (_verticalIncrement > 0) && !(_maxVertical isEqualTo [0, 0])];
|
||||||
|
GVAR(canAdjustWindage) set [_x, (_horizontalIncrement > 0) && !(_maxHorizontal isEqualTo [0, 0])];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} forEach [0, 1, 2];
|
||||||
|
|
||||||
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
||||||
GVAR(Optics) = _newOptics;
|
GVAR(Optics) = _newOptics;
|
||||||
GVAR(Guns) = _newGuns;
|
GVAR(Guns) = _newGuns;
|
||||||
|
Loading…
Reference in New Issue
Block a user