Triggering dialog option after a certain time

Started by Laura Hunt, Tue 16/08/2022 17:43:57

Previous topic - Next topic

Laura Hunt

I would like to implement a timer such that, if the player doesn't choose one of the options in a dialog in a certain amount of time, one of them will be triggered at random.

The idea I've been working on is to launch a timer right before the dialog starts, and to check it in repeatedly_execute_always like this:

Code: ags
function repeatedly_execute_always()
{

  if (IsTimerExpired(1) && !dExampleDialog.HasOptionBeenChosen(1) && !dExampleDialog.HasOptionBeenChosen(2) && !dExampleDialog.HasOptionBeenChosen(3)) {
    int rnd = Random(2);
    for (int i = 0; i<3; i++) {
      if (i != rnd) dExampleDialog.SetOptionState(rnd+1, eOptionOffForever);
    }
    dExampleDialog.Start();    
  }
}


The idea is to check if the player has not chosen any options, and then switch all other options to Off so that when I re-trigger the dialogue, there will only be one left and it will run automatically.

The logic seems sound, but there is an issue: I cannot trigger dExampleDialog.Start() from inside rep exec always. So now I'm stuck and maybe it's because I've spent too much time in front of this, but I can't find an alternative way to do it. Any suggestions?

Edit: actually, it seems like I can't trigger a new dialogue (or the same one) while one is running, so this makes it even harder now... Is there a way to exit/stop a dialogue from outside the dialogue itself?

Crimson Wizard

#1
If you were using custom dialog options rendering, they have their own "rep-exec" callback (called "dialog_options_repexec"), and theoretically you could check for the timer there, set a special ActiveOptionID and call DialogOptionsRenderingInfo.RunActiveOption();

https://adventuregamestudio.github.io/ags-manual/CustomDialogOptions.html
https://adventuregamestudio.github.io/ags-manual/DialogOptionsRenderingInfo.html

If you really have to use rep-exec-always for timer test, then perhaps you could instead set a global variable in there, and test for that variable inside dialog_options_repexec.

Laura Hunt

Unfortunately, I'm not using custom dialog options because our dialogs are very simple, so creating a custom system would be overkill for what we want (not to mention that it's always felt extremely intimidating to me).

If there are no other ways to achieve what I want, then I'll simply not implement this feature. It's not really vital, just a "nice to have", so it wouldn't be a huge loss.

eri0o

I missed this one. Did it work out in the end? Custom Dialog Options is not as complicated as it looks like, you should totally try it out.

This is the one for I Rented a Boat: https://github.com/ericoporto/i_rented_a_boat/blob/main/I_rented_a_boat/CustomSay.asc

It had two possible uses of it, so in line 355 forward there is the switch between the different ones.

I don't remember any way to do this without using Custom Dialog Options rendering though.

SMF spam blocked by CleanTalk