Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411482 Posts in 69370 Topics- by 58426 Members - Latest Member: shelton786

April 24, 2024, 02:08:31 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Branching dialogue in Game Maker?
Pages: [1]
Print
Author Topic: Branching dialogue in Game Maker?  (Read 13322 times)
denzgd
Level 1
*



View Profile WWW
« on: August 08, 2014, 09:44:18 PM »

Hello all! I'm working in the latest version of Game Maker Studio, and I'm trying to do branching dialogue. For the last week and a half, I've been searching 'the Google machine' for any modern tutorial to learn how to handle it. I keep running into a few issues. Mainly, I can't find any relevant Game Maker Studio tutorials; most are older versions, which use a series of obsolete functions. I don't know what they do, and I'm still relatively new to GML so I am unable to work around it. Other tutorials are for smaller projects, like scrolling space shooters, simple tower defense games, etc. I have found a few example projects as alternatives to an actual tutorial, but they suffer from the same problems, and I'm not experienced enough to understand what's going on in their complex blocks of GML.

I would love somebody to give me some advice here. Specifically, I'd love any recent Game Maker Studio tutorials you can point me to - in particular those that cover dialogue fairly well. Thanks in advance! Any input is appreciated.
Logged

fraxcell
Level 5
*****



View Profile
« Reply #1 on: August 09, 2014, 08:09:41 PM »

I was actually looking into this a couple weeks ago. You're right, there aren't any great examples that are compatible with GM Studio. I would recommend taking a look at this thread http://gmc.yoyogames.com/index.php?showtopic=554511. If you don't plan on having huge amounts of text, the example in the very first post should be sufficient. If I recall correctly, it will require a couple of changes to make it work with GM Studio, but I'd be happy to walk you through them if you're interested.
If you're looking to include more text/options, read through the posts by HaRRiKiRi (especially this one). It'll require some more programming knowledge, but he outlines a slightly more flexible system for handling dialog.

A few years back I used an example for a visual dialog editor made in GM, which exported text files to store all the choices and stuff, but for some reason I can't find it any more. It would probably require a significant amount of work to overhaul for GM Studio, but if anyone knows what I'm talking about I'd love to see a link to it.
Logged

ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #2 on: August 09, 2014, 08:53:36 PM »

um, this is really simple. create a small choice box that lets the user select an option (e.g. 'yes' and 'no' are classic). have that set a variable. then change the dialogue based on that variable

it requires a lot of gui coding and such, but it's not like, mentally challenging or anything

you could also write some kind of parser. e.g.

"do you like apples?"
"[choice:yes,no]"
"yuck, you like apples? i hate them. [if:yes]"
"hmph, you don't like apples? well, i love them! [if:no]"

the game would check the lines of strings, and remove what's in the brackets, and only display that line of text if the player answered with yes (or no). that is more complicated to code, and i would only recommend it if your game has a much branching dialogue as a wrpg like fallout 3 or something, but it's what it'd do.

note that you do *not* require string_execute to do that, the game would simply use the string functions to check inside the brackets and do certain code actions depending on what's inside (and also it'd always remove whatever's in the brackets before displaying it on screen).
« Last Edit: August 09, 2014, 09:11:10 PM by ஒழுக்கின்மை » Logged

ndke
Level 2
**


View Profile
« Reply #3 on: August 10, 2014, 04:31:50 AM »

I once made something that can do this for a game.
Then the code in the Create Event looks like this:

Code:
scr_npc_text_init(); // Initialize talking
scr_npc_text_add("Guard", "Hello young adventurer, what can I do for you?"); // Message number zero

scr_npc_text_option("Could you give me advice?", 1); // Display "Could you give me advice?" and when clicked, go to message number one.
scr_npc_text_option("What about a job?", 5); // Display "What about a job?" and when clicked, go to message number five
scr_npc_text_option("Could you inform me about skills?", 9);
scr_npc_text_option("What about items?", 14);

// advice
scr_npc_text_add("Guard", "Your best bet on making money is#probably in collecting stuff."); // Message number 1
scr_npc_text_add("You", "I don't think I will earn alot of#money on just selling basic things."); // Message number 2
scr_npc_text_add("Guard", "You'll learn how to process raw#materials into more useful items."); // Message number 3
scr_npc_talk_exit(); // Message number 4 (everything gets its own number/id)

// job
scr_npc_text_add("Guard", "I know the farmer was looking for someone#to do a job lately."); // Message number 5
etc. etc. etc.

It's probably not the most efficient way to do it, but it was made a long time ago and it works...
If you are interested in seeing how I did it, I hope this helps you...
You can download the .GMZ here: http://g2f.nl/0gu5iv8
Logged
denzgd
Level 1
*



View Profile WWW
« Reply #4 on: August 10, 2014, 11:05:39 PM »

If you're looking to include more text/options, read through the posts by HaRRiKiRi (especially this one). It'll require some more programming knowledge, but he outlines a slightly more flexible system for handling dialog.

This seems like it would be the best way to go. Right now, I plan to have a game world very much driven by dialogue and character development. Lots of this stuff doesn't make sense to me, because I'm coming from a background of platformer tutorials and like shmups - nothing really inherently involved - so a lot of this is going over my head.
Logged

oahda
Level 10
*****



View Profile
« Reply #5 on: August 14, 2014, 12:18:04 AM »

I'm pretty sure I've seen this done in GM using XML files in the past. That would be a good way of supporting the branching structure of such a system. Although perhaps not transparently compatible with the GM workflow, but reasonably easily transferred to one using something like XML to store the dialogue data, I could describe in rough terms how I solved this in Unity two LD's ago.

I did write it in C#, but as with any script in Unity, the variables were wonderfully brought into Unity's GUI editor for me to visually add dialogues with options and branches when the system was up and running. The only unfortunate exception to this wonderfulness was the fact that Unity for a long time has had, and according to the searches I did at the time does not plan to remove, a limit to the number of branches possible in the editor. I could have solved it by creating an XML-like system instead, but I decided against it due to the limited time of the LD competition, and rather designed the dialogues around this limitation instead – something you should be able to avoid with a system like this in GM.

Anyhow, imagine you might have an XML structure somewhat like this:

Code:
<dialogue>
<textbox character="John Smith" avatar="happy" />
<text>Oy, stranger!</text>
</textbox>

<textbox character="John Smith" avatar="happy" />
<text>Whatcha doin' here?</text>

<option text="Investigating!">
<textbox character="John Smith" avatar="suspicious">
<text>Huh? I don't want no coppers 'round here.</text>

<option text="Oh, I'm not a cop.">
<textbox character="John Smith" avatar="surprised">
Oh? Really? Well, off with ye anyhow. I ain't sayin' nuffin' to nobody!
</text>
</option>

<option text="You are under arrest." action="death-5">
<textbox character="John Smith" avatar="laughing">
Hah! You've entered the wrong neighbourhood. Come on, lads!
</text>
</option>
</text>
</option>

<option text="Eh, nothing.">
<textbox character="John Smith" avatar="expressionless">
<text>Oh. Me neither.</text>
</text>
</option>
</text>
</dialogue>

So what you need to do is parse the file somehow (I'm sure it's possible in GM if not by built-in means at least by some sort of add-on) and look for textboxes to begin with. Immediately consequent textboxes just come after each other. So the character will first say "Oy, stranger!" with no options, you'll be able to click next, and "Whatcha doin' here?" will be written in the following textbox, along with two options for your player to choose from: "Investigating!" and "Eh, nothing.".

Selecting the latter will simply have the character say "Oh. Me neither." and then ending the conversation, as there is no more data following. Choosing the first option, however, will begin branching into more textboxes and options. If you reach the end of a tree with no specific action supplied for any option, the conversation simply ends. However, the latter branched choice of the first choice, where your player tries to arrest the character, has been set to trigger an action designated death-5, leading perhaps to a cutscene where the thugs dispatch of your player.

Is that enough without actually supplying some code? I just wanted to try and explain the basic gist of the system.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #6 on: August 20, 2014, 07:36:25 AM »

alternatively use ren'py or twine
Logged

denzgd
Level 1
*



View Profile WWW
« Reply #7 on: August 25, 2014, 02:32:39 PM »

alternatively use ren'py or twine

Already bought Game Maker Studio, and I want to be able to use it fully. Plus the game's groundwork is already being developed in Game Maker Studio.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic