Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 3 (modified by rrogge, 7 years ago) (diff)

How to use interactive dialogues in level files

This tutorial will show you how to implement dialogue boxes in a level file.

Example: DialogueShowcase.oxw

Create an event & trigger

First open the xml file of the level you want your dialogue to appear in.

In order to start a dialogue you will need an event which is triggered. You can for example create a distance trigger (plus a light so that you see where it actually is) that you fly through like this:

<DistanceTrigger name="test" position="100,0,100" target="Pawn" distance=25 stayActive="true" />
    <Backlight position="100,0,100" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,1"/>

You should now see a violet light appearing in the game when loading empty level.

Add your first Question

But when flying through it doesn't do anything yet, so let's add a first dialogue. The basic structure looks like this:

<NextQuestion  question="Your question" a1="First answer" a2="Second answer" >
    <events>
        <execute>
           <EventListener event="test" />
        </execute>
    </events>
</NextQuestion>

The middle part makes sure that your dialogue appears when your event is triggered. When you fly through the light now, the dialogue box should open.

Create a proper dialogue

For each answer you may define a next question as a followup. For example:

<NextQuestion  question="Your question" a1="First answer" a2="Second answer" >
      <possibleQuestions>
          <NextQuestion  question="Your next question if a1 was chosen" a1="First answer" a2="Second answer" />
          <NextQuestion  question="Your next question if a2 was chosen." a1="First answer" a2="Second answer" />
        </possibleQuestions>
    <events>
        <execute>
           <EventListener event="test" />
        </execute>
    </events>
</NextQuestion>

Basically each question can have a vector (possibleQuestions) of following questions. If you define this vector make sure it has two elements (meaning two NextQestions). Now you can try out more nested strutures, have a look at the example level DialogueShowcase.oxw if you're lost. Enjoy!