User Tools

Site Tools


Sidebar

hpl3:game:dialoghandler

Dialog Handler

Overview

The dialog handler is a used to create dialog that support basic branching behavior. If you want to do straight forward dialogs that have no branching at all, you might as well just call the Voice Handler directly. But if there are some branching, even simple like breaking the dialog if the player stop looking at a character, then the Voice Handler is what you want.

Basic functioning

The dialog is setup just before it is a about to get played, so there is not special init (other than what you do for the voice handler). You begin by calling Dialog_Begin() which makes the initial preparations and allows you to call the other functions. After that it is time to add a branch using Dialog_AddBranch. You can then use Dialog_AddSubject to add voice subjects to that branch. Once you add a new branch, then those subjects will belong to the newly added branch. When all branches and subjects are added, call Dialog_End to run the dialog. Dialog_End will also check which characters are used in this dialog, and by using Dialog_CharacterIsActive you can check which are currently in the middle of a dialog.

Example:

Dialog_Begin();
	Dialog_AddBranch("A");
		Dialog_AddSubject("AdamEnter1");
		Dialog_AddSubject("AdamEnter2");
	Dialog_AddBranch("B");
		Dialog_AddSubject("AdamLeave");
Dialog_End();

This will create two branches, “A” and “B”. The first contains “AdamEnter1” and “AdamEnter2”, and the other “AdamnLeave”. When Dialog_End() is called, “A” will begin playing, starting with “AdamEnter1” as it was the first added. If you want to start with some other branch, just supply its name as a parameter for Dialog_End(), like this:

Dialog_End("B")

This would start with branch “B” instead.

Also of interest is that you can make one branch go directly to another by supplying the next dialog as a second parameter, like this:

Dialog_AddBranch("A", "B")

Now when “A” is done, “B” is started. This might seem a bit pointless at first, but is really useful when you add branching events (more on that soon).

Branch Events

hpl3/game/dialoghandler.1348756648.txt.gz · Last modified: 2012/09/27 14:37 by thomas