Dialog choices and branching

Started by bbalint85, Wed 28/08/2013 17:04:22

Previous topic - Next topic

bbalint85

Hi! I'm familiar with AGS, but I just started working with dialogs, so I have a question, hope you can help:
I want to do a branching, for example:
What do you want?
    -apple
    -orange
    -pear
How much do you want?
    -one
    -two
    -three
Thank you, your stuff will be ready, etc.

I can play with the options to always show, what I want, my problem is getting to the same line after choosing different options (The "How much do you want?" line) I need some kind of goto function, but goto-dialog jumps to another dialog, I just want another option. So no matter what fruit the player chooses, the next line should be printed, the code should get there.. Any suggestions? I'm hoping this is a trivial question...:=
Thanks!

Timeless Journey

Khris

The usual way is to use two dialogs, but you can put it into one, if you do something along these lines:

option 1: apple
2: orange
3: pear
(check show for each)
4: one
5: two
6: three
(uncheck show for those)

In the script:
Code: ags

@S
merchant: What do you want?
 choice = 3;
return
@1
 choice--;
@2
 choice--;
@3
option-off 1
option-off 2
option-off 3
option-on 4
option-on 5
option-on 6
 how_many = 3;
merchant: How much do you want?
return
@4
 how_many--;
@5
 how_many--;
@6
 Display("You chose %d of fruit #%d.", how_many, choice);
stop


(choice & how_many are global integer variables, lines indented by at least one blank space are treated as AGSScript)

Untested!

Snarky

I would emphasize this part:

Quote from: Khris on Wed 28/08/2013 18:02:58
The usual way is to use two dialogs

The way the dialog system has been designed, the idea is that a branching conversation is a collection of dialogs. This is the best and easiest way to do it.

bbalint85

Thanks for the replies. I have a custom dialog system, and I designed it to use 1 dialog per character (not the best idea, it seems), anyway thanks Khris, that's a neat trick, I haven't thought of that!

Timeless Journey

Khris

You're welcome, but I'm wondering why you'd limit yourself like that; is there a technical reason why you can't call different dialogs when talking to a specific character, even with a custom system?

bbalint85

The truth is, that I don't want to rewrite the whole dialog code. It uses some assumptions, for example dialog ID = character ID, for the speech bubble to be placed correctly, and so on. It could be done, but the game is not really based on long conversations, so this is the easier way right now. Btw, I have another question, maybe you have an idea, in the same topic:
how can I stop the dialog in an if statement? basically I want to do this, which doesn't work of course, but you get the idea:
e.g.:
Code: ags

@1 //this is the quit option, but I want to use it as a return to previous topic also
    if (Somecondition==true)
    {
        player.SayCust("I want to ask a few more things";
        dialog[11].SetOptionState(3, eOptionOn);
        dialog[11].SetOptionState(9, eOptionOff);
return        
    }
    else
    {
        player.SayCust("Good bye.";
stop
    }


So can I replace stop and return with some real ags code, not "dialog code"?

Timeless Journey

Khris

Yes, that's possible:

QuoteIf you want to conditionally break out of the dialog script, the special tokens RUN_DIALOG_GOTO_PREVIOUS, RUN_DIALOG_RETURN and RUN_DIALOG_STOP_DIALOG are available which you can return from inside a script block. For example:

@1
ego: "Hello. How are you?"
narrator: The man looks you in the eye.
  if (player.HasInventory(iKey)) {
    player.Say("Actually, I'd better go.");
    return RUN_DIALOG_STOP_DIALOG;
  }
otherman: "Here's a key for you."
return

Monsieur OUXX

@bbalint85 : pro-tip for you: if you want to avoid A LOT of trouble, don't forget to leave 2 or 3 unused dialog options inbetween each actually-used dialog option of your dialog. This way you can fix your dialog later if you forgot someting.
 

Andail

At least make sure the "Goodbye" option is first, so you can add topics indefinitely!

SMF spam blocked by CleanTalk