Script Triggers

Introduction
Scripts are one of the key concepts in the IE. Scripts are written in a simple scripting language and stored as BAF files. BAF files are compiled into BCS files, which are then processed by the game. Scripts consist of triggers and actions. Triggers are conditional checks, that will return either true or false. A trigger result can be inverted by preprending the trigger with the ! character (e.g. See([Anyone]) will return true if the active creature can see any other creature, while !See([Anyone]) will return true if the active creature can not see any other creature). Scripts are processed from the top of the file downwards, until a block is found where all the triggers return true. Once such a block is found, the associated actions are executed, and the script is processed again, from the top of the file. If no block is found with all its triggers returning true, the script is processed again, from the top of the file.

Script Locations
Scripts can run in various places. Some triggers and actions only make sense when run from specific objects (e.g. IsOverMe) while others are only parsed by the engine from certain objects (e.g. LockScroll()). A partial list of script locations is given below:
Parameters
Both triggers and actions may take parameters. Parameters are usually numeric, literal strings (i.e. enclosed in "quotes") or identifier strings. Parameters are a often values from an IDS file, i.e. a symbolic identifier is used which is converted to a numeric value when the script is compiled. An object parameter is a special case — it can be either a literal string (a death variable, such as "Gnoll3"), a object reference (e.g. Player1) or an object identifier. An object identifier can apply to a whole group/category of creatures. The format is [EA.FACTION.TEAM.GENERAL.RACE.CLASS.SPECIFIC.GENDER.ALIGN], though some engines do not accept the faction and team specifiers. Each field within the identifier is from the associated IDS file. An entry of 0 in a field will match any value. For example: [ENEMY.0.0.MAGE] specifies all creatures that are enemies of the party, any general category, any race, mages. An object identifier only evaluates visible creatures.

Note: Triggers with values below 0x4000 use an alternate event-driven system, which is buggy even for IE standards. A negated event trigger returns true if there are pending events that have yet to be processed, and if any of these pending events fails to satisfy the unnegated trigger.

You can see this effect by putting !OnCreation() on a creature. The block will fire every time the creature receives an event other than the one that is defined, such as taking damage — so not every time the triggers are checked after load as would be natural to expect.

Triggers
BG1 Triggers
BG2 Triggers
BG(2)EE Triggers
IWD1 Triggers
IWD2 Triggers
PST Triggers
PSTEE Triggers