Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Wed 29/10/2003 10:08:01

Title: make an off-screen character come on-screen
Post by: on Wed 29/10/2003 10:08:01
this is prolly a really major noobie question, but all the MoveCharacter functions seem to only work on characters that are on-screen. how can i bring a character from limbo (room -1) into a certain room?
like say, ego blows a whistle, and i want a bird to fly in.

currently i did it by making the character on-screen but invisible and unclickable, then trigger him visible and clickable in a script. but that is just so kludgey im embarassed to even admit it. plus, he pops up out of nowhere, instead of smoothly walking into the screen.
Title: Re:make an off-screen character come on-screen
Post by: CB.. on Wed 29/10/2003 12:25:07
you could experiment with the

interaction

run script  

FollowCharacterEx(BIRD,EGO,0,80);

this i think will bring the bird in from room -1

or place the bird in room -1 right at the edge of the screen then use the
move NPC to a different room
and it should appear in the desired room at the same co-ordinates yu set for room -1

then use

run script

MoveCharacter (BIRD, 160, 100);
MoveCharacterPath (BIRD, 50, 150);
MoveCharacterPath (BIRD, 50, 50);  
MoveCharacterPath (BIRD, 50, 150);
MoveCharacterPath (BIRD, 50, 50);
MoveCharacterPath (BIRD, 50, 150);


to have the bird fly where yu want him to..

the 50,150 are the mouse co-ordinates in the room
Title: Re:make an off-screen character come on-screen
Post by: on Wed 29/10/2003 12:33:29
groovy, that's what i was looking for, thanks.
Title: Re:make an off-screen character come on-screen
Post by: Timosity on Wed 29/10/2003 13:37:38
to bring in a character not in current room you can use this

character[BIRD].room=5;

will bring BIRD into room 5

you can also set the coordinates you want with

character[BIRD].x=50;
character[BIRD].y=150;

just another way
Title: Re:make an off-screen character come on-screen
Post by: CB.. on Wed 29/10/2003 15:03:04
Nice one T
i knew there was a better way..
whilst were here tho
can yu answer a question for me

is there a

StopFollowCharacter option ?

for the life of me i can't find it anywhere (tho im sure i've seen it)
Title: Re:make an off-screen character come on-screen
Post by: DoorKnobHandle on Wed 29/10/2003 16:19:57
Press F1 in AGS and search for STopFollowCharacter!

There is one!

Hope this helps!
Title: Re:make an off-screen character come on-screen
Post by: SSH on Wed 29/10/2003 16:48:39
No there isn't!

FollowCharacter(BIRD, -1);

will stop them following anyone
Title: Re:make an off-screen character come on-screen
Post by: DoorKnobHandle on Wed 29/10/2003 16:52:00
Ups!

You could also us this if you want to:



function StopFollowingCharacter (CHAR_ID FollowingChar)
{
    FollowCharacter (FollowingChar, -1);
}



This would work, but would also be the most stupid thing you can do as long as you don't expect to use this command really often!
Title: Re:make an off-screen character come on-screen
Post by: Meowster on Wed 29/10/2003 19:02:31
Isn't

FollowCharacter(BIRD, -1);

A lot easier than all of that, Mama?


I think he wants to know what to do, and not what not to do.

I know you want to help, and that's good of you, but calm down...
Title: Re:make an off-screen character come on-screen
Post by: DoorKnobHandle on Wed 29/10/2003 19:15:51
Yeah!

But I sometimes think, that this -1 thingie is a little weird and so.

And I wanted to show how to add a "StopFollowingCharacter function"!


I use these in my games because I don't like these "FollowCharacter (EGO, -1);" functions!
Title: Re:make an off-screen character come on-screen
Post by: DoorKnobHandle on Wed 29/10/2003 19:19:34
Also this one is quite interesting and useful:



function NewCharPos (CHAR_ID Char, int x, int y, int room_num)
{
    character[Char].x = x;
    character[Char].y = y;
    character[Char].room = room_num;
}



Good to reset the whole position of a character in one line (not in three stupid ones!)
Title: Re:make an off-screen character come on-screen
Post by: Scorpiorus on Wed 29/10/2003 23:39:03
Yeah, making custom functions generally a good idea. ;)


Quotefunction NewCharPos (CHAR_ID Char, int x, int y, int room_num)
{
character[Char].x = x;
character[Char].y = y;
character[Char].room = room_num;
}

...but don't forget to check if it's player character and make sure he isn't moving:

function NewCharPos (int Char, int x, int y, int room_num) {
StopMoving(Char);

if (Char == GetPlayerCharacter()) NewRoomEx (room_number, x, y);
else {
character[Char].x = x;
character[Char].y = y;
character[Char].room = room_num;
}
}

~Cheers
Title: Re:make an off-screen character come on-screen
Post by: CB.. on Thu 30/10/2003 00:27:19
all brilliant stuff and duly noted down for study!


the

FollowCharacter(BIRD, -1);


sounds handy
i need to keep the NPC in the same room..

i'm trying to develop some basic AI behavuoir for  NPC's
in this case i have a guard who randomly patrols an area ,
and searchlights that do the same..if the player enters the beam of the moving searchligt then the guard starts chasing the player...(works well)
but in order for it to be satisfying and be usefull for other areas aswell i need a way to escape from the guard without the NPC or the player leaving room

ie if the player uses a stealth item
or enters a unlit area the guard no longer follows the player..or similar..

if

FollowCharacter(BIRD, -1);

does the trick without bouncing the NPC to room -1 (have i read that right?) then bingo!
im happy!
Title: Re:make an off-screen character come on-screen
Post by: CB.. on Thu 30/10/2003 12:39:37
Quote from: SSH on Wed 29/10/2003 16:48:39
No there isn't!

FollowCharacter(BIRD, -1);

will stop them following anyone


many thanks! that seems to do the job! ;D