Author Topic: Modding the AI map strategy files  (Read 1978 times)

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Modding the AI map strategy files
« on: 23-03-2010, 16:03:03 »
Quote
How to stop Commander Spam? - Answer, One of the uncapable flags in the map was 2-way neighbored. The rule for neighboring uncapable flags is you 1 way neighbor the other flag to the uncap. It's useful to remember, "My neighbor comes to me" when neighboring SA.
- http://www.battlefieldsingleplayer.com/forum/index.php?showtopic=13677

Thanks to cannonfodder for pointing out this fix for the "commander defend spam" issue. It looks like it should be easy to fix - but whilst looking through the map AI files, I noticed quite a few other things in the map scripts that could potentially be fixed or improved. For example - Supercharge has a bug in the attack/defend conditions script which appears to be the reason the Germans don't attempt to counter-attack, whilst Op. Aberdeen has some of the CPs (notably the German forward strongpoint) incorrectly linked. Also, many maps don't have map-specific strategies, and their CPs aren't assigned tags such as "Base" and "SoldierSpawner".

The latter might not make much or any difference to the AI's behaviour, but the map strategy scripts (or the lack of them) in strategies.ai ought to make a big difference to the AI. For most FH2 maps, where both sides are fighting over the map, both sides need to have a "defend" strategy for when they're in control of all the capturable CPs, an "attack" strategy (all-out offence) when the enemy controls more CPs than them, and a "push" strategy (combining attack + defence) when they're starting to get the upper hand. Defensive maps like Siege/Fall of Tobruk are similar, but with one side more biased towards defence.

Where the map doesn't have its own strategies.ai file, the AI just uses the default strategies, which don't work well in some situations (e.g Sidi Rezegh where the British attack the uncappable German main base after capturing the airfield CPs, when they ought to go to a defensive stance).

Anyway, I'm currently experimenting with modifying the map scripts to fix some of the issues and add strategies to maps that don't have them. If it works out, I'll release the files for download in future.

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: Modding the AI map strategy files
« Reply #1 on: 23-03-2010, 18:03:45 »
Great going Drawde...

Frankly what i think is this: I know 2 offcial SP modders - Winterhilf and Leagion.

Now if Leagion is focused on headway in bot AI and Winterhilf is into maps, then Drawde, you should contact them so that you become the official repairman. So far, I can say you've all but repaired bots for 2.25 and are now moving into maps....

I really think the three of you today will make a solid team for SP - Winterhilf navmeshes new maps, you make bots do what they are supposed to, and Leagion works to try and make bots do even more or work under even more complex conditions ie. makes inroads.

But you need to contact the SP devs otherwise all this will be obsolete by the next patch.

Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: Modding the AI map strategy files
« Reply #2 on: 24-03-2010, 09:03:59 »
Quote from: Drawde
Thanks to cannonfodder...
No worries mate... :)

Quote
...I'm currently experimenting with modifying the map scripts to fix some of the issues and add strategies to maps that don't have them. If it works out, I'll release the files for download in future.
8)

Offline Zoologic

  • Masterspammer
  • ****
  • Posts: 4.141
  • In FH Since 0.67
    • View Profile
Re: Modding the AI map strategy files
« Reply #3 on: 24-03-2010, 18:03:20 »
I experimented several strategies in Bardia... i even waypointed the map so that bots would cross the shallow river bed to attack the position.

But all of that really didn't affect the overall gameplay other than making the bots attack from every direction and more dispersed.

Linking a base with every nearby neighbours will only cause the commander to distribute attack order to every post and weaken/spread the forces. However, this will also make the defense focus more difficult since you wouldn't know which spawnwave of bots will storm which flag. However too, it will make the fight less tactical and you see all the bots storming any positions aimlessly, unless they came in a spawnwave.

So creating a strategy is really difficult, since the bots are not designed to understand this completely. From what i've seen, we are just manipulating that strategies.ai so the bot would follow a kind of strategic pattern instead of really knowing what to attack or focus on.

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: Modding the AI map strategy files
« Reply #4 on: 25-03-2010, 09:03:57 »
Where the map doesn't have its own strategies.ai file, the AI just uses the default strategies, which don't work well in some situations (e.g Sidi Rezegh where the British attack the uncappable German main base after capturing the airfield CPs, when they ought to go to a defensive stance).

Actually this only occurs because of the heavy British tanks which the Germans can almost never penentrate. The Commander AI tells the British to stop attacking once the hold all the cap-pable flags. The British tanks on the other hand, tend to pursue enemy tanks within range, and once those are destroyed, they move on in because new tanks appear on the horizon. Finally, they make it all the way to the enemy base. With the commander AI going silent after capping all bases, it is easy for them to follow tanks all the way and nothing tells them to return

For some maps like Luttich, I must say, telling them to attack the enemy main base will actually make the gamplay more interesting since bots will engage each other in the area around the town of Mortain and not always within the town itself.

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: Modding the AI map strategy files
« Reply #5 on: 25-03-2010, 21:03:18 »
I agree that there's a limit to how much map scripting can improve the AI's behaviour - but map-specific strategies.ai files are still useful to tell the AI when to attack or defend. The same basic script works for most maps, with different trigger conditions depending on the number of CPs on the map.

I definitely agree that the heavy British tanks unbalance Sidi Rezegh - the 88s can kill them initially, but once the British overrun the airfield it's incredibly hard for the Germans to take it back (especially when they get control of the 88s and point them in the other direction...) - Either replacing these tanks with more Crusaders, or giving the Germans some bombers, would

I've made a fair amount of progress with map scripting, Supercharge in particular - the Germans will now counter-attack once the British have overrun the central CPs (previously, an error with the trigger conditions meant that they would attack right at the start of the game, but wouldn't bother later on).

Sidi Rezegh also seems to work better now the British go on the defensive once the airfield + blockhouse are captured. However, I haven't had much success adding the mosque and British outpost to the script (currently, the AI doesn't recognise these CPs so doesn't spawn from them) I just get a CTD shortly after starting the map, but I'll keep trying.

I'll experiment with changing the Luttich script to get the AI to attack the main bases, but I'm not sure this will work very well - I suspect they'll end up driving into the anti-base camp radius and getting killed. A better way of improving this map might be to add more pathfinding routes through the open country, and/or making more bots spawn at the outlying farm and abbey CPs (the latter might be doable via scripting)

Another "tweakable" thing in the map scripts, which I forgot to mention in the first post, is the "vehicle search radius" for CPs. This seems to affect the area around a CP within which spawning bots are aware of empty vehicles. On some CPs (such as the main German base on Supercharge) it's very low, which is presumably the reason bots rarely seemed to use the tanks there.

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: Modding the AI map strategy files
« Reply #6 on: 25-03-2010, 23:03:41 »
The only 2 things in Sidi Rezegh that I personally would deem worth changing is the heavy tanks and the radius for flag cap in the blockhouse to make it impossible to cap it from outside. Winterhilf was kind enough to make pathmaps all the way to the actual flag within the underground area so infantry should be able to enter the blockhouse fight their way down and cap it there... I really would ask you disist changing the commander decisions with regards to this map, Unless you can actually make the Brits DEFEND the flags, they ALREADY stop attacking once all flags were capped - The only reason they seem to go further is becuase without any default command, they will seek-and-destroy any enemy unit they come across and this leads them closer and closer to the German main.

An alternate solution for Luttich will be to include another 2 flags in the open fields on the way to the German main.. It means simply making the spawn areas for both sides (The front-most uncap) cap-pable - I wouldn't recommend putting a flag post there though.

great job figuring this out, Drawde... Please don't be modest anymore about your bot-modding skills... Its begining to get annoying considering your achievements :-)

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: Modding the AI map strategy files
« Reply #7 on: 26-03-2010, 18:03:49 »
I'll try changing the heavy tanks to Crusaders and temporarily removing the AI strategy script I added, and see how the map plays out. Getting the AI to recognise the two forward (uncappable) CPs would also help, since both sides can spawn infantry closer to the airfield.

Offline Michael Z Freeman

  • Jr. Member
  • **
  • Posts: 799
  • Formerly known as DJ Barney. The Few are many ;)
    • View Profile
    • Homepage
Re: Modding the AI map strategy files
« Reply #8 on: 01-04-2010, 07:04:26 »
Hopefully without sounding too much of a critical note (FH get's really interesting with some of these AI strategies sorted out) what about historical accuracy ? If I remember correctly some maps are deliberately unbalanced and have specific vehicles based on what was really there at the time ?

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: Modding the AI map strategy files
« Reply #9 on: 01-04-2010, 07:04:37 »
I get your point, but for bots who do not know how to use special AP shells, its an impossible win for the Axis... If you were to change the tanks to Crusaders, Stuarts or Cruisers, you would get a more balanced play with the battlefield changing hands several times, whereas you'd get a flat-out route were the heavies kept in since the only thing that can kill them is the 88, of which only one is ever used and the battlefield is too open for infantry to get close enough to use enough gabellte ladungs to kill the heavies

Basically,because of bot behaviour, its a mismatch

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: Modding the AI map strategy files
« Reply #10 on: 01-04-2010, 19:04:27 »
I've tried replacing the British heavy tanks with Crusaders in Sidi Rezegh, and the map seems to play much better. It's still definitely winnable for the British (especially if they use the AT guns + 88s on the airfield) but much more balanced, with very fierce fighting around the central airfield CPs.
I also added a limited AI strategy script, which starts the Germans off in defensive mode (so they're more likely to use AT/Flak guns) and makes the British fight more defensively once they've captured the airfield, but doesn't stop them from attacking.
If anyone's interested, I'll put the modified map files up for download.

Regarding the AI not understanding about using special AP rounds, I think there may be a fix for this (see my post in the Modding forum regarding armour types) which I was planning to try out, but got sidetracked trying to fix the Goodwood CTD. I plan to have another look at it fairly soon, though.

Offline Michael Z Freeman

  • Jr. Member
  • **
  • Posts: 799
  • Formerly known as DJ Barney. The Few are many ;)
    • View Profile
    • Homepage
Re: Modding the AI map strategy files
« Reply #11 on: 03-04-2010, 18:04:34 »
Ah, that's interesting. So that fix could retain historical accuracy where possible, otherwise game play comes first as Djinn says.

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: Modding the AI map strategy files
« Reply #12 on: 11-04-2010, 18:04:39 »
I've hit a couple of problems with Sidi Rezegh which have delayed me releasing the modded version.
Firstly, I'm trying to add the two forward uncappable CPs (Sidi Rezegh mosque and British outpost) to the .ai files, allowing bots to spawn at them. I've got the outpost to work OK, but the mosque always causes the map to CTD; not instantly, but about 10-20 seconds after the map loads, I'm guessing this is when a bot attempts to spawn there.
I first assumed it was because there weren't any bot-enabled spawn points at this CP, sure enough they all have the "setOnlyForHuman" flag, but either removing this or changing it to "setOnlyForAI" for one of the spawn points has no effect on the crash.
Any clues as to what else could be causing the CTD? I think I've linked the CP to the others correctly; as it's uncappable, I've only made the links one-way.

Secondly, I noticed that several CPs (Sidi Rezegh, mosque, and British outpost, but oddly not the British main base) have the setting "ObjectTemplate.isUnstrategicControlPoint 1". Anyone know what this does? Does it mean that the CP is ignored when working out the number of controlled CPs in strategies.ai?

Offline cannonfodder

  • Full Member
  • ***
  • Posts: 1.228
    • View Profile
Re: Modding the AI map strategy files
« Reply #13 on: 12-04-2010, 10:04:27 »
Dunno...maybe there's no mesh under the Mosque spawnpoints... :-\

Haven't played Sidi much, so I'm not sure where you're talking about.


"ObjectTemplate.isUnstrategicControlPoint 1"? Again, I dunno, but I'd say you're right.

I'd poke around on BFSP for an answer, but the stupid bloody thing won't let me log into my account for some reason and you can't use the search function if ya ain't logged in... >:(


EDIT: I just found this: http://planetbattlefield.gamespy.com/View.php?view=BF2Tutorials.Detail&id=79

Not sure if it'll be any use to ya, but there's a bit about soldier spawn points in there...
« Last Edit: 12-04-2010, 11:04:19 by cannonfodder »

Offline Drawde

  • Jr. Member
  • **
  • Posts: 160
    • View Profile
Re: Modding the AI map strategy files
« Reply #14 on: 13-04-2010, 16:04:23 »
Still haven't found the cause of the CTD (I'll probably just release an initial version of the map fix without this CP enabled) but I have found that "isUnstrategicControlPoint" doesn't have any effect on whether the CP is counted in strategies.ai. If one side has (for example) 2 uncappable CPs and is in control of 3 captured ones, they are counted as having 5 CPs.