NPC's walking around.

Started by Sinister, Sat 13/03/2004 19:13:38

Previous topic - Next topic

CB..

#20
theres a bit of a tutorial in the sticky technical archive ;
this works for me without blocking the game  and can be done for any number of characters in the background

///in as room loads///

SetTimer(2,200);

///in repeatedly execute///

if (IsTimerExpired(2)==1)
{int ran=Random(3);
if (ran==0) MoveCharacter(DD,character[DD].x,character[DD].y-70);
else if (ran==1) MoveCharacter(DD,character[DD].x,character[DD].y+70);
else if (ran==2) MoveCharacter(DD,character[DD].x+70,character[DD].y);
else MoveCharacter(DD,character[DD].x-70,character[DD].y);
SetTimer(2,200);
}    

///////

or just this for completely random movement..(in rep execute)

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

Sinister

So, where would i put this script?..

in the enter screen (after fade in)?

Radiant

repeatedly_execute (_always)

Sinister

Thanks,... im an idiot who didnt pay attention to the //// marks... :P

anyway, ill try it. Though i would like to get my hands on that plugin.

so a shout to anyone who has it.

Sinister

I tried the code... and i looks like an NPC walking around ramdomly, with about a second of a pause.

so i added a second NPC, they move at the same time. I changed the code so they dont move in the same dirrections, but how can i make them move on diferent times?..

i dont want them both move, then stop and start at the same time.

Candle

I believe this is the link you needed .
http://mega.ist.utl.pt/~fjds//download.html

This dynamic library is a collision detector for Adventure Game Studio (AGS for short). AGS is a great freeware program that allows you to create your own point-and-click adventure games, similar to the early 90's Sierra and Lucasarts adventures. This is a plugin, and cannot be used as a stand-alone utility.

Functions are provided to accomplish bounding-box sprite collision detection, and pixel-perfect sprite to pixel and sprite to sprite collision detection.

Collision detection can be performed between character/character, character/object, character/pixel, object/pixel and object/object.

Akumayo

As for the stopping and starting at the same time, set them to have different walking speed

ex:

in, When Player Enters Screen:

StopMoving(GUY);
StopMoving(SECGUY);
SetPlayerSpeed(GUY,5);
SetPlayerSpeed(SECGUY,3);
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk