Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mats Berglinn on Mon 12/05/2003 15:36:47

Title: Make character turn around and move characters to other rooms
Post by: Mats Berglinn on Mon 12/05/2003 15:36:47
I wonder, how do you make characters face other directions when he is NOT talking to a person, like if you want a character to turn away from the screen or make it turn right or left. Also how do you move characters that is not Playable characters to move to other rooms?

Thanks in advice.
Title: Re:Make character turn around and move characters to other rooms
Post by: Jimi on Mon 12/05/2003 19:32:58
QuoteFaceLocation
FaceLocation (CHARID, int x, int y)

Similar to the FaceCharacter function, except that this faces the character to screen location (X,Y). This allows him to face not only other characters, but also objects and hotspots as well (you can get co-ordinates by watching the co-ordinates displayed in the Room Settings mode as you move the mouse over the room background).
Example:

FaceLocation(EGO,150,146);

will make the character face at the room location (150,146)
See Also: FaceCharacter

Title: Re:Make character turn around and move characters to other rooms
Post by: Ishmael on Mon 12/05/2003 19:36:04
To move a NPC ot another room, I see no other way than use:

character[CHARID].room = WantedRoom,

where you put the char script name or number instead of CHARID, and the room number instead of WantedRoom...
Title: Re:Make character turn around and move characters to other rooms
Post by: Mats Berglinn on Mon 12/05/2003 21:04:36
Thanks.
Title: Re:Make character turn around and move characters to other rooms
Post by: Mats Berglinn on Tue 13/05/2003 21:02:08
I have another question. How do I place characters that are not playable at specific coordinations when they get to new rooms (I believe that it should be written the script for when player character comes into the room before fadein)? Please give me an answer as quickly as possible because it's just this left before my very first game are really finished. Then I can release it.
Title: Re:Make character turn around and move characters to other rooms
Post by: on Tue 13/05/2003 23:11:55
character[CHARID].x
character[CHARID].y

Don't use these if the character is moving, by the way.
Title: Re:Make character turn around and move characters to other rooms
Post by: Mats Berglinn on Wed 14/05/2003 06:36:20
Uh... got any examples of who write that down in the script? Where should I place the number for the X and Y position?
Title: Re:Make character turn around and move characters to other rooms
Post by: scotch on Wed 14/05/2003 07:05:30
If you want a character called GWB to be placed at coordinates 204,56 then you put:

character[GBW].x = 204;
character[GBW].y = 56;

in the script.
Title: Re:Make character turn around and move characters to other rooms
Post by: TerranRich on Wed 14/05/2003 07:21:02
Also, check out NewRoomEx in the manual.
Title: Re:Make character turn around and move characters to other rooms
Post by: Gilbert on Wed 14/05/2003 07:22:50
But note that NewRoomEx() can only be used for the player character, you must tackle with the variables if you want to move an NPC.
Title: Re:Make character turn around and move characters to other rooms
Post by: Scorpiorus on Wed 14/05/2003 11:56:23
Having a special function to place the character may help to organize the code:


//Global script:
ChangeRoom(int CharId, int NewRoom, int X, int Y) {
 if (CharId == GetPlayerCharacter()) {
    NewRoomEx(NewRoom, X, Y);
 }
 else {
    StopMoving(CharID);
    character[CharID].room = NewRoom;
    character[CharID].x = X;
    character[CharID].y = Y;
 }
}


//Script header:
import function ChangeRoom(int CharId, int NewRoom, int X, int Y);



Now you can use the function this way (for example):
Inside some interaction event:
ChangeRoom(EGO, 4, 100, 160);
ChangeRoom(MAN, 5, 110, 200);

etc.

-Cheers
Title: Re:Make character turn around and move characters to other rooms
Post by: Ishmael on Wed 14/05/2003 13:54:31
import function ChangeRoom(int, int, int, int);

in the script header, I believe... :P
Title: Re:Make character turn around and move characters to other rooms
Post by: Scorpiorus on Wed 14/05/2003 14:31:35
actually it doesn't matter ;)
Title: Re:Make character turn around and move characters to other rooms
Post by: Ishmael on Wed 14/05/2003 16:19:15
Oh, ok...