[gameprogrammer] Re: designing an RPG dialog system

I second what Bob says, those are both really good solutions.

Somewhat related, i have a map editor for my game and when you save, it just
spits out the lua commands to load and orient each model, set up the
lighting etc.

So the map file format is all lua but there's a graphical editor for
artists.

to load a map, it just runs the lua script! (:

it works nicely and scripters can hand tune specific values if they want to.
On Thu, Jun 18, 2009 at 10:51 AM, Bob Pendleton <bob@xxxxxxxxxxxxx> wrote:

> What you have is a tree off intro texts, questions/responses, and finally
> continuations. You have it coded up as lua which is actually quite nice, but
> requires some fairly nasty detail work to modify.
>
> What I would suggest is that you pick a format that is much easier to
> modify, and write a little bit of code to read the nice format and write the
> lua code. That is not as hard as you might think it is. For the input format
> I would use the save format from your favorite spreadsheet program. Output
> it as CSV or use any separator that works for you. The intro text is in
> column A, the actions types and question/termination, is a value stored in
> column B, the text for each action is stored in column C. If their are
> branches below the first level branches their actions start in column C, and
> so on... You can build a dialog that is as complex as you want, in the
> spreadsheet, output it in CSV (or whatever separator you like), read it in
> and the depth of each branch is indicated by the number of empty cells in
> the output format.
>
> The amount of effort that a system like this will save you is huge. You can
> use all the power of the spreadsheet to reorganize your dialogs, add new
> lines, add new actions, and then just output them, run them through your
> converter, and you have the dialog in lua in a form that you can directly
> use in your program.
>
> A nice thing about doing it this way is that if you decide to switch to any
> other programming language you can do it just by rewriting the converter and
> reprocessing all the dialogs. And, you can turn the job of writing and
> editing dialogs to someone who has no clue what lua is or how the dialogs
> are used. They only need to be able to enter text in a spreadsheet and move
> lines and columns around.
>
> Oh, yeah, if you don't have a spreadsheet you can download OpenOffice.org
> for free. It has a very nice spreadsheet that will handle this job just
> fine. It is amazing the number of game programming tasks that can be handled
> by a spreadsheet plus a little reformating code.
>
> If you don't like the idea of generating code from the dialogs, you can
> just read them into your program, store them in a nice tree structure, and
> interpret them at run time. Both ways work just fine.
>
> Bob Pendleton
>
>  On Thu, Jun 18, 2009 at 9:51 AM, Roger Durañona Vargas 
> <luo_hei@xxxxxxxx>wrote:
>
>> My pet project is an RPG, and I have advanced a little implementing a
>> dialog system. The problem is that it is script based, using Lua, and
>> each dialog needs to be manually edited. This is how the script looks
>> (excuse me the long post, but this is the shortest dialog I have that
>> illustrates at the same time the features i want):
>>
>> -- @param q Npc line number
>> -- @param player Player entity
>> -- @param npc NPC entity
>>
>> EM = EntityManager.EntityManager_getEntityManager()
>> ent = EM:getEntity(player)
>> npce = EM:getEntity(npc)
>> -- get the game GUI
>> gui = GuiSystem.GuiSystem_getGuiSystem()
>> dm = DialogManager.DialogManager_getDialogManager()
>> dm:reset();
>>
>> if (q=="root") then
>>    dm:setNPCLine("Bubbles, the official Calesoni alchemist at your
>> service.")
>>    dm:addPlayerChoice("What do you do Bubbles?","question")
>>    dm:addPlayerChoice("Sorry, was just wandering around","end")
>>    elseif (q=="question") then
>>        dm:setNPCLine("I mix health and mana potions for the army. But
>> mostly I distill the All-purpose potion.")
>>        dm:addPlayerChoice("All-purpose potion? And what is
>> that?","question1")
>>        dm:addPlayerChoice("Ah, ok. Ill see you later.","end")
>>    elseif (q=="question1") then
>>        dm:setNPCLine("Alcohol, of course. It works as courage potion,
>> for pain relieving and also to forget things.")
>>        dm:addPlayerChoice("I see. Can you teach me to distill alcohol
>> and potions?","ask")
>>        dm:addPlayerChoice("Ill see you later.","end")
>>    elseif (q=="ask") then
>>        if (ent.stats[GameEntity.stINT]>12) then
>>            dm:setNPCLine("You seem to be smart. Look here, Im
>> distilling some bottles, see?...")
>>            dm:addPlayerChoice("Yes, I follow you...","learn")
>>            else
>>            dm:setNPCLine("Sorry kid, you must finish the secondary
>> school first.")
>>            dm:addPlayerChoice("Ok.","end")
>>            end --if int
>>    elseif (q=="learn") then
>>        dm:setNPCLine("And thats the basic. Did you got it?")
>>        dm:addPlayerChoice("Oh yes, thank you bubbles.","end")
>>        ent.skills:addSkill("Alch")
>>        gui:addMessage("You have learned Alchemy. You can improve it by
>> practicing.")
>>    elseif (q=="end") then
>>    end
>>
>> I would like to hear suggestions and ideas to make it better, and
>> perhaps some method that ease the task of editing them.
>> Thanks in advance
>>
>> --
>> Roger D. Vargas
>> Gentoo Linux 2008.0
>> http://gpnfn.blogspot.com, The news for game programming newbies
>>
>>
>>
>> ______________________________________________
>> LLama Gratis a cualquier PC del Mundo.
>> Llamadas a fijos y móviles desde 1 céntimo por minuto.
>> http://es.voice.yahoo.com
>>
>>
>> ---------------------
>> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>>
>>
>>
>
>
> --
> +-----------------------------------------------------------
> + Bob Pendleton: writer and programmer
> + email: Bob@xxxxxxxxxxxxx
> + web: www.TheGrumpyProgrammer.com <http://www.thegrumpyprogrammer.com/>
>
>

Other related posts: