• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Dialog trees

S

Slothagami

Guest
I'm trying to make a dialog tree for my NPC's so that the player can make decisions and also have the NPC's reference the player's older desicions and dialog choices.

I can't seem to get it straight in my head how this would work, I don't want to get it wrong because I plan to have allot of dialog in my game and I want it to be easy to add and tweak the dialog lines.

What's a good way to do this?
Thanks in advance!
 

flyinian

Member
I'm trying to make a dialog tree for my NPC's so that the player can make decisions and also have the NPC's reference the player's older desicions and dialog choices.

I can't seem to get it straight in my head how this would work, I don't want to get it wrong because I plan to have allot of dialog in my game and I want it to be easy to add and tweak the dialog lines.

What's a good way to do this?
Thanks in advance!
I recommend starting here: Dialog system video

I haven't personally use the code in those videos but, it should give you an idea at the very least.
 

TailBit

Member
Something like that is actually the base for this too ..

I've been brainstorming to put figure out how to write a system like that out..

The idea is that the code will go through the chat array line by line and checking the arrays it contain .. and evaluating them.

To either do if checks, display text, gather (valid) menu options that it will display one is reach display_options, or change what index to continue reading from.

Inbetween setting the chat information, I do set a goto array with the current position of the chat array, to use when jumping position.

Still quite a mess, and I guess it would be a lot better if to fill out if one made a editor for this.
GML:
// this is the enums for one character .. the other ones should be defined in a parent object
enum _char_peter {_start, _opening, _introduction,_quest_preview }

enum _chat { _if,_option,_dia,_end,_display_options,_goto }
enum _need { _reputation,_unused,_progress }
enum _do { _use,_goto,_offer_quest }
/*
[ _chat._if ,
    [_need,operator,value], // requirement
    [_do,data],                // action if true
    [_do,data]                // action if false
]

[ _chat._option,
    "string",
    [_need._something ],    // requirement to display string
    [_do]                    // action when pressing string
]

[ _chat.dia, "string" ]        // just displays string and continues

[ _chat.end ]                // simply ends the chatbox
[ _chat.goto, index]        // jumps to a defined goto mark

[_chat._offer_quest,
                "string",             // short about the quest
                QUEST.index,        // quest index
                ["responce",_do?],    // responce if you accepted quest
                ["responce",_do?]    // responce if you declined quest
            ]

*/

var i=0;

goto[_char_peter._start] = i;
chat[i++] = [_chat._if,
                [_need._reputation,">",20],
                [_do._goto, _char_peter._opening],
                [_do._continue]
            ]
chat[i++] = [_chat._dia,"Sorry, but we want nothing to do with you"]
chat[i++] = [_chat._end]

goto[_char_peter._opening] = i;
chat[i++] = [_chat._option,
                "Hello",
                [_need._progress,"=",0],
                [[_do._goto,_char_peter._introduction],[_do._progress,1]]
            ]
chat[i++] = [_chat._option,
                "Need any help?",
                [[_need._progress,">",0],[_need._quest_status,QUEST.save_peters_farm,QUEST_STATUS._none]],
                [_do._goto,_char_peter._quest_preview]
            ]
chat[i++] = [_chat._option,
                "Any news?",
                [_need._unused,i,_need._progress,1],
                [_do._goto,_char_peter._introduction,_do._use,i]
            ]
chat[i++] = [_chat._option,"bye",,]
chat[i++] = [_chat._display_options]
chat[i++] = [_chat._end]

goto[_char_peter._introduction] = i;
chat[i++] = [_chat._dia,"I've lived with my father on this farm ever since my mother passed away"];
chat[i++] = [_chat._dia,"But now I haven't seen him for a week."];
chat[i++] = [_chat._goto,_char_peter._opening]

goto[_char_peter._quest_preview] = i;
chat[i++] = [_chat._offer_quest,
                "Can you ask around in town and see if you can find locate him?",
                QUEST.save_peters_farm,
                ["Thank you",[_do._quest_set,QUEST.save_peters_farm]],
                ["Maybe later?",]
            ]
chat[i++] = [_chat._goto,_char_peter._opening]
Maybe it could be structured differently .. this is just how I think I would define it in the create event.
 
K

KiD_Rager

Guest
@FriendlyCosmonaut made a fantastic tutorial section for dialogue.


It's very easy to apply to virtually any object you want to hold dialogue with, and making branching dialogue with separate scripts based on decisions made is also super easy to implement. I've even tested it with a state machine and it works wonders. Easily the most descriptive, educational, and effective dialogue system tutorial out there.
 
Top