Jump to content
iWazaru

Get All ai from a side in radius then set them new WP or Task

Recommended Posts

Hello all,
 

I am running a project where kind of opfor is Gendarmerie that act like real. Patrolling, chilling, and shoot at armed people.
(Player use Incon Incognito script, who's running well)

Spawn people with enigma civ, that mix with Fleeing Civ run well.
If i shoot near a civilian,
EH  create a marker, spawn two reinforcement that drive to the point.
There is check exist condition, peremption condition, no problem with that.

BUT

I have too Gendarmerie vehicle spawned by a second instance of Enigma traffic.

So, Im a trying to get all Gendarmes present, and set them to go to the same marker when the civilian EH is triggered.
And no way.
 

// Get actual alive west around 
//=====================================================================

_side = WEST;
_radius = 4000;

_nearMen = nearestObjects [player, ["Man"], _radius];
//_nearMen = entities [[], [], true, true];
{
if (side _x == _side) then {
# INSERT YOUR FAIL HERE
}
} foreach _nearMen;
};
//=====================================================================

I have fail a lot of things, like add group to an array and give them new wayoint
( Fail because they never get the new WP, not because they dont execute it instantly )

  

{
   	_grp = group _x;
  	_local_reinforc append [_grp];

 };
} forEach (_nearMen - [player]);


// And then
{

 if (side _x == _side) then {

     [_x, getMarkerPos "intervention", 1 ] call BIS_fnc_taskDefend;
     [_x, 1] setWaypointSpeed "FULL";
     [_x , 1] setWaypointCombatMode "RED";
     [_x , 1] setWaypointBehaviour "AWARE";
} foreach _local_reinforc;


I have try to delete all WP prior to execute,
I have try to get all task and delete before give a new one, but result is always the same :
None reaction.

Please.

Help..

 

Share this post


Link to post
Share on other sites

Try to delete all waypoints and afther that, add your, commands waypoints and deleteWaypoint🙄

Share this post


Link to post
Share on other sites

_local_reinforc seems to be an array of groups. But where did you define it? As local variable, it must be defined inside the script (even the scope) you want to use it.

Share this post


Link to post
Share on other sites
10 hours ago, iWazaru said:

_local_reinforc append [_grp];

is equal to

_local_reinforc pushBack _grp;

The second one being faster.

 

10 hours ago, iWazaru said:

{
if (side _x == _side) then {

[_x, getMarkerPos "intervention", 1 ] call BIS_fnc_taskDefend;
[_x, 1] setWaypointSpeed "FULL";
[_x , 1] setWaypointCombatMode "RED";
[_x , 1] setWaypointBehaviour "AWARE";
} foreach _local_reinforc;

This code has a syntax error, you are missing the closing "}" of the "then", this code shouldn't be able to even execute

 

 

Quote

{
       _grp = group _x;
      _local_reinforc append [_grp];

 };
} forEach (_nearMen - [player]);

This too has a syntax error, the closing "};" is never opened.

Share this post


Link to post
Share on other sites
10 hours ago, iWazaru said:

_nearMen = nearestObjects [player, ["Man"], _radius];

I think the performance of this might be bad if you do it over 4km.

_nearMen = allUnits inAreaArray [getPos player, _radius, _radius]

This is probably better, not sure if _radius or _radius/2 should be used here.

  • Like 1

Share this post


Link to post
Share on other sites

Ok, thank you all for your answer !

Here was the nooby mistake

On 4/2/2020 at 8:41 AM, pierremgi said:

_local_reinforc seems to be an array of groups. But where did you define it? As local variable, it must be defined inside the script (even the scope) you want to use it.


I was calling a method on a non declared variable... And the engine wasn't triggering error so... it work now !
In a proper test environnement, everything work as is.
In the mission, with a lot of spawned AI, managed by EOS, and VCOM, and Enigma, this is another stuff. But, its ok for the basics now! Thank you Pierre.

@Dedmen : The pieces of code i was dumping in the topic was some previous part that i was having kept in commentary. I haven't checked them before drop, forgive me.
 

On 4/2/2020 at 10:43 AM, Dedmen said:

I think the performance of this might be bad if you do it over 4km.


_nearMen = allUnits inAreaArray [getPos player, _radius, _radius]

This is probably better, not sure if _radius or _radius/2 should be used here.


Yeah, i have give it a try and work nice ( I was using entities to get vehicles too, allunits do the job aswell)

So, here is the working (Not optimised) code :

	// Get actual alive West to marker
	//===================================================================== 

              _side = WEST; 
              _radius = 4000; // Or less if your CPU Fly around the room

    // getpos azimut is unclear. Multiple test with multiple value and inconsistent results. 
    // 90 seems to be enough to make à 360 scan (The value seems to be check on all his axis. 
	// But i let you all the fun to spawn units 360 around and play with the radius value.. 
              _nearMen = allUnits inAreaArray [getPos player, _radius, 360]; // i've selected 360 to be sure

	// We declare the group array...
              _local_reinforc_raw = []; 
 
              { 
               if (side _x == _side) then { 
                     _grp = group _x; 
                     _local_reinforc_raw pushback _grp; // Following documentation, append and pushback seems to be the same, just better than "+"
               //Clean running task
                     _allxTask = _x call BIS_fnc_tasksUnit; 
                     _allxTask apply { _x call BIS_fnc_deleteTask}; 
  			  // Clean waypoint                   
			         while {(count (waypoints group _x)) > 0} do 
                     { 
                     deleteWaypoint ((waypoints group _x) select 0); 
                     }; 
                     waypoint1 = (group _x) addwaypoint [getpos _x,0]; 
              }; 
              } foreach _nearmen; 
	// Delete duplicate
              _local_reinforc = _local_reinforc_raw arrayIntersect _local_reinforc_raw; 
	// Fire task assignment
              { 
               [_x, getMarkerPos "intervention" ] call BIS_fnc_taskattack; 
               [_x, 1] setWaypointSpeed "FULL"; 
               [_x, 1 ] setWaypointCombatMode "RED"; 
               [_x, 1 ] setWaypointBehaviour "AWARE"; 
              } foreach _local_reinforc;

 

Thank you guys !


 

 

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

×