# AI Actions ## Primary Action (AI Player) Used by the AI to interact with objects in the game world. ### Definition ```ruby def PrimaryActionAI int8 :action_identifier byte24 :zero int32 :target_id int8 :selection_count byte24 :zero2 float :x_coord float :y_coord array :selected_ids, type => :int32, length => :selection_count, onlyif => :selection_count < 0xFF end ``` ### Description *:action_identifier*
Always has the value `0x02`. *:zero*
The 3 bytes following *:action_identifier* are unused. *:target_id*
The ID of the targeted object. *:selection_count*
The number of selected units. Always `0x01`. *:zero2*
The three bytes following *:selection_count* are unused. *:x_coord*
The x-coordinate of the targeted position. *:y_coord*
The y-coordinate of the targeted position. *:selected_ids*
The IDs of the selected units. ### Examples `02 00 00 00 21 1f 00 00 01 00 00 00 00 80 36 43 00 80 0f 43 72 1e 00 00` >`02` — action_identifier
>`00 00 00` — zero
>`21 1f 00 00` — target_id
>`01` — selection_count
>`00 00 00` — zero2
>`00 80 36 43` — x_coord
>`00 80 0f 43` — y_coord
>`72 1e 00 00` — selected_id ## Move (AI Player) Used for moving and attacking. If that is the only purpose is unknown. ### Definition ```ruby def PrimaryActionAI int8 :action_identifier int8 :selection_count int8 :player_number int8 :player_id int32 :unknown_id int32 :unknown_bytes int32 :target_id int8 :unknown_count byte24 :zero float :unknown_x_coord float :unknown_y_coord float :unknown_float float :unknown_float2 int32 :unknown_bytes2 array :selected_ids, type => :int32, length => :selection_count, onlyif => :selection_count > 0x01 end ``` ### Description *:action_identifier*
Always has the value `0x0a`. *:selection_count*
The number of selected units. *:player_number*
The player's number which can be changed in the lobby. Is only different from *:player_id* if playing in coop mode. *:player_id*
The ID of the player. *:unknown_id*
The ID of a unit that is able to move. *:unknown_bytes*
Purpose unknown. *:target_id*
The ID of a target. Is `0xFFFFFFFF` if no target is selected. *:unknown_count*
Could be the number of targets, but is never greater than `0x01`. Is `0xFF` if no target is selected. *:zero*
The 3 bytes after *:unknown_count* are always zero. *:unknown_x_coord*
Presumably an x-coordinate, that could describe the position of a target. *:unknown_y_coord*
Presumably an y-coordinate, that could describe the position of a target. *:unknown_float*
A float value that can be `1.0f` or `-1.0f`. *:unknown_float2*
A float value that can be `1.0f` or `-1.0f`. *:unknown_bytes2*
Purpose unknown. *:selected_ids*
The IDs of the selected units. Only present if *:selection_count* is greater than `0x01`. Always contains *:unknown_id*. ### Examples `0a 01 03 03 1b 17 00 00 c1 02 01 00 ff ff ff ff ff 00 00 00 00 00 09 43 00 00 4a 43 00 00 80 bf 00 00 80 3f 01 00 00 00` >`0a` — action_identifier
>`01` — selection_count
>`03` — player_number
>`03` — player_id
>`1b 17 00 00` — unknown_id
>`c1 02 01 00` — unknown_bytes
>`ff ff ff ff` — target_id
>`ff` — unknown_count
>`00 00 00` — zero
>`00 00 09 43` — unknown_x_coord
>`00 00 4a 43` — unknown_y_coord
>`00 00 80 bf` — unknown_float
>`00 00 80 3f` — unknown_float2
>`01 00 00 00` — unknown_bytes2 ## Waypoints (AI Player) Used for setting multiple waypoints for AI units. ### Definition ```ruby def WaypointsAI int8 :action_identifier int8 :selection_count int8 :waypoint_count array :selected_ids, type => :int32, initial_length => :selection_count array :x_coords, type => :int8, initial_length => :waypoint_count array :y_coords, type => :int8, initial_length => :waypoint_count end ``` ### Description *:action_identifier*
Always has the value `0x1f`. *:selection_count*
The number of units selected by the AI. *:waypoint_count*
The number of waypoints. *:selected_ids*
The IDs of the selected units. *:x_coords*
The x-coordinates on the AoC grid. *:y_coords*
The y-coordinates on the AoC grid. ### Examples `1f 04 09 84 21 00 00 bd 20 00 00 a4 21 00 00 bb 21 00 00 6e 6a 68 67 67 64 64 64 5f 99 a0 a4 a7 a8 b0 b4 b8 be` >`1f` — action_identifier
>`04` — selection_count
>`09` — waypoint_count
>`84 21 00 00` — selected_id
>`bd 20 00 00` — selected_id
>`a4 21 00 00` — selected_id
>`bb 21 00 00` — selected_id
>`6e` — x_coord1
>`6a` — x_coord2
>`68` — x_coord3
>`67` — x_coord4
>`67` — x_coord5
>`64` — x_coord6
>`64` — x_coord7
>`64` — x_coord8
>`5f` — x_coord9
>`99` — y_coord1
>`a0` — y_coord2
>`a4` — y_coord3
>`a7` — y_coord4
>`a8` — y_coord5
>`b0` — y_coord6
>`b4` — y_coord7
>`b8` — y_coord8
>`be` — y_coord9 ## Training Unit (AI Player) Used for training unit with AI player. ### Definition ```ruby def TrainAI int8 :action_identifier byte24 :zero int32 :building_id int16 :player_id int16 :unit_id int32 :const end ``` ### Description *:action_identifier*
Always has the value `0x64`. *:zero*
The 3 bytes after *:action_identifier* are always zero. *:building_id*
The ID of the building where the units are trained. *:player_number*
The number of the AI player who trains the unit (`0x01` - `0x08`). *:unit_id*
The `UnitID` (`LineID` for villagers) of the unit which is trained. *:const*
The value is always `0xFFFFFFFF`. ### Examples `64 00 00 00 ae 1a 00 00 03 00 27 00 ff ff ff ff` >`64` — action_identifier
>`00 00 00` — zero
>`ae 1a 00 00` — building_id
>`03 00` — player_id
>`27 00` — unit_id
>`ff ff ff ff` — const