Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Takkar Tekekak on Thu 21/10/2004 16:24:46

Title: Moving an NPC to a specific co-ordinate in a room
Post by: Takkar Tekekak on Thu 21/10/2004 16:24:46
i'm making my first AGS game and i'm kinda stuck at this situation:

After you pick up a piece of paper, room6 can be entered, you gain 30 points,Ã,  gloabal variable 2 now =5 and "EGO" moves to room 6 c0 ordinates 132, 46.

Thats not exactly right but its the generall situation, I can command it so that my character enters room 6, but he appear in the center of the room, no matter what i can't move him either, and using the "move character to co-ordiantes" says "error- character is not in room" (i tried putting thease in either order to no affect)

so the 2 commands
Character - move NPC to different room, and
Character - move to specific co-ordinates.

don't seem to work, is there anothe obvious command i'm missing here? (the character i'm trying to move isn't my player character either.)
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: Barbarian on Thu 21/10/2004 16:39:23
Not sure I follow what you're trying to ask, but to move an NPC character to a different room and at specific co-ordinates, from within a "Script" you might add the commnds that look like:

character[NPC_NAME_HERE].room = 3;
character[NPC_NAME_HERE].x=(157);
character[NPC_NAME_HERE].y=(34);Ã,  Ã, 


Would place the character "NPC_NAME_HERE" (use whatever script name you've given that character of course), in room 3 at x posistion of 157 and y posistion of 34.Ã,  Ã, This is just an example.

If moving your player character, be sure the location in the room is on a Walkable area. And you can use the command editor and select "Player - Go to a room (at specific co-ordinates)", or alternatively you could use it with scripting commands, here's a cut and paste from the AGS Help Manual:

"NewRoomEx (int room_number, int x, int y)

Identical to NewRoom, except that the player character is placed at co-ordinates (X,Y) in the new room.
Example:

NewRoomEx(4,100,50);

will move the player character to room 4 and also place him at coordinates 100,50."
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: Takkar Tekekak on Thu 21/10/2004 17:05:21
fixed! thanks alot!
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: strazer on Thu 21/10/2004 18:07:28
And AGS v2.62 will have the NewRoomNPC command, similar to NewRoomEx. It's already available in the beta version (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=15375.0).
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: Takkar Tekekak on Thu 21/10/2004 22:44:58
I'm downloading the file now.

Thanks guys!
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: BorisZ on Thu 21/10/2004 22:52:12
Quote from: strazer on Thu 21/10/2004 18:07:28
And AGS v2.62 will have the NewRoomNPC command, similar to NewRoomEx. It's already available in the beta version (http://www.agsforums.com/yabb/index.php?topic=15375.0).

What additional features does this command have? New room coordinates?
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: strazer on Thu 21/10/2004 23:05:00
NewRoomNPC(CHARID, int room_number, int x, int y)

Moves a non-player character to a different room. Character CHARID is moved into ROOM_NUMBER at co-ordinates (X, Y).
To move the player character to another room, use NewRoom or NewRoomEx.

Example:

NewRoomNPC(BOB, 4, 100, 50);

will move the character BOB to room 4 and place him at coordinates 100,50.
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: on Tue 05/09/2006 19:15:14
I'm trying to do the same thing but with the interactions editor, by doing Character move NPC to a different room and then Character: move character. I get the same error happening as mentioned above, with a message saying that the character is not in the room and the game crashes. How can you put an NPC at a specific place without using script?
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: Ashen on Tue 05/09/2006 19:30:00
Can you post the EXACT interactions you're using, and the EXACT error message you get? This threads is nearly 2 years old, and refers to AGS several versions ago.
Are you tring to more the NPC to a new rooms and new coords? If so, it might be quicker and easier to use scripting - the Character.ChangeRoom (http://www.adventuregamestudio.co.uk/manual/Character.ChangeRoom.htm) f function allows you to do this (replaces the functions strazer mentioned).
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: Khris on Tue 05/09/2006 20:26:29
Carrie: As soon as you've moved the NPC to another room, you can't change its coordinates any longer, because the NPC isn't in the current room. That's why you get this error message.
Please learn how to script, it really pays off and you don't have to struggle with basic things like this anymore.
Title: Re: Moving an NPC to a specific co-ordinate in a room
Post by: Candle on Tue 05/09/2006 20:50:47
CharacterControl script module for AGS v2.71.

Features:

* NPCs can walk around in other rooms, talk, animate etc. _in the background_
* Compatible with CCS plugin command strings
(That may change at any time so you're encouraged to use this module's commands.)

Advantages to the CCS plugin:

+ Cross-platform compatibility
+ Additional and extended, more flexible control commands
+ No need for a dedicated blank view
+ Extensible & customizable
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=24489.0