Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Sinister on Sat 13/03/2004 19:13:38

Title: NPC's walking around.
Post by: Sinister on Sat 13/03/2004 19:13:38
i've made a street in my game, but i want to make some random people walk on it.
Like in (pleurghburg or kq2 remake plaza).

ive already made the NPC characters, but how would i go about doing this scriptwise.?

any ideas? :P
Title: Re:NPC's walking around.
Post by: Ginny on Sat 13/03/2004 22:15:16
I've never experimented with the MoveCharacterPath function, but that should work for this, I believe.
Set up the character's start room and coordinates, and put each point in the path you want him to take, like it says in the manual:

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

I think that should work.
Title: Re:NPC's walking around.
Post by: piraatlife4me on Sat 13/03/2004 23:35:42
Hey Sinister,
You could use movecharacter but that would pause the script everytime the npc character moves. If I was you I would consider using the AGS character control plugin. You can get it off the AGS site and it rules. This will allow the npc's to move in the background with out stopping the game. I think this would help you out.

Daniel
Winebarger
Title: Re:NPC's walking around.
Post by: Sinister on Sun 14/03/2004 04:26:15
yeah i've used the movecharacter command and it does pauses the game, so that wont work.

If i need the pluggin then ill get it, but i still need technical help on how to use it.

so, what do i do next.


---EDIT A FEW MINUTES LATER---

I couldnt find the pluggin. I went to the download, pluggins section but the link isnt working for the CCS, pluggin.

how do i get it?
Title: Re:NPC's walking around.
Post by: Scummbuddy on Sun 14/03/2004 06:05:11
Good point brought up here. The 'check website' that is available only sends you to an old post right here on the forums, thats seems to have fallen off the edge of the boards.
Plus the link doesn't seem to be working either. I should have downloaded it when I had the chance.
Title: Re:NPC's walking around.
Post by: on Sun 14/03/2004 06:50:57
yea...id love this plug in also
Title: Re:NPC's walking around.
Post by: Minimi on Sun 14/03/2004 08:57:30
Yeah, that's exactly  what I need for my game, that plugin! Where is it? I ran into some difficulties too, with NPC :'(
Title: Re:NPC's walking around.
Post by: foz on Sun 14/03/2004 11:57:38
The character control plug`in has all the commands explained in the help file that comes with it.....it excellent and easy to use...
Title: Re:NPC's walking around.
Post by: Paper Carnival on Sun 14/03/2004 12:44:12
Then who has it? Could somebody host it? I think I'd need it as well!
Title: Re:NPC's walking around.
Post by: foz on Sun 14/03/2004 14:07:55
get the files from here:-



http://www.adventuregamestudio.co.uk/games.php?action=search&sterm=Scorpiorus&submit=Search%21


Plugin made by Scorpiorus
Title: Re:NPC's walking around.
Post by: Ginny on Sun 14/03/2004 14:13:30
That's odd, I thought at first that there would be trouble with this, because MoveCharacter would pause the script, but as far as it says in the manual, it doesn't, and instead of the MoveCharacterBackground function (which I must have imagined) there is MoveCharacterBlocking.

QuoteMoveCharacter (CHARID, int x, int y)

Starts the character CHARID moving from its current location to X,Y. CHARID can be either the character's number (as GetPlayerCharacter returns) or its ID set in the Room Editor. If the character cannot get to X,Y it will be moved as close as possible.
Control returns to the script immediately. The character will move in the background.

It's possible though that MoveCharacterPath is blocking... It also ignores walkable areas, which can be a problem. Maybe a parameter to determine wether it's blocking or not and wether it's direct?
Title: Re:NPC's walking around.
Post by: on Sun 14/03/2004 22:56:14
hmm...another dead link...anyone wanna email it to me?

parkercase@aol.com

thanks!

-p
Title: Re:NPC's walking around.
Post by: Sinister on Mon 15/03/2004 02:48:32
Yeah another dead link, i would rather try and contact scorpiorus to see if he can get it, but i dont know his email.

so if anyone knows how to contact him that'be good!

anyhow, back on the subject yeah the movecharacter command doesnt pause the game if you dont include the (wait till finish thingy... i dont remember exactly what the command is)..

so you could make various NPCs move at the same time, but the point would have to be to run a looping program, that allows NPCs walk across the screen forever without (1- slowing the game to much, 2-crash the game, or 3-make the game stuck cause of running a endless loop.)

so, thats why i wanted to know if script-wise theres a way to do this, if not we'll need the pluggin.
Title: Re:NPC's walking around.
Post by: Ginny on Mon 15/03/2004 12:52:20
I think there should be a way to do this with scripting, but anyway, while browsing my ags folder, I found that I have the character control system plugin.
I can send it, but I'm sure I downloaded it not too long ago, I just need to find where...
Title: Re:NPC's walking around.
Post by: on Tue 16/03/2004 03:21:19
hey ginny...yea if you could upload it somehow... ill take it through email thanks!

-p
Title: Re:NPC's walking around.
Post by: LordHart on Tue 16/03/2004 03:40:41
www.freewebs.com/skimbleshanks/plugin.htm

That site has it but it is down at the moment. When I get home, I'll put the file up somewhere for you guys and post back here later... :)

That site also has a fair few other plugins as well... in fact, I believe all of them.

edit: That is... if my brother isn't on the net. >:(
Title: Re:NPC's walking around.
Post by: TerranRich on Tue 16/03/2004 05:34:07
Don't know if this'll be of any help, but RickJ is a master of scripting (just like a-v-o and Scorpiorus), and he gave me this tidbit of code a year ago, for By the Sword...




Code for random walk-by's in background of room. (RickJ, 2.22.03, 2:09am)

Rich, you may want to try something like the example below.
You would have MAX_CHARACTERS number of characters that could be on the screen at any one time.  For each character youn would randomly select a view, walking speed, walking direction, and delay before that character would start walking again.  

The constant DUMMY_CHARS is used to map the index varable i to the correct range of characters you have designated for this purpose.

If you need more help on this just ask.

[size=+0]
int personState[MAX_CHARACTERS]; // static declaration outside function def
// valid states: 0=READY, -1=LEFT, -2=RIGHT, >0=Delay time      

int i=0;
while (i<MAX_CHARACTERS) {
 if (personState==READY) {            // start next move
   SetRandomCharView(i+DUMMY_CHARS);      
   SetRandomCharSpeed(i+DUMMY_CHARS);      
   personState = MoveRandomDirection(i+DUMMY_CHARS);
 }
 else if (person<READY) {        // already moving
   if (character[i+DUMMY_CHARS].walking==0)  {
     personState=GetRandomDelay();
   }
 }
 else {                                      // waiting
   personState--;
 }
i++;                 // I'm assuming this should be added in, to cycle through all i's
}
[/size]


The rest is by yours truly. Perhaps you can find these notes to myself useful somehow...

All I need to do is create a MoveRandomDirection(int charid) function that places the character beyond the left/right edge of the room, then makes the character walk right/left to beyond opposite edge of room.

GetRandomDelay() returns a random number of game cycles to wait until random person walks by again. Could be, say, between 5 and 20 seconds. (200 and 8000 cycles if 40cyc/sec)

Even more advanced: upon entering room, having characters starting in mid-path, maybe between 0 and 3 already walking left/right to beyond screen edge. Could be 40% chance for 0, 20% chance for each of 1,2,3.

personState-- will decrease the delay setting every cycle, in order to eventually elapse the customized timer.




Does that help at all? :)
Title: Re:NPC's walking around.
Post by: on Wed 17/03/2004 19:22:18
Okay, here is what you could do for people walking around:

Set a timer for about 10 seconds, every time the timer expires run this code (this code is for only one character moving around):

MoveCharacterBlocking(SOMEGUY,random(x coodinates of characters walking area),random(y coodinates of characters walking area);
SetTimer(timer#,loops that equal 10 seconds);


That should work, you have to add MoveCharacterBlocking functions for the other characters as well.  Tell me if it doesn't work though.
Title: Re:NPC's walking around.
Post by: on Wed 17/03/2004 19:24:43
Sorry that should be:

(Max x coodinates for character's walking area)

and

(Max y coodinates for character's walking area)
Title: Re:NPC's walking around.
Post by: Sinister on Wed 17/03/2004 19:50:16
hmmm....

alright maybe thats a little too complicated for me. :P

After all im still a newbie. So how about this,

first only get one NPC on the edge of the screen, make
him walk to the end of the screen, stop, set transparency to 100
and wait maybe 10 seconds, change view, face new direction, set
transparency to 0. then walk the NPC to the starting walk point,
then set transparency to 100.

im  my mind, this should look like, one NPC walking to the edge
of the screen and walking off, then 10 seconds later a new
NPC walks in, goes the way back, and walks off the screen.

then repeat in endless loops.

however no two npc's on the screen. at the same time, the question
being really.

how do i run this script, without stopping the gameplay?.
Title: Re:NPC's walking around.
Post by: CB.. on Thu 18/03/2004 12:00:13
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));}
Title: Re:NPC's walking around.
Post by: Sinister on Mon 22/03/2004 02:34:52
So, where would i put this script?..

in the enter screen (after fade in)?
Title: Re:NPC's walking around.
Post by: Radiant on Mon 22/03/2004 14:43:16
repeatedly_execute (_always)
Title: Re:NPC's walking around.
Post by: Sinister on Tue 23/03/2004 04:33:14
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.
Title: Re:NPC's walking around.
Post by: Sinister on Wed 31/03/2004 01:31:14
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.
Title: Re:NPC's walking around.
Post by: on Wed 31/03/2004 02:35:01
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.
Title: Re:NPC's walking around.
Post by: Akumayo on Fri 02/04/2004 01:54:40
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);