Yanfly's Foraging System - Question

Discussion in 'Javascript/Plugin Support' started by HintonR, Oct 5, 2019.

  1. HintonR

    HintonR Veteran Veteran

    Messages:
    197
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    Hello.

    I was about to implement a foraging system following the method Yanfly shows on Youtube. As I was understanding the common events he was implementing I started wondering the impact it would have on performance.

    Understandably, if there's only a few maps to check it wouldn't be too taxing but this is a system I wanted to implement globally to the extent of around 300+ maps. Meaning that at night, when the common event would execute the respawning check... it would have to do so for 300+ maps in parallel to what is going on actively for the player. My question is if my concerns are valid that at night or sleeping in the event that the common event would execute, I would facing a spike in performance.

    My concern stems from putting in the effort to implement this system now, while I only have a handful of maps, but when I start reaching larger amounts of maps the game will start facing performance issues every time day/night cycles.

     
    #1
  2. ImaginaryVillain

    ImaginaryVillain Map Event Specialist Veteran

    Messages:
    143
    Likes Received:
    140
    First Language:
    Event Gibberish
    Primarily Uses:
    RMMV
    It's difficult to say for certain, I mean depending on how you set up stuff besides this that could affect lag as well. But the player will definitely notice some amount of loading time, I mean you're executing likely over 1,000 commands (one for every forage event on every map). To give you an idea, for awhile (before I devised a better way) I was executing around 400 Yanfly map clears to reset my randomized dungeon. It took about 30 seconds... So the lag wasn't that bad, but that was on an average PC. If you did the same on a phone, it would likely be much longer. Then magnify that by at least 2.5+ times (given the larger quantity of events) and that might give you an idea of the performance issue such a command would be.

    Just a lot of speculation though, there's way too many factors to account for about your project that I and likely you don't know yet. You should definitely let us know how it goes! :hwink:
     
    #2
    HintonR likes this.
  3. HintonR

    HintonR Veteran Veteran

    Messages:
    197
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    haha. Yeah I'll hold off on making a resetting foraging system at the moment. It's rather important -- but that is what I thought, with how I understood how his common event would run -- I can only imagine and speculate the amount of processing it would have to do when checking and augmenting hundreds of events on several maps...

    I'm stilling wrapping my head around a way to reset events remotely while on other maps. I only have a handful of maps so my original tests haven't shown significant performance drops since I'm only effecting 4 maps and I can't say that the culprit is specifically these common events since I have other 'dynamic' systems in play such as weather probability and day/night cycling that rarely dips my performance but having 4 maps getting refreshed or checked seems to add to the already existent dip when the project says 'hey, there's gonna be this weather, and it's also this time of day, and I also have to check if things need to respawn'

    Haha. I also can't use Yanfly's event copier since it has a few compatibility issues with some other plugins I'm using. So I can't just do a crazy mass map mass copy test. If ever, I'll definitely share my findings.

    Otherwise, I'll also share any methods I figure out about resetting events remotely.

    If anyone else has two-cents to chime in about remotely resetting events, I'm all ears :)

    Thanks!
     
    #3
  4. ImaginaryVillain

    ImaginaryVillain Map Event Specialist Veteran

    Messages:
    143
    Likes Received:
    140
    First Language:
    Event Gibberish
    Primarily Uses:
    RMMV
    Honestly, I prefer to use an event spawner over the copier. Then just randomly execute randomly spawning the nodes before fading in a map. Way less overhead. Plus you can just have activating the event destroy it, since event spawners give the functionality to actually delete events. Personally I use Galv's Event Spawner but Yanfly has one too, http://www.yanfly.moe/wiki/Event_Spawner_(YEP)
     
    #4
    HintonR likes this.
  5. HintonR

    HintonR Veteran Veteran

    Messages:
    197
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV

    I'll have to read up on how event spawners work :)

    I was always confused with all the 'event' suffixes hahaha. There was the spawner, copier, morpher...
     
    #5
  6. ImaginaryVillain

    ImaginaryVillain Map Event Specialist Veteran

    Messages:
    143
    Likes Received:
    140
    First Language:
    Event Gibberish
    Primarily Uses:
    RMMV
    Haha that's fair. Honestly, I haven't found any real reason for the Morpher. Mostly because I can just despawn the event and spawn in another at the same location. Plus the Morpher creates an event that can't be despawned, well not directly at any rate. So the Spawner just kind of covers that, and does it better. I do use Yanfly's Copier though, but only because sometimes I want events on a map that aren't hit by the mass despawn option of the Spawner.

    Speaking of Spawners I've tried two, Yanfly's and Galv's. Yanfly's has the advantage of playing a lot nicer with Yanfly's Self Switches & Variables. It didn't matter often but sometimes complicated stuff can cause issues between the Yanfly's Self Switches & Variables and Galv's Spawner. My experiment with arrays and Self Variables in Galv spawned events was nightmare fuel.

    However Galv's Spawner has the ability to spawn events on top of events. So in the end for that functionality I decided to suffer a bit. If I knew then what I know now, I would have used Himework's Self Variables plugin instead of Yanfly's. But I'm not recoding everything I've done up to this point to switch. :headshake:
     
    #6
  7. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,453
    Likes Received:
    3,721
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    I'm not 100% sure, but my instinct is that your concerns are not valid, and that players won't experience any more lag than they would if you were, say, constantly rotating a picture onscreen for a few seconds. The code you're doing (essentially a series of simple assignments for each harvestable event) is very lightweight code, and I don't think there's anything in Yanfly's Self Switches/Vars script commands that eats up processing power.

    If you do find that your game starts to chug when the Common Event runs, then you could try a different approach and check the events on each map when that map loads: instead of ticking down the Self Variables every hour/day, you could have an in-game variable called Days (or Hours) that tracks the total number of Days (Hours) since Day (Hour) 1 and always counts up, never resetting to 0. Then, when a player harvests something, its Self Var is set equal to that variable. Put an Autorun event on each map (that will only run once each time you visit the map) which compares the Self Variable to the current Days variable, and if enough time has passed (e.g. Days > Self Var + 10), then set the event back to 'harvestable' mode. Or, even better, forget the Autorun event and use Hime's Page Conditions on the 'harvestable' event page for each event to determine whether that page will be active (and show the harvestable graphic) or not. Again, the custom page condition would compare Days to the event's Self Var.
     
    #7
    HintonR likes this.
  8. HintonR

    HintonR Veteran Veteran

    Messages:
    197
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    Does Hime's Page Conditions play nice with Yanfly's selfsw/var? For instance, have a global Self Var that increases and have individual events track their own Self Var -- in which case at a certain 'x' interval.
     
    #8
  9. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,453
    Likes Received:
    3,721
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Yes, they work together just fine. Yanfly's Self Switches plugin includes some script lines to reference the value of a given event's self-variable. You use those script lines in the Conditional Branch in Hime's Page Conditions. (You might even be able to just put the switch in since it's inside the event; I'm not sure. But if that doesn't work, the script lines will - I've done this before.)
     
    #9
    HintonR likes this.

Share This Page