Jump to content
Sign in to follow this  
hectrol

[SOLVED] doMove ASLtoATL getPosASL GROUP to nearest Enemy

Recommended Posts

Hi and Help me with script please:

//Spawn group whit one unit. WORKS

Rastreadores_1 = [getmarkerpos "marker_P1", west, ["vn_b_men_seal_39"]] call BIS_fnc_spawnGroup;

and helpme with:

{_x doMove ASLtoATL getPosASL to nearest Enemy group in 1000 meters or all; } forEach units Rastreadores_1;


 

 

Share this post


Link to post
Share on other sites
7 hours ago, hectrol said:

 


{_x doMove ASLtoATL getPosASL to nearest Enemy group in 1000 meters or all; } forEach units Rastreadores_1;

 

Something like this should do: 

Spoiler

// Define "enemy"
private _group = Rastreadores_1;
private _possibleSides = [ BLUFOR, OPFOR, INDEPENDENT ];
private _enemySides = _possibleSides - [side _group];

// Find nearest group
private _nearestGroup = grpNull;
private _distance = 1e39; // Start at "infinity"
{
	if( side _x in _enemySides ) then {
		private _d = leader _x distance2D leader _group;
      	if( _d < _distance ) then {
			_distance = _d;
          	_nearestGroup = _x;
        };
    };
} forEach allGroups;

// Execute move if closer than 1000 m
if( _distance < 1000 ) then {
	units _group doMove getPos leader _nearestGroup;
};

 

  • Like 1

Share this post


Link to post
Share on other sites

Perfect mrcurry very very thanks. I added a loop to repeat and it turned out perfect. I'm going to mention you in the thanks of the very next stage "Stealth Mode On The Bra".  Pleased to meet you. You have an overwhelming talent.

  • Thanks 1

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  

×