Jump to content
johnnyboy

detect if AI is being fired upon

Recommended Posts

I want to be able to detect if a particular AI is being fired at by the enemy.  FiredNear eventHandler is not good enough, as the AI may not be the target, and anyone within 70 meters (friend or foe) could be firing.  I can put Fired eventHandlers on the enemy AI, but that eventHandler does not tell you who he is shooting at.

 

How can I detect when AI shooting at or near a particular AI?

 

Thanks!

Share this post


Link to post
Share on other sites
14 minutes ago, johnnyboy said:

I want to be able to detect if a particular AI is being fired at by the enemy.  FiredNear eventHandler is not good enough, as the AI may not be the target, and anyone within 70 meters (friend or foe) could be firing.  I can put Fired eventHandlers on the enemy AI, but that eventHandler does not tell you who he is shooting at.

 

How can I detect when AI shooting at or near a particular AI?

 

Thanks!

You could use assignedTarget inside the fired eventhandler, but that doesn't work reliably either, since it can occasionally return objNull for some reason.

Tried to do something similar back in the days without finding a 100% reliable way to return a units current target.

 

Cheers

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Yes, same remark as GOM.

For my turrets, changing ammo along with the type of target, I'm using:

_tgts = (_unitFiring targets [true,700]) apply {[_unitFiring aimedAtTarget [_x],_x]};
_tgts sort false;

_tgt = _tgts select 0 select 1;

 

Perhaps, it's a little bit heavy as you need to loop it and apply it to several units.

  • Like 2
  • Thanks 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

×