Ultima-Like NPC schedule in MV?

Discussion in 'Game Mechanics Design' started by Maus Merryjest, Jun 17, 2016.

  1. Maus Merryjest

    Maus Merryjest Veteran Veteran

    Messages:
    240
    Likes Received:
    40
    Location:
    Colorado
    First Language:
    English
    I’m not entirely sure if there is a best practice for what I have in mind here, or whether this is the correct place to post this… let me tell you what I have in mind:


    I don’t know how many of you have ever played the Ultima games, but if you ever played Ultima VI, VII and VII part 2, you probably remember one of the most memorable things about the game world: the NPC schedules.


    Literally every NPC in the world of Ultima VI-VII had their own schedules- shopkeepers would tend to their shops in the morning, would go to the pub to eat at noon and at dusk, then head home and putz around their houses until it was time to sleep. Aside from the high level of interactivity with the world (you could harvest wheat, make dough and bake bread in the oven, for example, or shear sheep, spin the wool, take it to the loom, etc) this was one of the elements that made Britannia feel like an actual living world compared to so many RPGs where, for example, Granny is perpetually sweeping the front door of her house until the world ends. This feature is now typical of games like Skyrim, for example, but it Ultima was really the first franchise that put it into practice first.


    It’s something I’ve always wanted to incorporate in a game, because it's a fantastic way to bring that extra little breath of life, but I’m not entirely sure how to do it gracefully with MV.


    Using one of the many time systems out there is always an option, to keep track of time as well as having a day/night cycle , but there are some things I want to do that those Ultimas did so well, which is  the ability to keep NPC routes and schedules. If you stood outside, say, Gaye the Clothier’s shop at 6pm, you would see Gaye come out of her shop and walk all the way to the Blue Boar for dinner, and if you were at the Boar at 7, you would see her get up and walk out of the Boar- and if you followed her out, you could follow her route all the way home. This was managed because Ultima VII was a persistent world with no  separate instances to speak of, so everything happened on one gigantic  world map at the time.


    With RPGM Maker, we’d need to make separate screens, which makes this a little… tricky. There are a lot of things that MV would have to handle: it would need to track where each NPC is when in-transit from one location to the other (so that when you’re walking around in the street, you can see them actually moving from place to place instead of teleporting), as well as whether or not they should be on that route at all (in the case of plot-critical NPCs who may, at certain important junctures, go somewhere else entirely or disappear from the game world if they’re killed, for example- which could be handled through switch-checking.)


    The player experience would be something like this:


    The Player is at the local tavern at 7:02 pm.


    -At 7:03, Crystal gets up from the table and heads for the door- she will go to the room above her shop, The Ugly Duchess, arriving at 7:15pm and reading at her desk until 9:00pm, when she turns in until 7am, when she opens her shop.


    -At 7:20, Goofus and Gallant get up from their respective tables and walk out. They go into their meeting spot in the woods to look for luminescent mushrooms until midnight, when they go to their house. Goofus goes to bed immediately, while Gallant putzes around in his kitchen for an hour before sleeping. They both sleep until noon the next day.


    -At 11pm Elena the pubmaster closes the pub while her son, Frollo, wakes up and switches shifts with his father Umberto next door at the inn. Elena kicks out anyone who is in the pub at closing time and onto the adjacent inn (who, really, is only the player and maybe one or two NPC inn patrons who go to their rooms shortly thereafter.) Frollo tends the inn until 8am, when his father wakes up and takes over for him.


    We can add even more complexity: One of the NPC inn patrons is a traveling troubadour (we'll call him Tailesin) who spends a week in each town and travels between the two local towns and the city, leaving  Sunday of each week for the next town (so, for example, Limoges (stays 6 days) ->travels to->Rouen (stays 6 days)->travels to->Chartres (stays 6 days). On the fourth week of each month, he travels to the forest of Brocéliande where he spends a week in the court of the Faerie Queen (the entrance to which the player can’t find until he has a certain item in his inventory), and at the beginning of the month, he returns to Limoges to start the cycle again. The player should be able to encounter said troubadour on the road.


    How on earth could one replicate this in MV?


    I know there are ways to do it in a primitive fashion- such as adding one of the Time plugins and set the game to switch certain switches on or off at specific times of the day/month, and have events in specific maps where those NPCs would be to reflect the action, adding instances of the NPC in every map they would conceivably be and activated via switches. Pathfinding and seeing NPCs walking from one place to another wouldn’t be possible this way, since the sheer amount of things to do would look like this:


    -If the player exits the pub at the time NPC1 leaves for her house, he will see her walking outside and away from the pub when he appears in the outside area (switch switched so she’s not in the pub when the player comes back in). However, the problem with this is that if he gets into her house before she gets there physically, he will find her IN her house when he comes in. Of course, you could set it so that the switch “NPC1isHome” doesn’t get flipped until NPC1 reaches XY coordinates that have her touching the door (which would unlock the door so the player can get in)- but that would mean tracking the XY coordinates of every NPC in transit in that screen, which can bog down things like hell…  and then, of course, there’s the whole trouble of how to get those switches flipped when the player is nowhere near those screens so there’d be no tracking of the particular NPC event to trigger the unlocking of the door and the “NPC1isHome” switch, in case the player does get to that screen after the NPC –should- be home.


    I guess that what I’d be looking for here is having a way to have persistent instance information for each NPC and the ability to write routines for them and manipulate them in accordance with a time schedule and pertinent switches. I know that, as of recent, Stardew Valley has an NPC system that’s similar to this…  I’m not entirely sure MV can pull it off.


     


    Thoughts?
     
    #1
  2. Scythuz

    Scythuz Explorer Bot *beep beep* Restaff

    Messages:
    4,446
    Likes Received:
    3,360
    Location:
    Liverpool, UK
    First Language:
    English
    Primarily Uses:
    N/A
    I don't think you could get anywhere near the complexity of Ultima's system within a reasonable time frame on mv, but, you could probably make a somewhat basic routine for certain types of npcs?  For example: a guard patrols one section of an area during a specific time and then another at a later time until he/she goes off duty, and you find them at home (or the pub :p ) ?  What I'm trying to get at is that you could use 'classes' of npcs in order to reduce the workload rather than making every single npc completely different from one another.  I reckon you could definitely put basic schedules into the game with the help of a time system that let's you trigger events based on what time it is though.


    Maybe someone more experienced in scripting can help you better see what is possible though  :)  
     
    #2
  3. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV




    Some of your ideas are good, but you're going at it the wrong way.


    I have thought of this myself, and there is a different method to implement that. It will be tedious to do, but you won't have any consistency problems that way.


    First off, you need to remove one of your assumptions from the mechanic - simply because it will not work (as you realised yourself):


    The NPCs/Events do not need to move or be switched when the player doesn not see them.


    Or more precisely, never use switches for such a structure - that way lies hell.


    Use the time directly - have a time system (either scripted or evented, doesn't matter) count up a variable as a gamecycle. It cannot be the same as you use for displaying time, because it needs to count the entire day (or whatever you want the base of your cycle to be), and it needs to count that very high - probably not up to 86400 (that is the number of seconds per day), but you'll need to split the entire day into equal parts that are usable for controlling the schedule (24, once per hour, will only work with a very primitive schedule).


    Then you need to plan where an NPC is supposed to be at which count - and the NPC-placeholder-Event on the map where that is gets a page with condition based on that variable to become active. That page can contain an autonomous move route to go however it is intended, and you need to playtest when that NPC gets to the end of the moveroute, because the next page needs the count of that end of move to switch to the next part (which might be a cycling route at the new position or vanishing if that was the door to the home.


    So all you need is a single variable that controls all NPCs in the game by giving them their time on each map - and a lot of work planning and testing out the timing when should what happen if the player is on that map.


    Extremely tedious to do, but managable because you don't need to keep track of anything else but the current event and its interactions on the current map.


    Biggest problem is that the timing might change depending on adding more events that block original routes (or the player interfeering) - that might result in off-times if you're not carefull, but even if that happens it will automatically correct itself when the player goes to a different map (unless he blocked a move route for a long time and then intentionally runs to the next critical interception point - but that is not playing the game and doesn't need to have a world react to it.
     
    Last edited by a moderator: Jun 17, 2016
    #3
  4. Maus Merryjest

    Maus Merryjest Veteran Veteran

    Messages:
    240
    Likes Received:
    40
    Location:
    Colorado
    First Language:
    English
      I really love that idea. Sure, the plotting will be tedious, but the vitality something like that can bring to the game is totally worth it.  Thank you so much for this, if you have any more suggestions, I'm all ears.
     
    #4
  5. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,323
    Likes Received:
    2,965
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    I implemented this in my game and I would love to add this feature to my time system plugin. The only problem is: It's very hard to configure those schedules.


    I couldn't think of any simple way to let the users configure it, so I didn't turn it into a plugin yet. If you have any idea, let me know.
     
    #5
  6. Maus Merryjest

    Maus Merryjest Veteran Veteran

    Messages:
    240
    Likes Received:
    40
    Location:
    Colorado
    First Language:
    English
    Yeah, that level of detail will always require some serious tedium and elbow grease, I think. Implementing some of the more basic tools into a plugin might help, but I don't really think there'd be a simple way.


    Just thinking about the complexity of it all makes me respect the pre-EA Origin team more, considering they pulled it off in 1992.
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @Hudell: yes, the schedule configuration is the hardest part, and no one can really automate that - but if you're going to make a plugin, then you can include tools to test and output the schedules.


    You'll need a pathfinding added to it and several script call functions for the events.


    Basically the developer needs to place the event conditioned to the starting count, and instead of the step-by-step autonomous move route you have it give a script command to move to the intended position with the pathfinding. Then add a console command before and after that move call to output event name and current count before and after the move.


    You'll get a long list of how much the count has to increase, and need to use those numbers on the events to structure the parts.


    Still tedious, but you don't need to time everything manually and can test several events at the same time before reading the output.


    Then use an excel sheet to get all numbers together - still a lot of work, but much less than everything manually.
     
    #7
  8. Frogboy

    Frogboy I'm not weak to fire Veteran

    Messages:
    1,676
    Likes Received:
    2,101
    Location:
    North Carolina, U.S.
    First Language:
    English
    Primarily Uses:
    RMMV
    I remember playing Ultima V for the C64 and being absolutely amazed at how they pulled this off.  You could also have conversations with people.  It was pretty awesome being able to ask NPCs random things and have them have them talk to you about it.
     
    #8
  9. AwesomeCool

    AwesomeCool Bratty and spoiled little sister Veteran

    Messages:
    2,877
    Likes Received:
    1,954
    Location:
    Behind you! BOOOO!
    First Language:
    English
    Primarily Uses:
    N/A
    I tried to make a script for this once (create a harvest moon style NPC schedule)


    I made it so events would stay in the same position as they were when you left the map and would continue to update while off the map on a fake map (a much thinner on content map to try and save on resources). I then combined it with some pathfinding to prevent player blockage, a time script to obviously keep track of the schedule and added the ability for safety measures to prevent the player from being a troll (LOL I WILL STAND IN FRONT OF THIS DOOR AND RUIN EVERYTHING LOL).  Thus creating the effect with very little setup in the script due to it all being the player eventing the schedule (would be all eventing and based on complicated the player wants it).  


    I mean, this basically resulted in the player being able to build NPC schedules with only one new command to think about normally: If Event is in X region, Event's Self Switch is triggered (or global switch, or variable is changed by X), used to confirm that the event has hit it's next destination and will switch to a new page detailing what the NPC is doing then.


    But, it quickly added lag under pressure even with lots of optional optimization. ex: only events specified would update that have schedules (would then turn the event into just a collision check like all the other walls, if the user said they didn't need it to update).


    Although it probably could of optimized it a lot more tbh (like perhaps only have certain fake maps only update when certain switch is on, you don't need to keep updating that city 5 miles away after all) and the code itself was very sloppy due to it being me just playing around honestly.


    Hope this helps anybody thinking of taking this on as I do not have the time nor interest in it (I hope someone does, nothing scream lame then a person who spends their life in one spot).
     
    #9
    Rayhaku808 likes this.
  10. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,323
    Likes Received:
    2,965
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    The problem with that approach are timeskips.


    I also didn't use pathfinding for long distances because I want the villagers to use the road. Changing the default pathfinding to consider regions would be extra slow, but I have a new pathfinding script to write that should make it possible.


    Right now I generate an array with the position the event should be at each in-game second and then read from this array while the game is running. I then generate a move route based on that. This route uses several pathfinder calls (one for each time the event changes direction)


    it works, but I still want to make it much better
     
    #10
    AwesomeCool likes this.
  11. Candacis

    Candacis Pixel Pusher Restaff

    Messages:
    1,446
    Likes Received:
    1,933
    Location:
    Vienna
    First Language:
    German
    Sounds promising. I have been looking for a good npc schedule/pathfinding plugin for MV.
     
    #11
  12. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV


    As I said to the OP, checking and maintaining all positions of all events is a problematic approach imo - as you said yourself it can work, but it requires an insane amount of processing and planning.


    To be able to handle such schedules, the events need to be as independent from each other as possible - and you need to include some slack to cover for the times when an events move is blocked, probably by a number of waits at the end of the autonomous movement or by giving enough extra timecounts when using a pathfinding function.


    Yes, that will have some hickups in the end - but never forget that we all have limited time to work. Do people prefer to spend one month of planning to get a 95% result, or three years of planning to get a 100%? I rather have 95% in a managable time instead of perfection I don't have time for.
     
    #12
    AwesomeCool likes this.
  13. AwesomeCool

    AwesomeCool Bratty and spoiled little sister Veteran

    Messages:
    2,877
    Likes Received:
    1,954
    Location:
    Behind you! BOOOO!
    First Language:
    English
    Primarily Uses:
    N/A
    @Hudell - I handled timeskips with eventing (ex: if the player jumps ahead six hours, I flip on a special switch and the event moves to the location that the event should be in six hours).  I had most of the scheduling through events to try and keep it as user friendly as possible and already planned for most of that stuff being possible (ex: if the player blocks an NPC for to long they make the player move out of the way and basically say excuse me to give a reason to make the player move).


    I would also agree with @Ander on the idea of using array's for this.  It would be best to keep each schedule separate for each event to make it more manageable for the user atleast.

    Why am I getting interested in making this again lol



    Edit: @Hudell, hope you finish this and good luck  :)
     
    Last edited by a moderator: Jun 17, 2016
    #13
    Scythuz likes this.
  14. noctiluca

    noctiluca Veteran Veteran

    Messages:
    187
    Likes Received:
    167
    Location:
    California
    First Language:
    English
    I had started to setup event listeners/finite state machines to handle NPC schedules, but the hardest part definitely is getting them to move around properly. Especially since I had set schedules to be dynamic (like, aside from general sleeping and working hours, in their free time NPCs shop for items when their inventory is low, eat when they are hungry, trade items when they are in an amicable mood etc)...


    I was somehow able to get all of this working to have "smart" NPCs, but when it came to moving them around I started to run into problems. Teleporting from place to place is awkward (and confusing for the player), but keeping track of the event's coordinates is very difficult especially when their locations have a somewhat random factor.
     
    #14
    AwesomeCool likes this.
  15. Prescott

    Prescott argggghhh Veteran

    Messages:
    456
    Likes Received:
    327
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm doing this on our game as a last step, getting the time all sorted out.


    We are using a time system (I think it's the one by Hudell) so it already updates the time and saves quite literally everything into a variable, so that's nice already.


    I know how to do it, it will just, like you said, take a LOT of elbow grease and time. We have the benefit of there not being a LOAD of characters in our game world, since a lot of people are dead for various reasons, and a lot of people are sick as well so they'll be staying in bed or at home most of the time and possibly dying depending on what you do in the game world. The ones that do move will be quite static too and actually follow a schedule, but I think even that makes a game world seem so much more alive.


    Basically everybody working in MV (that's smart) also has the benefit of there being multiple maps instead of one giant world, so the schedules for each character won't bog down things too much, especially if you don't have too many characters moving around at once. You could even set it up so that it goes in a cycle of characters step by step instead of trying to run them all real-time, but I'm not sure if that would look clunky or not.
     
    #15

Share This Page