Advanced strategy commands for BF1942 By CareyBear

Ok, we all know the basics - or I hope you do, or this tut won't mean much.

I'm assuming you can write a custom ai - that is, your own conditions, prerequisites, strategies and strategic areas, or at least be fairly familiar with the contents of all of them. These commands can also be added to existing AI strategies.\

I take no responsibility for anything untoward which may happen to… ah stuff these disclaimers. They're a waste of time. This is all correct as far as I know. Of course, you might stuff your comp and BF install, but that's your problem. Agreed? :

Deep in the game.rfa file is an ai folder, containing conditions, prerequisites and strategies .con files. The strategies.con contains:

rem *** Create Strategies ***

rem run prerequisites

aiStrategy.createStrategy test1
aiStrategy.Aggression 0.8
aiStrategy.NumberOfAttacks 2
aiStrategy.NumberOfDefences 1
aiStrategy.setPrerequisite test1

aiStrategy.createStrategy assault
aiStrategy.Aggression 1.0
aiStrategy.NumberOfAttacks 4
aiStrategy.NumberOfDefences 3
aiStrategy.setPrerequisite constPrereq
aiStrategy.setTreeModifier TTNDefensivePos 0.75
aiStrategy.setTreeModifier TTNFriendGroundFixed 0.8
aiStrategy.setTreeModifier TTNHostileGroundFixed 1.25
aiStrategy.setStrategicObjectsModifier ControlPoint 4.0
aiStrategy.setStrategicObjectsModifier Flank 1.25
aiStrategy.setStrategicObjectsModifier Neutral 3.0

aiStrategy.createStrategy allOutAttack
aiStrategy.Aggression 0.8
aiStrategy.NumberOfAttacks 4
aiStrategy.NumberOfDefences 3
aiStrategy.setPrerequisite overwhelmingPowerPrereq
aiStrategy.setTreeModifier TTNDefensivePos 0.75
aiStrategy.setTreeModifier TTNFriendGroundFixed 0.8
aiStrategy.setTreeModifier TTNHostileGroundFixed 1.25

aiStrategy.createStrategy allDefence
aiStrategy.Aggression 0.0
aiStrategy.NumberOfAttacks 0
aiStrategy.NumberOfDefences 1
aiStrategy.setPrerequisite loosingPrereq
aiStrategy.setTreeModifier TTNDefensivePos 1.5
aiStrategy.setTreeModifier TTNFriendGroundFixed 1.2
aiStrategy.setTreeModifier TTNTransportation 0.8

aiStrategy.createStrategy default
aiStrategy.Aggression 0.7
aiStrategy.NumberOfAttacks 2
aiStrategy.NumberOfDefences 2
aiStrategy.setPrerequisite constPrereq
aiStrategy.setPrerequisiteWeight 5.0
aiStrategy.setStrategicObjectsModifier Base 0.5
aiStrategy.setStrategicObjectsModifier ControlPoint 4.0
aiStrategy.setStrategicObjectsModifier Flank 3.0
aiStrategy.setStrategicObjectsModifier Neutral 3.0

aiStrategy.createStrategy airToNaval
aiStrategy.Aggression 0.35
aiStrategy.NumberOfAttacks 1
aiStrategy.NumberOfDefences 3
aiStrategy.setPrerequisite airToNavalPrereq
aiStrategy.setTreeModifierCombatStrength TTNFriendAirMobile All 1.5
aiStrategy.setTreeModifierCombatStrength TTNFriendAirMobile NavalArmour 2.5
aiStrategy.setTreeModifier TTNHostileNaval 2.0
rem aiStrategy.setTreeModifier TTNAirField 1.5
aiStrategy.setTreeModifierCombatStrength TTNHostileNavalMobile NavalArmour 3.0
rem aiStrategy.setTreeModifier TTNFriendlyNaval 0.75
rem aiStrategy.setTreeModifier TTNFriendlyGround 0.5

The interesting lines are in dark blue and light blue - the light blue ones are remmed out, so we should probably be a little more cautious expecting them to do anything. There's more too - Let's have a little look at the strategies from Battle of Britain for a sec.

rem ** American **

aiStrategy.createStrategy Defend
aiStrategy.Aggression 0
aiStrategy.NumberOfAttacks 0
aiStrategy.NumberOfDefences 4
aiStrategy.setPrerequisite defendPrereq
aistrategy.setTreeModifierCombatStrength TTNFriendAir 5.0
aistrategy.setTreeModifierCombatStrength TTNFriendAirMobile CSTAir 5.0
aistrategy.setTreeModifierCombatStrength TTNFriendGroundFixed CSTAir 5.0
aiStrategy.setStrategicObjectsModifier Base 5 Owned
aiStrategy.setStrategicObjectsModifier LandSpawner 5 Owned
aiStrategy.setStrategicObjectsModifier AirField 8 Owned
aiStrategy.setStrategicObjectsModifier StrongPoint 6 Owned

There they are again! Ok, so we've found:

Command aiStrategy.setTreeModifier
Arguments aiStrategy.setTreeModifier TTNDefensivePos 0.75
aiStrategy.setTreeModifier TTNDefensivePos 1.5
aiStrategy.setTreeModifier TTNFriendGroundFixed 0.8
aiStrategy.setTreeModifier TTNFriendGroundFixed 1.2
aiStrategy.setTreeModifier TTNHostileGroundFixed 1.25
aiStrategy.setTreeModifier TTNTransportation 0.8
aiStrategy.setTreeModifier TTNHostileNaval 2.0
Command aistrategy.setTreeModifierCombatStrength
Arguments aistrategy.setTreeModifierCombatStrength TTNFriendAir 5.0
aistrategy.setTreeModifierCombatStrength TTNFriendAirMobile CSTAir 5.0
aistrategy.setTreeModifierCombatStrength TTNFriendGroundFixed CSTAir 15.0
aiStrategy.setTreeModifierCombatStrength TTNHostileNavalMobile NavalArmour 3.0
aiStrategy.setTreeModifierCombatStrength TTNFriendAirMobile All 1.5
aiStrategy.setTreeModifierCombatStrength TTNFriendAirMobile NavalArmour 2.5

So, what the hell do they do? I'm not sure what part of the AI structure the Tree is, but it's probably something to do with decision making. Another thing notable about the aistrategy.setTreeModifier arguments is that the number is between 0.75 (lowest) and 2 (highest). This could indicate that the argument is a weighting for AI behaviour - where 1 would indicate a 'normal' weight for the type defined in the argument (eg, TTNFriendGroundFixed). So the line aistrategy.setTreeModifier TTNHostileNaval 2.0 would mean the AI had a preference for (?targeting?) enemy Naval vehicle types which was double normal. The strategy this was found in is called airToNaval, so this seems to be a safe assumption.

The type arguments for the two seem to be the same as well. That is, they include:

aiStrategy.setTreeModifier aistrategy.setTreeModifierCombatStrength
TTNDefensivePos
TTNFriendGroundFixed
TTNHostileGroundFixed
TTNTransportation
TTNHostileNaval
TTNFriendAir
TTNFriendAirMobile
TTNFriendGroundFixed
TTNHostileNavalMobile
TTNFriendAirMobile

TTNFriendGroundFixed appears on both sides. If the commands are consistent, we can take some guesses at what some others might be too.

TTNDefensivePos
TTNFriendGround
TTNFriendGroundFixed
TTNFriendGroundMobile
TTNFriendNaval
TTNFriendNavalMobile
TTNHostileNaval
TTNHostileNavalMobile
TTNFriendAir
TTNFriendAirMobile
TTNHostileAir
TTNHostileAirMobile
TTNTransportation

The ones in blue are the ones we've found, the black ones are 'these will possibly/probably work'

Now, lets keep going with aistrategy.setTreeModifierCombatStrength This command has two different instances - one with two arguments, and the rest with three. We have a 'type' as above, a number (probably similar to the general strategy SA weighting numbers - they seem to be in the same range), and another 'type' of some sort..

CSTAir
NavalArmour
All

Ok, this is weird. Looks like it might more closely define the setting. So, if the (for example) command was

aiStrategy.setTreeModifierCombatStrength TTNFriendAir NavalArmour 2.5

we could probably expect the bots to favour using or boarding friendly Air vehicles which are effective against NavalArmour.
CSTAir may indicate anti-aircraft - that is, fighters and AA guns, for TTNFriendAir and TTNFriendGroundFixed

Other possible arguments for this might be HeavyArmour, LightArmour, Submarine etc, but that's just a guess.

I don't pretend to know all about this stuff, but this is what I've found out so far about this interesting aspect of BF's AI.

Creative and careful use of these can change the way a mission works by giving the AI preference for particular vehicle types. BoB used it to make them want planes, I've used it in Aberdeen to make the bots prefer ground vehicles to walking. It seems to have some effect.

There are more interesting tidbits hidden in game.rfa, but I'm not going through them now.. Cheers all..