Jump to content
Sign in to follow this  
Spitfire

Knowsabout & ai behaviour

Recommended Posts

... but still some questions without answers!

Knowsabout, engage at will, hold fire, open fire and their effect to AI behaviour are probably the most controversial issues when it comes to mission makers' experiences about them. I decided to take the bull by the horns and do some experiments, in order to finally understand the AI. I did some research around it since I'd like to know how the AI will respond to different situations in different combat modes so I don't always have to do complex time-consuming scripting in order to make AI behave the way I want.

Especially when deciding when to fire and when to hold fire the AI seems to be very complex and seems to use higher mathematics than any of the above.

There are a couple of things I've found out for sure. Behaviour (safe, aware, combat etc) and unit skill level are both affecting AI's ability to determine the knowsabout-level at different ranges. And of course another factor is the stance of the target (prone, crouch, stand).

So far so good. Another fact is that knowsabout of 1.5 is a magical treshold value when any AI with "safe" behaviour WILL ALWAYS draw his weapon (ie, change the behaviour to combat) when confronting the enemy. What happens after that, I don't know for sure. If the AI is allowed to open fire, he will do it immediately after knowsabout reaches 1.5 and the weapon is drawn. Even if the weapon is drawn already the AI will hold fire until the knowsabout rises to 1.5. Only the combat mode of "Never Fire", of course, causes the AI to... eh... never fire. wink.gif.

However, if the AI is ordered to Hold Fire, neither the knowsabout level nor the distance seem to bear no importance whatsoever.

I've stared at the wrong end of an AK-47 at 10 m distance with enemy knowing everything about me (knowsabout=4) but still not firing, only pointing the gun at me. However, during the next experiment the same enemy with the very same behaviour opened fire at me when the knowsabout level was only 2.5 and the distance being more than 50 m. I found out that a combination of "Hold Fire" and "Engage at Will" results in drawing the weapon at knowsabout 1.5 but not firing until I pose a threat too big for the AI, whenever that might be. When only "Hold Fire" without "Engage at Will" is issued, the weapon is not drawn until the AI is ready to pull the trigger, so it may still be holstered even at 10m with a knowsabout level of 4.

So, the only mystery about AI behaviour hides in the "Hold Fire" -command. What are the factors that the AI uses to determine when to break the command and change their GREEN combat mode to YELLOW? I guess BIS's input is needed again smile.gif

After reading all that I'm written above I really feel like I'm splitting hairs here wink.gif. Knowing these things about AI behaviour has really bugged me for quite some time now but I hope all this aimless sleuthing I've done is of help for someone.

Share this post


Link to post
Share on other sites

I know it's a really old post, but I've found those info really useful for a simple mod I needed to create for a mission of mine, so...

Btw, I've found why knowsAbout values 1.5 and 4 are important: I took a look in CfgVehicles.hpp, and I've found most units have a line "accuracy=1.5", or inherit from a base class with such line.

So it seems when knowsAbout raises above the unit's accuracy value, it's reckonized and fired upon (if enemy combat mode is fit). Snipers have "accuracy=3.5", which is really high (4 is absolute maximum), but since the Sniper base class is a soldier (like in "class SoldierESniper : SoldierEB"), it's fired upon, because an enemy soldier is always a threat.

Camouflage soldiers (SoldierEFakeW and similar) have a sligthly raised accuracy value (2), but their base class is the opponent's side, so they are not fired upon until knowsAbout value rises above 2, which takes quite a bit for AI to.

This also explains a trick Suma has suggested to make a unit class look identically to its base class to enemy by setting "accuracy=1000", a value knowsAbout will never get to. Here's the example Suma quoted:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

//Western trucks

class Truck5t : Truck

{

   accuracy=0.30;

};

class Truck5tOpen : Truck5t

{

   accuracy=1000; // never recognized

};

The "accuracy=1000" causes the Truck5tOpen always to be reported as Truck5t whatever value knowsAbout is.

Also, note the low accuracy value Truck5t has, it is to make it get reckonized as enemy if knowsAbout raises above a lowish level, 0.3. As long as knowsAbout is below 0.3, the truck will not be fired upon since its base class Truck has no defined side (which I think causes AI not to fire upon it).

Share this post


Link to post
Share on other sites
Quote[/b] ]I've stared at the wrong end of an AK-47 at 10 m distance with enemy knowing everything about me (knowsabout=4) but still not firing...

That might also have to do with the AK's rate of fire settings as determined in the config

Share this post


Link to post
Share on other sites
Camouflage soldiers (SoldierEFakeW and similar) have a sligthly raised accuracy value (2), but their base class is the opponent's side, so they are not fired upon until knowsAbout value rises above 2, which takes quite a bit for AI to.

Nevermind, this is not true. I've tried a soldier with accuracy=3.9, it's fired upon when knowsAbout raises above 1.5.

Then I can't actually tell where the 1.5 knowsAbout value comes from...

Share this post


Link to post
Share on other sites

Hey thanks for doing this. This is very valuable information and will help me to make the functions I've written for my mission much more valuable.

I wrote a function that detects how many enemies from one group of soldeirs are within a certain distance and know a certain amout about any of another group of soldiers. The funtion returns an array of soldiers that meet the condition. Basically, it returns a list of soldiers in one group that are a threat to any soldier in another group.

I'll be using it to control the leaders behavior and keep him from doing stupid things (like continuing on a waypoint that leads to an unneccesary conflict) during the mission I'm making right now.

Another function I wrote return an array full of arrays. Each array contains two units and what each of the units know about eachother. Arrays are only returned if one unit knows about another unit.

Here is an example result: [[East Alpha1,2,West Alpha1, 0]]

According to the example results...

East Alpha 1 knows a little bit about West Alpha 1

West Alpha 1 knows nothing about East Alpha 1

I've though of better ways to format the returned array, but that give an idea of what it can return. I'm going to use this one to make a dynamic voice engine for the AI soldiers.

The information you provided will be helpfull in both areas I'm working on! smile_o.gif

Share this post


Link to post
Share on other sites

That means that you can now determine who you were spotted by. wow_o.gif That should allow you to make very dynamic missions indeed.

Share this post


Link to post
Share on other sites
Another fact is that knowsabout of 1.5 is a magical treshold value when any AI with "safe" behaviour WILL ALWAYS draw his weapon (ie, change the behaviour to combat) when confronting the enemy. What happens after that, I don't know for sure. If the AI is allowed to open fire, he will do it immediately after knowsabout reaches 1.5 and the weapon is drawn. Even if the weapon is drawn already the AI will hold fire until the knowsabout rises to 1.5.

This is wrong.. I did my own test after getting baffling results with the aformentioned data.

With Resistance (1.91):

No matter what class of unit the target is and no matter what the skill/class of the enemy AI, the magic "knowsabout" number is actually a very low 0.105.

With CWC (1.46):

No matter what class of unit the target is and no matter what the skill/class of the enemy AI, the magic "knowsabout" number is 0.7.

What this means it the AI will not fire on an enemy soldier until his "knowsabout" level of an enemy has reached the 'magic number' or higher.

Spitfire might have been led to belive the magic level was 1.5 because <s>as soon as an AI unit pulls the trigger on an enemy, the unit's knowabout level instatly jumps to 1.5</s>.

Edit:As soon as An AI unit gets hit with a bullet his knowsabout level for the unit that shot him will instantly jump to 1.5, even if the shooter is 1000m away. Vice versa is also true. If An AI soldier's knowsabout level for an enemy is 0.7 and the soldier fires and hits the enemy, his knowsabout level about the enemy will instaly jumpto 1.5.

This seems like some sort of AI tweak BIS implimented to make things more realistic.

I might post more later if I learn anything new.

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  

×