Ramsen IV 2 Posted May 13, 2020 I'm trying to locate a specific unit in group by type: (I_Sniper_F and I_Spotter_F) _spawn = selectRandom ["snipe1_0","snipe1_1","snipe1_2"]; _grp = [getMarkerPos _spawn, RESISTANCE, (configfile >> "CfgGroups" >> "Indep" >> "IND_F" >> "Infantry" >> "HAF_SniperTeam")] call BIS_fnc_spawnGroup; _grp setBehaviour "STEALTH"; _grp setCombatMode "YELLOW"; _array = units _grp;_sniper = {_x isKindOf ["Man", configfile >> "CfgVehicles" >> "I_Sniper_F"]} forEach _array; // _x is general error so this way did not work _spotter = allUnits select {typeOf "I_Spotter_F" in _array}; // type string expected object - For what? the _array or typeOf? Anyhow no luck. I finally found out how to select all flag poles by 'Type' and I tried to implement that above with soldier types for the spotter but no luck either. _types = ["Flag_AAF_F","Flag_NATO_F","Flag_White_F"]; _poles = allMissionObjects "all" select {typeOf _x in _types}; I want to do similar but for specific soldiers in groups. Cheers. Share this post Link to post Share on other sites
beno_83au 1369 Posted May 14, 2020 Mmmmmmm, kinda on the right track: _sniper = ((units _grp) select {typeOf _x == "I_Sniper_F"}) select 0; _spotter = ((units _grp) select {typeOf _x == "I_Spotter_F"}) select 0; Using select in this case (Alternative Syntax 5) returns an array containing all units in the group that match the given type ("I_Sniper_F" or "I_Spotter_F"). Using select 0 just returns the first unit in that array (or the only unit if the array has just one unit in it). 1 Share this post Link to post Share on other sites
Ramsen IV 2 Posted May 14, 2020 Thx Beno that worked nicely. If there was more than one of the same type (say 4 spotters) can I use rand in addition to select 0,1,2 or 3? e.g _spotter = ((units _grp) select {typeOf _x == "I_Spotter_F"}) select rand; or more like... _spotter = ((units _grp) select {typeOf _x == "I_Spotter_F"}) selectRandom; Share this post Link to post Share on other sites
beno_83au 1369 Posted May 15, 2020 Yes, but like this: selectRandom. So just like your second example, except the array comes AFTER the command. There's also selectRandomWeighted. Share this post Link to post Share on other sites