Jump to content

Photo
- - - - -

Get array of detected targets


  • Please log in to reply
3 replies to this topic
Thread Starter
atledreier
atledreier

    Private First Class

  • Members
  • 31 posts

  • Joined: 08-July 2009

Posted 07 May 2010 - 06:05 #1

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

Benny.
Benny.

    Staff Sergeant

  • Members
  • 369 posts

  • Joined: 21-May 2009

Posted 07 May 2010 - 10:32 #2

nearTargets will work.

Thread Starter
atledreier
atledreier

    Private First Class

  • Members
  • 31 posts

  • Joined: 08-July 2009

Posted 07 May 2010 - 11:18 #3

Thank you!

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

SNKMAN
SNKMAN

    Sergeant Major

  • Members
  • 1617 posts

  • Joined: 29-August 2006

Posted 07 May 2010 - 12:30 #4

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;
	};
};

Posted Image