2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: KoffeinFlummi
|
|
|
|
*
|
|
|
|
* Checks if a player can adjust his optic in the given way.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Horizontal adjustment
|
|
|
|
* 1: Vertical adjustment
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Can adjustment be done? (Bool)
|
|
|
|
*/
|
|
|
|
|
2015-01-16 12:15:14 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
private ["_unit", "_weapons", "_zeroing", "_optic", "_maxHorizontal", "_maxVertical"];
|
|
|
|
|
|
|
|
_unit = _this select 0;
|
|
|
|
|
|
|
|
_weapons = [
|
2015-01-16 12:15:14 +00:00
|
|
|
primaryWeapon _unit,
|
|
|
|
secondaryWeapon _unit,
|
|
|
|
handgunWeapon _unit
|
2015-01-11 16:42:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
if !(currentWeapon _unit in _weapons) exitWith {false};
|
|
|
|
|
2015-02-10 02:00:40 +00:00
|
|
|
_adjustment = _unit getVariable QGVAR(Adjustment);
|
|
|
|
if (isNil "_adjustment") then {
|
|
|
|
_adjustment = [[0,0], [0,0], [0,0]];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-01-18 21:34:45 +00:00
|
|
|
if (isNil QGVAR(Optics)) then {
|
2015-01-16 12:15:14 +00:00
|
|
|
GVAR(Optics) = ["", "", ""];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-02-10 02:00:40 +00:00
|
|
|
_zeroing = _adjustment select (_weapons find (currentWeapon _unit));
|
2015-01-11 16:42:31 +00:00
|
|
|
_zeroX = (_zeroing select 0) + (_this select 1);
|
|
|
|
_zeroY = (_zeroing select 1) + (_this select 2);
|
|
|
|
|
2015-01-16 12:15:14 +00:00
|
|
|
_optic = GVAR(Optics) select (_weapons find (currentWeapon _unit));
|
|
|
|
_maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Horizontal");
|
|
|
|
_maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Vertical");
|
2015-01-11 16:42:31 +00:00
|
|
|
if ((count _maxHorizontal < 2) or (count _maxVertical < 2)) exitWith {false};
|
|
|
|
if ((_maxHorizontal isEqualTo [0,0]) or (_maxVertical isEqualTo [0,0])) exitWith {false};
|
|
|
|
|
|
|
|
if (_zeroX < _maxHorizontal select 0 or _zeroX > _maxHorizontal select 1) exitWith {false};
|
|
|
|
if (_zeroY < _maxVertical select 0 or _zeroY > _maxVertical select 1) exitWith {false};
|
|
|
|
|
|
|
|
vehicle _unit == _unit
|