Dialog Question - Random Response

Started by General, Sat 23/02/2008 08:57:08

Previous topic - Next topic

General

Let's say I'd let my main character talk to a man in a town and I have a Dialog Option:
"What can you tell me about the town?"
And now I want the man to respond randomly:
"We have a pretty nice pub. Check it out!"
or
"Try visiting the local park. It's quite nice."
and so on, and so on.
Is there any way to do that?
I thought about making a second, third etc. dialog-script, but that would mean, that I'd need to copy all other available options in those scripts too (for example "Hello, how are you?", "What do you know about X?" etc.). That looks pretty much like a major headache, if the conversation gets a bit more complex.
And if there is no way to make it random, is there at least a way to change the answers?
(First he tells me about the pub, then the park, then the inn etc. etc. and then about the pub again and so on)??
Any suggestions?

Radiant

#1
Use run-script in the dialog, and then put this in your main script:

Code: ags

function dialog_request (int num) {
  int are = Random (3);
  if (num == 1) {
    if (are == 0) character[SOMEBODY].Say ("Hello");
    if (are == 1) character[SOMEBODY].Say ("bye");
    if (are == 2) character[SOMEBODY].Say ("greetz");
    if (are == 3) character[SOMEBODY].Say ("huh?");
  }
}




(edit) Heh. Turns out you can't name a variable "R" in a code block without having it renamed "are"...

General

Big thx!
That cleared my head and gave me inspiration for new stuff!
Ah, I love this program.

Akatosh

If you're going to have that a "generic reply", you could also do something like this:

Code: ags

String genresponse[4];
genresponse[0]="Heya";
genresponse[1]="Whuzzup";
genresponse[2]="Eh?";
genresponse[3]="Portal reference!";
//and so on. you get the idea.

function dialog_request (int num) {
  if (num == 1) character[SOMEBODY].Say("%s",genresponse[Random(3)];
}

SMF spam blocked by CleanTalk