Hmm, I see the dialogue article effectively disappeared from the docs...
So here it is:
In addition to the original Game.AddResponse() and Game.GetResponse() methods, this build introduces new methods
Game.AddResponseOnce() and
Game.AddResponseOnceGame().
Game.AddResponseOnce(id, text)This method will add a dialogue response and once this response is selected by the player, it will disappear from the list of responses until the dialogue is finished.
Game.AddResponseOnceGame(id, text)This method will add a dialogue response and once this response is selected by the player, it will disappear from the list of responses and it will never reappear in the current game session.
Using these two methods you don't need to explicitly code whether a certain response should appear only once. The engine will remember which responses have been previously selected by the player and it will hide them automatically.
If you need to revive an automatically hidden response, you can use
Game.ResetResponse(id) method.
As an addition to this new functionality the Game.GetResponse() method now has an optional logical parameter, which specifies what to do when there's only one response left for player to select. If you pass a true value as a parameter to the GetResponse method and there is only one response available, the engine will select it automatically.
For your further convenience, WME now provides a new
Game.LastResponse attribute, which holds a text of the previously selected response.
But there's a small complication. In order to make the Game.GetResponseOnce* methods work, you must explicitly define where your dialogue branch starts and where it ends so that the engine is able to track to which dialogue which response belongs. You can mark a dialogue start using the new
Game.StartDlgBranch(name) method and end it using a
Game.EndDlgBranch() method.
OK, let's show the new functions in an example:
function MyTestDialogue()
{
Game.StartDlgBranch("MyTestDialogue"); // start a new dialogue branch
var EndBranch = false;
while(!EndBranch) // loop until the player ends this dialogue
{
Game.AddResponseOnce(0, "You can select this response only once in this dialogue");
Game.AddResponseOnceGame(1, "You can select this response only once in the entire game");
Game.AddResponse(2, "Ok, I have to go now.");
var res = Game.GetResponse(true); // automatically select last response
actor.Talk(Game.LastResponse);
if(res==2) EndBranch = true; // response #2 exits the dialogue
}
Game.EndDlgBranch(); // end this dialogue branch
}