Jump to content
Sign in to follow this  
Asclepius

Selecting spawned group as array?

Recommended Posts

I've been trying to figure this out for a couple of hours now and couldn't figure it out based on past posts...

so I spawned a group with the BIS_fnc_spawnGroup function. I already named their group and set their formation and behavior, but I want to make them all do a command (doWatch). I think the command doWatch expects a singular unit, or an array. I can't figure out how to set that group as an array or even put in the members of the group... Here is the latest trial and it's still not working.

_grp1 = createGroup Hills;
_grp1 = [getMarkerPos "Bad", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;
_grp1 setFormation "LINE";
_grp1 setBehaviour "COMBAT";
_array = [_grp1]
   {
   _x doWatch [markerPos"HILLWATCH"];
   };
forEach [unit, _array];

I've also tried just

forEach [_array];

I'm stabbing in the dark here based on what I'm seeing on other versions of running a group through an array function. If someone could help me out and explain each element you need to do this I'd appreciate it. I'm trying to learn and not just copy code.

Thanks.

Edited by Asclepius

Share this post


Link to post
Share on other sites

_center = createCenter east;
_grp1 = createGroup east;
_grp1 = [getMarkerPos "Bad", east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;
_grp1 setFormation "LINE";
_grp1 setBehaviour "COMBAT";

{_x doWatch markerPos "HILLWATCH"} foreach (units _grp1)

As for the explanation I would recommend going to each command and reading what is says.

For example:

Group = createGroup side

Side would be east,west,civilians,guer, etc

Group would be the name of your group, in your example you've named them _grp1 which is a local variable. If you named them grp1 they would be a global variable.

_SideHQ = createCenter east

Side is the same as above.

_sideHQ can be whatever you want it to say. You must make sure that you have at least one unit on the map of the side you are spawning with a probability presence of 0% if you do not use createCenter.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

hello! use the command "units" to separate a group into an array of units.

 foreach units _grp1 

Share this post


Link to post
Share on other sites

Thanks guys. I should have been more specific, I just meant the dissection of the last part (putting a group in to an array). I'll try this when I get home.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×