Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Blondbraid on Tue 02/06/2015 19:43:34

Title: how to determine if a character is in the room
Post by: Blondbraid on Tue 02/06/2015 19:43:34
How can I use the script to make an interaction play out differently depending on weather a certain npc is in the room?
Long story short, if the player clicks on a door while the character is in the room they will not allow the player to use the door,
but if the character isn't in the room, the player can use the door. I have everything else worked out, except which script command
to use in order to determine whether the npc is in the room.
Title: Re: how to determine if a character is in the room
Post by: Snarky on Tue 02/06/2015 19:54:46
It's one of those things that is mystifying until you see it, and then it's obvious:

Code (ags) Select
if(cCharacter.Room == player.Room)
{
  // Do stuff
}


(Assuming the NPC in question is called cCharacter)
Title: Re: how to determine if a character is in the room
Post by: Blondbraid on Tue 02/06/2015 20:53:16
I tried it, and it worked.
Many thanks for your help!