2016-12-01 20:20:51 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
2017-12-14 12:43:32 +00:00
|
|
|
* Gets the bore height of the weapon & optic combination with the given weapon index
|
2016-12-01 20:20:51 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Weapon index <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* bore height <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
2017-12-14 12:43:32 +00:00
|
|
|
* [player, 0] call ace_scopes_fnc_getBoreHeight
|
2016-12-01 20:20:51 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2017-12-14 12:43:32 +00:00
|
|
|
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;
|
2016-12-01 20:20:51 +00:00
|
|
|
|
|
|
|
if (_opticsClass == "") then { _opticsClass = _weaponClass; };
|
|
|
|
|
|
|
|
// Determine rail height above bore
|
|
|
|
private _railHeightAboveBore = 0;
|
|
|
|
private _weaponConfig = configFile >> "CfgWeapons" >> _weaponClass;
|
|
|
|
if (isNumber (_weaponConfig >> "ACE_RailHeightAboveBore")) then {
|
|
|
|
_railHeightAboveBore = getNumber(_weaponConfig >> "ACE_RailHeightAboveBore");
|
|
|
|
} else {
|
|
|
|
switch (_weaponIndex) do {
|
2017-10-22 08:28:20 +00:00
|
|
|
case 0: { _railHeightAboveBore = 3.0; }; // Rifle
|
2016-12-01 20:20:51 +00:00
|
|
|
case 2: { _railHeightAboveBore = 0.7; }; // Pistol
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// Determine scope height above rail
|
|
|
|
private _scopeHeightAboveRail = 0;
|
|
|
|
private _opticConfig = configFile >> "CfgWeapons" >> _opticsClass;
|
|
|
|
if (isNumber (_opticConfig >> "ACE_ScopeHeightAboveRail")) then {
|
|
|
|
_scopeHeightAboveRail = getNumber(_opticConfig >> "ACE_ScopeHeightAboveRail");
|
|
|
|
} else {
|
|
|
|
switch (getNumber(_opticConfig >> "ItemInfo" >> "opticType")) do {
|
2017-10-22 08:28:20 +00:00
|
|
|
case 1: { _scopeHeightAboveRail = 4.5; }; // RCO or similar
|
2016-12-01 20:20:51 +00:00
|
|
|
case 2: { _scopeHeightAboveRail = 4.0; }; // High power scope
|
|
|
|
default {
|
|
|
|
switch (_weaponIndex) do {
|
2017-11-20 19:14:24 +00:00
|
|
|
case 0: { _scopeHeightAboveRail = 2.0; }; // Rifle iron sights
|
|
|
|
case 2: { _scopeHeightAboveRail = 1.0; }; // Pistol iron sights
|
2016-12-01 20:20:51 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
(_railHeightAboveBore + _scopeHeightAboveRail)
|