NPC Wandering AI

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
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?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
Could be done using variables and regular event commands. ;)
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
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.
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
453
Reaction score
211
First Language
English
Primarily Uses
RMMV
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 :p
 
Last edited by a moderator:

CrazyCrab

Veteran
Veteran
Joined
Mar 5, 2014
Messages
950
Reaction score
403
First Language
Polish
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.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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.
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
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
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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.
 
Last edited by a moderator:

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
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.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Yeah, I know, I've already began on this ;] Will update if and when I make signifcant progress
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Good luck, it's always good to see games that feel more alive.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,635
Reaction score
5,116
First Language
English
Primarily Uses
RMVXA
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.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
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.
 
Last edited by a moderator:

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Oh! That looks excellent, add that to the list of things to buy next paycheck.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
It's definitely worth it, imo.
 

SamJones

Autorun
Veteran
Joined
Jul 12, 2015
Messages
113
Reaction score
47
First Language
English
Primarily Uses
RMMV
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.
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,924
Reaction score
535
First Language
English
Primarily Uses
N/A
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
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,035
Messages
1,018,459
Members
137,821
Latest member
Capterson
Top