Timed Guard Sequence

Started by FinalSin, Tue 10/08/2004 18:35:57

Previous topic - Next topic

FinalSin

Before you begin, please note that I am pretty sure this is a problem for this forum, and I have been unable to find another topic or a solution in the knowledge base because I simply don't know where to even start.

Here is what my designer wants:
you walk into a room. let's call it room 1. On the far side there is a door and it has a slit in it.
Objectives - Pass through room 2 into room 3.
Options - Option A) Walk into Room 2 straight away. There is a guard in the room and a conversation is kicked off (I can handle it from there).
Option B) LOOK through slit in door. Move to Room X where you view the guard (nice and simple, just a background i guess) then come back out. EGO makes a comment on there being a guard.
If you now enter the room the guard is not there. Apart from the obvious design gap that the guard walks away as soon as you look at it, how am I going to do this? Is it possible to do it with variables, or do i need to use timers, for instance ten seconds after finishing looking through the slit.

I'm sure its too simple to post here, and I apologise. Please help if possible.

FS
The Blue Casket

Ben

Well, you'll need to use a Global Integer.

In room 1, just choose a new global variable that you haven't used yet (I'll use 40) and set its value to 0:

SetGlobalInt(40,0);

A value of 0 will mean that the guard is there.

When the player looks in room X and the guard walks away, set the value to 1.

SetGlobalInt(40,1);

A value of 1 will mean that the guard is gone.

Now, in Room 2, you'll need to check whether or not the guard is there. To do this, just find the value of your global int and script and IF statement to react:

Code: ags

if(GetGlobalInt(40)==0) { //Guard is there
  RunDialog(...);
 ...
}

if(GetGlobalInt(40)==1)  //Guard is gone
  //Do nothing, unless you want the player character to say something..
}

Pumaman

Also, you can remove the guard from the room by just doing:

characters[GUARD].room = -1;

SMF spam blocked by CleanTalk