NPC's walking around.

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

Previous topic - Next topic

Sinister

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

Ginny

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.
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

piraatlife4me

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

Sinister

#3
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?

Scummbuddy

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.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

billy

yea...id love this plug in also

Minimi

Yeah, that's exactly  what I need for my game, that plugin! Where is it? I ran into some difficulties too, with NPC :'(

foz

The character control plug`in has all the commands explained in the help file that comes with it.....it excellent and easy to use...

Paper Carnival

Then who has it? Could somebody host it? I think I'd need it as well!

foz

#9

Ginny

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?
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

thisisparker

hmm...another dead link...anyone wanna email it to me?

parkercase@aol.com

thanks!

-p

Sinister

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.

Ginny

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...
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

thisisparker

hey ginny...yea if you could upload it somehow... ill take it through email thanks!

-p

LordHart

#15
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. >:(

TerranRich

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? :)
Status: Trying to come up with some ideas...

Akumayo who can't login

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.

Akumayo who can't login

Sorry that should be:

(Max x coodinates for character's walking area)

and

(Max y coodinates for character's walking area)

Sinister

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?.

SMF spam blocked by CleanTalk