Skip to content

AI triggers

Mapping

Changed in 0.2.0

Defines the weighted records from which a house draws its next one or two teams.

Format
Kind
Record
File
AI.INI, AIFS.INI, map file
Section
[AITriggerTypes]
Record form
<AITrigger ID>=<up to 18 comma-separated fields>
Enable section
[AITriggerTypesEnable]

Fields

#FieldAccepted valueRequired
1NameDisplay nameYes
2Primary teamTeamType ID or <none>Yes
3OwnerHouse ID, <all>, or <none>Tested only in a campaign game. A house ID the game does not recognize counts as <none>.Yes
4IgnoredPresent but discardedYes
5Condition typeInteger from -1 through 4Yes
6Condition objectObjectType IDYes
7ComparatorHexadecimal comparison blockYes
8Starting weightNumber truncated to an integerNo
9Minimum weightNumber truncated to an integerNo
10Maximum weightNumber truncated to an integerNo
11Skirmish0 or 1No
12IgnoredPresent but discardedNo
13SideThe side's position in the rules' [Sides] list, counted from one; 0 leaves the trigger unrestrictedNo
14Base defense0 or 1Stored and written back, never read; whether a trigger counts as defensive comes from its teams' IsBaseDefense.No
15Secondary teamTeamType ID or <none>No
16Easy0 or 1No
17Medium0 or 1No
18Hard0 or 1No

Each assignment in [AITriggerTypes] defines one AI trigger: its ID to the left of =, and its fields, separated by commas, to the right. AI triggers and team production explains how a house chooses among triggers and what each field decides.

The game reads AI triggers from AI.INI, then from AIFS.INI when Firestorm is enabled, then from the map.

Whether a trigger is enabled depends on where it was defined:

  • A trigger from AI.INI or AIFS.INI is enabled.
  • A trigger from the map is disabled unless the map’s [AITriggerTypesEnable] section enables it.

[AITriggerTypesEnable] pairs an AI trigger ID with a yes-or-no value. In a campaign game, yes enables the trigger and no disables it, and this works for a trigger from AI.INI or AIFS.INI as well. Outside a campaign, every ID listed in the section is enabled, whatever its value.

A map entry with the same ID as a trigger from AI.INI or AIFS.INI redefines that trigger. Each field the map entry supplies replaces the earlier value. The trigger stays enabled unless [AITriggerTypesEnable] disables it, and it counts as a map trigger, so IgnoreGlobalAITriggers=yes does not skip it.

Put a value in every field up to the last one you write. Consecutive commas count as one separator, so an empty field moves every later field one position earlier. Write <none> in a team or owner field you want to leave empty, and the intended value in every other field. A 0 in a weight field sets that weight to 0, and a 0 in a difficulty field turns the trigger off at that difficulty.

Fields 1 through 7 are required. If the value ends before field 7, the trigger is still registered with the fields read so far. A new trigger cut short after its owner and before its condition type has no condition, so a campaign game can still draw it. A redefined trigger cut short there keeps its earlier condition.

Fields 8 through 18 can be left off the end. A new trigger missing them has weights of 1, is not available in skirmish, has no side restriction and no secondary team, and is enabled at every difficulty. A redefined trigger keeps the values it already had.

The condition type selects what the trigger measures and which of the next two fields it reads. A field the condition does not read can hold anything.

ValueWhat it measuresFields it reads
-1Nothing; the condition always holdsNeither
0How many objects of the condition object’s type the enemy ownsCondition object and comparison block
1How many objects of the condition object’s type the owning house ownsCondition object and comparison block
2Whether the enemy’s power output minus its drain is below 100Neither
3Whether the enemy’s power output minus its drain is below 0Neither
4The enemy’s money, counting stored TiberiumComparison block

A condition type outside this table never holds. AI triggers and team production covers which house is the enemy and what happens when a house has none.

The comparison block holds the number to compare against and the comparison to apply. It is written in hexadecimal, two digits to a byte:

  • bytes 1 to 4 hold the number;
  • bytes 5 to 8 hold the comparison, as a value from the table below.

Each is a four-byte integer written low byte first. Digits after the sixteenth are not used.

Comparison valueHolds when the measured amount is
0Less than the number
1Less than or equal to the number
2Equal to the number
3Greater than or equal to the number
4Greater than the number
5Not equal to the number

Any other comparison value never holds. For example, “at least 5” is the number 5 with comparison 3, so the block starts 0500000003000000.

The condition object is an ObjectType ID. The game looks it up among infantry, vehicle, aircraft and structure types, in that order, and uses the first match. An ID that matches no type does not reject the trigger: the count is 0, and the comparison is made against that.

Accepted settings

1 of 1

KeyDescriptionValueWhen omitted
Name[<ObjectType ID>]The display name of a type definition, a scenario, a multiplayer map, or a music track.stringthe type's section name

Source files

Linked at revision 51b52aa38392.

History

  1. Changed0.2.0In development

    Name an AI trigger's side by its position