In my game I have characters that you can spawn in and take care of, feed, pet, sell, etc. But I want to go ahead and add a opportunity for a random NPC to interact with another, whether it be good or bad behaviors, or to interact with events that act as toys of sorts. Maybe even ways to tell npcs that what they did was bad or good. I understand it may be a bit complex but i really want to try it, AND NO, I am not asking for someone to make it for me, I am looking for help or guidance, since theres not alot of info out there that i can find. If you need more info please let me know.
NPC Dynamic functionality at random times.
RPG Maker MZ SupportIt’s a somewhat complex system, but it becomes much more manageable if you start by defining solid foundations, as that will help a lot with scalability later on.
One way to approach this is to break the problem into smaller systems. I would personally use plugins and events, although in many cases it might also be possible using only events and common events.
For example, you could implement a time or routine system, even if it’s not visible to the player. This already helps a lot with controlling NPC behavior triggers. Another useful base would be a relationship, affinity, or state system, to determine how an NPC reacts to another NPC, an object, or a situation.
One approach is to have each NPC periodically check if it can perform an action. Instead of trying to handle everything at once, every X time it could query a manager or trigger a common event to decide what to do. This process could validate things like:
if there is a compatible NPC nearby,
if an NPC with affinity X is available for interaction,
if there is an interactive object available to use,
or if there are conditions for a positive or negative behavior to occur.
The main thing to be careful about, in my opinion, is performance and system safety. Movement routes can become heavy if many NPCs are calculating paths at the same time. It’s also important to handle map blocking properly, because an NPC might get stuck trying to reach an unreachable destination, which can lead to strange behavior or even performance issues.
So I would start simple:
first make NPCs choose basic actions at intervals,
then add availability validations,
and only after that move on to more complex interactions between NPCs.
I think the key part here is building a solid decision manager first, even if it’s simple, before focusing on more advanced animations or interactions.
One way to approach this is to break the problem into smaller systems. I would personally use plugins and events, although in many cases it might also be possible using only events and common events.
For example, you could implement a time or routine system, even if it’s not visible to the player. This already helps a lot with controlling NPC behavior triggers. Another useful base would be a relationship, affinity, or state system, to determine how an NPC reacts to another NPC, an object, or a situation.
One approach is to have each NPC periodically check if it can perform an action. Instead of trying to handle everything at once, every X time it could query a manager or trigger a common event to decide what to do. This process could validate things like:
if there is a compatible NPC nearby,
if an NPC with affinity X is available for interaction,
if there is an interactive object available to use,
or if there are conditions for a positive or negative behavior to occur.
The main thing to be careful about, in my opinion, is performance and system safety. Movement routes can become heavy if many NPCs are calculating paths at the same time. It’s also important to handle map blocking properly, because an NPC might get stuck trying to reach an unreachable destination, which can lead to strange behavior or even performance issues.
So I would start simple:
first make NPCs choose basic actions at intervals,
then add availability validations,
and only after that move on to more complex interactions between NPCs.
I think the key part here is building a solid decision manager first, even if it’s simple, before focusing on more advanced animations or interactions.
I think I'm getting what you're putting down, a simple state machine that processes what thoughts a certain Npc is having at any given time, this is exactly what im thinking of, my biggest issue I suppose is how I would implement the system with the npcs not running parallel with the events due to the player needing to click them for certain things like feedings and all the other things I mentioned. Also I did try to see if there was some npc plugins to utilize but I can't seem to find any fitting what I have in mind, though I have skipped over a few I saw that mentioned a routine system so maybe I'll look back at those. Also just so you know I'm using Visu's Event and Movement core since it helps a ton with spawning and self variables.
bumping this!
while it can be complex, the best way is to use arrays to randomize
some stuff.
storing the event ID on that map and choices are where it can go messy.
if it does spawn, than the id's may be different and harder to control here.
CT Bolt had event trigger touch for MV (don't know if it works in MZ).
but what you want to achieve can be really complex.
but if you can point out some concrete context what you are after, I may
be able to guide you better.
some stuff.
storing the event ID on that map and choices are where it can go messy.
if it does spawn, than the id's may be different and harder to control here.
CT Bolt had event trigger touch for MV (don't know if it works in MZ).
but what you want to achieve can be really complex.
but if you can point out some concrete context what you are after, I may
be able to guide you better.
Well im making a pet game/rancher game where you take care of creature, fatten them up and sell them, you can either have very happy creature or sad ones and that's where the system would come in. It would randomly look within a series of random situation, choose one of the situations with a specific creature [event] or two, and activate it making certain creature have debuffs and stored memories. And with some events you can see a creature even approach another before the situation happens. like say a creature wants to talk to another, or play with a freshly bought ball? it'll detect the closest one and go to it!
this require some eventing and sensor range (which exist).
so find the closest one.
a way to get range can be this one [TSR_TransferTrigger].
while it isn't directly needed for transfer, it can have a range.
find a sensor that suits you as I also extended this plugin further for personal use.
so its really nice with touch.
I do have an event utility that can be handy with variables for a specific value.
so you can increase the array to make shorter branches or area's if you
want complex eventing.
but if the branching is also more complex by checking the event close by
if they are random, you may need to work with meta/notetags on the events
to see if its ground/animal (horse, cow, tiger, goat, lion, cat etc) in order to
do some more complex stuff to simplify those action.
a selfvariable plugin to increase or decrease points (sad - happy) to control those.
so the condition can be become quite long.
I also have an enhance conditionbranch but it isn't tested in MZ, which may or may not
work to simplify conditions.
so find the closest one.
a way to get range can be this one [TSR_TransferTrigger].
while it isn't directly needed for transfer, it can have a range.
find a sensor that suits you as I also extended this plugin further for personal use.
so its really nice with touch.
I do have an event utility that can be handy with variables for a specific value.
so you can increase the array to make shorter branches or area's if you
want complex eventing.
but if the branching is also more complex by checking the event close by
if they are random, you may need to work with meta/notetags on the events
to see if its ground/animal (horse, cow, tiger, goat, lion, cat etc) in order to
do some more complex stuff to simplify those action.
a selfvariable plugin to increase or decrease points (sad - happy) to control those.
so the condition can be become quite long.
I also have an enhance conditionbranch but it isn't tested in MZ, which may or may not
work to simplify conditions.
This does sound like exactly what I'm looking for! So if I can get a plugin to handle the sensors and range of things, it can detect whatever is near it and go to it, also I'm newer to arrays so I'll def have to check out the event utility! What I'm most confused by is I guess what you mean by notetags/metas? I know what notetags are, had to learn them to handle some of my plugins. Though my best guess is using notetags to classify which is what so the game doesn't mistake any event for another, am I correct? Also for self variables I am using Visu's Event and Move Core.
events can have notetags (can be used in various ways)
for what I know, MZ may use "meta" instead of note.
there is also comment tags, so only active page can draw them.
once you learn about those event notetag/comment tags, you can build
probably what you need, so not all events are bounds to one tag. but
multiple.
so instead target 20 events, you target 4 with the tag, so you gain more control.
I do have some plugin that target comment tags/notetags for events.
some of those are open, so you can study them.
there may exist for MZ that can use that as well or snippets.
even tags and comment tags array can be handy to or use variable
with the array of the event ID to handle them otherwise.
$dataMap.event.note === "something". (may not be correct)for what I know, MZ may use "meta" instead of note.
there is also comment tags, so only active page can draw them.
once you learn about those event notetag/comment tags, you can build
probably what you need, so not all events are bounds to one tag. but
multiple.
so instead target 20 events, you target 4 with the tag, so you gain more control.
I do have some plugin that target comment tags/notetags for events.
some of those are open, so you can study them.
there may exist for MZ that can use that as well or snippets.
even tags and comment tags array can be handy to or use variable
with the array of the event ID to handle them otherwise.
Original thread: https://forums.rpgmakerweb.com/threads/npc-dynamic-functionality-at-random-times.183147/