Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

How to use interactive dialogs in level files

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

Example: DialogShowcase.oxw

Create an event & trigger

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

In order to start a dialog 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="triggerName" 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.

Basis Dialog Structure

But when flying through it doesn't do anything yet, so let's add a first dialog. The basic structure looks like this: Name should be the name of the person you want the player to talk to and currentQuestionId will be the starting point of the conversation

<Dialog name="Max" currentQuestionId="start">
    <questions>
        ...
    </questions>
    
    <answers>
        ...
    </answers>

    <events>
        <execute>
            <EventListener event="triggerName"/>
        </execute>
    </events>
</Dialog>

The Questions and Answers part will be explained below. The event part enables the dialog to be executed once the trigger is activated. Multitrigger does not work yet, because the dialog is not reset on leaving.

Adding Text to your Dialog

A dialog without text would be prettey boring so we now will add text for the npc you are talking to and some replies. In the interface a question is always some text the npc says and an answer is one possible option for the player to reply. By linking the answers to a next question you can define how the npc reacts to the player saying someting. For the player you simply give the question all ids of the possible answers he could give. You need to give each question and each answer a unique id but multiple answers can lead to the same question and multiple questions can give the same answer as an option.

Structure of question section:

...
<questions>
    <Question Id= "someQuestion" question= "this is where you add the text you want to let the npc say">
        <answerIds>
            <AnswerId Id= "someAnswerId">
            <AnswerId Id= "maybeSomeOtherOptions">
            <AnswerId Id= "haveAsManyAsYouWant>
            <AnswerId Id= "orNoneThatsOkayToo">
        </answerIds>
    </Question>

    ... list all questions in this area with the template from above
</questions>
...

By giving no answerIds you can end the Dialog with a npc text.

Structure of answer section:

...
<answers>
    <Answer Id= "someAnswerId" nextQuestionId ="someQuestionId" answer= "this is where you add the text you want to give as a possible response" >
        
    ... list all answers in this area with the template from above
</answers>
...

If you want to end the dialog on a player response simply chose a nextQuestionId that does not exist, best would be to always use the same (for example "end") but any string that is not a questionId will do.

For both Question and Answer class it is possible to rearange the arguments but for readability and ease of use i recomend always defining ids befor text.

Example of a simple dialog

This is a simple example how everything together could look like but there are many more possibilities to use this structure. (And probably more creative texts for those too) This can also be found in the DialogShowcase level to test it directly.

<Dialog name="Kurt" currentQuestionId="loop1">
      <questions>
        <Question Id="loop1" question="Wanna be looped?" >
          <answerIds>
            <AnswerId Id="yes"/>
            <AnswerId Id="no"/>
            <AnswerId Id="giveItToMe"/>
          </answerIds>
        </Question>
        <Question Id="lorem" question="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." >
          <answerIds>
            <AnswerId Id="endIt"/>
          </answerIds>
        </Question>
        <Question Id="loop2" question="Wanna be looped again?" >
          <answerIds>
            <AnswerId Id="yes"/>
            <AnswerId Id="no"/>
            <AnswerId Id="end"/>
          </answerIds>
        </Question>
        <Question  Id="ok" question="Guess not then"/>
      </questions>
      <answers>
        <Answer Id="giveItToMe" answer="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." nextQuestionId="lorem"/>
        <Answer Id="yes" answer="yeah loop me" nextQuestionId="loop2"/>
        <Answer Id="no" answer="i'd rather not" nextQuestionId="ok"/>
        <Answer Id="endIt" answer="i will go now..." nextQuestionId="end"/>
      </answers>
      <events>
        <execute>
          <EventListener event="test"/>
        </execute>
      </events>
    </Dialog>

Now you know all the basics and can try it for your self, go have fun with it!

Last modified 7 years ago Last modified on Dec 14, 2017, 9:33:14 AM