Jump to content

Recommended Posts

How to get this idea to work?
AI group join another AI group if group size less 3.

this is a good start from what I have found on the forum.

 

if (count (units AI_GROUP) < 3) then { hint "HI" };

 

I think that the AI should be found at x distance from a team then the AI could join the team, but if not found then "FALSE"

Share this post


Link to post
Share on other sites

Hey I don't know what you are looking for but drongos hands command menu give you the ability to recruit any group on the map under your control. It has a lot of good functions to add to your ability to command your units 

 

Share this post


Link to post
Share on other sites

Something like...

//initServer.sqf

#define NEAR_GROUP_DIST	2000
#define MIN_GROUP_SIZE	3

addMissionEventHandler[ "EntityKilled", {
	params[ "_killed", "_killer", "_instigator", "_useEffects" ];
	
	//If the _killed is a man
	if ( _killed isKindOf "CAManBase" ) then {
		_group = group _killed;
		
		//Only if it is not a player group and the group size( alive units ) is less than MIN_GROUP_SIZE
		if ( units _group findIf{ isPlayer _x } == -1 && { count ( units _group select{ alive _x } ) < MIN_GROUP_SIZE } ) then {
			//All groups that are not this group and are the same side, listed by [ _distance, _group ]
			_nearGroups = ( allGroups - [ _group ] ) select{ side _x isEqualTo side _group } apply{ [ leader _x distanceSqr leader _group, _x ] };
			
			//If we have found any groups
			if ( count _nearGroups > 0 ) then {
				//Only those groups that are within NEAR_GROUP_DIST
				_nearGroups = _nearGroups select{ _x select 0 <= NEAR_GROUP_DIST };
				
				//If we have any groups within distance
				if ( count _nearGroups > 0 ) then {
					//Sort by distance
					_nearGroups sort true;
					//Join nearest
					units _group joinSilent ( _nearGroups select 0 select 1 );
					//Clear up old group
					deleteGroup _group;
				};
			};
		};
	};
}];

 

  • Like 1

Share this post


Link to post
Share on other sites

thank you, I didn't think it would be so easy to find an answer.
 

doesn't work as I imagined but a good start, can this also work as a loop?

Edited by Casio91Fin

Share this post


Link to post
Share on other sites
1 hour ago, Casio91Fin said:

doesn't work as I imagined but a good start,

Well, you didn't give me much to go on 😀. So I presumed that as AI died and the groups became thinned out you wanted them to find nearby groups to join.

 

1 hour ago, Casio91Fin said:

can this also work as a loop?

Why would you want a loop? The event is a Mission event so it works continuously for any groups( not those with a player ) that have units killed.

  • Like 1

Share this post


Link to post
Share on other sites

What Larrow means is that the Event Handler would work probably as you imagined a Loop would but it is far cheaper not firing repeatedly but checking only at the event that an entity is killed. He's assuming your talking about Units have that lost their Groups and thereby need to join another. What it sounds like your after is that for ANY individual or small 2 man group to seek out a larger group to join. Most people wouldnt assume that because that would break alot of mission

  • Like 2

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

×