Game Development Community

Implementing NPC dialogue

by Teddy Setiawan Wijaya · in Torque Game Builder · 07/09/2008 (2:45 am) · 12 replies

Hi, forgive me for the newbie question

in an old DOS game called Veil of Darkness (see here), everytime a dialogue is initiated:

1. A dialogue box will pop up (as if) from the character who initiate the dialogue (either player or NPC)
2. Some words in the stated dialogue are underlined (keywords) and clickable, leading to another conversation topic

Any pointers on how to implement those using TGB ?

Thousand thanks,

#1
07/09/2008 (6:31 am)
Have you look at the dialog resource for sale (Yack Pack)? I don't know if it's for TGB (never used it myself), but you might be able to port it. HTH.
#2
07/09/2008 (7:22 pm)
Hi Ted, thanks for the reply

Yack Pack seems really nice, I'll try it but I'd like to try something else first. I'll post what I've found later..

Oh, btw, Gamasutra has a nice article about dialogue system ...;-)

Cheers,
#3
07/09/2008 (7:40 pm)
No doubt there is a more elegant way to do this but you could always place a trigger over the word you want to be clickable and use the onMouseDown callback.
#4
07/11/2008 (3:58 pm)
I use textObjects and their mouse events for this. Took a few weeks to write. If I had to code it all again I'd probably just use the built in GUI system.
#5
07/11/2008 (10:47 pm)
Darkfire, Joe, how would you know where to place the trigger? Location of the dialogue frame is fixed, but the keyword (underlined word) location can be anywhere ... ;-(

Look at the example screen of Veil of Darkness (VOD) below
i34.tinypic.com/2r38jsj.jpg
#6
07/12/2008 (5:40 pm)
Currently, by using t2dStaticSprite as the dialogue frame I can get the pop-out effect (no. 1 above).

It is achievable by using the schedule method to resize and reposition the dialogue frame, starting from "0 0" and the character's position, gradually changed until we get the target size and target position.

I use t2dTextObject for the dialogue text but t2dTextObject doesn't seem to offer support for underlined or clickable word (no. 2 above) ....;-(
#7
07/12/2008 (5:45 pm)
Anyone give any thoughts towards changing the GUI for that sort of thing to both have the same functionality without having to click on hyperlinked words? I mean, there's more than one way to skin a cat, and you can probably pop out a list of questions to ask below the dialog that serve the same functionality as clicking on the underlined word, and make it seem to the user that they are actually asking questions to the NPC.

Just my 2 cents (God only knows what that's worth in Euro, lol).
#8
07/12/2008 (7:16 pm)
Well you could always add the functionality you need to t2dTextObject. Eg. something like this...

// Set the third word in the text object to be underlined and clickable
t2dTextObject::setHyperlinkWord( 3 );

// A callback that occurs when a hyperlinked word is clicked
function t2dTextObject::onHyperlinkClicked( %this, %wordCount, %wordString )
{}

This would require modifying the t2dTextObject render to draw the underline under hyperlinked words and modification of the on-mouse-click to test if the clicked position is over a hyperlinked word. This would most likely require a close look at how t2dTextObject actually renders the text -- so you can reverse engineer (so to speak) the word at a particular position.

I don't know a ton about the Torque-text rendering process but I am pretty sure the information you need is not exposed to script, so, thats why I reccomend doing this as a C++ modification to t2dTextObject.
#9
07/12/2008 (7:29 pm)
Instead of clickable words I chose to do clickable sentances. You could maybe try using different colored textobjects instead of underlining them. It may be possible to add a behavior to them that creates an underline. They are sceneobjects just like sprites remember ;) You have several options available.
#10
07/12/2008 (10:09 pm)
Ted,

Actually the necessity of having hyperlinked words is purely from 'game design' standpoint..;-). Having the hyperlinked words will make it easier for player to notice certain topics that he can ask to the NPC.

In Veil of Darkness (VOD), you don't have to click any of the 'hyperlinked' word. You can click elsewhere to 'close' the NPC dialog box. After that a list of keyword (that were previously highlighted) will be shown. Player can click any of the keywords listed or type his/her own word (to make the game more interesting and give it some puzzle elements which are solvable if player pays more attention to the story and dialogue stated by the NPCs).

Well.. being a newbie designer, personally I think this mechanism is quite interesting

Joe,

Clickable sentences would be similar to branching dialogue like the one implemented by most modern RPG games (Baldurs Gate II, Planescape Torment, etc). Currently, I am more interested in implementing VOD dialogue systems. Like you said, I can also probably breakdown the statement into multiple textobjects (and adding the underline) but it seems to be too much work ..;-(

I read the following documentation about GuiMLTextCtrl which seems to be interesting. I'll try to explore it further.

James,

sadly, I don't have TGB source and currently have no intention to delve into C++ modification..;-)

Cheers,

P.S: Another interesting topic about Dialogue Systems at Iron Tower Studios
#11
07/14/2008 (1:17 am)
WOO HOO!!!

GuiMLTextCtrl does deliver the magic!

Using it, we can indeed specify hyperlinks and handle those words (if clicked) using onURL method.
It's not perfect (I can not get the hyperlinks underlined like VOD) but it's OK (I can specify different color for the hyperlinks).

My only minor complaint would be if only we can change the mouse cursor only when it hovers above the hyperlinks (like how our Internet browser handle hyperlinks). Oh, well...

So.. in the end, I use t2dStaticSprite for the dialogue frame (to handle the 'pop-out' effect) and GuiMLTextCtrl for the dialogue text (to handle the hyperlinks)
#12
07/14/2008 (10:24 am)
Wow thats pretty sweet to know.