Legion, you asked... here it it.

When the debugger first came out, I went crazy, going thru all the mods, fixing every error I found. The result: I broke online gaming and had to re-install everything. That didn't stop me from wanting to fix the errors, but it did get me thinking about how fix them and not break online games. I came up with this technique so I could restrict my fixes to single player games, leaving multiplayer games untouched.

It didn't occur to me to use it to tweak the AI until Adz introduced me to Dnamro's Realplayer mod. After trying Realplayer, I wanted my bots to be just as aggressive. Dnamro gave me permission to use his behaviours, but I couldn't change anything in the Game.rfa that I was working with. In fact, I couldn't change anything in the Objects.rfa either. So this is what I did: I took everything I wanted to change and put it in one file, then I ran the file from the single player startup scripts, leaving all the multiplayer game modes untouched. The key was knowing when to run the script.

Maps load in stages. When the game loads, It runs the menu/init.con files for every map in the active mod and it checks to see what game modes are supported for each map, so it can give you a list of choices in the game menu. When you start map, the game runs the init.con file in the maps root folder, then it runs all the scripts in the Objects.rfa, creating all the object templates needed by the game. Custom objects usually are loaded here, before any of the games object templates are created.

After all the templates have been created, the game runs the maps startup script for what every game mode that you've chosen. Here is where I run my code. I put all the changes I've made to AI behaviour into one file and run it from the startup script, just before the control points and spawners scripts are run:

game.setNumberOfTickets 1 100
game.setNumberOfTickets 2 100
game.setTicketLostPerMin 1 15
game.setTicketLostPerMin 2 15
game.maxNrOfPlayers 18

run tweaks

run SinglePlayer/ControlPointTemplates
run SinglePlayer/SpawnpointManagerSettings
run SinglePlayer/SoldierSpawnTemplates
run SinglePlayer/SoldierSpawns
run SinglePlayer/ObjectSpawnTemplates

if v_arg1 == host

run ai

run SinglePlayer/ObjectSpawns
run SinglePlayer/ControlPoints
game.timeToNextWave 20
endIf


You can change the code for any existing template before it is spawned. This includes kits, weapons, vehicles and soldiers. I went thru all the con files in the Objects.rfa and Game.rfa, gathered anything that looked important to AI behaviour and put it into my tweaks.con file:

rem **********************************************************************
rem *** Direct Behaviour changes ***
rem **********************************************************************
aiSettings.activeBehaviourModifiers UnitWeights
aiSettings.setBehaviourModifier Idle 0.01
aiSettings.setBehaviourModifier Fire 7.0

aiSettings.activeBehaviourModifiers StandardWeights
aiSettings.setBehaviourModifier Avoid 5.0
aiSettings.setBehaviourModifier Idle 0.01
aiSettings.setBehaviourModifier Fire 7.0

aiSettings.activeBehaviourModifiers PlaneWeights
aiSettings.setBehaviourModifier Avoid 6.0
aiSettings.setBehaviourModifier Idle 0.01
aiSettings.setBehaviourModifier Fire 7.0
aiSettings.setBehaviourModifier Scout 4.0

rem **********************************************************************
rem *** kit mods ***
rem **********************************************************************
kitTemplate.active Medic
kitTemplate.setBattleStrength Infantry 5.0

kitTemplate.active AT
kitTemplate.setBattleStrength Infantry 2.0

kitTemplate.active Assault
kitTemplate.setStrategicStrength 0 2
kitTemplate.setStrategicStrength 1 2
kitTemplate.setBattleStrength LightArmour 4.0
kitTemplate.setBattleStrength HeavyArmour 2.0
kitTemplate.setBattleStrength Air 3.0

kitTemplate.active Scout
kitTemplate.setStrategicStrength 0 1
kitTemplate.setBattleStrength Air 1.0

rem *************************
rem *** weapons ai tweaks ***
rem *************************
weaponTemplate.active MedPackAI
weaponTemplate.setStrength Infantry 6.0

weaponTemplate.active RepairPackAI
weaponTemplate.setStrength LightArmour 7.0
weaponTemplate.setStrength HeavyArmour 7.0
weaponTemplate.setStrength NavalArmour 4.0
weaponTemplate.setStrength Submarine 1.0
weaponTemplate.setStrength Air 1.0

weaponTemplate.active BazookaRPG
weaponTemplate.deviation 0.5
weaponTemplate.deviationCorrectionTime 1.0
weaponTemplate.setStrength Infantry 0.0
weaponTemplate.setStrength LightArmour 5.0
weaponTemplate.setStrength HeavyArmour 4.0
weaponTemplate.setStrength Air 1.0

rem *** Panzershreck ***
weaponTemplate.active PanzerschrekRPG
weaponTemplate.deviation 0.5
weaponTemplate.deviationCorrectionTime 1.0
weaponTemplate.setStrength Infantry 0.0
weaponTemplate.setStrength LightArmour 5.0
weaponTemplate.setStrength HeavyArmour 4.0
weaponTemplate.setStrength Air 1.0

rem *** GrenadeAxis ***
weaponTemplate.active GrenadeAxisAI
weaponTemplate.minRange 8.0
weaponTemplate.maxRange 80.0
weaponTemplate.deviation 1.0
rem weaponTemplate.deviationCorrectionTime 6.0
weaponTemplate.setStrength Infantry 6.0
weaponTemplate.setStrength LightArmour 6.0
weaponTemplate.setStrength HeavyArmour 1.0

rem *** GrenadeAxis ***
weaponTemplate.active GrenadeAlliesAI
weaponTemplate.minRange 8.0
weaponTemplate.maxRange 80.0
weaponTemplate.deviation 1.0
rem weaponTemplate.deviationCorrectionTime 6.0
weaponTemplate.setStrength Infantry 6.0
weaponTemplate.setStrength LightArmour 6.0
weaponTemplate.setStrength HeavyArmour 1.0

rem *** BAR ***
weaponTemplate.active BarAI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength Air 2.0

rem *** DP ***
weaponTemplate.active DPAI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength Air 2.0

rem *** JohnsonLMG ***
weaponTemplate.active JohnsonLMGAI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength Air 2.0

rem *** M1Garand ***
weaponTemplate.active M1GarandAI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength Air 2.0

rem *** SG44 ***
weaponTemplate.active SG44AI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength Air 2.0

rem *** Type5 ***
weaponTemplate.active Type5AI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength Air 2.0

rem *** Type99 ***
weaponTemplate.active Type99AI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength Air 2.0

rem *** thompson ***
weaponTemplate.active ThompsonSMG
weaponTemplate.setStrength Infantry 5.0

rem *** Mp18 ***
weaponTemplate.active Mp18AI
weaponTemplate.setStrength Infantry 5.0

rem *** MP40 ***
weaponTemplate.active MP40AI
weaponTemplate.setStrength Infantry 5.0

rem *** NO4 ***
weaponTemplate.active No4AI
weaponTemplate.setStrength Infantry 4.0
weaponTemplate.setStrength Air 2.0

rem *** SniperNO4 ***
weaponTemplate.active SniperNo4AI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength Air 2.0

rem *** K98 ***
weaponTemplate.active K98AI
weaponTemplate.setStrength Infantry 4.0
weaponTemplate.setStrength Air 2.0

rem *** SniperK98 ***
weaponTemplate.active SniperK98AI
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength Air 2.0

rem *** P38***
weaponTemplate.active P38AI
weaponTemplate.setStrength Infantry 2.0

rem *** Colt ***
weaponTemplate.active ColtAI
weaponTemplate.setStrength Infantry 2.0

rem *** Knife Allies ***
weaponTemplate.active KnifeAllies
weaponTemplate.setStrength Infantry 2.0

rem *** Knife Axis ***
weaponTemplate.active KnifeAxis
weaponTemplate.setStrength Infantry 2.0

rem ****************************************
rem *** tank tweaks ***
weaponTemplate.active Chi-ha_MainGun
weaponTemplate.setStrength Infantery 8.0
weaponTemplate.setStrength LightArmour 7.0
weaponTemplate.setStrength HeavyArmour 5.0
weaponTemplate.setStrength NavalArmour 1.0

weaponTemplate.active PanzerIVMainGun
weaponTemplate.setStrength Infantry 7.0
weaponTemplate.setStrength LightArmour 8.0
weaponTemplate.setStrength HeavyArmour 7.0
weaponTemplate.setStrength NavalArmour 1.0

weaponTemplate.active ShermanMainGun
weaponTemplate.setStrength Infantery 9.0
weaponTemplate.setStrength LightArmour 8.0
weaponTemplate.setStrength HeavyArmour 7.0
weaponTemplate.setStrength NavalArmour 1.0

weaponTemplate.active TigerMainGun
weaponTemplate.setStrength Infantry 9.0
weaponTemplate.setStrength LightArmour 9.0
weaponTemplate.setStrength HeavyArmour 9.0
weaponTemplate.setStrength NavalArmour 2.0

weaponTemplate.active M10MainGun
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 7.0
weaponTemplate.setStrength HeavyArmour 8.0
weaponTemplate.setStrength NavalArmour 1.0

weaponTemplate.active T34MainGun
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 7.0
weaponTemplate.setStrength HeavyArmour 8.0
weaponTemplate.setStrength NavalArmour 1.0

rem *** AA Allies Base ***
weaponTemplate.active AA_BaseMainGun
weaponTemplate.maxRange 400.0
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength HeavyArmour 1.0
weaponTemplate.setStrength Air 8.0
rem weaponTemplate.deviationCorrectionTime 2.0

weaponTemplate.active Flak38MainGun
weaponTemplate.maxRange 400.0
weaponTemplate.setStrength Infantry 5.0
weaponTemplate.setStrength LightArmour 2.0
weaponTemplate.setStrength HeavyArmour 1.0
weaponTemplate.setStrength Air 8.0
rem weaponTemplate.deviationCorrectionTime 2.0

This is only a portion of the tweaks.con file I've used in the past. You only need to include commands for values you are going to change. The others can be omitted. Those commands have already been run. The values are set and you can leave them alone.

The SAI uses the strategic and battle strengths listed here to determine what class of soldiers to spawn and which weapons or vehicles to use. Having them all in one place made it real easy to go thru, increase values here, decrease there, run the map and see how the bots react to the changes. I believe these values were set for one of the realism mods I was working with and are somewhat tame. Since this is run at the map level, you can customize these values to fit the map. The SAI keeps a database of all the objects that exist in the map. It uses the values here to calculate the objects temperature. It breaks down every problem into a list of choices and chooses the hottest one. If you want the bots to use a weapon or vehicle more often, you can try increasing the strengths of everything associated with it, decreasing the strengths of every thing else or a combination of both. It's great fun.


the simplest way to use different kits for different gametypes (and the way I used for EoD) is to move the game.setKit lines you want changed into the gametype cons. This also works for skins. Tends to confuse the mappers tho tongue.gif

another way would be to use an if statement to find the gamemode, like so:
CODE

Var v_gamemode
game.gamePlayMode -> v_gamemode

if v_gamemode == GPM_CQ

game.setTeamSkin 1 1 VietcongA1
game.setTeamSkin 1 2 VietcongA2
game.setTeamSkin 1 3 VietcongB1
game.setTeamSkin 1 4 VietcongB2

game.setTeamSkin 2 1 USArmyA1
game.setTeamSkin 2 2 USArmyA2
game.setTeamSkin 2 3 USArmyB1
game.setTeamSkin 2 4 USArmyB2

game.setKit 2 2 USArmy_HeavyAssault
game.setKit 2 6 USArmy_HeavyAssault_Alt

else

game.setTeamSkin 1 1 VietcongA1_CHUTE
game.setTeamSkin 1 2 VietcongA2_CHUTE
game.setTeamSkin 1 3 VietcongB1_CHUTE
game.setTeamSkin 1 4 VietcongB2_CHUTE

game.setTeamSkin 2 1 USArmyA1_CHUTE
game.setTeamSkin 2 2 USArmyA2_CHUTE
game.setTeamSkin 2 3 USArmyB1_CHUTE
game.setTeamSkin 2 4 USArmyB2_CHUTE

game.setKit 2 2 SpecialForces_HeavyAssault
game.setKit 2 6 SpecialForces_HeavyAssault_Alt

endif


this works well in bfv, as there is really only conquest and coop, but in 42 it wont work so good since this accually works in reverse and checks for conquest not sp/coop. So I'd stick with putting it in the gametype cons, which is just what 4 is doing.

What about rearranging the order of the kits? For example, instead of

game.setTeamSkin 2 USSoldier
game.setKit 2 0 US_Sniper
game.setKit 2 1 US_Assault
game.setKit 2 2 US_AT2
game.setKit 2 3 US_HeavyAssault
game.setKit 2 4 US_Support

You'd have:

game.setTeamSkin 2 USSoldier

game.setKit 2 0 US_Support
game.setKit 2 1 US_Sniper
game.setKit 2 2 US_Assault
game.setKit 2 3 US_AT2
game.setKit 2 4 US_HeavyAssault

Would that work, or would that make the game go ZZUZZUZZZRRZRZRZRZZRZROZPZPZPZPZ or something equally awful?