Jump to content
Sign in to follow this  
Scrub

How do I know the unit has target in sight?

Recommended Posts

Hi all,

I was wondering if some guru could tell me how to script the knowledge that my unit has a target lined up and is clear to fire. If I just tell them to target the unit, they will... Through buildings, terrain, buses - you get the idea. While their barrels are pointed right at the target, they don't exactly have the ability to hurt it. Any ideas welcome, and thanks in advance. :)

Share this post


Link to post
Share on other sites

knowsAbout command seems to check if the AI know about another unit and by 'how much'.

If they unit has an assigned target, you can use assignedTarget.

Edited by Benny.

Share this post


Link to post
Share on other sites

You could try "unitReady unit" after giving unit the command to target something. But it may not be very reliable.

Why not just wait till they actually fire, since they normally only do that if there is a chance to hurt the target?

What do you want to use this for ?

Share this post


Link to post
Share on other sites
knowsAbout command seems to check if the AI know about another unit and by 'how much'.

For the problem at hand, I would use this : KnowsAbout returns a decreasing value when target is not in sight anymore. 2 consecutive readings should tell you if there is LoS. Big issue though : groups share their knowledge, meaning that if a squad member has LoS, but you test on another squad member that has no LoS, you'll get a false positive anyway.

Perhaps another trick would be to create a particle, shoot it from unit 1 to unit 2, and see where the particle stops...

Share this post


Link to post
Share on other sites

Thanks for all the replies. I'm looking for certanty on the target in sight, because I have several more decisions to make, and can't really trust inferring they *might* have it. Kind of like a big formula, if you get one part in the beginning sort of off, the rest quickly becomes a mess.

The particle idea sounds pretty concrete, thanks for that whisper. I know how to generate the particle, position it, and set vector velocity, how do I tell if it hits someone?

Again sorry for being a noob, but the functions and syntax in BIS games is beyond my capacity to use correctly, and I cant see how to hand off the name of what the particle collides with. Just a small snippet to get me going? oh, please oh, please? :bounce3:

Share this post


Link to post
Share on other sites

Sry for late reply. Perhaps just record in a loop the particle position until it disappear, then check the distance between last particle's known position and unit 2? if greater than... well, like 1m, then no LoS? (mmh, not really precise, unfortunately.).

Or use nearObjects, nearestObjects or one of the like, with object type of "All" to list all objects nearby last known particle's position, and you can determine if something stands in between?

I'm afraid i'ts still not good enough, for houses case for example, the unit 2 may be inside so hidden, but the house object's position, ie its center, would be "behind" unit 2 relative to last known particle's position and you can't know one of the wall is in front :(

Pretty tough matter

EDIt : another, not really good, but meh : shoot him!, really, with a real ammunition but changing velocity just at the last moment to avoid killikng unit 2, add an eventHandler "hit" on unit 2, and if unit is hit, then you have LoS! :D You'd have to remove the damage done afterwards, though

Share this post


Link to post
Share on other sites

Very creative idea, thanks!

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  

×