TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
219
Reaction score
103
First Language
English
Primarily Uses
RMMV
Hello! First time requesting a plugin. Don't... think this is too complicated of one?


In MV, when an animation is played for the first time, I'm seeing... a tiny amount of lag/framerate dips. Like, for a half a second, it drops from 60fps to, like, 45 or 30fps. Nothing too awful, but it happens for every animation, and it is a little noticeable, even with 1.1's new handling of fps. Only the first time though that an animation is played. Use it again, and the animation runs fine. Even if the battle is loaded out of, then a new battle starts. So, this seems to be an issue of lagging while loading.


What I am requesting is this. A plugin command call that could load... something. An animation. An audio file. Just resources in general. Not to display right then and there, but to simply have the file loaded early, to prevent any future lag. Like, before a huge animation plays, load it, to prevent it from lagging, even just a bit, when it plays.


If possible, it would be nice to check and see if the resource was already loaded into the game somehow.


I've used the Preload Manager for this, but it doesn't seem to work well enough. Still seeing hiccups. Minor lag, but lag nonetheless. Just trying to see MV run as smooth as possible.


Any help would be greatly appreciated.
 

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
219
Reaction score
103
First Language
English
Primarily Uses
RMMV
Testing out some things.


Made a dummy battle, and before the battle loaded, gave a 2 choice option, to either "preload" with a script call, or just battle normally. Battling normally had standard lag upon casting Spark. I changed Spark's animation to Thunder All 3, giving consistent drops to 18 fps the first time being used. For, like, a half second, then it shoots back up to 60 fps. Clearly, it's just because of the short load time.


So, the preload option then! Before the battle starts, I do a script call. The preload script that I wrote is:


ImageManager.loadAnimation("Thunder5", 0);


ImageManager.loadAnimation("PreSpecial1", 0);


Those are the 2 images inside of Thunder All 3, so, thought process is, if I just tell the game to load these images earlier, it won't lag during the casting in battle.


...And it doesn't work at all! Really hoping something simple and stupid like this would work, but, no such luck.


At this point, my simple programming knowledge is coming to a wall. Took long enough to understand Ruby code, and MV doesn't use that anymore! I don't know why this isn't working. Am I even on the right track here?


Oh, and, also...


BUMP!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,828
Reaction score
14,500
First Language
English
Primarily Uses
RMMV
It may not be getting called.  


ImageManager.loadXYZ returns a bitmap, so it might be worth saying bmp = ImageManager.loadAnimation("Thunder5", 0) just to put it into something.  However I'm more inclined to think that your commands aren't even getting executed.


What happens is that ImageManager puts an image into its cache after it's been loaded.  Next time that image is needed, it just returns the object in cache rather than loading it again.  When an image is requested, it looks to see if it already has it - if it does, it sends back the cached version; if it doesn't, it loads it from disc.  This is why, the longer you play in one sitting, the less you'll see of this lagging, as the images are being kept in cache.  The moment you close the program, the cache is lost.  When you start up again and go to play an animation that had no lag in the last sitting, it will lag, because the animation isn't in cache.


To remove absolutely ALL lag from image loading, you would need to load EVERY image resource when the program first runs - animations, battlers, characters, tilesets, and everything else.  If you want to do that, look for the place where the System images are loaded, and add the rest of your images there.  Of course, this is going to cause a big delay each time the game is started up, and as ALL the images are going to be cached at that point, you'll be using a lot more RAM than if you just loaded the images as they were needed.
 

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
219
Reaction score
103
First Language
English
Primarily Uses
RMMV
Yeah, adding everything to the cache would be a little overkill. Only really want the things that noticeably lag the game in there. A tiny 32x32 sprite isn't really gonna lag the game when loading at all.


Looking through the js files to the best of my ability. I see where in rpg_managers.js the cache is getting added to, but I don't see any spots that system files automatically get added to the cache. I found the ImageManager.loadNormalBitmap function. That has checking if an item is in the cache, and adding it if it isn't... I think. But that's just a subfunction of what I was calling before, so it isn't helpful to call upon. Maybe I'm just missing the spot...? Unlike Yanfly code, these default js files are not very user friendly for reading. I mean, they are NOT suppose to be edited, after all, unless you absolutely know what you'red doing. Still wish they had some more comments to them.


... Though in all of this, I suppose I have a clearer idea of what this plugin request really is: A plugin command that adds a file directly to this cache! So, like, a big cutscene is about to play that's full of one time animations that have never been seen before, and cannot afford to have lagging. Call this plugin, add those animations to the cache, during, like, dialogue or something, where loading would be unnoticeable, then when the animations play, they play seamlessly! That's kind of the idea. You'd be able to smartly load things into the cache as needed. Probably wouldn't be much work at that point to have another plugin command that could delete selected items from the cache, to be easier on your RAM.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,828
Reaction score
14,500
First Language
English
Primarily Uses
RMMV
It's in Scene_Boot.prototype.loadSystemImages - starting line 167 of rpg_scenes.js - all you've got to do is add all the images you want into that function.
 

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
219
Reaction score
103
First Language
English
Primarily Uses
RMMV
I added my files, and then some to cover even potential other bases, but I'm still experiencing the same first time play lag. Currently, this is the code in rpg_scenes.js:


Scene_Boot.prototype.loadSystemImages = function() {
    ImageManager.loadSystem('Window');
    ImageManager.loadSystem('IconSet');
    ImageManager.loadSystem('Balloon');
    ImageManager.loadSystem('Shadow1');
    ImageManager.loadSystem('Shadow2');
    ImageManager.loadSystem('Damage');
    ImageManager.loadSystem('States');
    ImageManager.loadSystem('Weapons1');
    ImageManager.loadSystem('Weapons2');
    ImageManager.loadSystem('Weapons3');
    ImageManager.loadSystem('ButtonSet');



    ImageManager.loadAnimation('Thunder1');
    ImageManager.loadAnimation('Thunder2');
    ImageManager.loadAnimation('Thunder3');
    ImageManager.loadAnimation('Thunder4');
    ImageManager.loadAnimation('Thunder5');
    ImageManager.loadAnimation('PreSpecial1');
    ImageManager.loadAnimation('PreSpecial2');
    ImageManager.loadAnimation('PreSpecial3');
};



When I mispelled a file name, I did get an error, so they are being read properly too.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,828
Reaction score
14,500
First Language
English
Primarily Uses
RMMV
then maybe it's caused by something else?  Are there other animations that could be loading that you haven't preloaded?  What about the battlebacks?  You could go into your ImageManager script, to the generic method that loads the resource (it's called by loadAnimation, loadBattleback, etc) just to print to the console what image is being loaded.  Then when you go into a battle, see if there are other things listed in the console that are being loaded that you hadn't thought of.
 

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
219
Reaction score
103
First Language
English
Primarily Uses
RMMV
I don't know how to do really anything with the console, printing or reading what's been printed, but I did my best testing this in other ways. I removed the battle, and just have a guy standing in an empty room with non animated tiles. Talk to him, he plays the animation Thunder All 3, and nothing else.


First time it plays, it lags, next time it plays, it runs perfectly fine, just like what happened in combat. There are no plugins, and the only change to the default js files are the extra load lines listed above. I am using version 1.1.0.
 

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
219
Reaction score
103
First Language
English
Primarily Uses
RMMV
Most likely final bump.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,871
First Language
English
Does this occur in a new project without any plugins?
 

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
219
Reaction score
103
First Language
English
Primarily Uses
RMMV
Yes, I believe so. I do not have MV installed anymore to test, but I am sure it was with all projects, plugins or not.
 

Latest Threads

Latest Posts

Latest Profile Posts

It's been half a month and I didn't give signs of life, not even in my website.

I've been studying about my project and I discovered something that I definitely think it will be better.

On the other hand, I still have to learn how to use it properly so I need time.
This catgirl name is Elyune.
Her hobby is cooking and eating sweets. She's also an alchemist.

Cat_girl.jpg
catgirl-1.jpg
Raptor Revolt Demo 4_10_2021 3_12_09 PM.png

Latest custom tileset work for RAPTOR REVOLT in this beach scene set in the acheroraptor capital in Ridge City, Hell Creek.
unknown.png


I figured it was about time to update the battle sprite for one of my characters. The old one was the first time I ever drew a battle sprite, and filled with lines that shouldn't be there. So far, the new one is cleaner.
EQAQeW8.png

This was supposed to become her neutral talking stance, but now i just feel like she looks a little puzzled :D
I'm also open for any name suggestions, as i seriously suck at those. In my notes everything is just THE CITY or THAT GUY and THIS PRIESTESS or whatever :D

Forum statistics

Threads
110,284
Messages
1,051,957
Members
143,304
Latest member
DarkBear
Top