Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: jamesreg on Sun 27/09/2009 23:36:25

Title: setting flags to not allow an event to happen till another event happens
Post by: jamesreg on Sun 27/09/2009 23:36:25
I need my characters to goto a room

once on that room I need to do the following things

have the characters try to talk to a npc character
interact an inventory object on him
interact a second inventory object on him
talk to him a second time

i need all of these conditions meet before the player will be allowed to leave back out of the room.

I kinda understand the principle behind this im sure I have to set some kind of global variable and tell the room script to check
and see if these conditions have been meet

but im still way to new to all this to understand exactly what I need to do cause i know its a two or three step process

can anyone help with this
Title: Re: setting flags to not allow an event to happen till another event happens
Post by: tzachs on Sun 27/09/2009 23:57:24
Create 4 global variables, all of them boolean and with default values false. Name them appropriately, for instance: FirstTalkToNPC, SecondTalkToNPC, FirstItemOnNPC, SecondItemOnNPC.

In the character talk script write:

if (!FirstTalkToNPC)
{
   //First talk to character here
   FirstTalkToNPC = true;
}
else if (!SecondTalkToNPC)
{
   //Second talk to character here
  SecondTalkToNPC = true;
}
else
{
  //Third talk and beyond here
}


In the interact item on character script write:

if (player.ActiveInventory == iFirstItem)
{
   //First item interaction here
   FirstItemOnNPC = true;
}
else if (player.ActiveInventory == iSecondItem)
{
  //Second item interaction here
  SecondItemOnNPC = true;
}


and in the part of the code that the player should change the room write:

if (FirstTalkToNPC && SecondTalkToNPC && FirstItemOnNPC && SecondItemOnNPC)
{
  player.ChangeRoom(x);
}
else
{
  player.Say("I can't leave the room yet...");
}
Title: Re: setting flags to not allow an event to happen till another event happens
Post by: jamesreg on Mon 28/09/2009 13:11:48
thanks that worked