Home › Lua API › AiMilitary

Available out of the box. Usable from Lua in the unmodified game.

AiMilitary

11 methods. Symbol/current columns are function addresses (RVA) of the native wrapper.

Community reference for this object: AiMilitary (Sukrit Tan, external).

Signatures are recovered from the game code. ⚠ = partly understood (arguments may be missing or approximate). ? after a name = optional argument. Types: integer/number are Lua numbers, enum-typed arguments show the C++ type in brackets. Two signatures mean the method is registered separately for the UI and the gameplay state and each wrapper was decoded on its own. "same code as" in the Symbol column means the compiler merged identical functions: those methods share one wrapper and cannot be told apart by address.

Method Signature Where Reference Symbol Current
AddUnitToScriptedOperation AiMilitary:AddUnitToScriptedOperation(operationId: integer[IDType], unitId: integer[IDType]) (or nothing)
args: unitId — An id.
gameplay yes ↗ 0x6c5910 0x6c5fe0
AllowUnitConstruction AiMilitary:AllowUnitConstruction(allow: boolean) (or nothing) gameplay yes ↗ 0x6c5970 0x6c6040
CanConstructUnits AiMilitary:CanConstructUnits() → boolean gameplay yes ↗ 0x6c59d0 0x6c60a0
HasOperationAgainst AiMilitary:HasOperationAgainst(player?: integer[PlayerTypes], mustBeReady?: boolean, unitRange?: integer, position?: any) → boolean
args: player — Id of a player (as in Players[id]).
gameplay yes ↗ 0x6c5a20 —
PrepareForWarWith AiMilitary:PrepareForWarWith(player: integer[PlayerTypes], prepare: boolean) (or nothing)
args: player — Id of a player (as in Players[id]).
gameplay yes ↗ 0x6c5a30 0x6c6100
ScriptForceUpdateTargets AiMilitary:ScriptForceUpdateTargets() (or nothing) gameplay yes ↗ 0x6c5a90 0x6c6160
SetRival AiMilitary:SetRival(rival: integer[PlayerTypes]) (or nothing)
args: rival — Id of a player (as in Players[id]).
gameplay yes ↗ 0x6c5ab0 0x6c6180
SetScriptedOperationReady AiMilitary:SetScriptedOperationReady(operationId: integer[IDType]) (or nothing) gameplay yes ↗ 0x6c5b00 0x6c61d0
SetScriptedTargetAndRally AiMilitary:SetScriptedTargetAndRally(operationId: integer[IDType], targetPlotIndex: integer, rallyPlotIndex: integer) (or nothing) gameplay yes ↗ 0x6c5b50 0x6c6220
StartScriptedOperation AiMilitary:StartScriptedOperation(operationName: string[const char], enemy: integer[PlayerTypes]) → number (IDType)
args: enemy — Id of a player (as in Players[id]).
gameplay yes ↗ 0x6c5bd0 0x6c62a0
StartScriptedOperationWithTargetAndRally ★ AiMilitary:StartScriptedOperationWithTargetAndRally(operationName?: string, enemy?: integer[PlayerTypes], targetPlotIndex?: integer, rallyPlotIndex?: integer) → unsigned_int
args: operationName — A string.; enemy — Id of a player (as in Players[id]).
gameplay yes ↗ 0x6c5c50 —

Notes (★)

StartScriptedOperationWithTargetAndRally

Starts a scripted AI operation by name against an enemy, with explicit target and rally plot indexes. Returns the operation id.

See also: AiMilitary.AddUnitToScriptedOperation, PlayerVisibility.ChangeVisibilityCount