2015-01-16 12:15:14 +00:00
|
|
|
/*
|
2015-04-11 12:02:44 +00:00
|
|
|
* Author: KoffeinFlummi, Ruthberg
|
2015-01-16 12:15:14 +00:00
|
|
|
* Changes the adjustment for the current scope
|
|
|
|
*
|
2015-02-10 04:22:10 +00:00
|
|
|
* Argument:
|
|
|
|
* 0: Unit <OBJECT>
|
2015-04-11 12:02:44 +00:00
|
|
|
* 1: Turret and Direction <NUMBER>
|
|
|
|
* 2: Major Step <BOOL>
|
2015-02-10 04:22:10 +00:00
|
|
|
*
|
|
|
|
* Return value:
|
2015-04-11 12:02:44 +00:00
|
|
|
* Did we adjust anything? <BOOL>
|
2015-01-16 12:15:14 +00:00
|
|
|
*
|
2015-02-10 04:22:10 +00:00
|
|
|
* Public: No
|
2015-01-16 12:15:14 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
2015-02-10 02:00:40 +00:00
|
|
|
|
2015-04-17 23:13:09 +00:00
|
|
|
PARAMS_3(_unit,_turretAndDirection,_majorStep);
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-04-18 21:14:40 +00:00
|
|
|
if (!(_unit isKindOf "Man")) exitWith {false};
|
2015-04-29 07:27:49 +00:00
|
|
|
if (currentMuzzle _unit != currentWeapon _unit) exitWith {false};
|
2015-04-11 12:02:44 +00:00
|
|
|
|
2015-04-17 23:13:09 +00:00
|
|
|
private ["_weaponIndex", "_zeroing", "_optic", "_increment", "_maxVertical", "_maxHorizontal", "_elevation", "_windage", "_zero", "_adjustment"];
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-02-12 14:57:55 +00:00
|
|
|
_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
2015-04-11 12:02:44 +00:00
|
|
|
if (_weaponIndex < 0) exitWith {false};
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-02-10 02:00:40 +00:00
|
|
|
_adjustment = _unit getVariable QGVAR(Adjustment);
|
|
|
|
if (isNil "_adjustment") then {
|
2015-04-11 12:02:44 +00:00
|
|
|
_adjustment = [[0,0,0], [0,0,0], [0,0,0]]; // [Windage, Elevation, Zero]
|
2015-01-16 12:15:14 +00:00
|
|
|
};
|
|
|
|
|
2015-04-11 12:02:44 +00:00
|
|
|
if (isNil QGVAR(Optics)) then {
|
|
|
|
GVAR(Optics) = ["", "", ""];
|
|
|
|
};
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-04-11 12:02:44 +00:00
|
|
|
_optic = GVAR(Optics) select _weaponIndex;
|
|
|
|
_increment = getNumber (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Increment");
|
|
|
|
_maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Vertical");
|
|
|
|
_maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Horizontal");
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-04-29 07:27:49 +00:00
|
|
|
if ((_increment == 0) or (count _maxHorizontal < 2) or (count _maxVertical < 2)) exitWith {false};
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-04-11 12:02:44 +00:00
|
|
|
_zeroing = _adjustment select _weaponIndex;
|
|
|
|
_elevation = _zeroing select 0;
|
|
|
|
_windage = _zeroing select 1;
|
|
|
|
_zero = _zeroing select 2;
|
2015-02-10 04:22:10 +00:00
|
|
|
|
2015-04-11 12:02:44 +00:00
|
|
|
switch (_turretAndDirection) do
|
|
|
|
{
|
2015-04-14 08:47:09 +00:00
|
|
|
case ELEVATION_UP: { _elevation = _elevation + _increment };
|
|
|
|
case ELEVATION_DOWN: { _elevation = _elevation - _increment };
|
|
|
|
case WINDAGE_LEFT: { _windage = _windage - _increment };
|
|
|
|
case WINDAGE_RIGHT: { _windage = _windage + _increment };
|
2015-04-11 12:02:44 +00:00
|
|
|
};
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-04-11 12:02:44 +00:00
|
|
|
if (_majorStep) then {
|
2015-04-14 08:47:09 +00:00
|
|
|
switch (_turretAndDirection) do
|
|
|
|
{
|
|
|
|
case ELEVATION_UP: { _elevation = ceil(_elevation) };
|
|
|
|
case ELEVATION_DOWN: { _elevation = floor(_elevation) };
|
|
|
|
case WINDAGE_LEFT: { _windage = floor(_windage) };
|
|
|
|
case WINDAGE_RIGHT: { _windage = ceil(_windage) };
|
|
|
|
};
|
2015-04-11 12:02:44 +00:00
|
|
|
};
|
2015-02-10 04:22:10 +00:00
|
|
|
|
2015-04-11 12:02:44 +00:00
|
|
|
_elevation = round(_elevation * 10) / 10;
|
|
|
|
_windage = round(_windage * 10) / 10;
|
2015-02-10 04:22:10 +00:00
|
|
|
|
2015-04-13 19:17:30 +00:00
|
|
|
if ((_elevation + _zero) < _maxVertical select 0 or (_elevation + _zero) > _maxVertical select 1) exitWith {false};
|
2015-04-11 12:02:44 +00:00
|
|
|
if (_windage < _maxHorizontal select 0 or _windage > _maxHorizontal select 1) exitWith {false};
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2015-04-11 12:02:44 +00:00
|
|
|
[_unit, _elevation, _windage, _zero] call FUNC(applyScopeAdjustment);
|
2015-04-14 18:17:54 +00:00
|
|
|
|
|
|
|
true
|