mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
f9d729c874
* 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
38 lines
1009 B
Plaintext
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
|