ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

AITriggerTypes: Difference between revisions

From ModEnc
Jump to navigation Jump to search
Adding notes here and there
m Updating with new sidebar
Line 1: Line 1:
{{WrongTitle|[AITriggerTypes]}}
{{WrongTitle|[AITriggerTypes]}}
{{SideBar|[[AI programming]]|Template:AI}}
{{AIBar}}{{clr}}
In {{ts}} through {{yr}}, this section defines a list of all AI Triggers in the game. An AI Trigger (different from a [[Maps/Triggers|Map Trigger]]) describes the conditions under which the AI will consider creating this trigger's associated Team(s) to perform a specific task.  
{{MappingBar}}
In {{ts}} through {{yr}}, this section defines a list of all AI Triggers in the game. An AI Trigger (different from a [[Triggers|Map Trigger]]) describes the conditions under which the AI will consider creating this trigger's associated Team(s) to perform a specific task.  


== Format ==
== Format ==
Line 144: Line 145:
*The infamous {{Tt|-G}} suffix has no meaning whatsoever.  
*The infamous {{Tt|-G}} suffix has no meaning whatsoever.  
*Unlike [[TaskForces]], there is no effect to prefixing an AITriggerType's ID with a hexadecimal prefix.
*Unlike [[TaskForces]], there is no effect to prefixing an AITriggerType's ID with a hexadecimal prefix.
[[Category:AI(md).ini Sections]]
[[Category:Maps Sections]]

Revision as of 15:12, 23 June 2008

This page should correctly be named "[AITriggerTypes]"; it is wrong due to technical restrictions.




In Tiberian Sun through Yuri's Revenge, this section defines a list of all AI Triggers in the game. An AI Trigger (different from a Map Trigger) describes the conditions under which the AI will consider creating this trigger's associated Team(s) to perform a specific task.

Format

This section is provided here mostly for completeness' sake. Editing this section, especially the comparator part, manually is not advised unless you really know what you are doing. Consider using FinalAlert 2's AI Editor or DCoder's AI Editor V2 instead.


This section uses a convoluted and complex data format:

[AITriggerTypes]
;format example
ID=Name,Team1,OwnerHouse,TechLevel,ConditionType,ConditionObject,Comparator,StartingWeight,MinimumWeight,MaximumWeight,IsForSkirmish,unused,Side,IsBaseDefense,Team2,EnabledInE,EnabledInM,EnabledInH


;actual example triggers
0CAD0C7C-G=Allied Anti-Weather,0A6E513C-G,<all>,9,0,GAWEAT,0100000003000000000000000000000000000000000000000000000000000000,70.000000,10.000000,70.000000,1,0,1,0,0CB246CC-G,0,1,1
0D535EDC-G=Nation German Tank 1,0A87293C-G,Germans,2,4,<none>,0000000003000000000000000000000000000000000000000000000000000000,500.000000,10.000000,500.000000,1,0,1,0,<none>,1,1,1
0D2769BC-G=Soviet Iron Curtain Easy,0D27E06C-G,<all>,2,5,<none>,0000000000000000000000000000000000000000000000000000000000000000,5000.000000,10.000000,5000.000000,1,0,2,0,<none>,1,0,0
08B9767C-G=Yuri Capture Oil,08B97B3C-G,<all>,1,7,CAOILD,0100000003000000000000000000000000000000000000000000000000000000,70.000000,10.000000,70.000000,1,0,3,0,<none>,0,1,1
Meanings of each string
String Meaning
ID This AI Trigger's ID.
Name A plain string used as a name. Must not contain commas, will be truncated to 47 characters for internal representation.
Team1 The first TeamType that will be created when this AI Trigger meets its condition.
OwnerHouse The Country that should use this AI Trigger. Defaults to <none>, can be set to an individual country's name or to <all>, indicating that all countries of the appropriate Side can use this AI Trigger.
TechLevel Minimum TechLevel required for this AI Trigger. Is recalculated internally to be the minimum TechLevel required to build all the units in this AI Trigger's first and second TeamTypes.
ConditionType Specifies a number to use as a Condition. This, along with "ComparisonObject" and "Comparator" desribed below, defines a logical comparison like "enemy house has more than 0 rhino tanks". In this example, "more than 0" is the Comparator, "rhino tanks" is the ComparisonObject, and "enemy house has ?????" is the Condition.
Possible values
Value Meaning
-1 Special case - Pool team (see below ↓)
0 "Enemy house owns ????"
1 "Owning house owns ????"
2 "Enemy house in low power (yellow)"
3 "Enemy house in low power (red)"
4 "Enemy house has ??? credits"
5 "OwnerHouse has an Iron Curtain charged to at least [General]AIMinorSuperReadyPercent= percentage"
6 "OwnerHouse has a ChronoSphere charged to at least [General]AIMinorSuperReadyPercent= percentage"
7 "Neutral/civilian1 house owns ????"

1 To find this house, the game scans all houses from the [Countries] list, starting with the first one on the [Sides]Civilian= list and going down the list, when it finds the first one with Template:TTL set.

ComparisonObject Specifies the object that will be used as the Comparison Object (see the section on ConditionType for more information). IDs of AircraftTypes, BuildingTypes, InfantryTypes and VehicleTypes are accepted here.
Comparator Defines the comparator for the ConditionType. A normal comparison contains two operands and a comparison operator. The first operand is dependant on the ConditionType (typically amount of objects owned, or credits owned). The second operand is encoded in this argument. The comparison operator is one of (less, less-or-equal, equal, more-or-equal, more, not equal) and is also encoded in this argument. This argument is composed of eight chunks of eight hexadecimal characters each (64 characters in total). Each octet contains a textual representation of a little-endian hexadecimal number. The first octet contains the second argument, the second octet contains the operator (0 stands for "<", 1 - "<=", 2 - "=", 3 - ">=", 4 - ">", 5 - "!="), the next six octets are unused.
StartingWeight Specifies a floating point value that will be set as this AI Trigger's Starting Weight when the game starts. (See the section on Trigger Weights for more info.)
MinimumWeight Specifies a floating point value that will be interpreted as this AI Trigger's Minimum Weight. (See the section on Trigger Weights for more info.)
MaximumWeight Specifies a floating point value that will be interpreted as this AI Trigger's Maximum Weight. (See the section on Trigger Weights for more info.)
IsForSkirmish This AI Trigger is enabled in any game modes except Singleplayer Campaign if and only if this is set to an integer other than 0.
unused A value that is unused. Must not contain commas, always set to 0 in the game's (no longer used) data saving routines.
Side Indicates the Side that may use this AI Trigger. 0 stands for "all sides", positive values indicate the owning side - Allied, Soviet, Yuri, ... .
IsBaseDefense If set to a non-zero integer value, this AI Trigger is interpreted as "Base Defense". If so, it is subject to limits set by [General]MinimumAIDefensiveTeams= and [General]MaximumAIDefensiveTeams=.
Team2 The second TeamType that will be created when this AI Trigger meets its condition.
EnabledInE If set to a zero value, this AI Trigger will not be considered by AI houses playing in Easy difficulty.
EnabledInM If set to a zero value, this AI Trigger will not be considered by AI houses playing in Normal difficulty.
EnabledInH If set to a zero value, this AI Trigger will not be considered by AI houses playing in Hard difficulty.

Weights

AI Triggers are given "weights" to define how important they are. Larger weight makes the AI Trigger more likely to get selected.

Each time an AI controlled TeamType is dissolved (when they complete their ScriptType or are destroyed), all AI Triggers using that TeamType as their primary (Team1) get their weight modified:

if the Team has executed a Script Action 49, 0 in this lifetime,
[General]AITriggerSuccessWeightDelta= is added to its weight,
otherwise,
[General]AITriggerFailureWeightDelta= multiplied by [General]AITriggerTrackRecordCoefficient= (the former is usually negative) is added.

Care is taken not to push the weight outside the limits set by MinimumWeight and MaximumWeight while doing so.

A Weight equivalent to 5000.0 stands for "ignore all other AI Triggers and fire this one immediately, if its condition is met". It is originally used for Teams utilising minor SuperWeapons, the Iron Curtain or the ChronoSphere.

Global and Local

Unlike other AI components, AITriggerTypes do care where they were defined - the ones defined in ai(md).ini are enabled by default, whereas ones defined in the map need to be enabled via [AITriggerTypesEnable] to function. However, the [Basic]IgnoreGlobalAITriggers= setting, if enabled, disables all AI Triggers declared in ai(md).ini, overriding the [AITriggerTypesEnable].

Global AITriggerTypes can be redefined in the map.

Pool Teams

"Pool Teams" are special in the sense that they do not use the normal comparator logic, and multiple Pool Teams controlled by the same House cannot be active at one time. If such an AI Trigger is activated, the Teams are simply created if doing so would not violate the Template:TTL or other conditions which limit human object construction, without doing a check with the comparator logic.

Additional information

  • This section is read from ai(md).ini and the current map file.
  • The infamous -G suffix has no meaning whatsoever.
  • Unlike TaskForces, there is no effect to prefixing an AITriggerType's ID with a hexadecimal prefix.