Jump to content

  • Log In with Google      Sign In   
  • Create Account


NPC dialogues : file or script?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 AndreaTux   Members   -  Reputation: 182

Like
0Likes
Like

Posted 06 August 2012 - 10:29 AM

I'm developing an action rpg with some friends. I would like to know the differences and pros/cons of making NPC's dialogue using a file in xml format instead of using a script. I see that script method is often used by game developers for NPC's text, but is it better then a xml file? We've thought that a xml file with tags like [text1] [text2] etc is perfect for NPC's text and also for possible quests to give the player. So what are the differences between this two methods? Is a script suitable for this aim? Thanks
AndreaTux~

Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 14273

Like
1Likes
Like

Posted 06 August 2012 - 10:31 AM

What do you define as a "script" in this case? I don't really see any difference between what you're calling a script and an XML description of a conversation tree, except possibly formatting and markup. Use whatever you prefer.

#3 french_hustler   Members   -  Reputation: 341

Like
1Likes
Like

Posted 06 August 2012 - 11:14 AM

Depends. If the dialogue is determined upon some previous logic or if the dialogue results in some arbitrary logic, then you would probably need to call some code within your project. Thus a script would probably be better.
On the other hand, if the dialogue is premeditated and always the same depending on some set actions, then a static file would be better.

But as ApochPiQ mentioned, the way you mention "script" is a bit different than what I'm thinking of. When I think of scripting, I think of LUA being integrated with a C++ project for example. A script would of course work, but in your case, I believe a standard XML file will suffice.

Edited by french_hustler, 06 August 2012 - 11:16 AM.


#4 AndreaTux   Members   -  Reputation: 182

Like
0Likes
Like

Posted 06 August 2012 - 01:26 PM

Yes, i mean Lua scripting for example (integrating with java/c++). The dialogue is always the same, the only "logic" operation is for the quests that NPC could give to the player: npc have to know all the completed quests for choosing which quest he can offer to the player!

Edited by AndreaTux, 06 August 2012 - 01:40 PM.

AndreaTux~

#5 french_hustler   Members   -  Reputation: 341

Like
1Likes
Like

Posted 06 August 2012 - 02:33 PM

Yes, i mean Lua scripting for example (integrating with java/c++). The dialogue is always the same, the only "logic" operation is for the quests that NPC could give to the player: npc have to know all the completed quests for choosing which quest he can offer to the player!


It could still be done without a script but it will greatly diminish flexibility. It'll also make it much harder to expand of tweak in the future. But if the behavior is set (which it looks like it is at the moment), I would do it the easy way first, and that would be with a static file, handling the set logic in code.

#6 AndreaTux   Members   -  Reputation: 182

Like
0Likes
Like

Posted 06 August 2012 - 02:40 PM

Undestood. Do you know short examples which shows the difference between these two ways?
AndreaTux~

#7 ApochPiQ   Moderators   -  Reputation: 14273

Like
0Likes
Like

Posted 06 August 2012 - 02:57 PM

What kind of differences are you interested in? I don't understand what you're looking for, honestly.

#8 AndreaTux   Members   -  Reputation: 182

Like
0Likes
Like

Posted 06 August 2012 - 03:05 PM

I would like to see an example in which writing a script is required (in lua for example), because I didn't found anything on the web..Most of examples I've read are writable in a simple XML format file! So when is suggested using scripting language? Ok, when the behaviour isn't static like NPC dialogue, but I can't figure that kind of situation!
AndreaTux~

#9 laztrezort   Members   -  Reputation: 954

Like
1Likes
Like

Posted 06 August 2012 - 03:25 PM

I would like to see an example in which writing a script is required (in lua for example), because I didn't found anything on the web..Most of examples I've read are writable in a simple XML format file! So when is suggested using scripting language? Ok, when the behaviour isn't static like NPC dialogue, but I can't figure that kind of situation!


You could store flags and/or condition keys with the XML file, so that certain dialog node is only produced if the attached flag/condition is true. You can also store "magic" attributes to do hardcoded actions, such as "Open Store" or "Give Key to Dungeon". You can insert special embedded strings into the dialog to control things such as "Pause Here" or "Ask for yes/no".

At some point, however, you will realize that you are basically re-inventing a scripting language, as the list of attributes and magic keys and embedded codes grows. Animations, taking player items, healing the player, etc. You may find that your design has become brittle, in that you now have to go back to the source code to change & add dialog logic, do a full re-compile etc to test.

At his point, it may be worth looking into leveraging full scripting, where all of the dialog logic is isolated into seperate scripts. These scripts can be modified (sometimes during runtime!) during testing & debugging without having to change the main source code.

The tradeoff is the complexity of adding the scripting support, which isn't exactly trivial.

If you haven't already, plan out exactly what the extant of and logic of your dialog will be. From your OP, if that is the extent of your dialog system, then it looks like you can just implement [Condition Flag][Dialog Node] nodes in a data file and call it day.

#10 Firestryke31   Members   -  Reputation: 350

Like
0Likes
Like

Posted 06 August 2012 - 07:23 PM

What about a little of both? XML stores the actual strings and gives them names (i.e. <string id="hello">Hello, <var ref="playerName" />!</string>) and a scripting language allows you to conditionally display the strings by ID and change player state based on the selected responses and other conditions.

#11 AndreaTux   Members   -  Reputation: 182

Like
0Likes
Like

Posted 07 August 2012 - 01:52 AM


I would like to see an example in which writing a script is required (in lua for example), because I didn't found anything on the web..Most of examples I've read are writable in a simple XML format file! So when is suggested using scripting language? Ok, when the behaviour isn't static like NPC dialogue, but I can't figure that kind of situation!


You could store flags and/or condition keys with the XML file, so that certain dialog node is only produced if the attached flag/condition is true. You can also store "magic" attributes to do hardcoded actions, such as "Open Store" or "Give Key to Dungeon". You can insert special embedded strings into the dialog to control things such as "Pause Here" or "Ask for yes/no".

At some point, however, you will realize that you are basically re-inventing a scripting language, as the list of attributes and magic keys and embedded codes grows. Animations, taking player items, healing the player, etc. You may find that your design has become brittle, in that you now have to go back to the source code to change & add dialog logic, do a full re-compile etc to test.

At his point, it may be worth looking into leveraging full scripting, where all of the dialog logic is isolated into seperate scripts. These scripts can be modified (sometimes during runtime!) during testing & debugging without having to change the main source code.

The tradeoff is the complexity of adding the scripting support, which isn't exactly trivial.

If you haven't already, plan out exactly what the extant of and logic of your dialog will be. From your OP, if that is the extent of your dialog system, then it looks like you can just implement [Condition Flag][Dialog Node] nodes in a data file and call it day.


Thank you, now it's clear!
@Firestryke31 it seems interesting, but I think doing controls and logic operations in java with an XML class handler is quick and easier!
AndreaTux~




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS