Jump to content
Blitzen88

How to get an array of enemy groups spotted by a side

Recommended Posts

Trying to figure out how to get an array of enemy groups which have been “spotted” by the player’s side.

 

I can get a list of all groups by using:

 

_Variable = allGroups select { playerside getfriend side _x <= 0.6}
 

But I dont know how to then filter/reduce that array to groups that have been spotted by the player’s side. 
 

The knowsAbout command seems promising but it’s apparently inconsistent and it always requires units - not groups? Would Bis_fnc_enemyTargets work?

 

 

The ultimate goal is to apply map markers to known enemy groups - without using Marta

Share this post


Link to post
Share on other sites
12 hours ago, Blitzen88 said:

Trying to figure out how to get an array of enemy groups which have been “spotted” by the player’s side.

 

I can think of two ways.

 

Method 1:

  • For each group of detecting side, command: groups playerSide
    • Call command targets on the current group
    • Use the result to create your marker

Method 2:

  • For each group of the detecting side
    • Add an "EnemyDetected" event handler
      • In the event handler add your marker
      • If you need information on the enemy you can use _groupLeader targetKnowledge _target

 

These methods doesn't include how you track markers, check if an object has a marker or delete markers that are no longer relevant.

If you want it, here's how I'd solve that:

Spoiler

 

There are probably other ways but I would maintain two HashMaps:

  • DetectedUnit -> Marker                   (Use BIS_fnc_netID as key)
  • Marker -> DetectingGroup,Target.

When detecting a new unit you check against the first hashmap if a new marker should be added or an old one needs to be updated.

If the target already has a marker you check if the new detecting group has the better knowledge set that in the second HashMap.

 

To update your markers you iterate over the second  HashMap and get the targetKnowledge info again..

 

Iterating over a HashMap isn't that expensive compared to an array and the benefit of the quick and easy lookup is really nice and should keep things performing well with lots of groups and targets.

 

 

Edit: Oops, just realized you wanted groups, but the logic should be easy to extend to manage detected groups instead of individual units.

 

The key is to remember that AI doesn't see groups, they see units. Groups are just an abstract composition, so you have decide what it means to "create a marker on the group". Do you mark the group leader's position or the average position of all units in the group? Do you include units that aren't detected yet? Do you interpret clusters of units as s group or rely on the game's predetermined groups.

Share this post


Link to post
Share on other sites
5 hours ago, mrcurry said:

The key is to remember that AI doesn't see groups, they see units. Groups are just an abstract composition, so you have decide what it means to "create a marker on the group". Do you mark the group leader's position or the average position of all units in the group? Do you include units that aren't detected yet? Do you interpret clusters of units as s group or rely on the game's predetermined groups

 

  Hide contents

Would likely create a group icon on the group leader’s location if a single unit of that group has been detected. 
 

I will look into targetknowledge and targets - those commands were not on my radar

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

×