RPGDialog - NPC interaction system
by Nelson A. K. Gonsalves · 11/29/2002 (12:27 pm) · 186 comments
RPGDialog is a Torque Game Engine modification that adds standard RPG Dialogs support, including multiple choice questions and question linking(underlined words on a question that perform actions when clicked on). Also included is an editor for creating and editing dialogs easily.
Instructions on installing are included on the zip file.
New download location since geocities is dead
Have fun using it! :)
And let me know of any problems you might find.
Contact me at dk_uo@yahoo.com or leave a comment here.
Features
- Multiple choice questions, present a question and a list of answers and do something depending on which answer the player picks, the choices are numbered and can be picked either by the mouse or by pressing the 1,2,...,9,0 keys on the keyboard, choices after 10 must be selected via mouse.
- Question Links, Ex: "Hello, I'm Mary, how are you?" clicking on the word Mary would trigger an action as if it was a choice in the Multiple choice window.
- Portraits, pictures that represent the NPC, change it depending on the choices of the player or even use them to show the mood of the NPC.
- Sounds, add voice overs or any sound effects that are triggered when the question is displayed.
- Fully functional in multiplayer games, only allowing one player to talk to each NPC at a time, sending a message telling the others that the NPC is busy if they try to talk to it.
- Moving the player too far away from the NPC closes the Dialog automatically.
- Each option triggers a function, allowing complete customization of the actions caused by the dialog, either by using the included functions, altering them or creating your own.
June 8th 2005.
I finnaly got around to giving this a much deserved update!
Firstly I updated the instructions and made a few changes to make it fully compatible with TGE 1.3.
Also I've added buttons to move the answers up and down in the editor, so its now easier to organize the available options.
And finnaly, multiple actions can now be triggered by one response, thanks goes to BrokeAss Games for the idea. To execute multiple actions just add them one after the other without anything separating them, there is one example of this in the test scripts. Ohh, and now clicking on the actions list will add them to the actions edit and not replace them.
I have one warning though, version 1.0 .dla files are incompatible with version 1.3, there is an easy workaround I've used on my files, just open them directly in a text editor and do a quick replace all from "<" to "<END><", add <END> to the end of each line and remove the <END> from the beginning of the line, that should make them 100% compatible.
Let me know if you find any problems.
-Nelson
Instructions on installing are included on the zip file.
New download location since geocities is dead
Have fun using it! :)
And let me know of any problems you might find.
Contact me at dk_uo@yahoo.com or leave a comment here.
Features
- Multiple choice questions, present a question and a list of answers and do something depending on which answer the player picks, the choices are numbered and can be picked either by the mouse or by pressing the 1,2,...,9,0 keys on the keyboard, choices after 10 must be selected via mouse.
- Question Links, Ex: "Hello, I'm Mary, how are you?" clicking on the word Mary would trigger an action as if it was a choice in the Multiple choice window.
- Portraits, pictures that represent the NPC, change it depending on the choices of the player or even use them to show the mood of the NPC.
- Sounds, add voice overs or any sound effects that are triggered when the question is displayed.
- Fully functional in multiplayer games, only allowing one player to talk to each NPC at a time, sending a message telling the others that the NPC is busy if they try to talk to it.
- Moving the player too far away from the NPC closes the Dialog automatically.
- Each option triggers a function, allowing complete customization of the actions caused by the dialog, either by using the included functions, altering them or creating your own.
June 8th 2005.
I finnaly got around to giving this a much deserved update!
Firstly I updated the instructions and made a few changes to make it fully compatible with TGE 1.3.
Also I've added buttons to move the answers up and down in the editor, so its now easier to organize the available options.
And finnaly, multiple actions can now be triggered by one response, thanks goes to BrokeAss Games for the idea. To execute multiple actions just add them one after the other without anything separating them, there is one example of this in the test scripts. Ohh, and now clicking on the actions list will add them to the actions edit and not replace them.
I have one warning though, version 1.0 .dla files are incompatible with version 1.3, there is an easy workaround I've used on my files, just open them directly in a text editor and do a quick replace all from "<" to "<END><", add <END> to the end of each line and remove the <END> from the beginning of the line, that should make them 100% compatible.
Let me know if you find any problems.
-Nelson
#102
also is there some way to hook a "spawner" into the mission editor so that the npcs are mission specific?
01/14/2006 (7:18 pm)
umm im pretty sure that all the file are in the right place.. but whenever i hit the delete button the darn thing crashes. I can seem to figure this one out.also is there some way to hook a "spawner" into the mission editor so that the npcs are mission specific?
#103
Anyways, theres 2 things I am going to look at 'Not using spawn spheres, but the spawn script' because thats missing I think;
I want the NPC's to have a 'facing' when they spawn in, and I am also interested in giving them default, and aktivation animations....
Maybe like;
Off to research...
01/16/2006 (8:15 am)
Well not sure whats going on there Jonathan -maybe a 'new' implementation is the next thing to do :/Anyways, theres 2 things I am going to look at 'Not using spawn spheres, but the spawn script' because thats missing I think;
I want the NPC's to have a 'facing' when they spawn in, and I am also interested in giving them default, and aktivation animations....
Maybe like;
SpawnNPC("Bili Nadr", "Bili", "Bili.png", 1, "25 11 13", "SpawnFacing", IdleAnim, ActivAnim);Off to research...
#104
The result i got was; 654 50 126.723 1 0 0 0 (for this specific char at its position and the default spawn facing.
Ran to it and talked, and then tried another dump; 654 50 126.723 0 0 1 3.50487
01/16/2006 (8:36 am)
He he, thanks to quick talk in the dev channel [TORK]Beffy suggested I should go into the game, get ID of one of the NPC's and then write (in the console) echo(ID.getTransform()); The result i got was; 654 50 126.723 1 0 0 0 (for this specific char at its position and the default spawn facing.
Ran to it and talked, and then tried another dump; 654 50 126.723 0 0 1 3.50487
SpawnNPC("Bili Nadr", "Bili", "Bili.png", 1, "654 50 126.723 0 0 1 3.50487"); did the trickThanks, and wohoo!
#105
Would just save us newbies the hassle of going through all this and understand hwo this works.
I am also looking for RPG script(ers) to help with my www.cursedempire.com indie game.
Hope some one can help,
Chris
01/18/2006 (8:43 am)
Ok, I am coming into this new and very new to torque, is there a lazy, all in one commented script that someone cares to share covering the functionality above. It would be great to have the script and a short paragraph saying "the aim of this is to....".Would just save us newbies the hassle of going through all this and understand hwo this works.
I am also looking for RPG script(ers) to help with my www.cursedempire.com indie game.
Hope some one can help,
Chris
#106
You must have the Bot spawner object resource installed.
Add this to the end of ~/server/scripts/RPGDialog.cs
Edit an NPC answer and add the Spawn() function to the actions list like: Spawn(4147)
Save the NPC script (in game).
When you talk to the NPC and get that answer the bot spawner object spawns bots.
Use trade/reward system for mission items, etc.
Instant missions, enjoy.
Ari
"Don't drink and serverCmd."
01/30/2006 (3:38 am)
Here's a fun piece of code.You must have the Bot spawner object resource installed.
Add this to the end of ~/server/scripts/RPGDialog.cs
//<ActionList>Spawn(spawner)
function Spawn(%spawner,%client,%sender,%npcFile)
{
Spawn(%spawner);
CloseDialog(%client,%sender,%npcFile);
}Drop a bot spawner object and note the object number in the editor (like 4147).Edit an NPC answer and add the Spawn() function to the actions list like: Spawn(4147)
Save the NPC script (in game).
When you talk to the NPC and get that answer the bot spawner object spawns bots.
Use trade/reward system for mission items, etc.
Instant missions, enjoy.
Ari
"Don't drink and serverCmd."
#107
I've got this working in TSE but still have to back up to talk to the NPC again, even after implementing the code to fix this as shown above. I'm getting some console errors of the following nature, don't know if they are relevant.
(0): Unable to find function CloseQuestion
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
Syntax error in input.
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
Syntax error in input.
So there appears to be a function missing. It's not in the code above, but it's not in the original file either. Any help greatly appreciated.
Dave.
02/03/2006 (9:00 am)
Hello folks, thought I'd just posted here but it's vanished! I've got this working in TSE but still have to back up to talk to the NPC again, even after implementing the code to fix this as shown above. I'm getting some console errors of the following nature, don't know if they are relevant.
(0): Unable to find function CloseQuestion
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
Syntax error in input.
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
getSubStr(...): error, starting position and desired length must be >= 0: (0, -1)
Syntax error in input.
So there appears to be a function missing. It's not in the code above, but it's not in the original file either. Any help greatly appreciated.
Dave.
#108
I am wondering about the difference in what is posted here, and in what BrokeAss is using, his GUI looks different (as someone noted above)
Also, big one! Why does the delete and backspace key not work while editing question text?
02/14/2006 (7:03 am)
Wow, this is one of the most useful resources I have ever seen!I am wondering about the difference in what is posted here, and in what BrokeAss is using, his GUI looks different (as someone noted above)
Also, big one! Why does the delete and backspace key not work while editing question text?
#109
02/14/2006 (10:58 am)
I have another question/comment... has anyone had an issue where the ingame dialog editor loses 3 characters at a time from the end of QuestionText and AnswerText? It looks like the getText function is messing up.
#110
I just have one problem, though; it seems like my game will freeze randomly some times when I use the TalkTo command. Has anyone else had this problem?
02/28/2006 (1:29 pm)
This is such an AWESOME resource. Nelson did an amazing job on it. :DI just have one problem, though; it seems like my game will freeze randomly some times when I use the TalkTo command. Has anyone else had this problem?
#111
Also just for anyone else, if you get the closeQuestion error I described above, change the command to closeDialog and it will work OK.
Now..!! The NPC that I am talking to does not display his name in the dialog question box. It seems to be set in script by the %senderName variable, which relies on %sender being sent to the functions. Does anyone know how/where %sender should be set?
Thanks,
Dave.
03/02/2006 (11:37 am)
Yep, I get the missing text problem as well.Also just for anyone else, if you get the closeQuestion error I described above, change the command to closeDialog and it will work OK.
Now..!! The NPC that I am talking to does not display his name in the dialog question box. It seems to be set in script by the %senderName variable, which relies on %sender being sent to the functions. Does anyone know how/where %sender should be set?
Thanks,
Dave.
#113
03/13/2006 (8:09 pm)
Best Resorce ever!
#114
03/15/2006 (8:00 pm)
The download link itself seems to be broken now.
#115
Has anyone created conditionals for the NPC dialog so that for instance it will change dialog after we have completed a quest.
03/19/2006 (4:51 pm)
Download link is working for me.Has anyone created conditionals for the NPC dialog so that for instance it will change dialog after we have completed a quest.
#116
1)No backspace in some text fields.
2)When you save , the editor strips portions of words from the file (funcitions also()) Leaving you with
""I dot kn why thi is happinin to m" Clo ()"
3) the editor dosn't update when you make changes to a script, you have to goto the next or previous ones and back again to see changes.If you are lucky.
4)each time you hit save, random letters and words are striped from the file..even if you were not working on that question.
5)Editing a answer asked you if you realy want to deleate the answer when you press "OK"
More...
I will post the revlent console logs when i get a chance.
Im loving this script only resorce! I even have fully voiced over Scripts!
And i am getting by by hand editing the DLQ and DLA files.
03/20/2006 (10:45 am)
I intergreated this into 1.4, but the editor is REALY bugy... REALY REALY bugy.1)No backspace in some text fields.
2)When you save , the editor strips portions of words from the file (funcitions also()) Leaving you with
""I dot kn why thi is happinin to m" Clo ()"
3) the editor dosn't update when you make changes to a script, you have to goto the next or previous ones and back again to see changes.If you are lucky.
4)each time you hit save, random letters and words are striped from the file..even if you were not working on that question.
5)Editing a answer asked you if you realy want to deleate the answer when you press "OK"
More...
I will post the revlent console logs when i get a chance.
Im loving this script only resorce! I even have fully voiced over Scripts!
And i am getting by by hand editing the DLQ and DLA files.
#117
03/20/2006 (10:50 am)
Allyn, I posted some info about it stripping the 3 chars off the end. The workaround is to edit the files in a text editor, as you are doing. Once you get the hang of the file layout, it's much easier than using the gui editors.
#118
Found this in another thread by Jase talking about possible bugs in 1.4.. try this....
It would seem that guiMLTextCtrl/guiMLTextEditCtrl is defunct. Backspace/delete doesn't work for removing characters, but backspace will move the cursor position back one space. You can, however, delete the text by selecting the characters you want deleted and hitting backspace or delete, but it leaves behind a single character which is a nuisance to get rid of.
Also, when using .getText() it removes the last three characters; and trying to resize it causes some weird behaviour.
Not sure if any of these problems happen with other GUI controls, haven't gotten around to testing them.
-Jase
[UPDATE]
Okay, I did some quick fixes to get guiMLTextEditCtrl to work pretty much how it should. However, I think there are some underlying issues going on and it should be looked into more fully. I've only recently really started delving into the GUI controls code and seeing how things are put together, so you know your way around better than I do.
Heres the fixes, as follows, for anyone who needs a quick fix for immediate use(such as myself). Look for the arrowed lines :-
guiMLTextEditCtrl.cc
That will fix the backspace/delete issues. And...
- guiMLTextCtrl.cc
That will fix the issue with using a script call to getText().
I've also noticed one other oddity about the control, the left justified text is actually a little bit too left justified, hiding the first character.
I'm sure theres a few other things that can be found that aren't quite right.. but for what I need it for, it works well enough.
Hope it helps.
-Jase
Again.. not my code, but I added this and it seems to do the trick in 1.4 :)
It's also worth doing some other searches on gui text controls, it looks like some bugs got in when converted to unicode and theres some fixes out there for passwords and being a few chars out of place.
What I can say, is after adding all these, this resource works fine for me in 1.4 as delivered and I can easily use the supplied Gui for editing my questions and answers.
Now, what I need is an upgraded resource that allows me to search on my database to see if the question asker has a certain item in their inventory and changes the window size of the response based on the number of answers available, or has the asker already done that quest, but hey each day I am getting closer and some of these I am getting close to:)
Regards
Graham
03/20/2006 (6:42 pm)
Allyn:-Found this in another thread by Jase talking about possible bugs in 1.4.. try this....
It would seem that guiMLTextCtrl/guiMLTextEditCtrl is defunct. Backspace/delete doesn't work for removing characters, but backspace will move the cursor position back one space. You can, however, delete the text by selecting the characters you want deleted and hitting backspace or delete, but it leaves behind a single character which is a nuisance to get rid of.
Also, when using .getText() it removes the last three characters; and trying to resize it causes some weird behaviour.
Not sure if any of these problems happen with other GUI controls, haven't gotten around to testing them.
-Jase
[UPDATE]
Okay, I did some quick fixes to get guiMLTextEditCtrl to work pretty much how it should. However, I think there are some underlying issues going on and it should be looked into more fully. I've only recently really started delving into the GUI controls code and seeing how things are put together, so you know your way around better than I do.
Heres the fixes, as follows, for anyone who needs a quick fix for immediate use(such as myself). Look for the arrowed lines :-
guiMLTextEditCtrl.cc
void GuiMLTextEditCtrl::handleDeleteKeys(const GuiEvent& event)
{
if ( isSelectionActive() )
{
mSelectionActive = false;
deleteChars(mSelectionStart, mSelectionEnd + 1);
mCursorPosition = mSelectionStart;
}
else
{
switch ( event.keyCode )
{
case KEY_BACKSPACE:
if (mCursorPosition != 0)
{
// delete one character left
//deleteChars(mCursorPosition-1, mCursorPosition-1);
deleteChars(mCursorPosition-1, mCursorPosition); // <-----------------------------
setUpdate();
}
break;
case KEY_DELETE:
if (mCursorPosition != mTextBuffer.length())
{
// delete one character right
//deleteChars(mCursorPosition, mCursorPosition);
deleteChars(mCursorPosition, mCursorPosition+1); // <-----------------------------
setUpdate();
}
break;
default:
AssertFatal(false, "Unknown key code received!");
}
}
}That will fix the backspace/delete issues. And...
- guiMLTextCtrl.cc
//--------------------------------------------------------------------------
const char* GuiMLTextCtrl::getTextContent()
{
if ( mTextBuffer.length() > 0 )
{
char* returnString = Con::getReturnBuffer( mTextBuffer.length() + 1 );
//mTextBuffer.get(returnString, mTextBuffer.length() );
mTextBuffer.get(returnString, mTextBuffer.length() +3 ); <---------------------------------
return returnString;
}
return( "" );
}That will fix the issue with using a script call to getText().
I've also noticed one other oddity about the control, the left justified text is actually a little bit too left justified, hiding the first character.
I'm sure theres a few other things that can be found that aren't quite right.. but for what I need it for, it works well enough.
Hope it helps.
-Jase
Again.. not my code, but I added this and it seems to do the trick in 1.4 :)
It's also worth doing some other searches on gui text controls, it looks like some bugs got in when converted to unicode and theres some fixes out there for passwords and being a few chars out of place.
What I can say, is after adding all these, this resource works fine for me in 1.4 as delivered and I can easily use the supplied Gui for editing my questions and answers.
Now, what I need is an upgraded resource that allows me to search on my database to see if the question asker has a certain item in their inventory and changes the window size of the response based on the number of answers available, or has the asker already done that quest, but hey each day I am getting closer and some of these I am getting close to:)
Regards
Graham
#119
I have a few questions about the "Action List". When in the Question Editor, I have three entries in the right hand box that will add actions. one is RPGDialog link, Name and Player Name.
BUT... in the Answers editor, I have a big empty box on the right, with nothing in it... Isnt this supposed to contain all posible actions, so you can quickly click them and edit them???
In RPGDialog.cs it says
// The commented out lines that start with are used when populating the action
// list on the RPGDialog Editor.
but when I uncomment them nothing happens... is anything supposed to...?
BTW I also get a few weird errors with the text... but i thught tat was only a 1.4 issue??/
Thanks
Mark
PS: apart from this I have lots of lovely NPC's with different bodies different names and different conversations... its getting there... (Thanks to Chris and Christian)
All I need now is this reward thing OH! and has anyone thought of this one... for an NPC to choose which question to show, depending on some variable being set previously... like a different NPC's conversation for example?
NPC 1 "go and ask NPC 2 for the password"
NPC 2 "Th password is Fish"
back to NPC1 "Hello again, do you know the password now?"
03/26/2006 (7:10 am)
Im back on this one after a 6 month hiatus... I have a few questions about the "Action List". When in the Question Editor, I have three entries in the right hand box that will add actions. one is RPGDialog link, Name and Player Name.
BUT... in the Answers editor, I have a big empty box on the right, with nothing in it... Isnt this supposed to contain all posible actions, so you can quickly click them and edit them???
In RPGDialog.cs it says
// The commented out lines that start with
// list on the RPGDialog Editor.
but when I uncomment them nothing happens... is anything supposed to...?
BTW I also get a few weird errors with the text... but i thught tat was only a 1.4 issue??/
Thanks
Mark
PS: apart from this I have lots of lovely NPC's with different bodies different names and different conversations... its getting there... (Thanks to Chris and Christian)
All I need now is this reward thing OH! and has anyone thought of this one... for an NPC to choose which question to show, depending on some variable being set previously... like a different NPC's conversation for example?
NPC 1 "go and ask NPC 2 for the password"
NPC 2 "Th password is Fish"
back to NPC1 "Hello again, do you know the password now?"
#120
03/28/2006 (6:27 pm)
Mark - How I would do that is, when you go to NPC2 and ask for the password, create a trigger(Action) that changes the 'Start Question' to "Hello again, do you know the password now?" Hope that makes sense. 
Torque Owner Christian S
Oak-Entertainment
for(%i=1;%i<=$RPGDialog::Answer[$RPGDialog::CurrentQuestion,0];%i++) { (Answer@%i).delete(); (Action@%i).delete(); (editAnswer@%i@Button).delete(); (moveAnswer@%i@UpButton).delete(); (moveAnswer@%i@DownButton).delete(); }Not sure, because im no code shark. But it seems like it do the first one in the planned array but then halts in the coming ones.? Or did you rename the variables to X2 ?
And, are you sure you added all script files to your projects stringing, not just simple folder placement ?