Zriel 12 Posted October 19, 2015 So, I'm working on a loadout system, and I would like to know if there is a way to check if a classname is a grenade (or is a throwable item, or at least I think that's how they are called on arma configs) I currently can check if a classname is a magazine used by a weapon, but grenades and such seem to use a different set of configs. Any common config item I should be looking for? Share this post Link to post Share on other sites
whiztler 137 Posted October 19, 2015 Have you had a peek here? https://community.bistudio.com/wiki/currentThrowable Share this post Link to post Share on other sites
Larrow 2822 Posted October 19, 2015 Query the magazines of each subclass of ( "CfgWeapons" >> "Throw" ) _item = "SmokeShell"; _isThrowable = count ( " _item in getArray( _x >> 'magazines' ) "configClasses ( configFile >> "CfgWeapons" >> "Throw" ) ) > 0;Same can be done for explosives and mines by using "Put" 1 Share this post Link to post Share on other sites
Zriel 12 Posted October 20, 2015 Have you had a peek here? https://community.bistudio.com/wiki/currentThrowable Nah, item is not given, I wan't to be able to check this before giving it to the unit. Query the magazines of each subclass of ( "CfgWeapons" >> "Throw" ) _item = "SmokeShell"; _isThrowable = count ( " _item in getArray( _x >> 'magazines' ) "configClasses ( configFile >> "CfgWeapons" >> "Throw" ) ) > 0;Same can be done for explosives and mines by using "Put" Yay! this is working perfectly. Many thanks! Share this post Link to post Share on other sites
KiloSwiss 16 Posted October 20, 2015 AFAIK this should work too:"className" isKindOf "Throw" <- No this does not work!// Returns true or falseRead the comments in the BIS Arma Wiki for other possible solutions:https://community.bistudio.com/wiki/isKindOf /edit This works: (getText(configfile >> "CfgMagazines" >> "className" >> "selectionFireAnim") == "zasleh"); But the solution posted by Larrow is actually the most reliable so you should stick to this. 1 Share this post Link to post Share on other sites
serena 151 Posted May 23, 2016 Query the magazines of each subclass of ( "CfgWeapons" >> "Throw" ) _item = "SmokeShell"; _isThrowable = count ( " _item in getArray( _x >> 'magazines' ) "configClasses ( configFile >> "CfgWeapons" >> "Throw" ) ) > 0; Seems like I found a much faster way to determine whether the item is throwable: Fn_Gear_IsThrowable = { private _cfa = configFile >> "CfgAmmo" >> getText(configFile >> "CfgMagazines" >> _this >> "ammo"); while {true} do { if (not isClass _cfa or {configName _cfa isEqualTo "GrenadeHand"}) exitWith {isClass _cfa}; _cfa = inheritsFrom _cfa} }; magazines player select {_x call Fn_Gear_IsThrowable} //Result: ["Chemlight_green","SmokeShell","SmokeShellGreen","Chemlight_green","HandGrenade","HandGrenade"] Share this post Link to post Share on other sites
Larrow 2822 Posted May 23, 2016 Seems like I found a much faster way to determine whether the item is throwable: Fn_Gear_IsThrowable = { private _cfa = configFile >> "CfgAmmo" >> getText(configFile >> "CfgMagazines" >> _this >> "ammo"); while {true} do { if (not isClass _cfa or {configName _cfa isEqualTo "GrenadeHand"}) exitWith {isClass _cfa}; _cfa = inheritsFrom _cfa} }; magazines player select {_x call Fn_Gear_IsThrowable} //Result: ["Chemlight_green","SmokeShell","SmokeShellGreen","Chemlight_green","HandGrenade","HandGrenade"] Careful on how/where you use that, it will return UGL magazines as throwable plus a host of vehicle ammo. You could nearly double its speed by using isKindOf instead of the while loop. _isThrowable = "1Rnd_SmokeOrange_Grenade_shell" call { params[ "_item" ]; private _cfa = configFile >> "CfgAmmo" >> getText(configFile >> "CfgMagazines" >> _item >> "ammo"); configName _cfa isKindOf "GrenadeHand" }; is TRUE 1 Share this post Link to post Share on other sites
serena 151 Posted May 23, 2016 You're right. First aproach failed. Second aproach: Fn_Gear_IsThrowable = { {if (_this in getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines")) exitWith {true}; false} forEach getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles") }; Filters grenadier inventory for ~0.027ms, your version for ~0.037ms. Thank you. Share this post Link to post Share on other sites
killzone_kid 1331 Posted May 23, 2016 Try this: fn_isThrowable = { private _cfgMagazine = configFile >> "CfgMagazines" >> _this; if (getNumber (_cfgMagazine >> "initSpeed") < 30) exitWith { toLower getText (configFile >> "CfgAmmo" >> getText (_cfgMagazine >> "ammo") >> "simulation") in [ "shotgrenade", "shotsmokex", "shotsmoke", "shotsubmunitions", "shotdeploy", "shotilluminating", "shotshell", "shotnvgmarker" ] }; false }; 1 Share this post Link to post Share on other sites
serena 151 Posted May 24, 2016 Try this: Works fine, ~80 times faster than my variant Share this post Link to post Share on other sites
killzone_kid 1331 Posted May 26, 2016 Added: A new BIS_fnc_isThrowable function (determining if the magazine of a given class name is throwable) https://community.bistudio.com/wiki/BIS_fnc_isThrowable Share this post Link to post Share on other sites