YEP Auto Passive States [short 'lag spikes']

AdamSakuru

[Null_Value]
Veteran
Joined
Mar 14, 2014
Messages
314
Reaction score
170
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:

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.
 

Attachments

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
663
Reaction score
373
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.
 

AdamSakuru

[Null_Value]
Veteran
Joined
Mar 14, 2014
Messages
314
Reaction score
170
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:

AdamSakuru

[Null_Value]
Veteran
Joined
Mar 14, 2014
Messages
314
Reaction score
170
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.
 

RK DracoRoy

Fire Emblem RPG Gamer
Veteran
Joined
Jun 29, 2017
Messages
161
Reaction score
20
First Language
English
Primarily Uses
RMMV
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.
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.
 

AdamSakuru

[Null_Value]
Veteran
Joined
Mar 14, 2014
Messages
314
Reaction score
170
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.
 

RK DracoRoy

Fire Emblem RPG Gamer
Veteran
Joined
Jun 29, 2017
Messages
161
Reaction score
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.
 

SoSick.

Veteran
Veteran
Joined
Jun 29, 2016
Messages
224
Reaction score
191
First Language
english
Primarily Uses
RMMV
Thanks for heads up man! Legend
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
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?
 

RK DracoRoy

Fire Emblem RPG Gamer
Veteran
Joined
Jun 29, 2017
Messages
161
Reaction score
20
First Language
English
Primarily Uses
RMMV

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

On the plus side, if all this rioting sparks another Covid outbreak... I will have a whole lot of time to work on my game. Not exactly how I wanted to get that time, but hey I'm a glass is half full... of RM kind of guy. :LZSwink:
A video once in a while won't hurt.
Have a craving for a Nesquik milkshake. No idea why. Haven't had one since I was a kid. lol. I remember them kinda tasting nice, but also leaving a lot of nasty powder at the bottom of the cup.
The more I think about it, the weirdest part of going to work post-virus will probably be getting used to seeing my coworkers' mouths again. :LZYshock:
I think one of my weirdest realizations is that my speed of game development would probably be about the same if I *didn't* work a full-time manual labor job.

Forum statistics

Threads
98,057
Messages
948,960
Members
129,338
Latest member
Ultra-Maximum
Top