Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ulysses31 on Sat 29/03/2008 00:32:58

Title: Charactor granting access to areas
Post by: ulysses31 on Sat 29/03/2008 00:32:58
Hi there Guys

This is the small problem i have.

I have a gate in my game. It is currently locked I want my character to talk to the guard and get him to open it. Can u guys help me with the scripting of this please.
Cheers
Title: Re: Charactor granting access to areas
Post by: Akatosh on Sat 29/03/2008 10:22:43
Well, that's rather simple. First of all, put this code into the "Interact with Door" section:


if (GetGlobalInt(1)==0) player.Say("I can't. It's locked."); //or something like that
else player.ChangeRoom(3); //whichever room you want the gate to lead to


You can use other global ints and values, too, but you get the idea.

Now, set up the dialog with the guard just as you would normally. In the option that leads to him unlocking the gate, you need the following.


ego: ... and that is why I need you to unlock the gate.
guard: I'm convinced!
run-script 1
option-off 5
return


Or probably more refined dialog and a different number (especially after option-off; it should be the number of the option that causes the guard to unlock the door); that's up to you. Now, in dialog_request:


if (parameter==1) {
//probably some sort of animation of the guard walking over to the door and unlocking it, but it's not needed
SetGlobalInt(1,1);
player.Say("Thanks!");}


And you're good to go.  :)
Title: Re: Charactor granting access to areas
Post by: SSH on Sat 29/03/2008 20:04:04
Can't you set global ints directly in dialog scripts without using the dialog request function?
Title: Re: Charactor granting access to areas
Post by: Akatosh on Sun 30/03/2008 10:20:02
Just looked it up in the manual and yes, you can use


set-globalint 1 1


too. Nice. Learned something today.
Title: Re: Charactor granting access to areas
Post by: ulysses31 on Sun 30/03/2008 16:10:12
Thank you so much for your help guys it works perfectly now cheers.