[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.8.4 Action Section

This section describes the action section.

Sequences and Triggers

With the sequences and triggers section you can define actions and interactions on objects in your map file. These sections are used to drive the engine sequence manager (internal note: add link when documentation on that plugin is available).

A sequence represents a small script with commands that operate on objects in the world. A trigger represents a series of conditions which will cause the sequence to be executed. The important thing of the sequence manager is that it is very time based. Operations don't all execute at once but at specific times relative to the start of the sequence. Note that all times in the sequence manager are specified in milli-seconds.

The easiest way to explain what you can do with the engine sequence manager is with a few examples:

 
<sequences>
    <sequence name="animlight">
        <fadelight light="l1" red="0" green="0" blue="0"
            duration="1000" />
        <delay time="1000" />
        <fadelight light="l1" red="1" green="1" blue="1"
            duration="1000" />
        <delay time="1000" />
        <fadelight light="l1" red="1" green="0" blue="0"
            duration="1000" />
        <delay time="1000" />
        <fadelight light="l1" red="0" green="1" blue="0"
            duration="1000" />
        <delay time="1000" />
        <fadelight light="l1" red="0" green="0" blue="1"
            duration="1000" />
        <delay time="1000" />
        <enable trigger="animlight" />
    </sequence>
</sequences>
<triggers>
    <trigger name="animlight">
        <sectorvis sector="large" />
        <fire sequence="animlight" />
    </trigger>
</triggers>

In this example there is a trigger called `animlight' that fires as soon as the sector named `large' is visible. Here is what happens as soon as the condition of the trigger (in this case `sectorvis') is true:

  1. First the firing of the trigger will cause the trigger itself to be disabled. This is to avoid the trigger firing again next frame.
  2. Then the `animlight' sequence will be executed. What this basically means is that all operations of that sequence are scheduled in the engine sequence manager at the appropriate times relative to the current time. The `delay' operation in the sequence is responsible for tagging every operation with the specified time. So in this particular example six operations will be scheduled: five `fadelight' operations (of which one is scheduled to execute immediatelly) and one `enable' operation.
  3. The first operation that is executed is `fadelight'. This operation will fade the light color of the light named `l1' from whatever color it has now to black. `l1' must be a pseudo-dynamic light for this to work.
  4. One second later (due to the `delay') the second `fadelight' gets executed. And so on.
  5. Finally the `enable' operation will execute which means that the `animlight' trigger is enabled again. If the `large' sector is still visible this will cause the trigger to fire immediatelly again.

It is important to note that the `duration' parameter that is given in some of the operations does NOT imply that the next operation will execute after that operation has finished. The `duration' parameter has no effect on the internal relative time that is maintained for the sequence operations. To influence that you must use `delay'.

If you want to use the same sequence for different lights you can use parameters like in the following example:

 
<sequences>
    <sequence name="animlight">
        <args>
            <arg name="l" />
            <arg name="trig" />
        </args>
        <fadelight light_par="l" red="0" green="0" blue="0"
	    duration="1000" />
        <delay time="1000" />
        <fadelight light_par="l" red="1" green="1" blue="1"
	    duration="1000" />
        <delay time="1000" />
        <fadelight light_par="l" red="1" green="0" blue="0"
	    duration="1000" />
        <delay time="1000" />
        <fadelight light_par="l" red="0" green="1" blue="0"
	    duration="1000" />
        <delay time="1000" />
        <fadelight light_par="l" red="0" green="0" blue="1"
	    duration="1000" />
        <delay time="1000" />
        <enable trigger_par="trig" />
    </sequence>
</sequences>
<triggers>
    <trigger name="animlight_l1">
        <sectorvis sector="large" />
        <fire sequence="animlight">
            <light name="l" light="l1" />
            <light name="trig" light="animlight_l1" />
        </fire>
    </trigger>
    <trigger name="animlight_l2">
        <sectorvis sector="large" />
        <fire sequence="animlight">
            <light name="l" light="l2" />
            <light name="trig" light="animlight_l2" />
        </fire>
    </trigger>
</triggers>

Here you see how the same sequence (`animlight') is used by two different triggers for two different lights. It is not only the light that has to be given as a parameter but also the trigger that needs to be enabled again. That's why two parameters are used.

A lot more is possible here. I will give a short summary of all commands (that are not operations) that are supported in sequences here:

Here is a list of all operations that you can use in a sequence. Note that every operation is tagged with a relative time (relative to the start of the sequence). If you want to use a parameter for an operation that uses an argument to the sequence then you have to add `_par' to the parameter name like this: `light_par'.

Here is a list of all conditions that are supported in a trigger:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html