The quest for npc behavior

Danatoth

Regular
Regular
Joined
May 19, 2023
Messages
133
Reaction score
71
First Language
English
Primarily Uses
RMMV
You can also do this with Yanfly Advance Switches and Variables, which lets you make a switch a JavaScript evaluation of anything you want.

You can set a self switch in a move route using
$gameSelfSwitches.setValue([$gameMap.mapId(), this._eventId, 'A'], true)

You can also remotely set a self switch from another event with
$gameSelfSwitches.setValue([mapNumber, eventNumber, 'A'], true);
Ah sweet, I'll try that out thanks~
 

Danatoth

Regular
Regular
Joined
May 19, 2023
Messages
133
Reaction score
71
First Language
English
Primarily Uses
RMMV
It just dawned on me while working on the game. If I have schedules for npcs, where they will actually do different things at different times of the day, it will be more difficult to have no "quest arrow" like morrowind had which is what I originally intended. I loved the exploration of that game, and really dislike quest arrows. If npcs are always moving everywhere, it will make it harder for the player to find them, especially in a big city...
 

AquaEcho

Script Kitty
Regular
Joined
Sep 20, 2021
Messages
2,264
Reaction score
1,694
First Language
English
Primarily Uses
RMMV
If npcs are always moving everywhere, it will make it harder for the player to find them, especially in a big city...
Newer Harvest Moon/Story of Seasons games have character faces on a minimap so you can see where everyone is at all times. I think some of them also state the characters' current location in text on the affection level status screen. You don't necessarily have to use the same solution but it is how that series solved it.

Or you can do what Persona (5) does and show who's at a location on the fast travel/location select screen, or just teleport the player to the quest giver's location when they accept the quest.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,692
Reaction score
11,262
First Language
English
Primarily Uses
RMMV
And having npcs move on maps that you aren't on.
Just because I didn't see anyone else mention it - this is, without significant effort, impossible.

Only the map you're currently on exists (is loaded) in RPG Maker, so it's impossible to directly manipulate events on another map.

You would have to either:
- Make a plugin that loads additional maps into memory and assigns them interpreters to run the events (might run into resource/computing issues)

- Have your time tracking system detail/calculate which tile every event is supposed to be on, down to the second.

There have been some other moderately lengthy threads about trying to implement this kind of thing. You might be able to find something useful.
 

Danatoth

Regular
Regular
Joined
May 19, 2023
Messages
133
Reaction score
71
First Language
English
Primarily Uses
RMMV
Just because I didn't see anyone else mention it - this is, without significant effort, impossible.

Only the map you're currently on exists (is loaded) in RPG Maker, so it's impossible to directly manipulate events on another map.

You would have to either:
- Make a plugin that loads additional maps into memory and assigns them interpreters to run the events (might run into resource/computing issues)

- Have your time tracking system detail/calculate which tile every event is supposed to be on, down to the second.

There have been some other moderately lengthy threads about trying to implement this kind of thing. You might be able to find something useful.
Yup, but it wouldn't matter for this exactly since if you weren't on a map you wouldn't see the npcs pop into existence when the switch turns on. If they are just moving through a town it's not a problem, but it I were to want to have npcs travel for several maps during parts of the game where you'd likely see them travelling then it would be. I just have to work around that and make sure they are never really going that far.

The bigger question, is all this time and effort really worth it? What are the pros and cons in an open world game to having npcs move around during the day. It adds a bit of immersion, while taking exponentially longer to create.
 

AquaEcho

Script Kitty
Regular
Joined
Sep 20, 2021
Messages
2,264
Reaction score
1,694
First Language
English
Primarily Uses
RMMV
If they are just moving through a town it's not a problem, but it I were to want to have npcs travel for several maps during parts of the game where you'd likely see them travelling then it would be.
You could just track the general area/map the NPC should be at a given time, which is much more reasonable than their exact tile location. You don't need to know their exact location unless you're currently on the map they are on.
 

Danatoth

Regular
Regular
Joined
May 19, 2023
Messages
133
Reaction score
71
First Language
English
Primarily Uses
RMMV
You could just track the general area/map the NPC should be at a given time, which is much more reasonable than their exact tile location. You don't need to know their exact location unless you're currently on the map they are on.
If you do this though and you do happen to be on that map, then they will just pop into existance.
 

AquaEcho

Script Kitty
Regular
Joined
Sep 20, 2021
Messages
2,264
Reaction score
1,694
First Language
English
Primarily Uses
RMMV
If you do this though and you do happen to be on that map, then they will just pop into existance.
Harvest Moon/SoS already does it the way I describe and they do not pop into existence, except at the edge of the map or at door locations.
 

Cythera

Regular
Regular
Joined
Jul 31, 2019
Messages
432
Reaction score
1,658
First Language
English
Primarily Uses
RMMV
Hey, so it looks like you've already got some ideas on this, but since this is something I recently implemented as well, I thought I'd share my experience on it. Hopefully it's helpful and gives you some more ideas on the matter :yhappy:

First, my NPC behaviors work like this: at 8pm, NPCs will walk home/to the inn/to the tavern. Houses are locked at this time, and the player is asked to leave (aka kicked out) NPC homes. This doesn't apply to anything quest related; those are always available unless the quest itself is time-sensitive. Player cannot enter NPC homes past 8pm, as doors as locked until the morning when NPC leave and return to their places in towns and their usual patterns.
If the player enters the town past 9pm, I assume every NPC has already walked home. Same in the morning; there's a small allowance window, before I assume everyone has already woken up and gone where they need to be. Otherwise player can get town at 3am and see everyone just then heading home, which I feel is strange :yswt:

I do all this using Yanfly Move Route Core and Save Event Location. Along with my time system, which I modded to control the switches I need based on time of day. I make use of NPC self switches, so they say different things while moving (ex: if Amy is going to bed, she might say 'excuse me, I'm going home' while walking instead of 'welcome to Starter Town TM*' that she would say in the day)

Now, some things I learnt while making all this: first, as pointed out, you cannot just turn a switch on and off. You will have NPCs teleporting, appearing from thin air, or disappearing into the void. I mean, you can, but if your goal is to make an immersive world, it's gonna look strange.
Second, you cannot actually move maps with an NPC. RM isn't good for that by default. But that's okay! We just need to make it LOOK like the NPC moved maps, which is possible by creating two events of the same person on two different maps.
Third, and this was an awkward one, albeit specific to the way I set up my system. If the player enters the town at 8:58 pm, the NPC start to walk home. Remember, if it's past 9pm, I assume everyone has already gone home. So at 9pm, the NPC switch to their 'already walked home' event, and just vanish. I had to manipulate self switches so NPCs that are walking...don't disappear. Even if it becomes past 9pm. And same goes for morning routes.

It's tricky eventing to start, for sure. Lots of logic had to go into which event page goes in which order, to preserve necessary priority.

This is 100% possible though. Is it perfect? Is it is as sophisticated as some game titles out there? Nope. But, I'm a rookie coder making an indie game, and I'm pretty proud of this functioning lil system, and I'm still expanding it. I'm sure some of the experienced coders in the community made better systems (I know there's an NPC scheduler for MZ, complete with weather and time conditions)

It's very time-consuming, however. Just make sure this is what you want to do before you start :yswt: I'm happy to share notes if you wanna go down this route.
 

Danatoth

Regular
Regular
Joined
May 19, 2023
Messages
133
Reaction score
71
First Language
English
Primarily Uses
RMMV
It's very time-consuming, however. Just make sure this is what you want to do before you start :yswt: I'm happy to share notes if you wanna go down this route.
Yeah, I'd love to see the workings on how you did it. Seems pretty much what I was going to do, but the save event location seems like it would work fantastically.
 

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,368
Reaction score
2,571
First Language
Spanish
Primarily Uses
RMVXA
I had talked to Victor at the time, giving him my upgrades from my system to improve his.
I don't know if he ever added them to that plugin, but if you can "remote control" an event (even non-existing ones!) from an NPC manager (as in, not from the event proper, directly), then that's the upgrade.
that's what I was using for my cutscenes, that worked around his system for proximity and detection: that exchange of "Go there" on one event and "Wait until triggered by X" from the target area, is the solution to this problem.
"on arrival", delete, or change routine, or whatever you want.... but there was the need to detect that arrival, hence, Victor's engine.
THAT solution, is Half-Life 2's method: send, wait, detect, trigger.
 

Latest Threads

Latest Profile Posts

Yknow what? Im seriously considering recruiting a manager to oversee my games development.
Because I cannot focus or complete these tasks by myself. I need someone to give me orders, without having them be my boss.
yp_4vS.png

Remember my latest plugin for rpg maker mz:

Acknowledgement Window is now available!

Take a look here:

Got my focus back, 9/59 maps have the door fix in place now.
Making a small RMMV project has made me realize that I've never actually made a credits sequence for a game.

Forum statistics

Threads
136,802
Messages
1,270,177
Members
180,557
Latest member
wellaa
Top