Mythruna
March 28, 2024, 12:51:17 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new forums. See "Announcements" for a note for new users.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Scripted Dialogs  (Read 13575 times)
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« on: October 14, 2011, 09:59:13 PM »

While actual conversations with NPCs will generally take a different form in the full game, there is still something about an old school scripted dialog system that gives me warm and fuzzy feelings.

My experiences on Neverwinter Nights modding showed me that this sort of system could be used for a variety of scripted user interfaces by modders, etc. and it's a pretty good way to present interactive information.  Any add on quests that the custom content community will end up putting together will surely have one or two of these... either to propel the story through an NPC dialog in a proper way or to represent a book of information, etc..

So, Mythruna just got one... and it's pretty powerful because it's pretty much entirely based on the embedded scripting engine.

As a test, I've used it to make an in-game help system.  You can see it in action in the screen shot below:



And for the curious, here is the dialog script that makes that happen:
Code:
defOption( id:"place", text:"What is this place?" ) {
   
    showPrompt( """\
                This is the public server setup to help test the networking
                support of the Mythruna test builds.  This server is run
                by the creator of the game and it is common to meet him here.
                """
                ) {
        option( "build" )
        option( "objects" )
        option( "blueprints" )
        option( "map" )
        option( text:"Done" );               
    }
}

defOption( id:"build", text:"How do I build?" ) {

    showPrompt( """\
                When a block material is shown in the bottom of the
                screen, the right mouse button will place that block
                type and the left mouse button will remove any type
                of block.
                """
                ) {
        option( "build2" )
        option( text:"Done" );               
    }
}

defOption( id:"build2", text:"How do I change block type?" ) {

    showPrompt( """\
                The mouse wheel will scroll through the major block
                groups and other tools.  The ctrl key + mouse wheel
                will change the sub-type or shape of a material. 
                """
                ) {
        option( "place" )
        option( "objects" )
        option( "blueprints" )
        option( "map" )
        option( text:"Done" );               
    }
}

defOption( id:"objects", text:"How do I place objects?" ) {

    showPrompt( """\
                Use the mouse wheel to find the 'Objects' tool.
                Ctrl + mouse wheel changes object to be placed.
                Right mouse button places or opens the menu of
                an existing object.  Left mouse button drags.
                """
                ) {
        option( "place" )
        option( "build" )
        option( "blueprints" )
        option( "map" )
        option( text:"Done" );               
    }
}

defOption( id:"blueprints", text:"How do I make my own objects?" ) {

    showPrompt( """\
                The in game object builder can be accessed using one of the
                following methods:<br>
                - press TAB and click 'Blueprints'<br>
                - press 'b'
                """
                ) {
        option( "blueprints2" )
        option( text:"Done" );               
    }
}

defOption( id:"blueprints2", text:"How does the blueprint editor work?" ) {

    showPrompt( """\
                The controls work similar to in game. Use the move keys to
                rotate the platform.  Mouse wheel, ctrl + mouse wheel, left
                click, and right click all work the same as in game.
                Select an existing object to edit or click 'New' to start a
                new one.<br>
                After editing, click 'Save' to save your work and have it
                available to be placed in game.
                """
                ) {
        option( "place" )
        option( "build" )
        option( "objects" )
        option( "map" )
        option( text:"Done" );               
    }
}

defOption( id:"map", text:"How do I see the map?" ) {

    showPrompt( """\
                The in game overland map can be accessed using one of the
                following methods:<br>
                - press TAB and click 'Map'<br>
                - press 'm'
                """
                ) {
        option( "place" )
        option( "build" )
        option( "objects" )
        option( "blueprints" )
        option( text:"Done" );               
    }
}

showPrompt( """\
Welcome to the Mythruna Public Server.
Please select a help option from below.
"""
) {
    option( "place" )
    option( "build" )
    option( "objects" )
    option( "blueprints" )
    option( "map" )
    option( text:"Never mind" )
}

The power of the scripting language (Groovy) is that I can customize it to make things flow more fluently.  Hopefully those of you interesting in the future of customization can understand what's going on above and can see the possibilities.

Because that's actually Groovy code, making any of those options or prompts conditional is simply a matter of adding the appropriate "if" statement.
Logged
caesar
Forum's Janitor
Global Moderator
Full Member
*****
Posts: 170


View Profile
« Reply #1 on: October 17, 2011, 12:08:11 AM »

Nicely done!
I have some experience with quest-modding in Fallout3. The abilites are similar but FO3 had some queststages. So if you have reached some certain point in a quest a npc had different dialog options.
Will we be able to use global variables with groovy to be able to use queststages and 'unlock' dialogs for npcs?
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #2 on: October 17, 2011, 01:18:23 AM »

Nicely done!
I have some experience with quest-modding in Fallout3. The abilites are similar but FO3 had some queststages. So if you have reached some certain point in a quest a npc had different dialog options.
Will we be able to use global variables with groovy to be able to use queststages and 'unlock' dialogs for npcs?

Let me preface this by saying that the real NPC standard conversation system will be different.  So this answer refers to mods that could have more traditional pre-scripted RPG style quests... of the type to which you refer.

Short answer is yes.  You can already do this right now, in fact, it's just a little crude:

In some script (playerData is multiplayer only but when I revamp the player object both single player and multiplayer will work the same and be simpler):
Code:
playerData.set( "quests.killBadger", 2 );
playerData.save();

Then in the dialog script:
Code:
showPrompt( "How have you been?" ) {
    if( playerData.get( "quests.killBadger" ) > 1 ) {
        option( "I killed another badger!" );
    }
    option( "Not much." );
}

You could even have different prompts:
Code:
if( playerData.get( "quests.killBadger" ) > 0 ) {
    showPrompt( "I see you've killed some badgers." ) {
        option( "Yes, I have." )
        option( "Why, do I stink?" )
    }
} else {
    showPrompt( "How have you been?" ) {
        option( "Fine, thanks." )
    }
}

Note: I've left off any actions associated with the options for clarity.  So technically all of those just end the conversation.

Hopefully you get the point I'm making. Smiley
Logged
caesar
Forum's Janitor
Global Moderator
Full Member
*****
Posts: 170


View Profile
« Reply #3 on: October 17, 2011, 06:36:12 AM »

Neat  Shocked

Are there limitations with these playerdata? You could add some awesome features, big choices affecting loads of quests, karma-levels, counters for statistics, clan or faction systems and ranks and TONS of other great things.
Freaking awesome.
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #4 on: October 17, 2011, 08:40:01 AM »

Neat  Shocked

Are there limitations with these playerdata? You could add some awesome features, big choices affecting loads of quests, karma-levels, counters for statistics, clan or faction systems and ranks and TONS of other great things.
Freaking awesome.

There aren't many limitations... it's plugging values into the player's JSON record in the player database, basically.  To make managing mod-related data easier, I'll probably add some things to make it easier for a mod to keep its data under one part of the tree and limit the scope of what a script can set to character specific data (right now you can do nasty things like directly set the player stats for example).

...and writing 100 times a second won't really be recommended either because of the persistence.  At some point, I will add some non-persisted thing to temporary shove player runtime-only stuff into... though really playerData acts that way until playerData.save() is called.

Anyway, that's all down the road a bit.  I just wanted to keep the potential modders up to speed on how important I view modding flexibility. Smiley
Logged
randomprofile
Global Moderator
Sr. Member
*****
Posts: 265


View Profile WWW
« Reply #5 on: October 30, 2011, 08:35:05 AM »

I don't really know the first thing about groovy, but I was reading the script and I notice you incude:
Code:
    option( "place" )
    option( "build" )
    option( "objects" )
    option( "blueprints" )
    option( "map" )
    option( text:"Never mind" )
}
after every single option... and I was thinking does groovy have a GOTO command or something cuz wouldn't it be easier to just do:
Code:
echo 'please pick an option';
echo 'place';
echo 'random';
echo 'another choice';
if ( $option == 'place')
{
goto place;
}
place:
echo 'Info... BLAH BLAH BLAH';
goto beginning
And for those of you who wonder that was written in PHP since I am not familiar with groovy.
The point is I was wondering if groovy had a way to write what I just wrote in php?
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #6 on: October 30, 2011, 01:53:15 PM »

I do that after every single option because the list changes from one to the other.  It is possible to group common options together and reuse them (at least in theory) but cut/paste was easier in this case and easier to tweak.

option() is doing more than just echoing text to the user.  In the default case, it's looking up a separately defined option from the defOption() set.  It can also be defined on the spot and/or override things from the defOption() (so you could associate a different event script for example).  It's using this to add a dialog option to a data structure that gets sent to the client (along with an ID) and is associating code to that ID. 

The {} you see under defOption is the code that gets run when the user clicks that option.  It can be anything.  In the case of the help dialog it's just more prompts and options.

At any rate, it's also just groovy code so in theory there should be a way to call a function to add a bunch of options from within a prompt.  I think I have to add some boilerplate to make that work right, though.  To make the dialog API look nice, I've done some "clever" things in the API layer.  However, technically these are just convenience wrappers and there's no reason dialog prompts couldn't be constructed a more ugly and manual way.
Logged
Jeremiah
Newbie
*
Posts: 3


View Profile
« Reply #7 on: January 04, 2012, 11:22:07 PM »

Scripted dialogue Mail
I think most people would prefer a stand-alone e-mail application on the desktop or on the web, instead of reading and sending e-mail inside Messenger.
On a more technical note, this would be very hard to do with Plus! scripting alone. Sending mails may be somewhat doable (1), but to receive and manage e-mails you'd need to build a complete storage system for it.
I think there's already a variety of e-mail clients available, adding another one would only cause more trouble when you use more than one. For example, how would you copy mails between the Messenger client and a different one? Outlook provides a bunch of export options, do you expect that the Messenger client can interpret all these as well?
In my opinion, it's too complex and totally not necessary. Why reinvent the wheel?
Logged

pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #8 on: January 05, 2012, 05:06:56 AM »

Scripted dialogue Mail
I think most people would prefer a stand-alone e-mail application on the desktop or on the web, instead of reading and sending e-mail inside Messenger.
On a more technical note, this would be very hard to do with Plus! scripting alone. Sending mails may be somewhat doable (1), but to receive and manage e-mails you'd need to build a complete storage system for it.
I think there's already a variety of e-mail clients available, adding another one would only cause more trouble when you use more than one. For example, how would you copy mails between the Messenger client and a different one? Outlook provides a bunch of export options, do you expect that the Messenger client can interpret all these as well?
In my opinion, it's too complex and totally not necessary. Why reinvent the wheel?


I can't find what this is in response to though I do remember discussing briefly the idea of in-game bulletin boards and message systems.

Some kind of in-game messaging can be nice because you often don't know the e-mails of the people you are playing with... but I would never do anything as complicated as e-mail for that.  That's why I kind of like the idea of leaving actual pieces of paper around as the system can be somewhat self-managing because of the clutter.  Or you have an NPC that comes an clears off old messages from the town message board every now and then.

But yeah, I definitely don't want to reinvent e-mail.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!