NPC Wandering AI

Games like Skyrim, Harvest Moon and Animal Crossing house this system where an NPC has a "mind of its own" traveling between maps at random... I've been thinking about this... is this possible? if so how would one go about coding this, I was thinking about coding this to be similar to coding a pathfinder, how much effort would this require, would you use it in your game?
Could be done using variables and regular event commands. 😉
Yes of course but not really, as I want the NPC to walk to each destination, besides that'd be incredibly tedious for every map.
I would use an A* search algorithm (or something similar) for something like this if you wanted to get fancy with it. You would have to account for passage settings of tiles/events and have the algorithm plot a path to a point that it makes based off those passage settings.  It's something that I haven't yet looked to much into so I don't how difficult it would be; but yea it would be something I would use especially if I could customize it for each event.

Edit: had copied the wrong link 😛
I've been looking into this as well, but at the end of the day I realized that I just don't have the time given the IGMC's 30 day requirement.

That said Nick had a shot at recreating the Skyrim system in his ''Living Town'' series, there is a blog dedicated to them - http://blog.rpgmakerweb.com/?s=Living+Town Seems pretty well implemented in my opinion and since you have scripting knowledge you'll probably be able to build upon it and maybe implement some AI or something 😉

Anyway, it should be a good enough start, I was stuck too until I realized that making everything happen on the same map makes everything SO much easier.
If you want to customize each NPC to have it's own set of movements/behavior, it would be tedious no matter how you do it. The only way it won't be tedious is if you only have a general AI behavior which all be used by all.
If you want to customize each NPC to have it's own set of movements/behavior, it would be tedious no matter how you do it. The only way it won't be tedious is if you only have a general AI behavior which all be used by all.
Not necessarily, as I was planning setting it up as NPC Class e.g.

Merchants have their own AI

Citizens have their own AI

Enemies have their own AI

Quest NPCs have their own AI
Yeah we have classes of AIs but does that mean that all NPCs within a class will have exactly the same AI? Like all Citizens would use the same AI? That would be really boring so you'd still need to make sure they're still different somehow. To make a class AI system like that while ensuring that each individual NPC of that class still retains it's personality will still be tedious.
They all would not do the same thing as the action they perform will be randomized, Like this

A citizen tasks would be:

  1. Explore the town
  2. Go into the bar
  3. Go into the inn
  4. Go to the lake
  5. Go fishing
  6. Eat
  7. Sit
All the citizens will have the ability to perform these tasks however When they do it will be randomized where they do it will be randomized

One NPC might be going to into the bar whilst the other into the lake.
Then you'd need to use a pathfinding algorithm like Sarlecc suggested (A* seems to be the favorite for this) to at least make them go to those places. There are some path finding scripts out there AFAIK. Then you would just need to make each case for those and make the NPCs use them
Yeah, I know, I've already began on this ;] Will update if and when I make signifcant progress
Good luck, it's always good to see games that feel more alive.
If I were doing this, I'd focus more on the NPCs than the pathfinding.  I'd come up with "motives" for an NPC and determine, based on whatever, "where does this NPC want to go right now?" and I'd put most of my effort into making these decisions rich and intuitive rather than spending that time on pathfinding.

Once I have the destination in mind, I'd have the game take note of which map they will be on as they traverse from their start point to their destination map, so that the player could "run into them" on the way.

But as far as the pathfinding, I'd use a real basic system like I did for automated player movement in timeblazer: set movement loops to keep moving (for example) up or down (based on their start point) until the character reaches y == 8, then right until they reach x == 30 (the map's exit).  Where there are maps with concave features (such as a courtyard with 3 walls) this basic form won't work as well but you can get around that by using different loops (such as one where they move up until y == 12, then right until x == 16, then up again until y == 8, then right again until x == 30) based on their initial start point on the map.

In a large world where NPCs can literally go from anywhere to anywhere else, this approach would be inefficient for the designer's time (though still very efficient from a computing resource standpoint), and you might want to turn to developing true search algorithms for pathfinding like suggested.

But you'd still need to do all of the setup necessary to determine where each NPC wants to go in the first place.

Also, I'm pretty sure there are some scripts out there that create "smart" routes for events/NPCs/the player to move from Point A to Point B on a single map.  So as long as you're tracking behind the scenes which maps the NPC should be moving toward, you can probably just plug in one of these scripts, set the appropriate map exit as the destination, and continue from there.
You might want to have a look at this for interesting and more 'natural' walking around on your map, as well as getting the NPC accurately to the exit.
Oh! That looks excellent, add that to the list of things to buy next paycheck.
It's definitely worth it, imo.
Yeah we have classes of AIs but does that mean that all NPCs within a class will have exactly the same AI? Like all Citizens would use the same AI? That would be really boring so you'd still need to make sure they're still different somehow. To make a class AI system like that while ensuring that each individual NPC of that class still retains it's personality will still be tedious.
That is usually handled by weighing different priorities, give separate timings and set them on different paths.

Same AI, different variables feeding it.
Touchfuzzy is doing the same thing and has a tutorial on it. Look for the living town series. He even has a demo of it implemented
pathfinding was actually the idea for my Emoji Engine where I usually auto_setup my AI in the script directly  but pathfinding is something somewhat hard to works on but it's worth the shot if this well made.

for myself I was plan to left the event almost not having any contents

it's was just calling a setup who call dialogues, reactions dependings of times 

but this made in scripts and contrary on my Emoji Engine Ace -Origine "AI Core" this not simple to use and require high knowledge in algorithm (what's I don't even have lol but I works hard )

in simple I if I was ever release that for publics that's would be complicate to use or to explain so for this shot I will maybe just left this part non-public

but anyways when it's come to pathfinding it's a pain in the ass lol but good luck!

Original thread: https://forums.rpgmakerweb.com/threads/npc-wandering-ai.42138/