mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Scopes - Adds 'Reset zero' interaction (advanced ballistics only) (#5789)
* Allows you to reset any zero adjustment on your current scope
This commit is contained in:
parent
a0e9b752e9
commit
9cad5873d0
@ -13,6 +13,16 @@ class CfgVehicles {
|
||||
//icon = QPATHTOF(UI\...); // TODO
|
||||
exceptions[] = {"notOnMap", "isNotInside", "isNotSwimming", "isNotSitting"};
|
||||
};
|
||||
class GVAR(resetZero) {
|
||||
// Updates the zero reference
|
||||
displayName = CSTRING(ResetZero);
|
||||
condition = QUOTE([ACE_player] call FUNC(canResetZero));
|
||||
statement = QUOTE([ACE_player] call FUNC(resetZero));
|
||||
showDisabled = 0;
|
||||
priority = 0.2;
|
||||
//icon = QPATHTOF(UI\...); // TODO
|
||||
exceptions[] = {"notOnMap", "isNotInside", "isNotSwimming", "isNotSitting"};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ PREP(adjustZero);
|
||||
PREP(applyScopeAdjustment);
|
||||
PREP(calculateZeroAngleCorrection);
|
||||
PREP(canAdjustZero);
|
||||
PREP(canResetZero);
|
||||
PREP(firedEH);
|
||||
PREP(getBaseAngle);
|
||||
PREP(getBoreHeight);
|
||||
@ -11,4 +12,5 @@ PREP(getCurrentZeroRange);
|
||||
PREP(getOptics);
|
||||
PREP(initModuleSettings);
|
||||
PREP(inventoryCheck);
|
||||
PREP(resetZero);
|
||||
PREP(showZeroing);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi, Ruthberg
|
||||
* Updates the zero reference for the current scope
|
||||
* Updates the zero adjustment of the current scope
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi, Ruthberg
|
||||
* Changes the adjustment for the current scope
|
||||
* Checks if the unit can change the zero adjustment of the current scope
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
|
31
addons/scopes/functions/fnc_canResetZero.sqf
Normal file
31
addons/scopes/functions/fnc_canResetZero.sqf
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi, Ruthberg
|
||||
* Checks if the unit can reset the zero adjustment of the current scope
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can we reset the zero reference? <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_scopes_fnc_canResetZero
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (cameraView == "GUNNER") exitWith {false};
|
||||
if (vehicle _unit != _unit) exitWith {false};
|
||||
if (!(missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false])) exitWith {false};
|
||||
|
||||
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
||||
if (_weaponIndex < 0) exitWith {false};
|
||||
|
||||
private _adjustment = _unit getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]];
|
||||
private _zero = (_adjustment select _weaponIndex) select 2;
|
||||
|
||||
// You can only reset your zero reference, if it is not 0 already
|
||||
_zero != 0
|
38
addons/scopes/functions/fnc_resetZero.sqf
Normal file
38
addons/scopes/functions/fnc_resetZero.sqf
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi, Ruthberg
|
||||
* Resets the zero adjustment of the current scope
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* true <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_scopes_fnc_resetZero
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (vehicle _unit != _unit) exitWith {false};
|
||||
|
||||
private _weaponClass = currentWeapon _unit;
|
||||
private _weaponIndex = [_unit, _weaponClass] call EFUNC(common,getWeaponIndex);
|
||||
if (_weaponIndex < 0) exitWith {false};
|
||||
|
||||
private _adjustment = _unit getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]];
|
||||
private _zeroing = _adjustment select _weaponIndex;
|
||||
_zeroing params ["_elevation", "_windage", "_zero"];
|
||||
|
||||
_elevation = round((_zero + _elevation) * 10) / 10;
|
||||
_zero = 0;
|
||||
|
||||
private _opticsClass = ([_unit] call FUNC(getOptics)) select _weaponIndex;
|
||||
profileNamespace setVariable [format[QGVAR(PersistentZero_%1_%2), _weaponClass, _opticsClass], nil];
|
||||
|
||||
[_unit, _elevation, _windage, _zero] call FUNC(applyScopeAdjustment);
|
||||
|
||||
true
|
@ -368,6 +368,10 @@
|
||||
<Chinesesimp>设定归零</Chinesesimp>
|
||||
<Chinese>設定歸零</Chinese>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Scopes_ResetZero">
|
||||
<English>Reset zero adjustment</English>
|
||||
<German>Nullung zurücksetzen</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Scopes_Description">
|
||||
<English>This module adds windage and elevation adjustment turrets on high power rifle scopes.</English>
|
||||
<German>Dieses Modul fügt Absehenverstellung (horizontal und vertikal) zu Zielfernrohren hinzu.</German>
|
||||
|
Loading…
Reference in New Issue
Block a user