Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Tue 03/01/2006 02:31:07

Title: How to start new dialogue branch?
Post by: on Tue 03/01/2006 02:31:07
I'm trying to make a dialogue branch that is contingent upon a previous action having been completed, in this case an item being used on a hotspot.

After copmleting the action in one room, the playable character should then be able to enter into another dialogue branch with the NPC in the other room.
Title: Re: How to start new dialogue branch?
Post by: Play_Pretend on Tue 03/01/2006 03:53:57
This may be a newbie answer, but what I think might work is:

Create a global variable (for this I'll assume it's number 5), with an initial value of zero...

Put script like this in the NPC's Talk Interaction:

if (GetGlobalInt(5) == 0) {
    RunDialog(0);
}
else if (GetGlobalInt(5) == 1) {
    RunDialog(1);
}

Then put a line in your script so when the item is used on the hotspot, there's a SetGlobalInt(5, 1); command.  Set up the two separate dialog branches (0 and 1, or whatever numbers you end up using).  This way it'll only play the second dialog branch (#1) if the item's been used, otherwise it'll just stick to the first (#0).

Hope that makes sense, and if there's an easier way, I'd like to learn too. :)
Title: Re: How to start new dialogue branch?
Post by: Ashen on Tue 03/01/2006 16:59:41
Now that the Wiki's up, there's no excuse not to have read the BFAQ:
Quote from: Front page of the BFAQNOTE: Please keep the following in mind. Most of our problems can be easily solved using variables. Need to change a hotspot's state in another room? Use variables! Need an object to be used only once? Use variables! You can either use Global Integers and Global Strings (look inside the AGS manual for these) or custom variables. Look at the solution to that problem HERE under "Scripting, Code & Interaction".

Specifically:
Working with variables: the basics (http://americangirlscouts.org/agswiki/index.php/Scripting%2C_Code_%26_Interaction#Working_with_variables:_the_basics) (a slightly more 'advanced' way to do it) and GlobalInts, your friend: what they are and how to use them (http://americangirlscouts.org/agswiki/index.php/Scripting%2C_Code_%26_Interaction#GlobalInts.2C_your_friend:_what_they_are_and_how_to_use_them) (this is pretty much what Strange Visitor said, but with a bit more detail).