Jump to content
arma_max

Group multiple groups in batallion

Recommended Posts

Hi,

 

i am creating a scenario where I want to build some kind of battalion composed of multiple different groups. The idea is to have multiple different battalions and then direct them to different targets. 

 

I know that i can use waypoints for all the groups and sync them all per battalion but is there another more elegant to group them all together and just assign waypoints to that battalion instead?

 

needs to work in SQF files, not by placing groups and waypoints in Eden. 

 

Max

Share this post


Link to post
Share on other sites

Hello arma_max and welcome to the forums.

 

Regarding your question... In general you can put units in the same group with the join command. If you have named the units then this would be as simple as

private _hq = createSide WEST; // Create a side, which is needed to create a group -> ONLY IN THE CASE YOU HAVEN'T CREATED ONE IN THE EDITOR
private _firstBattalion = createGroup [WEST, true]; // Create a group for the BLUFOR and set to be deleted when emptied -> IN CASE YOU DON'T HAVE A GROUP TO USE ALREADY

[unitOne, unitTwo, unitThree] join _firstBattalion; // This will assign the units in the array to the _firstBattalion group

This shows how to add three units to a group (after creating it). Similarly you could add as many units as you want. This is a "not-so-good" implementation as you have to hardcode all the units one-by-one. In a better implementation you would "proceduraly" find the units and add them to the array which will be as argument to the join command. For the last step it would be beneficial to agree to a name for all the units you wish to include (such as battalion_1_unit_X, where X is a number just to differentiate the units that will join the first battalion).

 

Now for the part of assigning waypoints... You can use the addWaypoint command. This will add a waypoint to a group. A simple example would be

_firstBattalion addWaypoint[[2508.64, 5681.47, 0.0356369], 50]; // Add a waypoint to the first battalion at a specific (random in this case... taken from a page of the wiki) position with a radius 50 metres (the waypoint will be chosen randomly in the circle with center the position and radius the specified radius)

Hope this helps a bit as a starting point. If there's anything more you would like help with, please don't hesitate to ask.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the explanation - I get the concept of groups and creating units and waypoints etc (years of Java coding are finally paying off 😉

 

but I was wondering if there is any construct to group multiple groups in one super group? In a worst case scenario I would have to create an array per super group and add all groups to the array. If I then want to send the whole super group to the same destination, I just loop over all groups in the array.

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, arma_max said:

Thanks for the explanation - I get the concept of groups and creating units and waypoints etc (years of Java coding are finally paying off 😉

 

but I was wondering if there is any construct to group multiple groups in one super group? In a worst case scenario I would have to create an array per super group and add all groups to the array. If I then want to send the whole super group to the same destination, I just loop over all groups in the array.

Something to get you started:

 

//initPlayerLocal.sqf

//can populate the array with custom groups
TAG_battalion = allGroups select {side _x isEqualTo side player AND {isPlayer _x} count units _x isEqualTo 0};

//make controlled groups and movements visible on map
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", "
	_display = _this#0;
	{
		{
			_icon = getText (configfile >> 'CfgVehicles' >> typeof _x >> 'icon');
	    	_display drawIcon [_icon,[0,0,1,1],getPosVisual _x,24,24,getDirVisual _x,name _x,1,0.03,'TahomaB','right'];
			_display drawLine [getPosVisual _x,getPosVisual leader _x,[0,0,1,1]];
		} forEach units _x;
	} forEach TAG_battalion;

	{

		_offSet = [15,15,0];
		_iconPos = getPosVisual leader _x vectorAdd _offSet;
		_icon = getText (configfile >> 'cfgGroupIcons' >> _x getVariable ['GOM_fnc_groupIcon','b_inf'] >> 'icon');
		_grpInfoText = _x getVariable ['GOM_fnc_groupInfoText',groupID _x];
    	_display drawIcon [_icon,[1,1,1,1],_iconPos,24,24,0,_grpInfoText,1,0.03,'TahomaB','left'];
		_display drawLine [_iconPos,getPosVisual leader _x,[0,0,1,1]];
		_dest = (expectedDestination leader _x)#0;
		_dest set [2,0];
		if (!(vectorMagnitude _dest isEqualTo 0) AND (_dest distance2d getPos leader _x) > 20) then {
			_display drawLine [getPosVisual leader _x,_dest,[0,0,1,1]];
		_icon = getText (configfile >> 'CfgVehicles' >> typeof leader _x >> 'icon');
	    	_display drawIcon [_icon,[0,0,1,0.5],_dest,24,24,0,'',1,0.03,'TahomaB','right'];
		}
	} forEach TAG_battalion;
"];

TAG_fnc_moveMultiGroup = {
	params ["_groups","_spacing","_movePos","_watchDir"];
	{_x move (_movePos getPos [(_spacing * _forEachIndex) - (_spacing * count _groups / 2),formationDirection (leader (_groups#0))])} forEach _groups;
};

addMissionEventHandler ["MapSingleClick", {
	params ["_units", "_pos", "_alt", "_shift"];
	_groups = TAG_battalion select {{alive _x} count units _x > 0};
	[_groups,35,_pos] call TAG_fnc_moveMultiGroup;

}];

Obviously needs some more tweaking, like handling the direction of the battalion etc.

Could also add custom formations for all group, so groups on the edge will assume left/right echelon, center takes wedge and anything in between as line etc.

Then you could make all groups assume a half circle around the target position, plenty of possibilities, heh.

 

 

Edit: Here's the post containing the group icons on map snippet.

 

Cheers

  • Like 3

Share this post


Link to post
Share on other sites

Thanks a lot for that script, that gives me something to start with! :)

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, arma_max said:

Thanks a lot for that script, that gives me something to start with! 🙂

Feel free to post if you get stuck or can't figure something out after consulting the wiki.

 

Cheers

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

×