Lags in battle when opening skill window?

Status
Not open for further replies.

kerbonklin

Hiatus King
Veteran
Joined
Jan 6, 2013
Messages
1,726
Reaction score
275
First Language
English
Primarily Uses
RMMV
What are some of the scripted things to look/search for that could potentially cause lag when opening actor skill windows in battle? I drop down to like 10 FPS and it lingers on until process_victory/defeat.

One thing i'll try later is searching for Window_BattleSkill and Window_SkillList stuff. I will not list my current list of used scripts, I don't have much time to and i'm just looking for broad hints of the cause(s). As well as the old "delete scripts 1 by 1 and check" method.

I have to go to sleep, so i'll be back in the morning to read any responses.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I recall once when a 'list' type window REALLY lagged noticeably, it was because I was drawing an outline around all the text, and everything was being rewritten on every frame. But that was in XP, and Ace has its own methods of drawing outlines. In Ace, that might equate to completely redrawing the list in the update method, rather than in the refresh method.


I'd be looking at those same scripts that you indicated, for starters. Particularly any that you've made mods to.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
a good start might be to look for all scripts that open the window as they might be doing some extra things... so maybe try doing a whole list search of @skill_window.open or @skill_window.activate or simply @skill_window

and any script that modifies the Window_BattleSkill... especially the update, update_basic and the refresh methods...
 
Last edited by a moderator:

kerbonklin

Hiatus King
Veteran
Joined
Jan 6, 2013
Messages
1,726
Reaction score
275
First Language
English
Primarily Uses
RMMV
Okay, I found the issue.  I had @skill_window.refresh within the Scene_Battle update(basic) and that's what caused it. Sadly the reason why I had this modification in the first place was to un-gray out skills that are only usable within certain $game_timer frames.  Is there any other way I can do such a thing so that I can achieve the same result without @skill_window.refresh?

I had an old Support thread on the subject found here.

I was thinking maybe there's a way to only do @skill_window.refresh when the switches are turned on/off by $game_timer, to possibly lighten the load. Actually this may be bad cause it would have to do it for both on/off scenarios and that's just the same thing as updating every single frame... Sadly I cannot shove .refresh method into the Game_Timer class.  If there was a way to do so, then this would be super easy to fix. =/

Edit: I think I found a solution. I managed to make it

def update_basicsuper@skill_window.refresh unless @ungray == false@ungray = falseAnd then the switches going on/off within Game_Timer turn @ungray = true.  So far my FPS is remaining at 60 but I need more testing to confirm.

Edit 2: Sadly it ain't working right, which update has priority? updating scene_battle or game_timer? I feel like it's scene_battle so that it doesn't get to do the refresh cause scene_timer makes it true afterwards.

Edit 3: Okay so if I turn it into

def update_basic super @skill_window.refresh unless @ungray == false if @ungray == true @ungray = false endthen it works perfectly, however my FPS drops to 40 for the remainder of the battle. Is there a better way to optimize this?
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That's a bit of a convoluted way about it.

unless @ungray == falsecan be written as
Code:
if @ungray
For the lot you could just do this:
Code:
if @ungray  @skill_window.refresh  @ungray = falseend
But that won't change the fps.Instead of calling the refresh method, you could create a new method that would identify which ones need to be rewritten, clear the bitmap for the correct rect, and just rewrite the entries that have changed, instead of rewriting the whole thing. But unless your skill list is quite large, that won't make much of a difference.

I wonder if there's something else affecting it?
 

kerbonklin

Hiatus King
Veteran
Joined
Jan 6, 2013
Messages
1,726
Reaction score
275
First Language
English
Primarily Uses
RMMV
OKAY SO I FOUND A WEIRD SOLUTION!

Instead of using @ungray, being an Instance Variable, I changed it to $ungray, being a Global Variable. It fully solved the FPS lag issue for some reason. O_O  You think you (or anyone) can explain how? Cause I certainly don't understand. xD

Note to everyone - if an @ variable (instance) cause FPS lag within things like "def update", make it a $ variable (global) instead.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I wouldn't offer that advice. Better to keep global variables to a minimum.


Did you initialize @ungray during window creation?
 

kerbonklin

Hiatus King
Veteran
Joined
Jan 6, 2013
Messages
1,726
Reaction score
275
First Language
English
Primarily Uses
RMMV
Did you initialize @ungray during window creation?
Nope! Maybe that's why. But wouldn't it have given me an error though if I didn't?

Oh well at least my situation is fixed one way or another.  Thanks for the programming lesson.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
No, because if you don't define it, it's nil.


It would have given you an error if you'd tried to do something like this: @ungray += 1 and it hadn't been defined, because there is no + operator for a nil class.


But you're only doing comparisons, and you can compare nil with other values. if nil == true and if nil (which is the same thing) will both result in false.


I don't really know that that would be contributing to the significant lag though. Would certainly be interesting for you to declare and initialize it on window creation, and then see if that makes a difference to your fps.
 
Last edited by a moderator:

kerbonklin

Hiatus King
Veteran
Joined
Jan 6, 2013
Messages
1,726
Reaction score
275
First Language
English
Primarily Uses
RMMV
Alrighty, i'll try that and report my findings. Where should I initialize it? Window_BattleSkill, Window_SkillList, Window_Selectable, or Scene_Battle?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
If your code is in the Scene_Battle class, and is to do with updating the @skill_window property, then I'd probably put it into the create_skill_window method - just add @ungray = false at the end of that method.


Where do you set it to true, and what conditions do you check when determining whether to set it to true or not? THAT could be where the lag is.
 
Last edited by a moderator:

kerbonklin

Hiatus King
Veteran
Joined
Jan 6, 2013
Messages
1,726
Reaction score
275
First Language
English
Primarily Uses
RMMV
Well, my tests after initializing @ungray within create_skill_window, and various other places like Scene_Battle def start, Game_Timer def initialize, etc. come up not-applicable. The FPS problem fixes BUT my switches and @skill_window.refresh goes wrong apparently.

By looking at the console that you helped me with earlier, it tells me that the switch immediately ends up turning off as soon as it turns on, without doing the skill_window.refresh. (which after the refresh it should turn off)

This seems to be a special case for me.  I'll just stick to using Global Variables $ungray for this case.

This thread can be locked I guess.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I'm sure, if you sent me the code to take a look at, I could help you figure it out. With my scripts, rather than just "making it work", I like to know why things weren't working in the first place, and fix them properly - only then can I be sure they won't start glitching again later for some unknown reason.


But if you're happy with the current solution, I'll go ahead and lock it. :)


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top