GeezerVison is showing war3ai.com — API catalog - War3AI
API catalog
103 APIs, each one telling you “Verified? How fast? How does it work?”
Generated from code by python -m openwar3 catalog --write and updated along with the SDK, so models never have to guess which methods exist or which ones actually work. The same data is also available as JSON to hand straight to an agent.
Full state of the whole map (WorldState): .units .players .items .clock .me; repeated calls within max_age seconds return the same copy.
⚠ Workers inside a gold mine are not in the list; by default the whole map is visible (in the lockstep model everything exists locally), and only Game(fair=True) filters by vision.
Mechanism W3P world block Local\War3World_<pid> (pushed by the runtime every 50 ms, seqlock)
Enemy units (or 'creep' for creeps, or a given player number) as last seen: [(the unit as it was then, the game clock at that time, seconds elapsed since)], newest first.
Units seen dying are removed from the list. Both fair mode and normal mode record based on "what we can see right now" — this is the map in a player's head:
scouted army, where the enemy hero was last seen, when the enemy expansion went up. max_age keeps only entries from within that many game seconds.
Mechanism visibleTo of the pushed snapshot (every snapshot refresh records the visible enemy/creep units)
This game's terrain table MapInfo: .walkable(x,y) .buildable(x,y) .at(x,y) .bounds (playable area) .starts (start locations) .cells (bit0 unwalkable, bit1 unbuildable).
It takes a few seconds after the game starts to compute; returns None until it's ready. Trees aren't included (use trees()).
Mechanism W3P map block Local\War3Map_<pid> (computed in batches by the runtime after the game starts; IsTerrainPathable walk/build)
{'gold','lumber','food_used','food_cap','gold_gathered','lumber_gathered'}; player defaults to us, and any player can be read.
Returns None when it can't be read — don't treat that as 0.
Whether it's a building (including towers). Determined by movement speed 0 in the unit table; the Undead hall has a footprint of 0, so don't go by footprint.
Workers with nothing to do: no order and no task (workers you just gave a job this tick don't count).
⚠ Re-issuing a gather order to a worker that has a task interrupts its harvest cycle (income drops to zero).
Whether this worker is building something (or walking over to build / helping repair; includes jobs assigned this tick). Skip it when picking a builder, otherwise the previous foundation stops.
Mechanism Pushed snapshot (order = building four-character code, or construction/repair order)
This building isn't finished yet (HP not full). ⚠ Damaged buildings aren't at full HP either — good enough for the opening, but once fighting starts, combine it with timing.
Mechanism Pushed snapshot (a foundation's HP climbs from very low all the way to full)
Gold mines on the map. ⚠ A Night Elf Entangled Gold Mine and the neutral gold mine are two separate units at the same coordinates; send harvesters to your own one.
Creeps (neutral hostile). ⚠ Vision shrinks at night; once distant camps fall into the fog of war, target commands on them are rejected (reason code 1001).
{'order','target','x','y'}: the order the unit is currently carrying out (order is 0x000D00xx or a building four-character code; 0 = idle).
target is a handle pair; use g.unit(target) to turn it into a unit.
Mechanism World block unit order / order target / order target point
The unit it is **actually attacking/chasing** (None if there isn't one).
⚠ After an attack order, the order slot quickly empties and the attack hangs on the task — to tell "what it's attacking", use this, not current_order.
What this building is producing: Production(kind, queue, duration, elapsed, blocked, progress, remaining…); returns None if it's idle.
kind 'queue' (training/research/hero; queue has up to 7 slots, [0] is the one in progress) / 'construction' (being built) / 'upgrade' (upgrading a hall/tower);
blocked = something is queued but hasn't started (usually not enough food — time to build a Farm); progress 0..1.
Opponents' buildings can be inspected too (in fair mode, only buildings you can see).
Mechanism World block production table (Aque/ABnP/AUnP ability objects + elapsed time tracked by the runtime; measured error < 0.2 game seconds)
All production in progress [(building, Production)]. owner works like units(): 'me' / 'enemy' / player number / 'all'.
Pro use: see what units the opponent is training, what tech it's researching, and when it tiers up (once you've scouted the buildings).
Walking distance for a ground unit from a to b (a and b can be units or (x,y)); None if unreachable. On island maps, use this to decide "can ground units reach this creep camp/expansion" —
it's more reliable than straight-line distance (it goes around forests, cliffs and buildings). Precision is one 128 cell; gaps narrower than a cell count as blocked.
Mechanism Map block (engine IsTerrainPathable) + tree block + building footprints, A* on the SDK side (128 per cell)
Path corner points [(x,y)...] (the last point is b); combine with path(units, points) to move the army along this route (around towers, via side paths).
Upkeep level: {'level': 'none'/'low'/'high', 'income': 1.0/0.7/0.4, 'next_at': food count at which the next level starts (None if there isn't one)}.
Pro common knowledge: stay at 50 food while teching to tier 3 / getting attack/armor upgrades, and only go up to 80 right before the decisive fight.
Mechanism Fixed 1.27 rule: 0~50 food no upkeep, 51~80 income ×0.7, 81~100 ×0.4
Groups the (visible) creeps on the map into camps: [{'x','y','units','level','hp','max_level'}], sorted from nearest to farthest from our main base.
level = total camp level (the usual measure of creeping difficulty), hp = total HP. Combine with time_to_kill / path_distance to pick camps.
Mechanism Pushed snapshot (creeps within 600 of each other are grouped together) + levels from units.json
The unit's combat stats combat.UnitStats: max HP/mana, armor (including attack/armor upgrades and hero agility), armor type, movement speed, day/night sight range,
weapons (what it can hit, range, attack cooldown, damage range, attack type, splash). u is a unit (automatically uses its owner's tech and its hero level) or a four-character code (player defaults to us).
Then use .dps_vs(other) / .hits_to_kill(other) / combat.time_to_kill(group, other). ⚠ Doesn't include items, auras or buffs.
Mechanism Data tables (UnitBalance/UnitWeapons/UpgradeData/MiscGame) + live tech levels + hero level
Verified Pushed snapshot + fast lane (batched every 5 s)
How many game seconds this group of units needs to kill target together (uses target's current HP; accounts for counters, armor and attack/armor upgrades; not for movement, splash or healing).
Pro use: focus fire the one that "dies fastest" (smallest time_to_kill) first, not the closest one. Can't hit it = None.
In-game time of day (hours, 0~24). The game starts at 8 AM; a full day = 480 game seconds (240 seconds each for day and night, scaled by the day/night speed).
Returns None when it can't be read (old runtime / not in a game).
Mechanism World block extension area: GetFloatGameState(GAME_STATE_TIME_OF_DAY)
Whether it's night now (18:00~6:00). Pro play: at night creeps are asleep (you get the first hit when creeping, without being surrounded), and every unit's sight range shrinks (a good time for surprise attacks);
Night Elf Sentinels/units are invisible next to trees at night. Returns None when it can't be read.
Mechanism World block extension area (daytime is 6~18)
Living trees (those whose targType in DestructableData includes tree); given (x,y), sorted from nearest to farthest, up to limit trees.
Each is Tree(addr, handle_lo, handle_hi, type, x, y, life), and can be passed straight to gather to harvest lumber.
Mechanism Tree block Local\War3Trees_<pid> (refreshed every 2 seconds)
What happened since the last call: unit.appeared / unit.died / unit.removed / unit.damaged / order.changed /
hero.levelup / owner.changed / item.appeared / item.removed / game.started (these come from diffing publishes; precision = publish period 50 ms),
plus the engine-level damage / killed (the runtime records them on the game thread as they happen, so there's one for **every single hit**):
damage: handle = the unit being hit, .source_addr = who hit it (snapshot().unit_by_addr turns it into a unit), .value = actual HP lost,
.raw_damage = pre-armor damage, .attack_type (normal/pierce/siege/magic/chaos/hero/spell), .damage_type
killed: this hit killed it, .source_addr = the killer
plus production.done, derived by the runtime tracking the production table (precision = publish period): unit = the building, .done_code = four-character code of what finished,
.done_kind = 'training' (units/heroes/revives) / 'research' / 'construction' (building completed) / 'upgrade' (tier-up/tower upgrade), .value = game seconds taken
Added 09-25:
spell.cast: unit = the caster, .spell spell four-character code, b level, value cooldown seconds, x,y cast point (recognized when the spell's cooldown starts; precision = publish period)
player.left: .player the number of the player who left / was removed after being defeated; game.ended: left the game
selection.changed: the local player's selection changed (get the units with g.selection())
message: a line in an on-screen message frame (game hints, chat, system): .text full text, .frame message frame number,
.chat = {'channel', 'sender', 'text'} (when it's chat; this is where you read what the player typed in the chat box)
ui.click / ui.hover / hotkey / mouse.world: UI & input (g.ui); .key is the canvas key / hotkey string
Each one is Event(seq, kind, clock, addr, handle, type, owner, a, b, x, y, value, extra).
Fair mode (fair=True) only gives: events for your own units, events for units visible right now (or still visible within the last 1 second), damage dealt to us or by us,
and local UI / message / game events.
Mechanism Event ring Local\War3Events_<pid> (publish diffing + damage events captured by the runtime)
Messages newly shown in the on-screen message frames since the last call: [{'text', 'frame', 'repeat', 'seq', 'game_ms'}].
Game hints ("You need more farms", "Can't build there"), chat and system messages are all here; frame tells you which message frame.
Same batch as the message events in the event stream (each has its own cursor).
Mechanism Shared memory Local\War3Msgs_<pid> (screen messages captured by the runtime)
The engine's feasibility verdict: 0/220 OK; 3 not enough food, 8 not enough gold, 9 not enough lumber, 32 queue full, 183 missing prerequisite, 185 altar is reviving, 221 no such item/under construction.
⚠ Always 221 for a worker constructing a building, so it can't be used to check placement (use build_near).
Ask many can_do at once: pairs = [(unit, four-character code), ...]; returns a list of verdict codes in the same order (None where it couldn't be asked).
When planning what to build/train in a tick, ask about everything at once first — N times faster than one can_do at a time (reference brain 09-23: build planning 76 -> 25 ms).
Mechanism W3P query q_feasible × N, submitted as one batch
The computer AI's captain: where it's taking its army (you know which part of your base it will attack before it leaves home). Only works against computer opponents; returns None if the unit isn't following a captain.
Mechanism W3P query q_captain (the computer captain that enemy units follow)
The unit's current order, **including ones you just issued this tick** (uses the new order from the receipt until the snapshot catches up).
⚠ 09-23 live game: hello_bot had just sent a peasant to build a Farm, and in the same tick rush_bot saw it as "idle" in the snapshot and sent it to build Barracks, so the Farm was abandoned halfway over and over.
When picking "idle/not building" units, use this instead of u.order.
Mechanism Snapshot order + commands just accepted in this process (receipts)
Whether current gold/lumber is enough to buy code (units, buildings; by the prices in units.json). Anything missing from the price table is treated as affordable.
⚠ Tier-up four-character codes have cumulative prices in the table, so this errs on the conservative side; the engine's receipt is the final word.
Mechanism Our resources from the pushed snapshot + prices from units.json
Data for the map being played (openwar3.mapdata.MapData): name_of('HC07') for the names of custom units/items/abilities, hero_names, tooltip.
Most units in RPG maps are created by the map itself and aren't in the built-in name table. Returns None for games not started by the launcher (the map file can't be found).
Mechanism Map file (the launcher's --map path): w3u/w3t/w3a + wts; for protected maps, reads the TXT files inside the map
Combine a tick's commands into one batch:
with g.batch() as b:
g.attack(archers, target) # returns Pending; becomes a receipt only after the block ends
g.move(wounded, *home)
g.cast(hero, "thunderclap")
print(b.sent, b.wait_ms, [r.reason for r in b.receipts])
Sent one by one, every command waits for the game thread once (about 10 ms); a batch waits only once — this is how the reference brain cut a round from 48 -> 26 ms on 09-23.
* Claims are still checked per command (a unit held by someone else gets a held receipt immediately and isn't added to the batch);
* Commands inside the block return Pending: reading its .ok before the block ends raises an error (the receipt doesn't exist yet); after the block ends, use it like a Receipt;
* An exception inside the block = the whole batch is discarded (status 97 cancelled), and the units it held are released;
* Queries (can_do / tech / visible …), build_near and buy aren't batched and are still asked immediately — their results are needed on the spot;
to ask about many things at once, use can_do_many / tech_many;
* A nested with g.batch() merges into the outermost batch; beyond 16 commands the runtime automatically splits it into several segments (one wait per segment).
Mechanism Commands in the block are gathered into one batch and submitted once when the block ends (executed in the same frame, waiting on the game thread only once)
Move to (x,y) without fighting on the way (use this for retreating). Accepts a single unit or a list (ordered together in the same frame).
queue='after': go after finishing the current task (inserted after the current order). Receipt values[0] = how many orders this unit has queued after the command (including the current one).
Attack target. Uses right-click by default (on an enemy = attack this one; measured 09-23: both the order target and the task target are it).
⚠ The target must be in vision; targets you can't see are rejected (reason code 1001).
force=True uses the attack order 0x0F (needed to attack your own units/neutral critters) — measured: it only switches to the attack order and doesn't remember the target,
so the unit goes off to attack other enemies nearby. Don't use it to attack a specific target.
Attack ground: artillery fires at an area (to hit invisible units, units behind trees, or to block a choke point). Only units that can attack ground accept it.
Mechanism W3P point: attackground (siege units / Mortar Teams / Demolishers)
Move through a series of points in order (Shift-click waypoints: patrol routes, routing around towers, scouting routes). attack=True makes every leg an attack-move.
Submitted once; one receipt per point (in points order).
Mechanism One batch: the first leg runs immediately, the rest are inserted in reverse order with queue='after' (the engine can only insert right after the current order)
Harvest gold/lumber (target is a gold mine or a tree from trees()). ⚠ Only assign idle workers (idle_workers): re-issuing to a worker that has a task interrupts its harvest cycle.
Pro use: go back to mining after building = gather(worker, mine, queue='after') after build(...).
Have a worker build code at (x,y) (coordinates aligned to a 32 grid). Receipt accepted = the worker's order is now this building (or the start-construction order);
with queue='after' = added to the worker's order queue (receipt values[0] is the queue count).
⚠ Accepted ≠ built: the engine also accepts a spot inside a forest on the spot, and the worker only fails once it gets there (measured 09-23); gold being spent elsewhere can also keep the foundation from appearing.
If you don't know where it fits, use build_near (it tracks the result and blacklists failed spots). To build several in a row, use build_queue.
Mechanism W3P build: build order, with the worker's order read back in the same frame to confirm
One worker builds several in order (Shift-queued building): plan = [(four-character code, x, y), ...]. Submitted once; receipts in plan order.
⚠ Gold is deducted only when construction starts (not when queued) — if you queue 3 but can only afford 1, the other two fail when the worker gets there.
Mechanism One batch: the first immediately, the rest in reverse order with queue='after'
Find a spot that fits around (x,y), searching from near to far, and build code there. **Non-blocking** — fine to call every tick:
* An attempt for this building type is still in progress (the worker is on its way) -> returns that spot without re-issuing the order;
* The last attempt succeeded (the foundation appeared) -> finds a new spot this time if needed;
* The last attempt failed (the worker found on arrival that it didn't fit, the engine dropped the order, no foundation) -> that spot is blacklisted for 45 seconds and the next one is tried;
* Not enough gold -> returns None right away (no attempt, no blacklisting); returns None once every spot has been tried.
⚠ Why tracking is needed: in 09-23 live games, the engine **accepted on the spot** a point inside a forest, and the worker only failed once it got there (the same-frame receipt can't tell);
and the engine's placement check always returns 221 for a worker constructing a building, so you can't "check" before building either. Only obviously occupied spots (the middle of the hall) are rejected on the spot.
Mechanism Per-point build + tracking (foundation appears = success; worker drops the order with no foundation = that spot is blacklisted)
Train units / research tech / upgrade the hall (tier up = give the hall itself the target hall's four-character code, e.g. 'hkee').
When rejected, the receipt's reason says why (not enough food, not enough gold, not enough lumber, queue full, missing prerequisite…).
Mechanism W3P immediate: four-character code, with the feasibility reason code when rejected
Cast a spell. spell is an order string ('thunderbolt' Storm Bolt, 'blizzard', 'holybolt' Holy Light…; see data/order-ids.txt) or an order ID.
Give target = on a unit; give x,y = on the ground; neither = no target (Thunder Clap, Divine Shield, Summon Water Elemental).
An accepted receipt only means the engine accepted it; to see whether it actually went off, check whether cooldown() shows a cooldown or buffs() shows the buff.
Mechanism W3P target / point / immediate (chosen by arguments)
Revive a dead hero at the altar (if hero isn't given, revives the first one in the list).
Common rejection reasons (written in the receipt's reason): not enough food (heroes cost food too), not enough gold, died too recently (a hero can only be revived about 3 game seconds after dying),
revive already in progress (the engine clears that slot on the spot once it's accepted).
Mechanism W3P revive: dead hero list -> the altar casts revive on the dead hero
The hero goes to pick up an item from the ground (item comes from items_on_ground). Once picked up, it appears in the inventory and an item.removed event is emitted for the ground item.
Use the item in inventory slot slot (0~5); can take a target unit or a target point.
⚠ For point-targeted item use (e.g. Ivory Tower), the engine returns 0 even on success, so the receipt always counts as accepted — check whether that slot has emptied.
Give the item in inventory slot slot to to (another hero / unit; the hero walks over and hands it over). Giving it to a shop = selling it (see sell_item).
Mechanism W3P item_drop (mirrors JASS UnitDropItemTarget: dropitem on a unit)
UI & input (openwar3.ui.UI): clickable buttons and choice cards, hotkeys, picking a position by clicking the ground, where the mouse is pointing.
The game never receives the click that lands on a button; pure local input + local drawing, so it's safe in multiplayer.
Publish period of the world state (16~1000 ms, default 50). One sample takes about 0.5 ms, so even 33 ms is fine; there's a single value shared machine-wide, and the last write wins.
Show a chat bubble over a unit's head (for streaming/debugging; doesn't affect the game). Returns False if the bubble didn't appear; the reason is in g.last_say_error.
Print a line in the message area at the bottom left of the game (visible only on this machine). The game must have shown a notice on its own first (the DLL grabs the message box from that one).
Canvas: draw text boxes, panels, progress bars, images, circles on the ground and routes on the game screen (openwar3.canvas.Canvas).
Drawn by the runtime itself — no game handles created, no game state changed — so it's safe in multiplayer; style it however you like (CJK text, rounded corners, translucency).
Mechanism W3P 73 canvas_enable + shared memory Local\War3Canvas_<pid> (drawn by the runtime every frame just before the game draws the mouse cursor; the cursor covers it)
Press Space once on the "Press any key to continue" loading screen. Many RPG / story maps need a key press after loading before they start (measured on WarChasers, 09-24:
without it the game sits on the loading screen, the game clock stays at 0 and the fast lane never drains). openwar3.run presses it itself while waiting to enter the game, so you rarely need to call it by hand.
Mechanism PostMessage WM_KEYDOWN/UP Space to the game window (doesn't steal focus)
Call any JASS native by name: g.jass.CreateUnit(g.jass.Player(1), "Hpal", x, y, 270.0).
Arguments I/R/B/S/H are converted automatically (pass unit/item objects directly); in multiplayer only read-only natives can be called. See openwar3/jass.py and docs/COMPANION_ZH.md for details.
Mechanism W3P 70 jass (the runtime looks the name up in the native table, 1291 entries)
The 16 player slots: controller (user = human / computer / neutral…), state (empty / playing / left), human, me, ally (whether it's allied with me).
Use it in RPG maps to find an empty slot for a companion, or to tell whether it's a single-player game.
Create a unit at (x,y) (player defaults to the local player) and return it as a snapshot unit (after the next world publish, ~50 ms); returns None if it can't be created.
The returned unit has an extra attribute, jass_handle. ⚠ Single-player only (it desyncs in multiplayer).
Set player a's alliance toward b: allied = don't attack each other + request help from each other; vision = shared vision; control = shared unit control (b can command a's units);
xp = shared experience. both=True sets both directions at once (control is only set a -> b).
Show a line of text at the bottom left of the screen (the kind map triggers use), shown to the local player by default. Supports |cffRRGGBB color codes.
You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.