ACE3/addons/rangecard/functions/fnc_updateClassNames.sqf
ulteq a687c49d2a Adds settings module for ace_scopes
* Interconnects the rangecard and scopes modules
* Hides the zeroing text when the vanilla zeroing is overwritten
* Makes the scopes module fully compatible with any 3rd party weapon pack without the need for addition compat pbos (though their use is still recommended)
2016-11-15 23:11:22 +01:00

52 lines
1.5 KiB
Plaintext

/*
* 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
*/
#include "script_component.hpp"
private ["_unit", "_ammoClass", "_magazineClass", "_weaponClass", "_ammo", "_ammoConfig", "_parentClasses"];
_unit = _this;
_ammoClass = "";
_magazineClass = "";
_weaponClass = primaryWeapon _unit;
if (_weaponClass == "") exitWith { (GVAR(ammoClass) != "" && GVAR(magazineClass) != "" && GVAR(weaponClass) != "") };
{
_ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo");
_ammoConfig = (configFile >> "CfgAmmo" >> _ammo);
_parentClasses = [_ammoConfig, true] call BIS_fnc_returnParents;
if ("BulletBase" in _parentClasses) exitWith {
_ammoClass = _ammo;
_magazineClass = _x;
};
} forEach (primaryWeaponMagazine _unit);
if (_ammoClass == "") exitWith { (GVAR(ammoClass) != "" && GVAR(magazineClass) != "" && GVAR(weaponClass) != "") };
if (_unit == ACE_player) then {
GVAR(zeroRange) = [_unit] call EFUNC(scopes,getCurrentZeroRange);
GVAR(ammoClass) = _ammoClass;
GVAR(magazineClass) = _magazineClass;
GVAR(weaponClass) = _weaponClass;
} else {
GVAR(zeroRangeCopy) = [_unit] call EFUNC(scopes,getCurrentZeroRange);
GVAR(ammoClassCopy) = _ammoClass;
GVAR(magazineClassCopy) = _magazineClass;
GVAR(weaponClassCopy) = _weaponClass;
};
true