How to make wandering peoples.

Started by , Mon 10/10/2005 17:56:39

Previous topic - Next topic

Fribbi AGDI joker

I don't know if this question has ben asked before but I am having problem letting NPC walking wandering peoples and cars appear randomly on screen.

Remember when you played King Quest 2 or Quest for glory 2 games but there was a wandering peoples who walked there on street and appeared there randomly.  Sometime there was no people on the street and sometimes there was two or three wandering people on street who was just browsing on the street.

I just want to know how that is done or what is the code for that thanks.


monkey0506

#1
Well...the code would have to be specific to your game I suppose, but if you could set up some sort of integer within the room to store the number of possible entrances/exits to/from the room, then perhaps you could set them up to appear at a random entrance, then walk to a random exit that isn't where they came in at?

I'm thinking something along the lines of:

Code: ags
// room script file
readonly int maxexits = 5;
readonly int maxchars = GetGameParameter(GP_NUMCHARACTERS, 0, 0, 0);

// room rep_ex
int enter = Random(maxexits - 1);
int exit = enter;
while (exit == enter) exit = Random(maxexits - 1);
Character* ranchar = character[Random(maxchars - 1)];
while (ranchar.Visible) ranchar = character[Random(maxchars - 1)];
ranchar.StopMoving();
ranchar.Visible = true;
ranchar.Walk(hotspot[exit].WalkToX, hotspot[exit].WalkToY, eBlock);
ranchar.Visible = false;


This code isn't tested...and you can't just copy & paste it...but hopefully it will get you thinking in the right direction.  And the fact that it's blocking.  But I'm too tired to work it out properly right now.

Ashen

If you haven't already, you might also want to check out the CharacterControl Module (or the original plugin, linked in that thread). Depending on how complicated you want the 'wanderings' to be, it might give you better control.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk