Campaign and Mod Creation

This section is for users who already got experience with Warcraft 3 modding and only want the specific information needed to make AMAI work with custom units and abilities.

Note: There is currently an issue with using the default AMAI on custom melee maps that dont use the latest melee patch data. AMAI will not work past tier 1

Defining custom units and abilities for AMAI.
For this you need a table editor like Microsoft Excel or any other program capable of opening and saving tables file in form of tab separated text files.

Be-aware that Microsoft Excel has the tendency to make true and false upper case and adds extra ( " ) symbols when types and such have a comma between them. e.g. mutated, worker becomes in excel "mutated,worker" . Make sure you change these back otherwise compile errors will occur.

To add simple new custom units just edit the table file "StandardUnits.txt". There is one of these files for each version of AMAI. You find it in TFT or RoC folder together with some other table files used for adding special units that got some kind of morph abillity like Gargoyle - > Statue -> Gargoyle or can be upgraded to another unit like Head hunter -> Berserker. The StandardUnits.txt is at least the main table for all buildings, units, abilities, upgrades and items in the game that AMAI knows of, once you open it you will understand.

To add a new unit here just insert an empty line in the category where it belongs and add all the info in the columns. All columns got labels explaining what to put in them at the first line of this file and you will also understand what to enter by looking at the existing units.
You might also want to replace a standard unit, do that by just entering new info in its line.

All units that appear by using an ability from another unit or morph or cannot be built directly should have the word "mutated" in the 'type' column so they don't appear as buildable in the editor. Such units also need to be added to some of the other tables depending on what kind of transformation they come from.

Upgraded units go in here too and are added to tc_add on the original units line.

Global Setting Files:

CommandBuilds.txt = What computer builds if issued an order using the commander

Dragons.txt = The types of dragons that can be built from the different roosts

DragonTypes.txt = The Range of sizes of dragons available

GlobalSettings.txt = This contains the global settings of the custom ai. This can be edited using the option on the strategy manager. (They all have comments next to them so you know what they do)

sleep_multiplier // increases performance by checking stuff not so often
slm_start // how many computer players is needed tor the sleep multiplier to start increasing.
slm_end // how many computer players is needed tor the sleep multiplier to stop increasing.
slm_start_mult // how much is the sleep multiplied when it´s below the slm_start codition
slm_end_mult // how much is the sleep multiplied when it´s above the slm_end codition
hero_radius // scanning this small area around hero to detect if the hero gets surrounded by enemy or is in danger of becoming that so it should move
use_linear_upkeep_saving // should the computers save the upkeep threshold gold over the time above or save it all at once when it get's to the upkeep border?
repair_threshold // computers only repair buildings if they have more than this many workers
repair_threshold_threatened // computers only repair buildings when the town is under attack if they got more than this many workers
max_follow_dist // Distance behind the arme a zeppelin follows
neutral_hero_time // when is neutral heroes available in seconds /5
buy_distance // how close to a shop do a unit have to be for buying?
buy_timeout_large // time in seconds the hero goes to a shop before it gives up if it haven't reached it
buy_timeout_small // time in seconds a hero tries to buy items at shop before giving up
build_array_reset_time // every this * 5 seconds, the build array is reset
rp_strat_normal // normalizing strategy priorities added from strengths with this value
strategy_tier_bonus // the priority bonus added to a strategy if the computer is in the same tier as specified for the strategy
attacking_strategy // strategy when attacking enemy players
focus_fire_limit // if a enemy heros hp fall below the computers combined strength of ranged attackers in a battle * this, they will focus fire on the hero
focus_fire_ranged_dist // Distance from ranged units enemy units can be targeted with focus fire
focus_fire_melee_dist // Distance from melee units enemy units can be targeted with focus fire
flee_health_percentage // Units flee from battle if the health goes below his % value(0.25 = 25%)
flee_minimum_health // Units flee from battle if the health goes below this
statue_distance // how near the units a statue used by undead should be in the fights
teleport_radius // units will stay within this radius from a hero that is using town portal
gold_exchange_level // computers give extra gold above this value to other computers on the same team in need of gold
wood_exchange_level // computers give extra lumber above this value to other computers on the same team in need of lumber
max_towns // how many towns is a computer allowed to have?
add_tag // Add the [AMAI] tag in front of name
add_skill // Add the current skill after the name
fav_hero_add // priority added to heroes to be picked if they are favorites of the used profile
max_harass_groups // how many different harass groups you can use
attacking_aggression // the base agression value for all computers, higher value and they will play more agressive. Recomended -5 to 5
expansion_radius // the radius araound a mine computers check for creeps before expanding there
harass_radius_attack_ranged // how far away from ranged enemy units harassing units attack a inferior enemy unit
harass_radius_attack_melee // how far away from melee enemy units harassing units attack a inferior enemy unit
harass_radius_flee_ranged // how far away from ranged enemy units harassing units turn and flee
harass_radius_flee_melee // how far away from melee enemy units harassing units turn and flee
chatting true computers use chat taunts
full_threat_distance // a enemy army within this distance is counted as a full threat
no_threat_distance // a enemy army outside this distance is counted as no threat
distance_threat_exponent // how fast the threat increases as the enemy army gets from the no_threat_distance to the full_threat_distance
distance_threat_mult // how much the threat vlaue goes up on a rown when a enemy army aproashes, higher value means higher threat to town
atl_time_start // accepted threat level increase starts at this time
atl_time_end // and ends at that time
atl_time_start_val // it starts with this value
atl_time_end_val // and ends with that value
atl_enemy_start // accepted threat level multiplier increases at that enemy number
atl_enemy_end // until that enemy number
atl_enemy_start_mult // the multiplier starts for accepted threat level starts with this
atl_enemy_end_mult // and ends with this
teleport_low_threat // Army uses TP to get home and defend if a threat is greater than this and the army is more far away from thretened town than teleport_low_threat_distance
teleport_high_threat // Army uses TP to get home and defend if a threat is greater than this and the army is more far away from thretened town than teleport_high_threat_distance
teleport_low_threat_distance // Army won't use TP home if they are closer to base than this and a low threat level appears
teleport_high_threat_distance // Army won't use TP home if they are closer to base than this and a high threat level appears
teleport_army_min_strength // how big the army need to be for use of TP to threatened town
teleport_min_threat // minimum threat level TP use is allowed on
shredder_peon_count // how many peons does a goblin shredder replace in lumber harvesting
minimum_peon_wood // computers don't build any workers for lumber harvesting if they have more lumber than this
maximum_peon_wood // computers build all needed workers for lumber harvesting if they have lumber lower than this
ver_neutral_heroes_available // does the version have neutral heroes ?
ver_neutral_hero_number // how many neutral heroes ?
ver_only_heroes_buy // can only heroes buy stuff ?
ver_food_limit // what is the versions food limit ?
normal_battle_radius // units within that radius are considered belonging to the current battle
creep_battle_radius // same as with normal_battle_radius, but for battles against creeps
expansion_taken_radius // how near a mine a enemy building must be to make amai recognize it as taken
ver_strat_change_enemy_strength_min // don't allow strategy change unless the maximum strength of all enemy players in the game is above this.
ver_hero_base_value // what is the base strength of a hero (the level number is added to get the actual strength) ?
ver_hero_ultimate_level // at what level do the heroes get their ultimates ?
ver_hero_ultimate_value // how much extra strength does the ultimate give to the hero ?
ver_creeps_attack_buildings_dist // how far away do creeps attack buildings ?
ver_mercs_night_buy // can mercs be bought at night without waking up creeps ?
ver_tower_check_radius // check for towers in this radius around a target
ver_harass_tower_check_radius // check for towers in this radius during harassing
destroy_buildings_on_defeat // Should the buildings of the AI be destroyed on defeat or given to neutral player ?
ver_gold_mines // what are the gold mine ids in this version (in TFT that is Set3('ngol','egol','ugol') ) ?
attack_reform_length // reform the attack group (getting new units) every that time on an attack (in seconds / 2)
front_base_distace// the distance of front of base from start location

Healers.txt = The different units that can do healing. The heal order codes are as follows.

  1. 852160 = Rejuvenation
  2. 852063 = Heal
  3. 852109 = Healing Ward
  4. 852545 = Essence of Blight
  5. 852248 = Neutral Hostile Heal

Healertypes

HeroAbilities.txt = Add new abilities that your heros can learn or edit.

HeroLevels.txt = Range of levels your heros can go up to

HealingItems.txt = Healing items that can be used by the ai

Mercs.txt = Mercenaries that can be brought from the different mercenary camps

MercTypes.txt = Types used for the column headings in Mercs.txt (Remember to change those headings if you change these). I reccomend not to change this file.

NeededExtra.txt = If a unit has more needs that cannot be fitted into the standardunits.txt, put them here

NeutralHeroSkills.txt = The skill orders that neutral heros use. The ability names are in the HeroAbilities.txt. See heroSkills.txt below for more information.

Profiles.txt = This is the raw txt file of your profiles. You should not need to edit this as you use the strategy manager instead.

Races.txt = The available races the ai can use and the script files it creates. The example layout of this file is below

RACE AMAI script Original Blizzard entertainment script

Note by changing the original blizzard entertainment script selections to custom made scripts and placing that custom script in the version folder you can see how your ai plays against AMAI when you compile the AMAI vs AI version.

StrengthPredictionRules.txt = This contains conditions that are used to predict changes to an enemies strength so AMAI can react before it actually happens. This file has not yet been officially tested so use at your own risk.

Strengths.txt = The strength names. I reccomend not to change as you then have to change loads of other files which had the old strength names in.

UnitConversions.txt = Where unit conversions are placed like 'Archer + Hippo -> Hippo rider'

UnitEquivelence.txt = Where extra upgraded forms go if there is no space in the standardunits.txt file or if you want to use special equivelences.

e.g. UPGRADED_TO or BUILT_FROM

Upkeep.txt = Settings that monitor the upkeep.

FoodValueBorders = The places where upkeep become low or high
Resistance = Amount of gold to save before entering desired upkeep level
SaveTime = How many seconds *5 the computer should wait and save money before entering upkeep level
MinesNeeded = Number of mines to have before entering upkeep level

Racial Setting Files :

BuildSequence.ai: = This is the data of your strategy builds. Do not change. Use the strategy Manager instead. Strategy Manager also allows you to change the racial global builds that are always built no matter what strategy the ai uses.

CommandBuilds.ai = Units race builds when issued an order from the commander.

Heros.txt = The heros the race can build and there different proities to be built. Be aware that the first heros must be the neutral heroes. The number of rows that count as neutral are set in the global settings file. If neutralheroes = 0 then first heros will just be normal ones.

HeroSkills.txt = The skill orders for the racial heros. The ability names are set in HeroAbilities.txt. These skill lists must be for heros defined in same order as in the heros.txt document. Each hero will in total have 9 skill lines(3 for tier 1, 3 for tier 2, 3 for tier 3) . The format example is below.

Tier Priority Abilitiy names
1 60 list of 10 abilities
  30 list of 10 abilities
  10 list of 10 abilities
2 60 list of 10 abilities

RaceAgression.txt = Agression of race against the other races.

RacialSettings.txt = Global values for the race and what special abilities race can do. Use the strategy Manager to edit this instead of editing directly here. (The settings have comments next to them so you know what they do)

hero1_revive_prio // priority for reviving hero1
hero2_revive_prio // priority for reviving hero2
hero3_revive_prio // priority for reviving hero3
prio_n_inc // priority increase for building needed buildings
prio_t_inc // priority increase in time
prio_q_inc // priority increase in quantity
farm_food // build farm when this near food used to food produced
farm_food2 // builds another farm at the same time when this near food used to food produced
farm_prio // priority for farm building
peon_prio // priority for peon building
expa_prio // priority for expansion building
expa_emergency_prio // priority for making expansion when it's an emergensy (current mine/mines + own resources are about to be depleted)
expa_rebuild_prio // priority for rebuilding an expansion
peon_1_mine_number // number of peons to build when 1 mine is owned
peon_2_mines_number // number of peons to build when 2 mines are owned
peon_mines_number // number of peons to build when more mines are owned
min_peon_number_single_mine // minimum number of peons when 1 mine is owned
min_peon_number_multi_mine // minimum number of peons when more than 1 mine is owned
strat_persistence // extra added priority to the current strategy to make computer not change strategy too fast
strat_food_persistence // * current food use added to priority for current strategy (prevents computers from changing styrategy when having large army)
relevant_strat_change_number // number of strategies with highest RPs that can be chosen when changing strategy
kb_add1 // priority added to all strategies having a building the computer already got as a key building
kb_add2 // priority added to all strategies having a building the computer already started to build as key building
kb_add3 // priority added to all strategies having both building the computer already got as key buildings
kb_add4 // value for 2 of a key buildings
ku_add1 // priority added to all strategies having a upgrade the computer already got as key upgrade in first level
ku_add2 // priority added to all strategies having a upgrade the computer already got as key upgrade in second level
ku_add3 // priority added to all strategies having a upgrade the computer already got as key upgrade in third level
fav_unit_add // priority added to strategies havign the current profiles favorite unit as key units.
debug_strategy // this race is locked to this strategy number for testing.(-1 is unlocked)
race_use_fountain // does the race use healing fountains ?
race_manual_loading // does the race need manual loading of wisps in goldmines ?
race_manual_loading_wisp // What is the unit to load ?
race_manual_loading_mine // What unit is it loaded in ?
race_towerrush_available // does the race have a towerrush ?
race_tower_orderstring // the orderstring for building the tower for towerrush
race_militia_expansion_available // does the race have a militia expansion ?
race_hero_number // how many racial heroes ?
race_simple_melee // a basic melee unit, only necessary when basic_melee is used
race_advanced_melee // an advanced melee unit to replace the basic one, only necessary when basic_melee is used
race_has_ghouls // has the race a ghoul-like wood harvester/fighter unit ?
race_has_power_build // can multiple racial workers work on the same building ?
race_no_wood_harvest // has the race no wood harvesters ?
race_ignore_injured // should the race leave injured units at home ?
race_uses_mine_expansion // does the race expand with a mine building like undead ?
race_uses_shredder // does the race use the goblin shredder ?
race_militia_available // does the race have militia ?
race_militia_max_distance // how far away from the town hall are the militia allowed ?
race_militia_ability // what is the militia ability id ?
race_militia_hall_ability // what is the militia ability of the hall ?
race_militia_unitstring // what is the unitstring/name of the militia ?
race_militiaworker_unitstring // what is the string of the unit that can be turned to militia ?
use_militia_only_on_bigger_threats // shall the computer only use militias against larger threats ?
race_towerrush_requirement // what is the building required to build towers ?
race_ghouls_attack // do those ghouls go with the army on attacks ?
race_ancient_expansion_available // can the race expand with an uprooted building that also helps fighting the creeps ?
race_ancient_expansion_probability // how high (in percent) is the probability of doing an ancient expansion when possible ?
race_ancient_expansion_strength // up to how much expansion strength is an ancient expansion allowed ?
race_ancient_expansion_hero1 // allow ancient expansion for that hero
race_ancient_expansion_hero2 // allow ancient expansion for that hero
race_sell_ziggurats // does the race sell ziggurats that are at no more needed expansions ?
race_ziggurats // for selling ziggurats, a set of ziggurats the race has (use old ids)
race_ziggurat_keep_distance // keep ziggurat if this near another building except a ziggurat is

 

Strategy.txt = File that stores the strategies of the race. Use the strategy manager to create and edit strategies instead of editing here.

Tiers.txt = The available tiers that the race has.

The next files are files outside of the ROC and TFT folder and are just in the AMAI folder

Versions.txt = The different versions available. So adding version "yuck" would require folder "yuck" to be created which has all the files above in as if it is another TFT folder. Scripts folder also needs a folder of this name to store the create scripts at that location.

Jobs.txt = This calls the functions in the Jobs folder. Those files all end in .eai and can be edited in notepad for advanced users.

Common.eai = Open in notepad but can be edited by advanced users. Main file of AMAI to create common.ai script. (Contains main globals of ai's)

HeroFleeRules. ai =Controls the flee control of heros. Can be edited by advanced users

.j extension files =Can be edited by advanced users.

Blizzard.eai = Can be edited by advanced users. Main file of AMAI to create blizzard.j scripts. (Contains all the commander and language functions)

Race.eai =Can be edited by advanced users. Main file of AMAI to create racial script ai's.

keywords.txt= key words used in all ai scripts. This file is used for optimizing the ai scripts so dont go changing it.

Adding into your campaign.

First import scripts into your campaign. You could rename them if they are only being used at a particular mission e.g. human01.ai. Then in the map that wants to use them, do "run campaign ai" or "run melee ai" somewhere (initialisation is best if no in game cinematic playing at beginning of map) and select your imported ai script. (campaign ai prevents parts of the scripts from running which melee ai would have)

If you leave the script names as human.ai, orc.ai etc and change there location in map to scripts/ you can just use melee - run ai scripts action to run them.

Upgrading your AMAI

As AMAI is improved you may wish to upgrade your AMAI to use new features and to take advantage of new developer settings. AMAI is very easy to update unless we give specific instructions on release.

First download the new developer edition and extract to appropiate place. Copy your amai version folder over to the new amai directory.

Open versions.txt and add the name of your custom amai. Save and close.

Now run "apply table changes.pl" and all the nessary updates are applied to your custom amai so that you may continue to use it.

Using AMAI's commander system

AMAI's commander system is very powerful in allowing players to issue orders to there allies when a player presses the esc key. Custom game makers can use this to there advantage to make some direct control of AMAI in a custom map who may wish to control the AMAI in some way. There is a trigger command in the world editor that allows you to issue commands to a computer 'AI-Issue command' or you can use the common.j native CommandAI() if you prefer scripting. Basically certain combinations of command and data orders will make AMAI do something. I shall list the results of the commands below.

Command Data Result
0 N/A Cancels all custom commands and default control given back to AMAI
1 N/A Cancels build order commands and control given back to AMAI
2 N/A Cancels all attack orders and control given back to AMAI
10 N/A Stop AMAI's current attack
11 N/A Makes AMAI no longer attack until all attack orders are cleared using command 2
12 (0-12) Make AMAI attack the player number given in the data
13 N/A Makes AMAI attack a point. You must issue another command with this where the new command is the x point and the data is the y point otherwise this will not work
14 N/A Makes AMAI no longer attack creeps
15 N/A Makes AMAI no longer attack players
16 (0-12) Makes AMAI attack the current selected unit of the player given in the data
17 N/A Make AMAI tower rush (only works if the race can towerrush)
50 N/A Turn AMAI chatting systems on and off
51 N/A Turn AMAI debugging systems on and off
52 N/A Balancing debug system turns on to report strengths of enemies etc
53 N/A Stops AMAI from changing its current strategy
60 N/A Displays Current Strategy Name
61 N/A Displays All Strategy Names
70 0 ->

Forces AMAI to change strategy. The data contains a value that depicts what strategy number to change to.

71 row AMAI changes language to the that in the languages.txt file on that chosen row. First row is 0
20 0 -> Forces AMAI to build the amount specified in data of air2air units
21 0 -> Forces AMAI to build the amount specified in data of air2ground units
22 0 -> Forces AMAI to build the amount specified in data of ground2air units
23 0 -> Forces AMAI to build the amount specified in data of ground2ground units
24 0 -> Forces AMAI to build the amount specified in data of farm units
25 0 -> Forces AMAI to build the amount specified in data of tower units

N/A = Value is Ignored
0-> = May use any value