Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
---
title: "Script Triggers"
---
<div class="title_main"> Script Triggers </div>
<br />
<div class="actionHeader">Introduction</div>
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.<br />
<br />
<div class="actionHeader">Script Locations</div>
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:<br />
<ul>
<li>Creatures</li>
<li>Regions</li>
<li>Containers</li>
<li>Areas</li>
<li>Player AI scripts</li>
<li>baldur.bcs</li>
</ul>
<div class="actionHeader">Parameters</div>
Both triggers and actions may take parameters. Parameters are usually numeric, literal strings (i.e. enclosed in &quot;quotes&quot;) or identifier strings. Parameters are a often values from an <code><a href="../../files/ids/index.htm">IDS</a></code> 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 &mdash; it can be either a literal string (a <code><a href="../../file_formats/ie_formats/cre_v1.htm#CREV1_0_Header_0x280">death variable</a></code>, such as <code>"Gnoll3"</code>), a object reference (e.g. <code><a href="../../files/ids/bgee/object.htm#Player1">Player1</a></code>) or an object identifier. An object identifier can apply to a whole group/category of creatures. The format is <code>[<a href="../../files/ids/bgee/ea.htm">EA</a>.<a href="../../files/ids/pst/faction.htm">FACTION</a>.<a href="../../files/ids/pst/team.htm">TEAM</a>.<a href="../../files/ids/bgee/general.htm">GENERAL</a>.<a href="../../files/ids/bgee/race.htm">RACE</a>.<a href="../../files/ids/bgee/class.htm">CLASS</a>.<a href="../../files/ids/bgee/specific.htm">SPECIFIC</a>.<a href="../../files/ids/bgee/gender.htm">GENDER</a>.<a href="../../files/ids/bgee/align.htm">ALIGN</a>]</code>, though some engines do not accept the faction and team specifiers. Each field within the identifier is from the associated <code><a href="../../files/ids/index.htm">IDS</a></code> file. An entry of <code>0</code> in a field will match any value. For example: <code>[<a href="../../files/ids/bgee/ea.htm#255">ENEMY</a>.0.0.<a href="../../files/ids/bgee/class.htm#1">MAGE</a>]</code> specifies all creatures that are enemies of the party, any general category, any race, mages. An object identifier only evaluates visible creatures.<br />
<br />
{% capture note %}
Triggers with values below <code>0x4000</code> 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.
<br /><br />
You can see this effect by putting <code><a href="../triggers/bgeetriggers.htm#0x0036">!OnCreation()</a></code> 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 &mdash; so not every time the triggers are checked after load as would be
natural to expect.
{% endcapture %}
{% include note.html %}
<br />
<div class="actionHeader">Triggers</div>
<a href="bg1triggers.htm"> BG1 Triggers</a><br />
<a href="bg2triggers.htm"> BG2 Triggers</a><br />
<a href="bgeetriggers.htm"> BG(2)EE Triggers</a><br />
<a href="totltriggers.htm"> IWD1 Triggers</a><br />
<a href="iwd2triggers.htm"> IWD2 Triggers</a><br />
<a href="psttriggers.htm"> PST Triggers</a><br />
<a href="psteetriggers.htm"> PSTEE Triggers</a><br />
<br />
</div>
</div>