setting flags to not allow an event to happen till another event happens

Started by jamesreg, Sun 27/09/2009 23:36:25

Previous topic - Next topic

jamesreg

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

tzachs

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:
Code: ags

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:
Code: ags

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:
Code: ags

if (FirstTalkToNPC && SecondTalkToNPC && FirstItemOnNPC && SecondItemOnNPC)
{
  player.ChangeRoom(x);
}
else
{
  player.Say("I can't leave the room yet...");
}

jamesreg

thanks that worked

SMF spam blocked by CleanTalk