Forcing player to pick every option

During dialogue, I wanted to present the player with three options.

Talk about X, Y, Z.
If you choose X, you would talk to the NPC for a bit before returning to an option where you choose Y or Z. If you choose Y, you would talk again until you were granted the option to talk about Z.
Once that was done, you'd be allowed to continue.

I could, in theory, map every choice out but that seems a bit tedious and excessive. Are there better ways?


I would suggest making a list of the available options, and removing items when they're done.

For example, if this is John's "speak to" verb, you could have something like:

if (not HasAttribute (John, "speak_options")) {
  // The first time this script is run, set up the list of options
  John.speak_options = Split("X;Y;Z")
}
if (IsDefined ("result")) {
  // If the player has chosen an option, remove it from the list so they can't choose it again
  list remove (John.speak_options, result)
  // … and then show that conversation
  switch (result) {
    case ("X") {
      // conversation code for X goes here
    }
    case ("Y") {
      // conversation code for Y goes here
    }
    case ("Z") {
      // conversation code for Z goes here
    }
    default {
      // This message makes it easier to debug if you made a typo
      // It should only happen if the one in the case statement is spelled differently to the Split
      error ("Unexpected option for John: " + result)
    }
  }
}
if (ListCount (John.speak_options) > 0) {
  // There are still options left, so we ask the player to choose one
  ShowMenu ("What do you want to ask John?", John.speak_options, false, John.speak)
}
else {
  // anything you want to do when all the options have been done goes here
}

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums