Jump to content
Sign in to follow this  
atledreier

Get array of detected targets

Recommended Posts

Is there any way for a group or unit to pass an array of all their detected units?

Share this post


Link to post
Share on other sites

Thank you!

I am assuming this only returns targets the unit actually knows about?

Share this post


Link to post
Share on other sites

Yeah "nearTargets" will return all units in the given range/position friendly and enemy.

So you would need to do something like:

private ["_unit","_targets","_count","_selectTarget"];

if (isNil "EnemyArray") then
{
EnemyArray = [];
};

_unit = MyUnit;

_targets = _unit nearTargets 200;

if (count EnemyArray > 0) then
{
_targets = _targets - EnemyArray;
};

if (count _targets > 0) then
{
_count = 0;

while { (_count < count _targets) } do
{
	_selectTarget = (_targets select _count);

	if ( (_unit knowsAbout _selectTarget > 0) && (_unit countEnemy [_selectTarget] > 0) ) then
	{
		EnemyArray = EnemyArray + [_selectTarget];
	};

	_count = _count + 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  

×