ACE3/addons/scopes/functions/fnc_getBaseAngle.sqf
ulteq f9d729c874 Scopes - Fix 'boreHeight' and 'baseAngle' MP synchronization (#5917)
* Scopes - Unify 'getBaseAngle' & 'getBoreHeight' API

* Scopes - Fix boreHeight and baseAngle MP synchronization
* TODO: Cache the calculation or use publicVariables instead

* Cleanup unused GVARs

* Scopes - Cache getBaseAngle and getBoreHeight results

* Sync baseAngle/boreHeight

* Remove boreHeight/Angle caching

* Cleanup inv check
2017-12-15 10:22:31 -06:00

38 lines
1009 B
Plaintext

/*
* Author: Ruthberg
* Gets the base angle of the weapon & optic combination with the given weapon index
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon index <NUMBER>
*
* Return Value:
* base angle <NUMBER>
*
* Example:
* [player, 0] call ace_scopes_fnc_getBaseAngle
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit", "_weaponIndex"];
if (_weaponIndex < 0 || {_weaponIndex > 2}) exitWith { 0 };
private _weaponClass = [primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit] select _weaponIndex;
private _opticsClass = ([_unit] call FUNC(getOptics)) select _weaponIndex;
private _weaponConfig = configFile >> "CfgWeapons" >> _weaponClass;
private _baseAngle = getNumber(_weaponConfig >> "ACE_IronSightBaseAngle");
if (_opticsClass != "") then {
if (isNumber (_weaponConfig >> "ACE_RailBaseAngle")) then {
_baseAngle = getNumber(_weaponConfig >> "ACE_RailBaseAngle");
} else {
_baseAngle = DEFAULT_RAIL_BASE_ANGLE;
};
};
_baseAngle