AI Scripting Info

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
VR_Nocturne
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 62
Joined: Thu Aug 04, 2011 12:51 am

AI Scripting Info

Post by VR_Nocturne »

Is there a document somewhere that lists the functions and variables, etc that are allowed/defined in the AI script? Can I write my own functions?

What aspects of the AI can be changed? Can I change how it buys units for a skirmish match? How it values it units (too often it throws away units on moves that don't make sense to try to make)? VP value and priority (had one game on the first stage of the Kharkov campaign where it could have made my friend and I lose but the AI outright refused to just take the damn VP on the bridges. Allowed us to fill an objective and keep playing when by rights we should have lost. It just looks bad, imo.

How does the AI reason about the map? I know there's no "maphacking" where it has vision of everything, but there's also times where it has an uncanny sense of where things are and it's not just lucky guesses with suppress area or barraging. Is there some sort of "intuition" where the AI can go "hmm...that's a spot where there might be some troops, let me fire there and see"? Is there a way to change this in the script (I'd like to make it stronger because part of good play is good instincts and any logic that attempts to emulate this I'd like to strengthen)? One reason I'm asking is that in the first Kharkov stage, I had a lone engineer holding fire in the building around where all those huge numbers of armor come from to attack the west bridge. The AI clustered its forces around it (with armor so it couldn't see into the building and there was no infantry around) as if it "knew" something was there.

Playing a skirmish and the AI just had most of its forced holed up in the corner of the map. The hardest fights we've had in the game were trying to take it's last VP for the shutout win. What the heck? I mean we're taking IS-2, SU-152, T34/85, T70, ZiS trucks, infantry - really?

Seeing enough of this, I wanted to see if I can't do something to make our games more challenging and the AI fight more competently. However, there's no documentation for the scripting or how/why the AI designer set things as he/she did. Perhaps there's some limitations or such to work around or what not. I'm sure things were done in stock code for a reason, and I'd be interested to know what those reasons were or the intended goals and what stuff does before I go mucking about because, believe me, the temptation is strong to just go in there and change some numbers big and see what happens! :mrgreen:

Oh - and if I do change things, a couple questions:

1) Can my friend and I still do our co-op? Will the server block me/us because we're using non-stock code?

2) What would I need to do to let him install any changes I make onto his game?
pipfromslitherine
Site Admin
Site Admin
Posts: 9923
Joined: Wed Mar 23, 2005 10:35 pm

Re: AI Scripting Info

Post by pipfromslitherine »

Once you have set up a local campaign in your My Documents/My Games/BA2/Campaigns (or Multiplayer) folder you an tinker as much as you like - to share with a friend you only have to share that folder for them to drop in to their folder. You can also share more widely with a LST file but I will leave the explanation of that for later :)

The AI_ functions (AI_REBUILD, AI_TEAM, AI_BUILD_LIST, and AI_UNIT) are the only ones which need to exist as they are called by the code to pump the AI. All the other scripting can be tweaked, changed, or replaced as you desire (as an example, the AI for BA2, P&S, and Hell are all radically different).

Cheers

Pip
follow me on Twitter here
VR_Nocturne
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 62
Joined: Thu Aug 04, 2011 12:51 am

Re: AI Scripting Info

Post by VR_Nocturne »

Do I need to copy the AI.bsf to my Campaign?

Also, if I changed the AI.bsf and wanted to use it with the existing campaigns or for skirmishes - do I just give my friend the copy of the AI.bsf I made so we'll have the same data?
pipfromslitherine
Site Admin
Site Admin
Posts: 9923
Joined: Wed Mar 23, 2005 10:35 pm

Re: AI Scripting Info

Post by pipfromslitherine »

Yes, you need to make an AI folder in your custom campaign and then create your own AI.bsf file which the game will load. This would then be used this with whatever scenarios were in the same campaign folder. Sending the campaign folder to someone else will allow you to play together in MP (provided it is a MP campaign of course).

Cheers

Pip
follow me on Twitter here
Post Reply

Return to “Battle Academy 2: Modders Corner”