Skip to content

Reference

SMUnlimited edited this page Sep 18, 2026 · 2 revisions

Reference

This is the practical reference for Strategy Manager build code and its source files. Signatures come from current common.eai and races.eai.

Strategy Manager controls

Control Action
Version/race Select the source tables being edited.
Strategies / Profiles Switch between race strategies and version-wide personalities.
New / Copy / Remove Manage entries.
Edit Open metadata and strategy code.
Extract / Insert Export/import .ais strategies and .aip profiles.
Lock / Unlock Force an entry for testing or restore normal selection.
Edit Racial Builds Edit goals used by every strategy for the race.
Edit Global/Racial Settings Edit the selected settings tables.
Compile Version / All Build one version with optimized output, or run MakeAll.bat.

Goals and priorities

Build calls describe desired totals, not sequential commands. AMAI inserts them into a priority-sorted array and adds prerequisites from version data.

For quantities above one, earlier copies gain prio_q_inc over the final priority. At its default 2, BuildUnit(4, uRIFLEMAN, 50) yields priorities 56, 54, 52, and 50. This interlaces similarly weighted goals. Custom racial settings may change the increment.

Basic builds

function BuildUnit takes integer qty, integer unitid, integer prio returns nothing
function BuildUpgr takes integer qty, integer unitid, integer prio returns nothing
function BuildItem takes integer qty, integer unitid, integer prio returns nothing
function BuildExpa takes integer qty, integer unitid, integer prio returns nothing
  • BuildUnit maintains a unit/building total. A main hall goal advances the main base's tier.
  • BuildUpgr researches through the requested level.
  • BuildItem obtains the requested total across eligible inventories.
  • BuildExpa requests expansion halls rather than normal main-base construction.
call BuildUnit(8, uRIFLEMAN, 60)
call BuildUpgr(2, uUPG_RANGED, 45)
call BuildItem(1, uHEALING_POTION, 80)

Use current generated u identifiers. Valid names differ by version and originate in tables such as StandardUnits.txt.

Specialized builds

function SetBuildUnitIfAvailable takes integer qty, integer unitid, integer prio returns nothing
function SetBuildUnitExAM takes integer easy, integer med, integer hard, integer unitid, integer prio returns nothing
function SetBuildUpgrExAM takes integer easy, integer med, integer hard, integer unitid, integer prio returns nothing
function SecondaryTownAM takes integer town, integer qty, integer unitid, integer prio returns nothing
function BuildFront takes integer qty, integer unitid, integer prio returns nothing
function BuildAtMine takes integer qty, integer unitid, integer prio returns nothing

SetBuildUnitIfAvailable skips unavailable goals. ExAM calls select quantities for Easy, Normal, and Hard. SecondaryTownAM targets a tracked town; BuildFront and BuildAtMine request special placement.

Reactive composition

function SetBuildReact takes integer food, integer min1, integer unit1, integer min2, integer unit2, real enemy_strength, real strength1, real strength2, integer prio returns nothing

After minimum counts, food is divided between the unit types. At or below strength1 it favors unit1; at or above strength2 it favors unit2; intermediate values interpolate. Food costs are accounted for and both result sets interlace.

call SetBuildReact(20, 3, uFOOTMAN, 5, uRIFLEMAN, enemy_unarmored + enemy_air * 2 - enemy_normal * 2, 4, 25, 70)

If one side resolves to zero, its unit and prerequisites are not requested.

Upgrade scaling

function BuildAdvUpgr takes integer qty, integer unitid, integer starttier, integer unitcount, integer maxunits, integer tierprio, integer prio returns nothing
function BuildAdvUpgr2 takes integer qty, integer upgid, integer starttier, integer unitcount, real unitper, integer max, integer prio returns nothing

BuildAdvUpgr scales priority with relevant unit count and adds tierprio at later tiers. BuildAdvUpgr2 makes repeated chance-based requests as unit count grows, capped by max percent. Use current race files as examples because their behavior intentionally differs.

Blocks and tier pacing

function SetTierBlock takes integer tier, real unitper, integer foodlimit, boolean expansionblock returns nothing
function AddBlock takes integer req_qty, integer req_type, boolean only_done, integer allow_qty, integer allow_type, integer expire_time returns nothing
function AddRBlock takes integer req_gold, integer req_wood, integer req_food, integer allow_qty, integer allow_type, integer expire_time returns nothing
  • SetTierBlock delays tiering until enough earlier unit goals are complete; the food limit bypasses it and expansionblock also blocks while expanding.
  • AddBlock caps allow_type until req_type is started (only_done=false) or completed (true).
  • AddRBlock caps a goal until stored gold, lumber, and used food reach thresholds.
  • Expiry values are five-second AI ticks: 60 is roughly five minutes.
call AddBlock(1, uBLACKSMITH, false, 1, uHOUSE, 60)
call AddRBlock(360, 160, 0, 0, uAVIARY, 60)

Blocks belong in initialization, not repeatedly evaluated tier code.

Harassment

function AddHarass takes integer groupnum, integer qty, integer unitid returns nothing
function Harass takes integer groupnum, integer harass_target, boolean avoid_towers, real strength_limit, real flee_percent, integer flee_number, boolean cond, integer min_time, integer time returns nothing

AddHarass assigns units during initialization. Harass launches when its condition, initial time, and repeat interval permit it. Times are five-second ticks. Strategy targets are HARASS_TARGET_PEONS, HARASS_TARGET_EXPANSION, and HARASS_TARGET_MAIN_HALL.

call AddHarass(1, 2, uFOOTMAN)
call Harass(1, HARASS_TARGET_PEONS, true, 5, 0.75, 0, GetPlayerRace(nearest_enemy) != RACE_UNDEAD, 50, 80)

This avoids towers, flees from strength 5, aborts below 75% group health or with no units, first runs after 400 seconds, then waits at least 250 seconds. distraction_group selects a configured group for diversionary attacks.

Town and race helpers

function DefendTowns takes integer qty, integer unitid, integer prio returns nothing
function DefendTownsDone takes integer qty, integer unitid, integer prio returns nothing
function DefendTownsFront takes integer qty, integer unitid, integer prio returns nothing
function DefendTownsFrontDone takes integer qty, integer unitid, integer prio returns nothing
function basic_melee takes integer food, integer prio returns nothing

DefendTowns* requests quantities at qualifying expansions. Done counts only completed copies; Front includes the main town and uses front placement there. basic_melee divides food between the race's configured simple and advanced melee units.

Strengths and conditions

enemy_air          enemy_casters       enemy_towers
enemy_piercing     enemy_normal        enemy_siege
enemy_magic        enemy_unarmored     enemy_lightarmor
enemy_mediumarmor  enemy_heavyarmor

Values may be weighted in expressions. Common conditions include:

TownCountDone(uFOOTMAN) >= 5
TownCount(uBARRACKS) > 0
GetPlayerRace(nearest_enemy) != RACE_UNDEAD
GetPlayerUnitTypeCount(Player(0), 'hfoo') > 0
Min(TownCountDone(uFOOTMAN) / 5, 1)

TownCountDone counts completed units/buildings; TownCount includes construction. Use Warcraft natives only when safe in AI scripts—avoid thread-spawning natives because AI has a fixed thread budget.

Source layout

Path Role
common.eai Shared engine, build API, chat parsing, and strategy selection.
races.eai Shared race helpers.
Blizzard.eai Editable Commander/map integration.
Jobs\*.eai, Jobs.txt Scheduled behaviors and registration.
REFORGED, TFT, ROC Version tables, strategies, settings, and compatibility inputs.
Languages, Languages.txt Translations and language metadata.
Commands.txt Commander definitions.
Scripts Generated output; do not edit directly.
Electron Installer source and packaging.

Common.j, Natives.j, and Blizzard.j are Warcraft reference/runtime files and must not be changed. AMAI's editable Commander source is Blizzard.eai.

JASS/eJASS rules

  • Declare all locals at the beginning of a function.
  • Define or import functions above callers; order matters.
  • Preserve tab-separated schemas and lowercase booleans.
  • Reuse common helpers and the job scheduler.
  • Rebuild affected versions and test generated output.

Installer modes

Value Mode
0 No Commander
1 Commander
2 AMAI versus Blizzard AI

Lower-level InstallVERToMap.bat also contains internal tag-vs-tag mode 3, which normal installers do not expose.

Further reading

Clone this wiki locally