2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-05-28 17:17:29 +00:00
|
|
|
/*
|
|
|
|
* Authors: Ruthberg
|
|
|
|
* Updates the ammo and weapon class names
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Update successful? <BOOLEAN>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* unit call ace_rangecard_fnc_updateClassNames
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _unit = _this;
|
2015-05-28 17:17:29 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _ammoClass = "";
|
|
|
|
private _magazineClass = "";
|
|
|
|
private _weaponClass = primaryWeapon _unit;
|
2015-05-28 17:17:29 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
if (_weaponClass == "") exitWith { (GVAR(ammoClass) != "" && GVAR(magazineClass) != "" && GVAR(weaponClass) != "") };
|
2015-05-28 17:17:29 +00:00
|
|
|
|
|
|
|
{
|
2017-10-10 14:39:59 +00:00
|
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo");
|
|
|
|
private _ammoConfig = (configFile >> "CfgAmmo" >> _ammo);
|
|
|
|
private _parentClasses = [_ammoConfig, true] call BIS_fnc_returnParents;
|
2015-05-29 13:07:30 +00:00
|
|
|
if ("BulletBase" in _parentClasses) exitWith {
|
|
|
|
_ammoClass = _ammo;
|
|
|
|
_magazineClass = _x;
|
|
|
|
};
|
2015-05-28 17:17:29 +00:00
|
|
|
} forEach (primaryWeaponMagazine _unit);
|
|
|
|
|
2015-05-29 13:07:30 +00:00
|
|
|
if (_ammoClass == "") exitWith { (GVAR(ammoClass) != "" && GVAR(magazineClass) != "" && GVAR(weaponClass) != "") };
|
2015-05-28 17:17:29 +00:00
|
|
|
|
|
|
|
if (_unit == ACE_player) then {
|
2016-11-08 13:47:12 +00:00
|
|
|
GVAR(zeroRange) = [_unit] call EFUNC(scopes,getCurrentZeroRange);
|
2016-12-01 20:20:51 +00:00
|
|
|
GVAR(boreHeight) = [_unit, 0] call EFUNC(scopes,getBoreHeight);
|
2015-05-29 13:07:30 +00:00
|
|
|
GVAR(ammoClass) = _ammoClass;
|
|
|
|
GVAR(magazineClass) = _magazineClass;
|
|
|
|
GVAR(weaponClass) = _weaponClass;
|
2015-05-28 17:17:29 +00:00
|
|
|
} else {
|
2016-11-08 13:47:12 +00:00
|
|
|
GVAR(zeroRangeCopy) = [_unit] call EFUNC(scopes,getCurrentZeroRange);
|
2016-12-01 20:20:51 +00:00
|
|
|
GVAR(boreHeightCopy) = [_unit, 0] call EFUNC(scopes,getBoreHeight);
|
2015-05-29 13:07:30 +00:00
|
|
|
GVAR(ammoClassCopy) = _ammoClass;
|
|
|
|
GVAR(magazineClassCopy) = _magazineClass;
|
|
|
|
GVAR(weaponClassCopy) = _weaponClass;
|
2015-05-28 17:17:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
true
|