Author Topic: Finally found a partial fix for the AI howitzer issue  (Read 1476 times)

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Whilst I've hit some annoying problems with getting the current AI minimod version finished (notably planes not firing rockets, and bots not firing small arms at exposed vehicle crew positions), I've finally found out how to get the AI to use artillery howitzers (and the Nebelwerfer): Just set the indirect fire value for HE shells (weaponTemplate.indirect) to "0" in the weapons.ai file.
Bots will now be able to fire artillery at anything they can see (and with the raised viewpoint, this is quite a lot - for example, the German LeFH18 on Siege of Tobruk can fire at the British forward line, and the British 25pdr at the two bases nearest the main). 

By default, all FH2 artillery weapons have HE shells set for indirect fire. However, BF2's AI only seems to recognise mortars as "indirect" weapons. The AI treats howitzers as direct-fire weapons, same as an AT gun (bots can automatically work out the amount of vertical elevation to get the round to hit, same as with low-velocity tank guns) so they won't work if you set them as indirect-fire weapons. (The Nebelwerfer will occasionally fire if set as indirect - but not as much as it does now...)

This is still only a partial fix, bots are still limited to targets in their visual range and they can't fire at spotted targets. They're also oblivious to scenery blocking their line of fire (the Nebelwerfer on Totalize usually ends up hitting the windmill when firing at Allies advancing along the road/railway). Bots also seem very reluctant to use howitzers on some maps, especially if they're on the attack (the US 105mm on Cobra should be able to see plenty of targets from its hilltop position, but I never saw a bot use it).
I suspect there's not a lot more that can be done to improve things, though if I can find a way to raise the viewpoint higher without blocking spawnpoints, it should allow the bot gunners to see more distant targets.

One other thing: I've disabled the AI for howitzer AP rounds, I initially did this just to try and get bots to fire HE, before I discovered the direct fire fix - but I'm thinking it would be a good idea to keep this change, since bots are notoriously bad at picking the right shell type. Direct HE hits appear to be able to kill most FH2 tanks in one shot, so the lack of AP shells isn't a great disadvantage. Anyone have any thoughts on this?

Offline Raziel

  • Jr. Member
  • **
  • Posts: 859
  • Bullet Magnet
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #1 on: 24-06-2010, 20:06:39 »
Woooohhhooooooooo!!!  :o
Congrats Drawde!! U really amaze us mate!

You mentioned never seeing a bot use the howitzer on Cobra....yesterday was playing the updated version by Remick and sure enough there were bots manning the howitzer but unfortunately not firing it....they were turning it 360 degrees and even altering the elevation of the barrel.

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #2 on: 24-06-2010, 20:06:21 »
Same here. Seen bots man them more often than not.

Great job man. If anyone could, it would be you.

I think setting howitzers as both offensive and defensive weapons might help bots use it more, since howitzers have great use for attackers also.
Same goes for the nebelwerfer, deployable mgs like the .30cal, and mortars.
About the rockets, did you try to work them to work without a missile lock?

Offline Remick04

  • Moderator
  • ***
  • Posts: 103
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #3 on: 24-06-2010, 20:06:41 »
Excellent work Drawde! I'm really looking forward to you ai updates! Now if we could only figure out why artillery and mortars seem to ignore infantry on maps with vehicles, and why they don't seem to fire at their max range even if nothings obstructing their view.

On a somewhat related note... Do you know if the US 81mm Mortar suffers from the same aiming bug as the British 3inch once did? On one of the maps I'm currently working on I've got the US bots entering their mortars but they never fire at anything... vehicles or infantry. When I watch them I see them rotating left and right, but not up and down. This is using your current 2.26 beta files...

Offline Raziel

  • Jr. Member
  • **
  • Posts: 859
  • Bullet Magnet
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #4 on: 25-06-2010, 08:06:47 »
With the elevated perspective for artillery what will limit the bots maximum view distance? Is it the same as the fog generation distance? AFAIK bots can see through fog, so what is their limit?

Offline Devilman

  • I belong to Naughty Club
  • **
  • Posts: 274
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #5 on: 25-06-2010, 08:06:28 »
Yes bots can see through fog,and see in the dark
Bots also know where all human players are on the map
Bots also precalculate a projectiles trajectory,and will not shoot unless the projectile can reach/hit their target
I also (through testing) have found out that the distance in a weapons AI for for the bots to engage,is probably only about,maybe,perhaps etc,about 70/80 % of its premade distance code


Offline Raziel

  • Jr. Member
  • **
  • Posts: 859
  • Bullet Magnet
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #6 on: 25-06-2010, 08:06:39 »
So technically if the weapons' ai can be altered to be effective at an X amount of distance before vanishing, then bots will fire the weapons. Eg effective distance of projectile 2500m -> Bots will fire the weapon to a target not more than 2000m away (80%) Did I get you right Devilman?

Offline Devilman

  • I belong to Naughty Club
  • **
  • Posts: 274
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #7 on: 25-06-2010, 08:06:14 »
that would be a very safe number
but basically keep slowly increasing the distance,till the desired target distance is reached

Quote
weaponTemplate.minRange 10.0
weaponTemplate.maxRange 110.0

my tests were made in a chopper with a bot gunner,and i had added a range finder to my HUD

Note ..certain projectiles have a time to live code,which sometimes needs to be checked with its velocity

BUT 1 important thing,the more possible types of targets,and the more different weapons a vehicle/stationary weapon has,the more the bots get confused,and actually fire less "overall"

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #8 on: 25-06-2010, 15:06:39 »

Bots also know where all human players are on the map

Not sure about that. Bots on guns or even as infantry can be sneaked up on and will only be aware of you when you start firing, or if you are in a vehicle and get close to be 'heard'

Something I noted since bots in Fh1 had omni-presence  ::)

Offline Devilman

  • I belong to Naughty Club
  • **
  • Posts: 274
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #9 on: 25-06-2010, 15:06:35 »

Bots also know where all human players are on the map

Not sure about that. Bots on guns or even as infantry can be sneaked up on and will only be aware of you when you start firing, or if you are in a vehicle and get close to be 'heard'

I am quite sure i recall hearing that a few years ago,but i may be mistaken
but remember,bots have builtin priorities,and also map specific priorities,so their attention isnt always focused on attacking the enemy

Edit...maybe its more like "the computer" knows where humans are,arty will always aim for you in singleplayer
also read post #4

http://forums.bf2s.com/viewtopic.php?id=73708
« Last Edit: 25-06-2010, 15:06:15 by Devilman »

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #10 on: 25-06-2010, 21:06:27 »
I'll release a separate file package containing the howitzer fix soon, as it may be a few more weeks before I finish the final version of the 2.26 minimod. This will need to be manually added into your mod .zip files.

Howitzers (and mortars) already have high priority for both defence and offence, as well as very high temperatures. The map strategy files also affect whether or not bots use static weapons.

I've decided to add AP shells back in (I only really disabled them in a futile attempt to get the bots to fire HE) but with a very short range (200 or so) and only against light/medium/heavy armour targets - so bots can use howitzers against tanks at close range, but they'll always fire HE when bombarding distant targets.

The range issue is interesting, I think I'll just give all howitzers a max.range of 2500, which should be far enough to hit more or less anything on the map. (Currently it's only 1000)

On a somewhat related note... Do you know if the US 81mm Mortar suffers from the same aiming bug as the British 3inch once did? On one of the maps I'm currently working on I've got the US bots entering their mortars but they never fire at anything... vehicles or infantry. When I watch them I see them rotating left and right, but not up and down. This is using your current 2.26 beta files...

Haven't spotted this bug yet, I did see a bot manning the US mortar on Luttich and not firing, but I assumed this was because nothing was within range. The 81mm mortar .tweak files seem to have been "cloned" from the sGWr34, and have the same elevation/rotation movement values.

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #11 on: 28-06-2010, 21:06:17 »
On a somewhat related note... Do you know if the US 81mm Mortar suffers from the same aiming bug as the British 3inch once did? On one of the maps I'm currently working on I've got the US bots entering their mortars but they never fire at anything... vehicles or infantry. When I watch them I see them rotating left and right, but not up and down. This is using your current 2.26 beta files...

I've tested out the US 81mm mortar (replaced the British mortars with it on Siege of Tobruk) and it appears to work correctly, bots can aim vertically as well as rotate, and will fire at targets OK.

The artillery fix "patch" will included updated mortar files, so if there's an error with the 81mm in the 2.26 beta version, it should be fixed by the patch.

Offline Raziel

  • Jr. Member
  • **
  • Posts: 859
  • Bullet Magnet
    • View Profile
Re: Finally found a partial fix for the AI howitzer issue
« Reply #12 on: 29-06-2010, 11:06:51 »
Take your time Drawde! Admire your perseverance! Good job once again!  :D