This tutorial is the result of countless hours of observation, experimentation, and deep dives into long-forgotten threads from the golden age of BF2 modding, particularly from the Battlefield 2 Single Player Forums. Before discovering these hidden mechanics, I had only a vague understanding of how the AI worked. Concepts like “bot suppressed” or tweaking weapon accuracy seemed promising but rarely resulted in bots behaving with any believable sense of tactical awareness.
Eventually, I stumbled across a telling quote from Tobias Karlsson, one of the the original AI designer of BF2, who once said in an interview:
“I feel that the criticism is sometimes too hard. [...] In Battlefield, there are huge maps, a vast array of vehicles of very different types, and yet the AI is compared to other game bots in tactical infantry games or flight sims.”
This statement confirmed some suspicions: the limitations we perceive in BF2's AI are not born out of technical incapacity, but rather of contextual constraints and design priorities. DICE had to scale AI behavior primarily to suit large-scale, vehicle-heavy warfare, but at the same time left the potential for more intricate infantry behavior which is the main object of this tutorial.
I first discovered the hidden potential of these AI mechanics on small, stripped-down maps, completely free of heavy assets. Using only base-game soldiers and default weaponry, I witnessed something unexpected: bots actively dodging my fire, briefly taking cover behind objects, and behaving in ways that felt reactive and situational. That moment made one thing clear : the vanilla AI wasn't broken; it was simply underutilized.
What triggered this behavior wasn't just a fluke. The conditions were ideal: the map had very low asset weight (less than 20,000 polygons), no vehicles, and highly optimized vanilla soldiers and weapons. Under these circumstances, Battlefield 2's AI suddenly had the processing headroom to act more intelligently, even without extreme parameter tweaking (which you will see below).
This observation led me to a critical realization: many of Battlefield 2's stock maps and AI configurations simply don't allocate enough CPU time or memory resources for advanced behavior to emerge. But when those constraints are lifted, even the stock bots can show sparks of brilliance.
The tutorial is divided into two parts for better readability. Some information may be new or already known to some modder. Feel free if you have any suggestion to give or rectification or just questions to ask. The ultimate goal is to make the single-player experience more enjoyable.
Battlefield 2's bots have long been criticized as little more than animated shooting dummies : mechanical soldiers charging head-on in straight lines, oblivious to incoming fire, and often standing still under suppression. For many players who were more interested in the multiplayer side, bots served more as mobile target practice than as genuine battlefield opponents.
But beneath this surface lies a surprisingly flexible and modular AI framework, capable of far more than what most players ever experience, based on Temperature heuristics and Behavior weights defined across two core systems:
Object.ai templates
(for AI classes like soldiers and vehicles) andThe global
AIBehaviours.ai
which governs behavior weights
What is "Temperature heuristics" and "Behavior weights" in Battlefield 2?
1. Temperature Heuristics (basicTemp in Object.ai)
Temperature in Battlefield 2 AI is not related to heat, but rather a priority metric used by the decision system to evaluate how "important" or "visible" an object is to the AI. Also, governs the bot's internal reaction speed on how "alert" or "responsive" a bot behaves in combat.
How it works:
Both soldiers and vehicles in Battlefield 2 possess actual AI templates through:
Object.ai file
These are located,
for example, for soldier in:
Objects_server/soldiers/common/ai/Object.ai
For vehicles in:
Objects_server.zip\Vehicles\Land\aav_tunguska\Object.ai
A standard soldier's AI template looks like this:
rem *** AITemplate ***aiTemplate.create SoldieraiTemplate.addPlugIn SoldierUnitaiTemplate.addPlugIn SoldierPhysicalaiTemplate.addPlugIn SoldierMobileaiTemplate.addPlugIn SoldierCtrlaiTemplate.addPlugIn SoldierArmamentaiTemplate.addType ITUnitaiTemplate.addType ITMobileaiTemplate.addType ITBiologicalaiTemplate.addType ITGroundaiTemplate.addType ITSoldieraiTemplate.degeneration 15aiTemplate.allowedTimeDiff 0.5aiTemplate.basicTemp 1aiTemplate.commonKnowledge 0
A standard vehicle's AI template looks like this:
rem *** AITemplate ***aiTemplate.create Tunguska_TopMG_AIaiTemplate.addType ITUnitaiTemplate.addType ITBiologicalaiTemplate.addType ITGroundaiTemplate.degeneration 15aiTemplate.allowedTimeDiff 2aiTemplate.basicTemp 8aiTemplate.commonKnowledge 0aiTemplate.secondary 1aiTemplate.addPlugIn TunguskaTopMgArmsaiTemplate.addPlugIn TunguskaTopMgUnitaiTemplate.addPlugIn TunguskaTopMgCtrl
aiTemplate.basicTemp
This basicTemp
value acts like an awareness or interest level. Higher values will cause AI agents to prioritize or react faster to a given object or in a combat situation (soldier, vehicle, etc.).For Vehicles,
basicTemp
acts as a selection heuristic in the AI's asset evaluation system.Function:
Controls the attractiveness of the vehicle as a usable asset.
Higher temps make bots prioritize entering, driving, or choosing that vehicle more often.
Also used in strategic vehicle selection: tanks, APCs, or aircraft with higher temps are more likely to be targeted or driven.
In short: For vehicles, it's a priority weight used in decision-making and pathing.
Example:
aiTemplate.basicTemp 60 ; A preferred vehicle you may want for attack roles
For Soldiers,
basicTemp
governs the bot's internal reaction speedFunction:
It influences the AI's internal decision cycle frequency.
A higher value
100 or higher (the highest value I tried was 1000)
makes the bot process decisions more often, increasing its:Reflexes
Reaction time to threats
Ability to switch behaviors (e.g., fire, avoid, take cover)
It indirectly controls how "alert" or "responsive" a bot behaves in combat.
In short: Raising a soldier's
basicTemp
improves combat sharpness, especially under heavy fire or close encounters.What is
aiTemplate.degeneration
&aiTemplate.allowedTimeDiff
Defined in the
Object.ai files
primarily for soldiers and vehicles inObjects_server/…/ai
?aiTemplate.degeneration
This value defines how long the AI retains memory of an event (like a threat, target, or destination) before discarding it due to inactivity or disappearance. The unit is in frames (1 frame ≈ 1/15th of a second by default).
How it works:
If a bot sees an enemy, then loses visual contact, the
Example:degeneration
value tells the AI how long to continue acting on that last known information. After the countdown, the memory "degenerates", and the bot may choose a new goal.aiTemplate.degeneration 15
➡ The AI keeps acting on the memory for 15 frames (≈0.5 seconds).
Best Use:Low values (15–20): Makes bots reactive but potentially forgetful.
Medium values (30–45): More natural memory span.
High values (60+): Strategic AI that holds memory of events longer.
"If the bot sees the enemy, the bot will remember the location of the enemy and which point on the enemy the bot saw. The bot also updates its team's common knowledge data base."- Tobias Karlsson, Lead AI Programmer, Battlefield 2
aiTemplate.allowedTimeDiff
This value sets the maximum acceptable time difference (in seconds) between the game world's physical state and the AI's internal perception of it.
How it works:
Due to performance constraints, AI doesn't constantly refresh every object's state. Instead, it tolerates some delay. This parameter adjusts how tightly synchronized the AI is with real-time game updates.
Example:aiTemplate.allowedTimeDiff 0.5
➡ The bot can react to data that's up to 0.5 seconds out-of-date.
Best Use:Low values (0.1–0.5): Highly reactive AI (used for infantry, special forces).
High values (1.0–2.0): AI tolerates desync, good for tanks or heavy units that don't need split-second reactions.
Example Template for an Experimental Elite Soldier:
aiTemplate.basicTemp 100aiTemplate.degeneration 40aiTemplate.allowedTimeDiff 0.25
This bot:
Makes decisions quickly,
Retains knowledge of enemies and obstacles briefly after losing them,
Reacts almost in real-time to environmental changes.
Performance Consideration:
These parameters impact CPU performance:
Lower
allowedTimeDiff
and highbasicTemp
require more frequent updates.On heavy maps (many statics, vehicles, or effects), the engine may not process all AI agents with high precision.
Balance is crucial: AI quality vs. performance cost.
2. Behavior Weights: (AIBehaviours.ai)
Behavior weights define how likely a bot is to choose a specific action when faced with multiple valid decisions (move, shoot, avoid, idle, etc.) that you can manually edit in AIBhaviours.ai file.
Its located in BF2/AI/AIBehaviours.ai
This system is like a decision matrix where each behavior is assigned a numerical priority.
How it works :
rem *** Construct standard weights ***aiSettings.createBehaviourModifiers StandardWeightsaiSettings.setBehaviourModifier Avoid 1.0aiSettings.setBehaviourModifier MoveTo 1.0aiSettings.setBehaviourModifier Idle 0.1aiSettings.setBehaviourModifier Fire 7.5aiSettings.setBehaviourModifier Special 3.0aiSettings.setBehaviourModifier TakeCover 2.0aiSettings.setBehaviourModifier Change 1.9aiSettings.setBehaviourModifier Revive 3.0aiSettings.setBehaviourModifier c4 1.0aiSettings.setBehaviourModifier Special2 1.0aiSettings.setBehaviourModifier Special3 1.0aiSettings.setBehaviourModifier Random 1.0aiSettings.setBehaviourModifier Triggerable 1.0
Understanding Each Behaviour Modifier in Battlefield 2 AI
In Battlefield 2, bots choose their actions based on behaviour weights, which act as numerical priorities for available tactical decisions. Each behaviour represents a specific type of action or response, and the higher its weight, the more likely the AI will favor that behaviour when multiple options are available.
Here's a breakdown of the standard behaviour modifiers and what they generally represent:
Avoid
– This governs how much effort a bot will attempt to evade under incoming fire or proximity to threats. A higher value increases likelihood of evasive maneuvers like breaking line-of-sight, rapid short-distance retreats and short jumps (which happens very rarely). It also ensures that bots don't run into each other or block friendly units in narrow environments.MoveTo
– This determines how strongly a bot prioritizes moving toward objectives (flags), waypoints, or destinations in general navigation. Setting it to 0 will cause all your bots to stand still and do nothing.Idle
– This sets how willing a bot is to do nothing at all, staying in place and not making any tactical decision.(Never set it to 0, you will get a CTD without error)Fire
– This weight dictates how likely a bot is to engage an enemy with their weapon. A high value leads to aggressive firing behavior. Setting it to 0 will result in bots ignoring you completely. Occasionally but rarely some will still use their knife to kill you.Special
– Class-specific behavior. For medics, this triggers use of the medkit to heal themselves or teammates.TakeCover
– Governs how often a bot will seek out and use cover in dangerous situations, often in reaction to being shot at or outnumbered.Change
– This relates to a bot's readiness to change state or tactics, such as switching weapons or changing posture (e.g., crouch/prone) based on context.Revive
– Specific to medic classes, this controls the likelihood of a bot attempting to revive fallen teammates with their defibrillator.C4
– A behavior reserved for C4 logic, mostly for SpecOps bots. Controls how likely they are to plant C4 when the opportunity is detected (e.g., placing it on vehicles).Special2
– Typically used by engineers to repair critical assets like bridges, or vehicles.Special3
– Also for engineers. Enables bots to defuse mines or interact with enemy explosives.Random
– Introduces an element of unpredictability to bot behavior. Rarely essential but can make bots feel less robotic.Triggerable
– No documentation found on this. Its not consistently implemented across all Battlefield 2 builds or community mods and only linked to infantry-specific behaviour logic (aiSettings.setVehicleBehaviour Infantery Triggerable BBTriggerable BBPTriggerable 12 UCUnion UnitWeights). It's likely used (maybe?) for triggering scripted behaviors.
Example of modification, let's focus on :
Boosting
Avoid
to8.25 (original 1.0)
makes them break line-of-sight more frequently, giving the illusion of tactical evasive movement.Increasing
TakeCover
to
4.5 or higher (original 2.0)
makes them retreat or hide briefly behind objects .
Lowering
Fire
to4.25 (Original 7.5)
make them hesitate or delay their decision to shoot, even when enemies are in range and visible.
Understanding Weight Constructs Across Vehicle and Soldier AI
- Battlefield 2's AI architecture utilizes multiple weight configurations defined under
rem *** Construct weights *** blocks
, each tailored for different unit types: infantry, tanks, APCs, helicopters, jets, etc.
- Each of these blocks establishes a unique set of
BehaviourModifiers
that govern how bots of that specific type will prioritize their available actions; whether it's firing, avoiding, taking cover, or using special tools like C4.
- However, among all these categories, infantry soldiers are primarily governed by the
rem *** Construct standard weights ***
. Meaning ALL seven infantry classes : Assault, Medic, Support, Engineer, Anti-Tank, Sniper, and SpecOps ; rely on a shared behavior template, defined under the"Construct standard weights" block
. This means they ALL inherit the same behavioral modifiers, regardless of whether certain actions make sense for their class or not.
For instance, a SpecOps soldier will carry a behavior modifier for "Revive", even though only the Medic class is actually equipped to perform that action. In gameplay, this translates to wasted processing: the SpecOps bot spends time evaluating actions like reviving a teammate, even though it has no medkit and no means to do so. The same applies to Special
, Special2
, or Special3
which are typically used for healing, repairing, or mine defusal.
As a result, each class is burdened with irrelevant decision-making logic, reducing the efficiency and clarity of their combat roles.
But through advanced tweaks, we can break this limitation by decoupling these behaviors and assigning dedicated AI templates to each class, one can tailor each bot's behavior weight logic to its actual function. (e.g., SoldierSupportWeights
, SoldierSniperWeights
, etc.). A SpecOps bot, for example, can be stripped of "Revive", "Special" modifiers; freeing up its cognitive scope to focus solely on its true specialties: explosives, and tactical movement (Avoid, TakeCover).
This shift doesn't just improve realism, it dramatically increases behavior responsiveness and lets each bot class act with greater tactical clarity, fulfilling the gameplay role it was intended for.
(Which will be explained in more depth in the second part of the tutorial).
3. Emergent Evasion Behavior – Making Bots Feel Organic
“The first thing I would like to do with the Battlefield AI is to make it use cover. The lack of self preservation that is currently prevailing in the bots is their most obvious weakness. A more general skill, and somewhat related to the covers, I would like to give the bots a much better spatial awareness.”
- Tobias Karlsson, Battlefield 2 AI Designer
Two of the most crucial missing behaviors in vanilla bots are self-preservation (connected to the Avoid
behavior modifier) and cover usage (directly mapped to the TakeCover
weight). These were not disabled by engine limitations, but rather underutilized in practice. By increasing these weights and leveraging class-specific behavior maps, :
Bots are far more likely to:
Break line-of-sight when under fire
Quickly sidestep or shift position when spotted
Simulate reactive dodging or hiding behavior
This doesn't require Python or hardcoded animation overrides, it emerges naturally from the BF2 AI system once you tip the behavioral scales toward survival instincts instead of constant aggression (Define a harmony between the priorities of Fire, Avoid, Take Cover and so one.. :) )
BF2 bots don't literally “dodge” with sidestep animations. Instead, they may break from their path briefly or veer toward a new cover point, giving the illusion of evasion.
4. Why Increasing AI Skill Levels Doesn't Necessarily Improve Tactical Behavior ?
Increasing their overall skill level is one of the alternative ways to make Battlefield 2 bots more challenging ; ranging from "Easy" to "Expert", typically represented by general skill values like
0.1
, 0.5
, or 1
At the highest levels, however, you're not exactly getting tactical masterminds ; you're getting something closer to an aimbot with legs.
Superhuman Accuracy & Instant Reaction Time
At Expert level, bots tend to react with uncanny precision. They can spot you across a vast battlefield, and headshot you in under a second, even if only a sliver of your head was visible.
Understanding the Trade-Offs of Enhanced Bot Accuracy in BF2.
This kind of behavior might look impressive at first, but it's driven primarily by one key behavior weight: Fire
The higher their skill, the more the AI prioritizes shooting over anything else : avoid, revive, or taking cover become secondary (or nonexistent).
5. The Limits of the Engine – Why It Doesn't Always Work
Battlefield 2's engine, developed in the early 2000s, was not designed for high-level AI simulations under heavy load. Key limitations include:
Resource Allocation: The game engine must balance between AI processing, terrain rendering, physics, sound, and more.
Complex Maps: On maps filled with high-polygon statics, terrain detail, or dense navmeshes, the AI decision engine has fewer resources to process behaviors.
Frequency of AI Updates: AI logic doesn't tick every frame like player input ; there are delays, throttling, and simplified logic on low-spec machines.
As a result, even with optimized behavior weights, reactive behaviors may not occur consistently, especially under performance strain.
6. AI Resource Allocation
When overloaded with high bot counts, even the most carefully tweaked behavior systems can fail to execute properly. Here's what you need to understand:
Don't Overload the System
While it's tempting to populate your map with 64 or even 128 bots, doing so, especially on ultra-detailed custom maps , can completely cripple intelligent behavior. Bots stop reacting, fire randomly, or run in circles.
Mainly because each bot count:
Every bot runs its own instance of sensory perception, and communication protocols, meaning : On top of their own behavior, bots observe their surroundings, track allies and enemies, and share information about what they see.
"Other systems, like the sensing system, are dependent on the number of bots. When a bot checks what it sees, it checks against all other players to see if it sees them (there are lots of early outs, but the principle is true). All bots need to check all other bots, so the total cost for sensing grows quadratically with the number of bots."
- Tobias Karlsson, Lead AI Programmer, Battlefield 2
Every Bot Costs Processing Time
Here's what the engine has to juggle for each bot :
Sensory perception (the bot sees and shares what it sees with other bots)
Line-of-sight checks and target acquisition
Dynamic reaction to enemy fire (MoveTo, TakeCover, Fire priorities)
Friendly awareness (collision avoidance, revive priority, squad following)
Weapon usage logic (accuracy, range)
Vehicle control
- etc...
Multiply that by 64 bots or more, and you begin to see why performance degrades quickly, and why bots start to become "stupid" on large heavy maps.
7. Assets Optimization
If you want to maximize the potential of your AI enhancements without an hardcoded overrides, considere these principles for your assets:
✅ Clean Assets
Use only polished soldier, vehicles and weapons models. (A stock BF2 soldier has less than 10K polygons, the same for weapons and some vehicles)
Avoid buggy statics or broken object bundles that could confuse navigation (Bots in Battlefield 2 do not possess adaptive intelligence to understand why they're stuck or when a path is completely blocked).
✅ Smart Static Design
Simplify high-detail statics if possible (A lot of BF2 static doesn't exceed 20K at all, or even less).
Use optimized LODs to reduce render strain (All stock vehicle models, soldiers, basic weapons in BF2 have several lods (1,2,3) to boost performance ).
✅ Moderate Map Density
Avoid overloading maps with hundreds, thounsand of small props and ultra-high-detail terrain which sometimes, are totally unnecessary.
Even modest reductions in complexity can dramatically improve bot behavior frequency.
✅ Texture Efficiency
Ultra-High-resolution textures may look impressive, but they significantly increase VRAM usage, slow down map loading, and cause lag spikes, especially on densely populated maps.
Avoid using large texture on unimportant objects. There is no logical reason why 40 different objects should all have a 8K texture each for an old game from 2005.
The second part of this tutorial will focus on implementing CustomAITemplates, fine-tuning StrategicStrength and understanding BattleStrength values for each of the seven soldier classes
The smarter the environment and the more streamlined the game's internal resources, the more lifelike your bots will become.
Thanks for sticking with it this far. It definitely takes several rereads and repeated testing to make any sense.
NanohTheGreat!