Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Bender86 on Wed 05/05/2004 19:19:49

Title: Getting a non-player character to follow you into a new room
Post by: Bender86 on Wed 05/05/2004 19:19:49
At this point in the game, there are 2 characters available to control. When one character enters a certain room, I need the one which isn't being currently controlled to also enter that room. I tried using:

if (GetPlayerCharacter()==2) {
   character[0].room =6;
   NewRoomEx(6,75,162);
   } 
else if (GetPlayerCharacter()==0) {
   character[2].room =6; 
   NewRoomEx(6,75,162);
   } 
}

In the rooms 'player enters screen (before fadein) script. This produced a black screen. I then tried it in the 'player enters screen' script, which made the room flash between black and normal...kinda crazy...:P The character however was not to be seen. I'd appreciate some help on this one, thanx ^_^
Title: Re: Getting a non-player character to follow you into a new room
Post by: Ishmael on Wed 05/05/2004 19:34:59
See FollowCharacter and FollowCharacterEx commands in the manual, they might help you.
Title: Re: Getting a non-player character to follow you into a new room
Post by: stuh505 on Thu 06/05/2004 01:31:01
1) You are trying to use character[CHAR].room as a function to change the character's room.  This is only a variable that records what room the character is in...changing it won't actually move the character.  You are also using this function incorrectly; you need to put the character's script name in the brackets.

2) if you set follow, they will follow through room transitions.  this could work for your situation.  I am also curious if there is a way to directly move a non-player character from one room to another

3) Why do you have the same line (NewRoomEx) repeated in both conditional statements?  It could be written only once
Title: Re: Getting a non-player character to follow you into a new room
Post by: Gilbert on Thu 06/05/2004 02:40:40
1) Actually changing that character[...].room variable is a valid way of moving a non-player character to another room (use NewRoom(Ex)() for player character to ensure the room change), and refering to a character with number is okay also, though using the script names is a cleaner and better way for it (in case the numbers are changed for some reasons).
2) Just alter the character[...].room variable

Bender:
Actually I don't quite understand why you'd put this in "character enters screen (whatever)" interactions, as it's strange that you want a room change immediately after entering a room, UNLESS that part of script is put in room 6 itself (which I had guessed).
In that case the problem was with your NewRoomEx() lines, as you put them in "character enters screen (whatever)", it will go on an infinite loop of re-entering forever. If you're already in room 6 you don't need the NewRoomEx() lines anymore, so comment/delete these troublesome lines:

if (GetPlayerCharacter()==2) {
Ã,  Ã, character[0].room =6;
Ã,  // NewRoomEx(6,75,162);
Ã,  Ã, }Ã, 
else if (GetPlayerCharacter()==0) {
Ã,  Ã, character[2].room =6;Ã, 
Ã,  // NewRoomEx(6,75,162);
Ã,  Ã, }Ã, 
}
Title: Re: Getting a non-player character to follow you into a new room
Post by: Bender86 on Fri 07/05/2004 13:02:46
Thanx guys ^_^ The follow character command works just fine and..as for those new room comands in my script..god knows why they were there. I think I forgot to delete em after a copy n paste.  Anyways..thanx for the help, its all workin dandy now.