Charactor granting access to areas

Started by ulysses31, Sat 29/03/2008 00:32:58

Previous topic - Next topic

ulysses31

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

Akatosh

Well, that's rather simple. First of all, put this code into the "Interact with Door" section:

Code: ags

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.

Code: ags

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:

Code: ags

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.  :)

SSH

Can't you set global ints directly in dialog scripts without using the dialog request function?
12

Akatosh

Just looked it up in the manual and yes, you can use

Code: ags

set-globalint 1 1


too. Nice. Learned something today.

ulysses31

Thank you so much for your help guys it works perfectly now cheers.

SMF spam blocked by CleanTalk