YEP Auto Passive States [short 'lag spikes']

Discussion in 'Javascript/Plugin Support' started by AdamSakuru, Aug 10, 2018.

  1. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    Plugin Link:
    http://yanfly.moe/2015/10/17/yep-13-auto-passive-states/

    I'd like to make use of Auto-Passive States for certain things in my game project, but I have a lot of stuff going on in my battles visually/with eventing. I think this, coupled with the amount of plugins I'm using, has all the processing build up and in some cases there are short lag spikes as a result. I've found ways to get around or mediate this in most cases.

    When I use Auto Passive States, there are brief lag spikes that occur whenever a turn ends and begins. The length/severity of the lag spike increases when the total number of actors/enemies on the field increases. If I have three actors and three enemies on the field, the lag spike drops to about 25-30 FPS. I should mention that this issue with the lag was noticeable when I was originally using this plugin last summer. My game had less plugins, though there was still a lot going on in my battles.

    Does anyone know how to optimize Auto passive States so that any lag is less noticeable when there are more processes going?

    Here's an image containing all my plugins/their order:
    [​IMG]

    And here's what my battles look like:
    (see attached image)

    If possible I would really love to trouble-shoot this. Having that plugin would be really handy for certain things in my game. If you need anymore information from me to help with this, I'm more than happy to oblige.
     

    Attached Files:

    #1
    SoSick. likes this.
  2. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    Le'Bump
     
    #2
  3. ramza

    ramza Lunatic Coder Veteran

    Messages:
    525
    Likes Received:
    287
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    While I haven't looked into this yet myself, I dealt with another developer who was having a problem very similar to this in his own project, with possibly dozens of passive states, and sometimes up to 12 separate battlers in the CTB (or I think STB later) battle system, that just died once the fourth party member was put into the party.

    As I understand it, the biggest performance hit with auto-passive states is a function where it sorts the state icons. The loop iterates each state on each battler, and checks them against all other states it's already checked on that same battler, in order to re-arrange the order in which the icons show up on the HUD. Naturally, the more states you have, the longer this takes, and adding an extra battler exponentially increases the time this takes.

    The only time a passive state should have to update the order in which is it displayed, is immediately after it becomes active, as this sort function would also apply whenever a new normal state is applied via a skill or whatever. So you can probably safely comment out most of the calls to the sorting function. I apologize for not knowing exactly what it is or where it's located in the plugin, as it wasn't me that figured this out, and I didn't get a chance to attempt it in my own project yet.
     
    #3
    AdamSakuru likes this.
  4. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    Woah! I didn't even see someone replied to this. Thanks for getting back to me, @ramza

    I'm possibly commissioning someone to fix this but they were only going to look into it on the information I gave them. So I think your insight will be helpful. I'll pass it along to them.

    Edit: If anyone has anymore information feel free to share!
     
    Last edited: Sep 17, 2018
    #4
  5. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    Courtesy of AloeGuvner, he provided a quick fix which lessens the lag. However, by using this fix, you will DISABLE Auto Passive State conditions. So keep that in mind!

    PHP:
    Game_BattlerBase.prototype.states = function() {
        var array = 
    Yanfly.APS.Game_BattlerBase_states.call(this);
        if (!
    this.__passiveStates) {
          
    this.__passiveStates this.passiveStates();
        }
        array = array.
    concat(this.__passiveStates);
        
    //this.sortPassiveStates(array);
        
    return array;
    };
    Install directly below YEP's Auto Passive States.
     
    #5
  6. RK DracoRoy

    RK DracoRoy Fire Emblem RPG Gamer Veteran

    Messages:
    153
    Likes Received:
    20
    First Language:
    English
    Primarily Uses:
    RMMV
    I had this same problem for a long while, until I found this solution which really works.
    For some reason, when I have this plugin enabled, the passive states that are provided from weapons and armor don't show up at all. It'll only show for actors, classes, and enemies.
     
    #6
  7. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    That's a bit of a bummer, but still a decent trade-off.
    Feel free to share this issue and the current solution around to any RPG Maker coders you may know who may be able to improve upon this. AloeGuvner said he felt there was probably a more elegant way of doing it, so there's nothing to lose from looking into it.
     
    #7
    RK DracoRoy likes this.
  8. RK DracoRoy

    RK DracoRoy Fire Emblem RPG Gamer Veteran

    Messages:
    153
    Likes Received:
    20
    First Language:
    English
    Primarily Uses:
    RMMV
    I recently got this updated script from Zarsla that would provide passive states through weapon and armor.

    Code:
    Game_BattlerBase.prototype.states = function(){
       var array = Yanfly.APS.Game_BattlerBase_states.call(this);
       if (!this.__passiveStates) {
         this.__passiveStates = this.passiveStates();
       }
       array = array.concat(this.__passiveStates);
    if(this.isActor){
    for (var i = 0; i < this.equips().length; ++i) {
         var equip = this.equips()[i];
         array= array.concat(this.getPassiveStateData(equip));
       }
    }
    
       //this.sortPassiveStates(array);
       return array;
    };
    
    Unfortunately, when I attempt to start the game with this, it will crash coming up with the "Cannot read property 'code' of undefined" error. And I haven't heard from the user since then. I'm not sure what's really causing the crash from this script, hope to find out one day because the lagless Passive State fix you got helped me tremendously.
     
    #8
    AdamSakuru likes this.
  9. AdamSakuru

    AdamSakuru StudioDaeera Veteran

    Messages:
    314
    Likes Received:
    168
    Location:
    Calgary, Alberta.
    First Language:
    English
    Primarily Uses:
    N/A
    #9
    RK DracoRoy likes this.
  10. SoSick.

    SoSick. Veteran Veteran

    Messages:
    216
    Likes Received:
    179
    Location:
    UK
    First Language:
    english
    Primarily Uses:
    RMMV
    Thanks for heads up man! Legend
     
    #10
    AdamSakuru likes this.
  11. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    Is anyone still having this sort of problem? I've got the latest version, but whenever I have more than a couple of passive states active, the lag gets noticeable and then nasty really quick.

    What I've got right now is:
    -One Passive State with Custom Passive Condition (checks a bunch of weapon types and only activates with the right ones). Only one actor has this one.
    -One Passive State that keys off of the first one if there is nothing in the off-hand
    -About 42 basically blank states (no content or icons) that I apply as passives to actors or enemies so I can check for the existence of those states in damage formulas. Each actor would have about 8 or 10 of these, and each enemy might have 1-6 or so.

    That just destroys the performance.

    I would use switches, since that's effectively all these are, but I need something I can apply to actors AND enemies.

    Thoughts?
     
    #11
  12. RK DracoRoy

    RK DracoRoy Fire Emblem RPG Gamer Veteran

    Messages:
    153
    Likes Received:
    20
    First Language:
    English
    Primarily Uses:
    RMMV
    #12
    Sword of Spirit likes this.
  13. Sword of Spirit

    Sword of Spirit Veteran Veteran

    Messages:
    114
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks! I'll look into that.

    What I'm currently doing to deal with it is that I removed the passive nature of the state with all of the conditionals, and made it toggleable instead, and cut down those 42 states that a battlers may have 6-10 active, to 10, of which you might have 0-4. That seems to have drastically reduced the lag.
     
    #13
    SoSick. likes this.

Share This Page