Wandering Character

Started by Jodo Kast, Sun 16/11/2003 19:06:26

Previous topic - Next topic

Jodo Kast

This is probably beginner script but, how do I make a NPC wander around the screen?

I'm not sure how to do it with the walkable areas messing it up.  NPC walks off in one direction, randomly pauses.  

This will be a 'cleaning' character.

Thanks!

MrColossal

in the room's repeatedly execute:

if (character[NAMEOFCHAR].walking!=1){
MoveCharacter(NAMEOFCHAR, Random(320),Random(200));
}

that should do it yes no?
"This must be a good time to live in, since Eric bothers to stay here at all"-CJ also: ACHTUNG FRANZ!

Totoro

Quote from: MrColossal on Sun 16/11/2003 20:03:02
in the room's repeatedly execute:

if (character[NAMEOFCHAR].walking!=1){
MoveCharacter(NAMEOFCHAR, Random(320),Random(200));
}
that should do it yes no?
Would that mean the player character could do his actions while NAMEOFCHAR is sort of minding his business in the background?

MrColossal

yup, i've done it tons of times, it's quite neat

only thing is it's random, so they'll just walk around bumping into walls and heading off in the strange directions

so it's best for birds or cats or robots or maids

not trying to trick someone into thinking the character has an agenda
"This must be a good time to live in, since Eric bothers to stay here at all"-CJ also: ACHTUNG FRANZ!

CB..

#4
many thanks from me allso  ive been doing it with all this messy stuff!

if (IsTimerExpired(1)==1)
{int ran=Random(7);
if (ran==0) MoveCharacter(GDTWO,character[GDTWO].x-36,character[GDTWO].y);
else if (ran==1) MoveCharacter(GDTWO,character[GDTWO].x+34,character[GDTWO].y);
else if (ran==2) MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y-36);
else if (ran==3) MoveCharacter(GD,character[GD].x+34,character[GD].y);
else if (ran==4) MoveCharacter(GD,character[GD].x,character[GD].y-36);
else if (ran==5)MoveCharacter(GD,character[GD].x,character[GD].y+36);
else MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y+36);
SetTimer(1,200);
}  

then put this in enters room after fade in

SetTimer(1,200);

you saved me a lot of messing around !  

great source this forum many thanks all!

Jodo Kast

Thank you!  I think I can make this a function then and tell a character to wander after each conversation is over.

It should also work with a group of insects I wanted swarming above the swamp!  Thanks again!

SMF spam blocked by CleanTalk