random lines of dialogue?

正在查看此主题的用户

Cartread

Sergeant at Arms
I was wondering if anyone knows if it is possible to have characters say random lines of dialogue in game.
I am asking because I don't know how to use shuffle_range, store_random, & store_random_in_range.  I know these are used to chose random fighters in the arena (and elsewhere?), but I'm wondering if that can be applied to dialogue?

Thanks
 
Simplest way:

[store_random, "$random_reply", 10],

Picks a number between 0 and 9.

Then list ten lines of dialogue, each with the conditional:

[eq, "$random_reply", 0],
bla, bla, bla

[eq, "$random_reply", 1],
bla, bla, bla

[eq, "$random_reply", 2],
bla, bla, bla

etc. down to 9.



 
A cleaner way would be to use strings. Something like:

(assign,reg(1),"Your first string"),
(assign,reg(2),"Your last string +1"),
(store_random_in_range,reg(0),reg(1),reg(2)),
(str_store_string,1,reg(0)),

[trp_isaac,"hit_on_the_head",[],"{s1}","by_an_apple",[]],

That way, you can easily add more strings (dialogs).  Either way will work, though.
 
silverkatana 说:
A cleaner way would be to use strings. Something like:

(assign,reg(1),"Your first string"),
(assign,reg(2),"Your last string +1"),
(store_random_in_range,reg(0),reg(1),reg(2)),
(str_store_string,1,reg(0)),

[trp_isaac,"hit_on_the_head",[],"{s1}","by_an_apple",[]],

That way, you can easily add more strings (dialogs).  Either way will work, though.

For this you'd have to call from module_strings?
 
I'm not sure that I really understand your question, so let me be more specific.

In module strings:
  ("say_1","Two Fairies"),
  ("say_2","e^(2*pi*i)"),
  ("say_3","Tortillas"),
  ("response_1","Three Kittens"),
  ("response_2","1"),
  ("response_3","Beans"),

In module dialogs:
[trp_isaac,"hit_on_the_head",[
    (assign,reg(1),"str_say_1"),
    (assign,reg(2),"str_say_3"),
    (val_add,reg(2),1),
    (store_random_in_range,reg(0),reg(1),reg(2)),
    (str_store_string,1,reg(0)),
    ],"{s1}","by_an_apple",[]],

[trp_isaac|plyr,"by_an_apple",[
    (val_add,reg(0),3),
    (str_store_string,1,reg(0)),
   ]."{s1},","close_window",[],   

If you have any more questions, let me know.
 
silverkatana 说:
  ("say_1","Two Fairies"),
  ("say_2","e^(2*pi*i)"),
  ("say_3","Tortillas"),
  ("response_1","Three Kittens"),
  ("response_2","1"),
  ("response_3","Beans"),

[trp_isaac,"hit_on_the_head",[
    (assign,reg(1),"str_say_1"),
    (assign,reg(2),"str_say_3"),
    (val_add,reg(2),1),
    (store_random_in_range,reg(0),reg(1),reg(2)),
    (str_store_string,1,reg(0)),
    ],"{s1}","by_an_apple",[]],

[trp_isaac|plyr,"by_an_apple",[
    (val_add,reg(0),3),
    (str_store_string,1,reg(0)),
   ]."{s1},","close_window",[],   

I don't know if I'm right, but doesn't store_random_in_range function will give you "str_say_1" or "str_say_2", and never will give you "str_say_3"? I mean, don't you need to have a fake "str_say_end" after "str_say_3" to set the upper limit for the range?

Maybe I'm confused with another function that works in that way...
 
Or, if there's already another string after it, you could just use that string as the top of the range.  When you got to the end you would use the first string.
 
I asked if you'd have to call from module strings because I thought it might all be possible in dialogues.  Thanks for clarifying, silverkatana.  The way you have the random dialogues setup up, one line appears and then another takes over and stays (in a second or so)--just a note

Is it possible to set up dialogues so that they randomly display and also eliminate from the random pile the lines which have already been called?

I tried with the way Khalid ibn Walid posted by setting up conditions, but I couldn't get it working.  I image it would be difficult or extensive (and probably not worth it).
 
You could use registers like I said, and then have a variable assigned to each line, so it would look like this:

  [trp_bourghal,"start",[(store_random_in_range,reg(11),1,5),(eq,reg(11),1),(eq,"$random_dialogue1",0)],"Yes, {king/queen}?","Bourghal_talk1",[(assign,"$random_dialogue1",1)]],
  [trp_bourghal,"start",[(eq,reg(11),2),(eq,"$random_dialogue2",0)],"Yes, lord?","Bourghal_talk1",[(assign,"$random_dialogue2",1)]],
  [trp_bourghal,"start",[(eq,reg(11),3),(eq,"$random_dialogue3",0)],"Need something done, {sir/madam}?","Bourghal_talk1",[(assign,"$random_dialogue3",1)]],
  [trp_bourghal,"start",[(eq,reg(11),4),(eq,"$random_dialogue4",0],"Aye?","Bourghal_talk1",[(assign,"$radoghir_dialogue4",1)]],
  [trp_bourghal,"start",[],"Buh?","Bourghal_talk1",[]],
, but it would be kind of ugly.
 
Cartread 说:
<snip>  one line appears and then another takes over and stays (in a second or so) <snip>

You probably put the second "str_store_string" in the consequences block of the first dialog state; if you put it in the conditions block of the second state, that won't happen.
 
I have it like this:

  [trp_the_black_knight|plyr,"tbknight_talk",[
    (assign,reg(1),"str_say_1"),
    (assign,reg(2),"str_say_3"),
    (val_add,reg(2),1),
    (store_random_in_range,reg(0),reg(1),reg(2)),
    (str_store_string,1,reg(0)),
    ],"{s1}","by_an_apple",[]],

[trp_the_black_knight,"by_an_apple",[
    (val_add,reg(0),3),
    (str_store_string,1,reg(0)),
  ],"{s1},","close_window",[]],

 
Well, that's just weird.  Change reg(0) to some variable (might I suggest "$flaming_sword_of_register_perdition"?)  It will work- I've done this before, just never with registers.  Something odd is going on in register-land.
 
That val_add is very handy.  I was attempting to do something similar to all this and going completely crazy and thinking you could not do a store_string using a variable, but thankfully this thread showed me I was wrong and there was a completely different problem....
 
后退
顶部 底部