Author Topic: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)  (Read 3409 times)

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
As other posters have mentioned, there appears to be a problem with the bot AI in FH2 2.25 causing them to not aim and rotate fixed AT and artillery guns. Bots will often man the guns when enemy tanks are near, but will not actually aim the guns and will only fire when enemies are right in front of them. Bots manning anti-aircraft guns do NOT have this problem and will aim at and track enemy planes very effectively - and if you set the AI strength values of the AA gun to allow it to be fired at ground targets, they'll aim at infantry and tanks just as well.

Any clues as to what could be causing this problem? I've looked at the object.ai files for the various AT, AA and artillery guns and there don't appear to be any significant differences in the data which could be causing the problem. A few gun types have very limited max/min rotation values, but altering these doesn't change the AI's behaviour.
Reading older posts from previous versions of FH2 seems to suggest that this problem wasn't present in previous versions - am I correct?
« Last Edit: 29-01-2010, 16:01:43 by Drawde »

Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery
« Reply #1 on: 27-01-2010, 12:01:49 »
I don't know about the early versions of FH, but 2.2 had the same problem.

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery
« Reply #2 on: 29-01-2010, 16:01:24 »
I think I've fixed the problem (after much comparing of the AA and AT gun .tweak and .ai files to try and find why exactly bot AA guns work but AT ones don't).

In the gun's objects.ai file, change the following lines:

aiTemplatePlugIn.aimHorizontalControl       PIMouseLookX
aiTemplatePlugIn.aimVerticalControl         PIMouseLookY
aiTemplatePlugIn.lookHorizontalControl      PIMouseLookX
aiTemplatePlugIn.lookVerticalControl        PIMouseLookY

to:

aiTemplatePlugIn.aimHorizontalControl       PIRoll
aiTemplatePlugIn.aimVerticalControl         PIPitch
aiTemplatePlugIn.lookHorizontalControl      PIRoll
aiTemplatePlugIn.lookVerticalControl        PIPitch

Most guns (excluding AA, MGs and mortars) have PIRoll/PIPitch rather than MouseLook as their input for turning and aiming, but all object.ai files (for every PCO) are set up with MouseLook as the aiming inputs. It might be possible to edit the gun .tweak files instead and change the inputs to PIMouseLookX/Y, but editing the objects.ai files is a lot simpler.

With these changes to all the AT and artillery gun PCOs, bots can now use them effectively. This should make a big difference to SP/co-op games, especially on maps like Siege of Tobruk where one side is defending. They still don't seem to know how to use mortars, though - the bots will aim them at targets but don't fire.

Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #3 on: 30-01-2010, 06:01:44 »
Yep, that works beautifully... 8)

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #4 on: 30-01-2010, 09:01:56 »
So hold on, these are spread out across Vehicles_Server.zip and weapon_Server.zip right? I basically went to every problematic gun's folder and replaced those lines... some seemed to appear more than once

I sure hope this doesn't crash my game... I'm not sure what files to replace

Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #5 on: 30-01-2010, 10:01:43 »
Yep, although I've only changed the GB guns so far (so I could test it on Siege of Tobruk) - the 6pdr and 25pdr are in objects_vehicles_server.zip and the 2pdr is in objects_weapons_server.zip.

She'll be right, just backup beforehand... ;)

When I've changed them all, I'll post a list of the affected guns...


EDIT: The guns that need fixin'...

DE
Flak18
Pak35
Pak35_static
Pak38
Pak38_static
Pak40
Pak40_static

GB
6pdr
6pdr_static
2pdr

They're all in the objects_vehicles_server.zip, except for the 2pdr which is in the objects_weapons_server.zip.


The US guns, the '57mm_m1_atgun_static' and the '76mm_M5_atgun_static' is where I found another possible problem...the objects.ai file of both is for a mobile gun. The .tweak files are different too by the look of it.

I don't know think there's any SP maps that these US guns are on atm, so I'm just going to leave them alone for the time being.
« Last Edit: 31-01-2010, 09:01:57 by cannonfodder »

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #6 on: 30-01-2010, 14:01:00 »
Now AT guns are mad deadly firing at tanks barely in view - I know tanks do so too, but AT guns are mad deadly, followed closely by the Crusader and Puma, then the 88... Other tanks are distant third.

Perhaps if bot infantry would use their hand-help weapons (i.e. from zooks, to rifles to grenades) on AT personnel, it might even things up cuz currently the only thing that can kill them is mounted mgs, which need constant firing to kill them and other tanks

And the latter, as should be, isn't up to the challenge. I had the single 76mm (I guess that will be the American version of the 6pdr?) on Luttich take out wave after wave of Tanks AND some infantry... And no one could stop it until I came on the scene, infantry either tossed smoke or bypassed it like it wasn't there


Oh, and unless it has HE shells, I don't think AT guns should fire at infantry. The Pak35 doesn't fire HE either, which is bad, and the 2Pdr (issue there since 2.15), like the Mg35 keeps making the firing sound in between its actual firing... it is wierd, you hear the gun firing at double speed, and yet you see it actually fire only half the time - Same goes for the mg34

YES, this should definitely be moved to SP.. please, Flippy?





Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #7 on: 30-01-2010, 16:01:05 »
Thanks Flippy.

Now AT guns are mad deadly firing at tanks barely in view - I know tanks do so too, but AT guns are mad deadly, followed closely by the Crusader and Puma, then the 88... Other tanks are distant third...
Fantastic, innit? Watchin' an 88 on Supercharge firing at everything that moved (inc. planes) was a joy to behold. And watching the 2pdr's on Siege firing at vehicles as they came over the crest of the ridge was pretty funny too... ;D

The problem with the AT guns is the bots are shooting at the gun itself and not the gunner. They probably see them as being "inside the vehicle" and as such they're effectively invisible.

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #8 on: 30-01-2010, 18:01:40 »
Indeed. But the .50cal pierces through the gun like the .50cal of the light British armor, destroying it if not killing the gunner and enough firing can get a headshot...  The idea is, let infantry be a threat to AT guns, first with suppressive fire (if its you, or for effect, or maybe distraction), then zook rockets, then grenades, charges and sticky bombs, then cold hard steel

Guns would always win against tanks - That's just how it should be, but infantry should win against AT guns - THAT too is how it should be... Same goes for other emplacements like mgs and AA guns... infantry should treat them like 'armored infantry' using all within their means (perhaps as well as anti-tank bombs)

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #9 on: 30-01-2010, 18:01:58 »
I'll see if I can fix the bug with the static US AT guns being defined as mobile (didn't notice that) for my AI tweak mini-mod which should be in a releasable state in a few days. Hopefully the FH2 developers will be able to fix this, as well as the AI aiming bug for the next official release, now that the problem has been tracked down (assuming they haven't found the problem already).
I think the mobile versions of the 6pdr and PaKs also need the AI control inputs fixing in the same way as the static ones - the bots don't seem to be able to aim them, though they can wheel them about (sometimes halfway across the map...)

The bots are certainly deadly with AT guns - even the 2pdrs on Siege of Tobruk managed to knock out several dozen German tanks before the guns were eventually taken out and the first defensive line overrun. Flak 88s and similar are beyond lethal - especially against AI tanks who don't have the sense to shell the gun positions with HE from as far away as possible before moving in.

Putting "aiTemplatePlugIn.setHasExposedSoldier 1" in the objects.ai file should (theoretically) allow bots to shoot at the gun/vehicle crew rather than the object itself - though tanks still seem to prefer firing shells at the guns.

Also, it looks like I was wrong about mortars - I twice spotted Allied bots firing them on Siege of Tobruk and El Alamein - though they're not very accurate to say the least. Haven't seen the AI use artillery yet. Bots still seem to be very reluctant to use mounted MGs, though, even though I've set them to have a high "temperature", defensive StrategicStrength and target strength vs. infantry.

Bubbles

  • Guest
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #10 on: 30-01-2010, 21:01:02 »
First great work by the group here to tweak the AI on FH2!

I can attest that this is the first time I've really seen mortars being used effectively by bots!


Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #11 on: 30-01-2010, 21:01:15 »
With mortars, bots fire them continually if an enemy is less than 10 meters away while they are mounting the piece, but they aim far off in the distance, this is especially noticeable in El Al, at Kidney ridge

What I don't get, however, is howitzers. Bots on a map like Gazala, can fire their tank cannons a good kilometer, but don't seem to care for howizers at all

A warning regarding artillery however is, once its fixed, we need to introduce some sort of check to prevent it becoming a rape-fest - For example, perhaps have bots like arty only partially so that they harass targets within range or LOS and then bet off the gun once there are none in sight so that arty can be used  only at times...

 Bots used to like the lafette Mg42 about 50-50 in 2.2, now however, they don't seem to see either the bipod or the tripod of this gun. They do use the mg34, although I've seen this occur i.e the lafette, only once in PHL. However, the bots consider it a must when they are close to the Mg15 and they stay on this gun indefinitely.

The worst part of dealing with bots is that there are so many schools of thoughts as to what bots should and shoudln't do, so when one person changes AI to do one thing right, they tend to  make bots do something else completely wrong

Inspite of all its shortcomings, however, I must say the 2.25 bots show signs that they underwent the most ambitious modifications... For instance, if you get the rare occasion where an AT-rifleman decides to lie prone to use his AT rifle, he remains there indefinitely firing flat - A sign that the devs tried to make bots use this position exclusively, or at eleast alot more than standing.

Also, bots who get startled by a tank or an enemy infantryman, run a good pace before stopping to fight or change direction, moreso than in 2.15 and 2.2, where fleeing was first introduced





Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #12 on: 31-01-2010, 09:01:18 »
I'll see if I can fix the bug with the static US AT guns being defined as mobile (didn't notice that) for my AI tweak mini-mod which should be in a releasable state in a few days...
Cool... :)

Quote
...I think the mobile versions of the 6pdr and PaKs also need the AI control inputs fixing...
Yep, they do...

Quote
...Putting "aiTemplatePlugIn.setHasExposedSoldier 1" in the objects.ai file should (theoretically) allow bots to shoot at the gun/vehicle crew rather than the object itself - though tanks still seem to prefer firing shells at the guns...
I'll have to try that...


G'day Bubbles... :)


...The worst part of dealing with bots is that there are so many schools of thoughts as to what bots should and shoudln't do, so when one person changes AI to do one thing right, they tend to  make bots do something else completely wrong...
IMO the main priority should be fixing the brainless commander. He ruins otherwise working maps with his stupid orders. Siege of Tobruk and Supercharge are good examples.

Quote
...Also, bots who get startled by a tank or an enemy infantryman, run a good pace before stopping to fight or change direction, moreso than in 2.15 and 2.2, where fleeing was first introduced...
I think they run a bit too far. The AT guys seem to run a mile when they see a tank, when they really should be just shooting at it to eliminate the threat (as long as they're not within the blast radius).

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #13 on: 31-01-2010, 12:01:53 »
The worst part of dealing with bots is that there are so many schools of thoughts as to what bots should and shoudln't do, so when one person changes AI to do one thing right, they tend to  make bots do something else completely wrong

On this subject, what do you think about (temporarily) disabling the AI for anti-tank mines? Bots don't seem to understand how to use them properly (unlike vanilla BF2) and it's rather stupid watching engineer bots making futile charges at enemy tanks with mines they don't know how to place correctly  ;D

With my AI tweak minimod, I've tried as much as possible to just fix things that are non-working (AT guns), not working properly (tank HE shells and MGs) or inconsistent (range/target strength values for similar/identical vehicles and weapons) rather than making any radical changes, especially to the infantry AI. The only major changes I've made to the infantry weapon AI are with the AT weapons.
However, BF/BF2's AI coding is so unpredictable and complicated that I may well have ended up making some things worse! (currently, bots seem reluctant to stay in vehicle gunner positions, maybe as a result of changing the StrategicStrength values for different vehicles and crew positions). My minimod probably won't please everybody, but anyone who wants (including the FH2 developers) will be free to incorporate any parts of it into their own work if they want to.

Currently I'm playtesting the AI to make sure everything works reasonably well, I won't attempt any other major additions (such as getting planes to drop bombs) until I've released a basic playable version with the fixes/tweaks I've already made.

Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: SP/AI bug - Bots not aiming AT guns and artillery (FIXED)
« Reply #14 on: 31-01-2010, 13:01:37 »
On this subject, what do you think about (temporarily) disabling the AI for anti-tank mines?...
Yeah, why not? It'll free up bots who crouch indefinitely near tanks.

And you notice how they try to use the mines the way vanilla/AIX bots use C4?...e.g: run up to tank, place/throw C4, retreat to a safe distance then detonate?


Quote
...Currently I'm playtesting the AI to make sure everything works reasonably well, I won't attempt any other major additions (such as getting planes to drop bombs) until I've released a basic playable version with the fixes/tweaks I've already made.
The planes sound like a job for Clivewil (AIX dev/rabid flyboy) to me... ;)