Doggifast 2 Posted December 21, 2022 For example, i have an array of objects: _array = [object1, object2, etc] and i have a switch case for "_i" from 0 to ((count _array - 1) do { _newObject = _array select _i; switch ((Somekindof typeOf command) _newObject) do { case "Mines": {code to do something to the object}; case "Man": {code to do something to the object}; case "Cargo": {code to do something to the object}; }; }; //_newObject is updated everytime for each of the element so that it applies the code to every element, but that's not the point of the question How would i get these base classes so I'm basically switching between types? Share this post Link to post Share on other sites
gc8 977 Posted December 21, 2022 for your switch BIS_fnc_itemType probably is the best solution https://community.bistudio.com/wiki/BIS_fnc_itemType there's also https://community.bistudio.com/wiki/isKindOf if needed Share this post Link to post Share on other sites
Doggifast 2 Posted December 21, 2022 2 minutes ago, gc8 said: for your switch BIS_fnc_itemType probably is the best solution there's also https://community.bistudio.com/wiki/isKindOf if needed Thanks, i'll try the function. isKindOf returns bool and not the base class, so i'd have to make a LOT of if-then statements... By the way, i get array by doing nearestObjects with this filter: _array = ["Explosives", "Container", "Cargo", "Backpacks", "Items", "ItemsHeadgear", "ItemsUniforms", "ItemsVests", "Magazines", "Ammo", "Mines", "WeaponAcessories", "WeaponsHandguns", "WeaponsPrimary", "WeaponsSecondary", "MineGeneric", "Man"]; _nearestObjectsLoot = nearestObjects [_caller, _array, 100]; //_caller - it's an action btw Share this post Link to post Share on other sites
gc8 977 Posted December 21, 2022 nearestObjects gets you objects in the world. So i doubt WeaponsPrimary, ItemsHeadgear etc work there Share this post Link to post Share on other sites
Doggifast 2 Posted December 21, 2022 9 minutes ago, Doggifast said: Thanks, i'll try the function. isKindOf returns bool and not the base class, so i'd have to make a LOT of if-then statements... By the way, i get array by doing nearestObjects with this filter: _array = ["Explosives", "Container", "Cargo", "Backpacks", "Items", "ItemsHeadgear", "ItemsUniforms", "ItemsVests", "Magazines", "Ammo", "Mines", "WeaponAcessories", "WeaponsHandguns", "WeaponsPrimary", "WeaponsSecondary", "MineGeneric", "Man"]; _nearestObjectsLoot = nearestObjects [_caller, _array, 100]; //_caller - it's an action btw Wait. I'll just use the nearestObjects several times for different arrays and then use forEach for those arrays. I'll report back when i try this. Share this post Link to post Share on other sites
pierremgi 4879 Posted December 22, 2022 See also the new command (in 2.10) and its next update (in 2.12, for the alternative syntax and better filters): allObjects Share this post Link to post Share on other sites
Doggifast 2 Posted December 22, 2022 Found a way. [ configFile >> "Configwiththeclassnameofathinginit" >> "Classname of a thing", true ] call BIS_fnc_returnParents; example: [ configFile >> "CfgAmmo" >> "Bo_GBU12_LGB", true ] call BIS_fnc_returnParents; will return ["Bo_GBU12_LGB","ammo_Bomb_LaserGuidedBase","LaserBombCore","BombCore","Default"] and with a command (i dont remember which) to check if a specific element is in an array, i can find, for example, for several types of bombs "BombCore" is always present, while obviously not being present for other projectiles or items, etc. now i can check the parents for several objects in an array of all nearest object and maybe pushBack them to another array. found the command: 1 *in* [0, 1, 2]; // true Pretty poggers. Share this post Link to post Share on other sites
pierremgi 4879 Posted December 22, 2022 1 hour ago, Doggifast said: Found a way. [ configFile >> "Configwiththeclassnameofathinginit" >> "Classname of a thing", true ] call BIS_fnc_returnParents; example: [ configFile >> "CfgAmmo" >> "Bo_GBU12_LGB", true ] call BIS_fnc_returnParents; will return ["Bo_GBU12_LGB","ammo_Bomb_LaserGuidedBase","LaserBombCore","BombCore","Default"] and with a command (i dont remember which) to check if a specific element is in an array, i can find, for example, for several types of bombs "BombCore" is always present, while obviously not being present for other projectiles or items, etc. now i can check the parents for several objects in an array of all nearest object and maybe pushBack them to another array. found the command: 1 *in* [0, 1, 2]; // true Pretty poggers. private _bombs = ("configName _x isKindOf 'BombCore' " configClasses (ConfigFile / "cfgAmmo")) apply {configName _x} // will return something like: ["BombCore","LaserBombCore","ammo_Bomb_LaserGuidedBase","Bo_GBU12_LGB","Bo_GBU12_LGB_MI10","Bomb_03_F","Bomb_04_F","Bo_Mk82",......] All these bombs are "BombCore" type, according to the condition for configClasses result. then: "Bo_GBU12_LGB" in _bombs // will return TRUE But not sure what you intend to do with that. Don't confuse objects and classes, so things like ammos, magazines, with mines and weapon holders. mines are objects and you can find them with: nearestMines [getpos player,[], 100]; much more selective than: nearestObjects [player,[], 100] Projectiles are objects with ammo class names. They exist when a magazine is fired (from: a pylon (air)..., a weapon (primary, launcher, handgun)..., an unit (throwing grenade, with throw as weapon muzzle), a turret of a vehicle). They have a life time. If you want to work on projectiles (and not mines) you need to use an event handler for catching it as object: See eventHandler "fired" for the basic. Share this post Link to post Share on other sites
Doggifast 2 Posted December 27, 2022 On 12/22/2022 at 5:02 PM, pierremgi said: private _bombs = ("configName _x isKindOf 'BombCore' " configClasses (ConfigFile / "cfgAmmo")) apply {configName _x} // will return something like: ["BombCore","LaserBombCore","ammo_Bomb_LaserGuidedBase","Bo_GBU12_LGB","Bo_GBU12_LGB_MI10","Bomb_03_F","Bomb_04_F","Bo_Mk82",......] All these bombs are "BombCore" type, according to the condition for configClasses result. then: "Bo_GBU12_LGB" in _bombs // will return TRUE But not sure what you intend to do with that. Don't confuse objects and classes, so things like ammos, magazines, with mines and weapon holders. mines are objects and you can find them with: nearestMines [getpos player,[], 100]; much more selective than: nearestObjects [player,[], 100] Projectiles are objects with ammo class names. They exist when a magazine is fired (from: a pylon (air)..., a weapon (primary, launcher, handgun)..., an unit (throwing grenade, with throw as weapon muzzle), a turret of a vehicle). They have a life time. If you want to work on projectiles (and not mines) you need to use an event handler for catching it as object: See eventHandler "fired" for the basic. Hey. I needed base classes for a draw3D script, so it would place a icon on every object near the player that would match the base class, and i succeeded in that. For example, addMissionEventHandler ["Draw3D", { if (goggles player == "USP_GP21_SH4_BLK3") then { {_pos = ASLToAGL getPosASLVisual _x; drawIcon3D [getMissionPath "Icons\IconMine.paa", [1,0,0,1], _pos, 1, 1, 0, "Mine", 0, 0.05, "RobotoCondensed", "center", true]; } forEach nearestObjects [player, ["APERSMine", "MineBase", "MineGeneric","ModuleExplosive_F"], 20]; }; }]; If you want to test this, change the googles classname to whichever you want, and place some mines around you with zeus, and put the code into the debug console. Don't forget to change the icon path to something different. I originally wanted to make it like a one-time scan with a cooldown (hence the struggle with getting base classes of the objects), but i decided to go with procedural scanning instead, hence the struggle with getting base classes of the objects. (for different types of objects, such as loot (objects/weaponholders on the ground that can be picked up) i just do more entries in the Draw3D event handler. I also put it in initPlayerLocal.sqf, so don't worry about the locality for multiplayer) Share this post Link to post Share on other sites