Jump to content
madrussian

Alternative to assignedTarget

Recommended Posts

Playing around with assignedTarget command, using some visual indicators and rays to see what's going on under the hood.

 

I had always assumed that assignedTarget was how to tell who a given unit is targeting (and always used it this way), but appears this is actually only partly true and the implications are perplexing. 

 

Here the setup:

 

It's just me the player facing off against a bunch of enemy, with player damage turned off so I can observe properly (aka without getting killed).  So basically I have red rays being shown from all AI units to their assignedTargets.  And when they don't have an assignedTarget, their red ray disappears.  All enemies are aiming/shooting at me (again I'm the only one to shoot at), but only some of the enemy (perhaps 60%) have the red rays.

 

So perhaps 40% of enemy dudes are aiming/shooting at me without me being their assignedTargets.

 

The question is:  For these remaining 40%, how do I get their target?

 

(Btw - One conclusion I've reached based on this test is that assignedTarget is really about the leader assigning targets.  Anyhow, how on earth do we simply get the actual target?)

Share this post


Link to post
Share on other sites

I did see getAttackTarget when looking through all the target related commands, but something I read about that specific command on different command ref made me think it was for example, when an AT unit is going after a tank, the tank would be his "attack target", but he would target other units on the way to attacking tank.

 

If getAttackTarget really returns what I'm describing in OP (getting the simple target), then I find it bizarre that anyone/everyone has managed to get by this long (since the beginning of the series) without it!

 

Regardless, many thanks I will check it out and report back. 🙂

 

  • Like 2

Share this post


Link to post
Share on other sites

AttackTarget = what unit the AI currently goes after

AssignedTarget = what the AI(?) GL has assigned - however AI engage targets also without assignment 

  • Like 1

Share this post


Link to post
Share on other sites

Quick follow-up, finally checked out the getAttackTarget command (running Development Build 1.99.146550).  Result is quite disappointing.

 

In short, getAttackTarget appears to be operating like an simple alias for assignedTarget.

 

Specifically, same test as before:

Quote

It's just me the player facing off against a bunch of enemy, with player damage turned off so I can observe properly (aka without getting killed).  So basically I have red rays being shown from all AI units to their assignedTargets.  And when they don't have an assignedTarget, their red ray disappears.  All enemies are aiming/shooting at me (again I'm the only one to shoot at), but only some of the enemy (perhaps 60%) have the red rays.

 

^ Only now I also added green rays from unit to their getAttackTarget (slightly offset upward from the red rays so the two rays don't overlap).

 

In my experience, the only time I see the green rays (for getAttackTarget) is when red rays (for assignedTarget) are already showing.  In this case, both red rays and green rays appear at the same time (and always to the same target).  [Also, I checked my code several times to ensure red ray points to assignedTarget and green ray points to getAttackTarget.]

 

Next, I also independently monitored these units and verified that getAttackTarget returns objNull until assignedTarget actually returns a target, and then at that moment getAttackTarget also returns that same target.  Even in cases where the unit was focused and shooting on me for some time well prior to me becoming his assignedTarget.

 

I reread the getAttackTarget command description, which says:

Quote

Returns a unit's assigned/engaging target.


And the example given is:

Quote

_theEnemyWhoHesAimingAt = getAttackTarget unit;

 

In summary, (at least at present) appears getAttackTarget command does NOT work as advertised (in the example anyhow).

 

^ Curious if someone else can confirm what I'm seeing in-game?

 

(Important - Perhaps the description of getAttackTarget is actually correct, and this command will indeed return the target he is engaging, but he will aim and fire at other targets along along the way during his engagement of his main target.)

 

Meanwhile, back to the original question:  How to find out via script command who a AI unit is targeting, when he is obviously aiming at (& shooting at) an enemy unit, but he has no assignedTarget?

 

Surely there is a way?  Otherwise, if everyone is simply using assignedTarget, seems to me that can't be very efficient or proper for current AI mods.  We need to know who these AIs are aiming at!

 

Share this post


Link to post
Share on other sites
51 minutes ago, madrussian said:

Meanwhile, back to the original question:  How to find out via script command who a AI unit is targeting, when he is obviously aiming at (& shooting at) an enemy unit, but he has no assignedTarget?

Surely there is a way?  Otherwise, if everyone is simply using assignedTarget, seems to me that can't be very efficient or proper for current AI mods.  We need to know who these AIs are aiming at!

 

 

aimedAtTarget only works for vehicles. Perhaps something to ask as feature request.

  • Like 3

Share this post


Link to post
Share on other sites
9 hours ago, .kju said:

still getting improved: https://feedback.bistudio.com/T152567

 

Thanks, that's exactly what the doc ordered.

 

Quick summary from the report (for those interested):  Looks like two others had my exact issue with getAttackTarget for AI led groups, and like it currently works correctly for player squad AI.

 

Quote

https://feedback.bistudio.com/T152567

BIS_fnc_KK added a comment. (Mon Aug 3, 2:28AM)

 

"xShould work better from 1.99.146567"

 

Very nice, there is hope still. 🙂

  • Like 1

Share this post


Link to post
Share on other sites

What about the group targets ? 

I input a = group this;  {getattacktarget _X} foreach units group a

And it returns objNull , anyway to  get an array of all targets engaged by the group ?

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

×