make an off-screen character come on-screen

Started by , Wed 29/10/2003 10:08:01

Previous topic - Next topic

urgrue

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.

CB..

#1
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

urgrue

groovy, that's what i was looking for, thanks.

Timosity

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

CB..

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)

DoorKnobHandle

Press F1 in AGS and search for STopFollowCharacter!

There is one!

Hope this helps!

SSH

No there isn't!

FollowCharacter(BIRD, -1);

will stop them following anyone
12

DoorKnobHandle

Ups!

You could also us this if you want to:

Code: ags


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!

Meowster

#8
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...

DoorKnobHandle

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!

DoorKnobHandle

Also this one is quite interesting and useful:

Code: ags


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!)

Scorpiorus

#11
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

CB..

#12
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!

CB..

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

SMF spam blocked by CleanTalk