The 3rd Age

BFME 2: Arcade Edition

BFME 2: Arcade Edition

Throws out all the conventional rules of a RTS game and opens the game up like a playable cheat code

Button for The 3rd AgeButton for The Dwarf HoldsButton for The Elven AllianceButton for Helm's Deep Last HopeButton for GothmogtheOrcButton for BFME+Button for The Four AgesButton for HDR HeadquartersButton for Middle Earth CenterButton for Project Perfect Mod

Become an affiliate!


Quick Lists

Top Rated Popular New Updated Last Comments Users

Register and log in to move these advertisements down

In-depth AI Coding

Avatar of Sulherokhh


Category: Code
Level: Expert
Created: Wednesday October 3, 2007 - 6:28
Updated: Friday August 27, 2010 - 19:26
Views: 26221
Summary: The beginning of a comprehensive guide to AI-modding for BfME2


Staff says


Members say




20 votes

Page 1 2 3 4 5 6 7 8 9 10 11
C2. General SkirmishAI_1 and _2 Settings: 'aidata.ini'


The file 'data\ini\default\aidata.ini' is set up much the same as 'data\ini\default\gamedata.ini'. But it's entries are mostly concerned with the way the AI works, how it handles pathfinding, what constitutes a 'threat', how far it looks for enemies, trigger ranges for being 'wealthy' or 'poor', etc. Most of these entries are ONLY for SkirmishAI_1. I have changed quite a few values when modding SkirmishAI_2, just in case it might work, but the results are inconclusive. Proceed at your own risk. Some entries are definitely not for SKirmishAI_2. Most of the entries are well annotated, even if they are inapllicable. Still, i will list the entries and give a short description of what they might be good for.

The file itself looks like this:


I will now give you an overview, step by step, with the entries rearranged to make commenting them easier.
What follows is ---- Only Partly Verified ----.

UseLowLODTrees = Yes
LowLodTreeScale = 1.2
LowLodTreeName = TreeF03
LowLodTreeNameNoGrab = GenericHarvestOnlyOptimizedTreeA
LowLodTreeNameNoHarvest = PTStump02A

  • LOD settings. Not exactly just AI related.

    StructureSeconds = 0.0 ; Ai tries to build a new structure every N seconds.
    TeamSeconds = 10 ;Ai tries to build a new team every N seconds.
    Wealthy = 7000 ; Number of resources for the AI to consider itself wealthy
    Poor = 2000 ; Number of resources for the AI to consider itself poor
    StructuresWealthyRate = 2.0 ; (2=twice as fast) Rate modifier for structure building when wealthy.
    StructuresPoorRate = 0.6 ; (0.5=half as fast) Rate modifier for structures when poor.
    TeamsWealthyRate = 2.0 ; (2=twice as fast) Rate modifier for teams building when wealthy.
    TeamsPoorRate = 0.6 ; (0.5=half as fast) Rate modifier for teams when poor.
    TeamResourcesToStart = 0.1 ; (1.0=100%) Amount of resources required to start building a team.
    MaxRecruitRadius = 400.0 ;The maximum distance a unit will be from a unit that recruits it.

  • Settings that, as far as i know, only influence SKirmishAI_1, meaning the build- and team-scripts used in BfMe1. You can fudge around here to adjust SkirmishAI_2, but as yet i have found it doesn't do anything at all. Equivalent settings can be found in 'skirmishaidata.ini', which i will come to on the next page.

    GuardInnerModifierAI = 1.1 ;The radius modifier to vision which a guarding (AI Controlled) unit will agressively attack
    GuardOuterModifierAI = 1.333 ;The radius modifier to vision which a guarding (AI Controlled) unit will chase after
    GuardInnerModifierHuman = 1.8 ;1.1 ;The radius modifier to vision which a guarding (Human Controlled) unit will agressively attack
    GuardOuterModifierHuman = 2.2 ;1.333 ;The radius modifier to vision which a guarding (Human Controlled) unit will chase after
    GuardChaseUnitsDuration = 15000 ;The number of msec for which a guarding unit will chase attackers before giving up
    GuardEnemyScanRate = 500 ; when actively guarding, how often to scan for enemies (msec)
    GuardEnemyReturnScanRate = 1000 ; when returning to "active" guarding (from pursuing someone), how often to scan for enemies (msec)
    AlertRangeModifier = 1.1 ;The adjustment applied when a unit is alert and doing various scans for enemies (AI units only)
    AggressiveRangeModifier = 1.5 ;The adjustment applied when a unit is aggressive and doing various scans for enemies (AI units only)

  • These settings should in fact have some incluence on SkirmishAI_2, although one has to admit that GUARD has been completely removed and replaced by the STANCE functions.

    ForceSkirmishAI = No ; Use skirmish instead of solo ai. For development till the skirmish ui is finished.
    RotateSkirmishBases = Yes ; If yes, rotate base layout so same side of base faces center of map.

  • Experimental toggles. Never tried the first one (odd, isn't it?), but the second one has no discernable effect.

    ForceIdleMSEC = 67 ;The number of milisec a unit must be idle before looking for an enemy, 2 frames.
    AttackUsesLineOfSight = Yes ; If yes, attack for ALL UNITS (player and ai) uses line of sight.
    EnableRepulsors = Yes ; If yes, KINDOF_CAN_BE_REPULSED will run from enemies & repulsors.
    RepulsedDistance = 120.0 ; How far beyond vision range a repulsed civilian will run before stopping.
    ; so if vision range is 120.0, he will move to a point at least 270.0 away from the enemy, and then stop running.
    WallHeight = 35 ; Height of the "Wall", made of KIND WALK_ON_TOP pieces.
    AttackIgnoreInsignificantBuildings = Yes ; If yes, units will ignore enemy-owned buildings that are not faction buildings

  • These settings work, but hardly need any adjustments for your AI.

    SupplyCenterSafeRadius = 240.0 ; Radius to scan for enemies to determine if a supply center is safe.
    RebuildDelayTimeSeconds = 30 ; Delay this many seconds when a base building is destroyed or captured before attempting rebuild.
    AIDozerBoredRadiusModifier = 1.6 ; Multiplier to dozer scan radius for repair & mine clearing. 2.0 means ai uses twice the radius as human dozers.
    AICrushesInfantry = Yes ; If yes, ai will attempt to crush infantry with vehicles.

  • Some more working entries. Supply centers are remnants from 'C&C-Generals' but are still working, just like the Dozer (read:Porter) autorepair functions. They can be reinserted if needed, but might interfere with some other AI-module. The crushing thing is used with the KINDOF = VEHICLE, if you want to add it to some of your units.

    ; SkirmishGroupFudgeDistance is the distance that is multiplied by the number of units in a group to
    ; determine if they are close enough to the waypoint to consider themselves AT the waypoint. This is
    ; only used for "Follow Waypoint Path as a Team."
    SkirmishGroupFudgeDistance = 4.0
    ; Note that these group pathfind parameters are inter-related, and modifying them may produce really
    ; ugly results & require code changes.
    InfantryPathfindDiameter = 6 ; Number of pathfind cells wide group path is for infantry.
    VehiclePathfindDiameter = 6 ; Number of pathfind cells wide group path is for vehicles.
    MeleeApproachDist = 48.0 ; Melee units will move towards targets if > this distance.
    MeleeApproachTolerance = 20.0 ;
    WadeWaterDepth = 5.0 ; How deep we can wade into water or cross fords.
    DeepWaterDepth = 6.0 ; How deep water needs to be for ships & subs (non-shallow-water craft).
    ; Group (formation) pathfinding parameters.
    MinDistanceForGroup = 200.0 ; Have to be moving at least this far for group (formation) movement.
    FormationEnemyDistance = 500.0 ; Don't use formation movement if enemies are closer than this to the center of the group.
    FormationColumnWidth = 60.0 ; Space between columns.
    FormationRowDepth = 55.0 ; Space between rows.
    FormationSquadSpacing = 30.0 ; Extra space between squads.
    FormationColumns = 2 ; form up two hordes abreast, or 4 smaller units. (valid values are 2 or 3.)
    UseFormations = Yes ; Move in formation. Can be turned off in a map.ini if necessary.
    WaitForOthers = No ; When moving in formation wait (or not) for others at first waypoint. Default=No.
    NarrowPassageScale = 0.4;
    HordesWaitForHordes = Yes ; If yes, hordes will stop and wait for other hordes to pass. If no, they just run through each other.
    AttackMoveUsesFormations = Yes ; If yes, player attack moves will move in formation (if UseFormations == Yes)
    ; Retaliation parameters.
    MaxRetaliateDistance = 410.0 ; If the attacker is more than this far away, won't chase. Keeps from chasing artillery.
    RetaliateFriendsRadius = 120.0 ; Retaliator gathers allies within this distance & attacks.
    ChaseFromBehindLimit = 50.0 ; How far from behind units can do melee attacks when chasing other units. 01Oct2004
    CastleSiegeStandBackDistance = 500.0 ; How far for units to stand back from if they cannot enter the castle

  • Important Pathfinding Parameters, not just for SkirmishAI but for every unit in the game. 'AttackMoveUsesFormations = Yes' is broken in BfMe2, but it works in RotWK.

    ForceHordesToLowLOD = Yes
    AllowForestFires = No

  • Experimental toggles. Never tried them.

    AttackPriorityDistanceModifier = 80.0 ;The distance required to reduce attack priority by 1.
    ;// The entire AttackPriority system is no longer in use
    ;// target priorities are now defined much more generically in SkirmishAIData.ini
    AttackPriority DefaultAttackPriority ; define THIS IS OUTDATED, DO NOT USE THIS
        Default = 35
    AttackPriority AttackPriority_Infantry ; define THIS IS OUTDATED, DO NOT USE THIS
        Default = 35

  • These DO work, but have been simplified by the new AttackChainDefinitions in 'SkirmishAIdata.ini' (see also next page), which are also used for 'intelligent' TeamBuilding by SkirmishAI_2. Especially 'AttackPriorityDistanceModifier' has significant input in AI target acquisition and threat assessment. If you reduce this number, the AI will tend to ignore targets that lie far-off until anything close by has been dealt with and other stuff with a priority setting has been tended to, like building structures and upgrades. If you raise it too high, the AI will tend to perceive any place on the map as if it was just next to it and consequently seldom feel safe enough to spend resources on 'safe' activities, like basebuilding and upgrade acquisition.
  • Consequently what we have here is AttackPriority Sets with only a default value. If you would like to reimplement them then take a look at the way they are set up in BfMe1. Mind you that all units/hordes will need to have a set among their object code, and the set must be defined here. They can then even be adjusted by scripts, if you are doing something like a campaign map with adjusted values for everything.

    ; Build Phase Priority Modifiers
    ; These numbers are the amount by which the priority of a structure is increased per second
    ; for each thing that needs said structure to exist
    BuildPhase1_PerSecondPriorityModifier = 50
    BuildPhase2_PerSecondPriorityModifier = 30
    BuildPhase3_PerSecondPriorityModifier = 20
    BuildPhaseN_PerSecondPriorityModifier = 10

  • These values seem to work, though rather unpredictably, and tie in with the build phases defined in SkirmishAIdata.ini. I will try to explain the whole priority setup on the next page, to the best of my abilities.

    SideInfo Rohan
        ResourceGatherersEasy = 0
        ResourceGatherersNormal = 0
        ResourceGatherersHard = 0
    ... (etc.)
    ;Skirmish AI Build List
    SkirmishBuildList Gondor
        Structure GondorBarracks
            Location = X:863.19 Y:1151.87
            Rebuilds = 0
            Angle = 0.00
            InitiallyBuilt = No
            AutomaticallyBuild = No
        END ;Structure GondorBarracks
        Structure GondorFarm
            Location = X:888.34 Y:996.71
            Rebuilds = 0
            Angle = 0.00
            InitiallyBuilt = No
            AutomaticallyBuild = No
        END ;Structure GondorFarm
        ... (etc.)
    END ;SkirmishBuildList FactionGondor END

  • The first entries seem to have had a certain impact on the old teambuilding scripts for SkirmishAI_1 (for lumber workforce building), but they seem to not work for SkirmishAI_2. You may have noticed that the AI does not replace killed workers, if you have somehow convinced the AI to build lumbermills at all, since EA didn't make them do that in the standard settings.
  • The second entries refer to the structure build scripts for SkirmishAI_1, though i am not entirely certain how exactly those come together. One thing is sure, SkirmishAI_2 doesn't use these entries at all.

  • ... progressing ... SĂ»l



    Display order: Newest first | Page: 1, 2

    Prolong - Thursday July 29, 2010 - 9:21

    Very nice guide, even though it never got finished there is still a ton of great information here.

    Elrond99 - Sunday February 15, 2009 - 7:52

    Thanks for updating the Tutorial
    It´s great to hear that it´s possible to make a new AI from scratch

    Can´t wait for section F, custom AI scripts, that sounds really interesting
    Especially since I know D and E already ;)

    Sulherokhh (Team Chamber Member) - Saturday February 14, 2009 - 21:19

    After 'D. The Faction Base and Fortress', i guess.
    If you are asking for a date, you are asking the wrong guy. I don't have one. I work on modding related stuff mostly when i find the time and the mood strikes me. It's supposed to be fun, right? :)

    Edit: But i might do it before the fortress and base setup. Depends on, well, which kind of work is going to be most interesting to me at the time. Scripts should be easier to do then the Basebuilding stuff, but a bit more to write as well, at least if i am going to do it right. I am starting to ramble... :O

    jakonic - Saturday February 14, 2009 - 12:05

    when will be finished Spell Purchase Scripts???please answer

    Sulherokhh (Team Chamber Member) - Thursday November 29, 2007 - 17:26

    I sure will...

    Edit: Do you have any particular requests? If i have done it already, it shouldn't be hard to post a solution here. If it's not, chances are that i was going to look into it anyway. Except for the general skirmishsetup and bases, since those will require extesive explanations which i was planning to do anyway when i find the time.

    So shoot! :)

    Rob38 (Team Chamber Member) - Thursday November 29, 2007 - 11:00

    This is by far one of my favorite tutorials on T3A! Please continue to add more :)

    Sulherokhh (Team Chamber Member) - Wednesday October 3, 2007 - 23:07

    I am glad you can put it to use, Rob! Your feedback means a lot to me. :D

    Rob38 (Team Chamber Member) - Wednesday October 3, 2007 - 22:27

    Amazing! I also found a way to recognize if a player is controlled by the AI, but this looks to be a much easier method to use. Thank you for all your wonderful knowledge as there is some really cool stuff in here.

    Sulherokhh (Team Chamber Member) - Wednesday October 3, 2007 - 19:18

    I'll split it up. Let's see what would be a good way. - Edit: Done. I hope you like it.

    Crashdoc - Wednesday October 3, 2007 - 16:48

    Nice findings and interesting ways to use them. Thanks for sharing the knowledge!

    Go to top


    "One site to rule them all, one site to find them,
    one site to host them all, and on the network bind them."