Theo - Insane Anti Lag (Version 1.1 added page check enhancer!)

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,619
Reaction score
5,259
First Language
Indonesian
Primarily Uses
RMVXA
Theo - Insane Anti Lag
For those who insane enough to put a lot of events on map
Version : 1.1​
 ​
Introduction :
As most of you already know, lag is common problem in RPG Maker games. You may think it was because you have many events on map. And so, to avoid lag, you split your map into part and limiting the event as well. 
 
It's not entirely wrong because when you have a lot of events, program need to checks all events. However, it wasn't done efficienly. This script increase the efficiency on how default script works and prevent unecessary update when it's not needed to gain speed.

However, I can not guarantee that it will have high compatibility since I overwrite most of stuff. I will likely to make compatibility with my own scripts. But I'm not sure about someone's script.
 
Screenshot :
 
 

Features :

  • Optimize Event XY. Registered all events into table for faster collision detection using default 32 x 32 grid movement
  • Optimize Event Start. Registered any event that started to prevent check all event and see which is starting
  • Optimize Sprite. Prevent update character sprites located on far away
  • Insane - Table search. When you have insane number of events. It checked map table instead of iterating through all event. So, if you have 10.000 events you will have no worry about performance.
  • Insane - Sprite dispose. When the sprite is off screen, it disposed immediately to prevent performance loss.
  • Insane - Enhance page checking to prevent mini freeze when checking all event pages (*NEW)
Testing :
Tested using Core i3 @ 2.40 GHZ, 4GB of RAM, Windows 7 64-bit with no additional scripts, I got following results :

  • 150 x 150 map with 250 events. I got 60 FPS while no antilag I got 49 FPS at the minimum
  • 17 x 13 Full load of events. All events are on high frequency. I got 30 FPS while no antlag I got 10 FPS
  • 150 x 150 map with 10.000 events, all events are off screen. I got perfect 60 FPS while no antilag I got 1 FPS
  • 150 x 150 map with 10.000 events, and have around 190 events on screen, I got 55 FPS at the minimum. While no antilag, I got 0 FPS.
Limitation :

  • So far this will only works with default grid based movement, not intended to be used together with any pixel movement.
  • Using insane mode antilag will only works if events on screen is around 250 despite of the total events on map.
  • Using larger screen resolution may affect the performance as well
Download :
Click here
 
Final Note :
After all, these are just my attempt to speed up the game. Performance are still under influence by many factors. These include but may not limited to

  • Your CPU speed
  • Your laptop / PC temperature
  • How much power do you give for your CPU
  • Multi tasking
  • Someone's scripts
I once used RM in old computer. When I switched to more advanced laptop, I saw that 60 FPS is really smooth.

If your CPU seems overheat, turn off your laptop / PC for a while for cooling. My laptop was once overheat due to broken fan. When I played my own game I got 10 FPS. I made my own antilag and no one of them worked until I realized my laptop was overheat.

Power saver mode in laptop may affect performance. Try to go high performance instead and let see if the lag gone. Once my friend played my game using power saver mode, and he got 15 FPS.

If you have many programs running at same time, it may cause a little lag in RPG Maker games. Something like the screen won't be updated for a while.

Some scripts can affect performance if it's not done right. This antilag script is tested using default script without additional scripts which directly affect something on map.
 
For scripter, feel free to modify my script to be better and better. You can edit and repost in your own version as long as you credit me, as TheoAllen or Theolized RGSS3.
 
Special Thanks :

  • Tsukihime for performance analisyst
  • KilloZapit who helped me to brainstorm this concept
  • Galv
 
Last edited by a moderator:

KeyToTruth12

Grammar Nazi
Veteran
Joined
Aug 16, 2014
Messages
124
Reaction score
7
First Language
English
Primarily Uses
Let's try it~

Edit: it works!
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
I just tested this with a 800x470 res on a 25x15 map with 1 event and it was putting out 35 fps (just the same as before I put the script in) so unfortunately, this doesn't help with the inadequacies that the new dll (that steam FORCES us to now use) brings. :/

Not that I really expected it to, just kinda hoped ^_^
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,619
Reaction score
5,259
First Language
Indonesian
Primarily Uses
RMVXA
I just tested this with a 800x470 res on a 25x15 map with 1 event and it was putting out 35 fps (just the same as before I put the script in) so unfortunately, this doesn't help with the inadequacies that the new dll (that steam FORCES us to now use) brings. :/

Not that I really expected it to, just kinda hoped ^_^
800 x 470 is not standar RM resolution. I already stated in the limitation
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
lol yea I know, was worth trying though ^_^

I really dont fancy having to rewrite tilemap into a more efficient dll, but atm, that seems like the thing that would improve performance the most imo. :)

Anyway, cool script dude. I never thought of disposing events when outwith the screen, always just left them there not updating. :p
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,619
Reaction score
5,259
First Language
Indonesian
Primarily Uses
RMVXA
lol yea I know, was worth trying though ^_^

I really dont fancy having to rewrite tilemap into a more efficient dll, but atm, that seems like the thing that would improve performance the most imo. :)

Anyway, cool script dude. I never thought of disposing events when outwith the screen, always just left them there not updating. :p
I also tried your antilag script, at the first glance it seems work with many events, but when the character sprites become too much, your script wont work. Hence the idea came up. I guessed that the total of the sprite itself affect the performance even they're not being updated   :)
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
No doubt.

There are also many other random things that can be done for extra performance. Like using a region based movement restriction script, cache-ing various bits of data to avoid the heavy calcs that get done for them (such as finding out if an event can walk on tile [x,y])

Also, when you dont use Tilemap/tiles at all, it lifts the performance dramatically, so yea, tilemap certainly needs redone (well). Thats where the biggest performance boost would come from, for the larger resolutions :D
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,619
Reaction score
5,259
First Language
Indonesian
Primarily Uses
RMVXA
There are also many other random things that can be done for extra performance. Like using a region based movement restriction script, cache-ing various bits of data to avoid the heavy calcs that get done for them (such as finding out if an event can walk on tile [x,y])
I also tried to caching the calculation of round_x_with_direction in Game_Map but it doesn't seems affect the performance so much. So I scrapped the idea. And the way I use @character.screen_x in Sprite_Character is one of the pre-caching trick

Also, when you dont use Tilemap/tiles at all, it lifts the performance dramatically, so yea, tilemap certainly needs redone (well). Thats where the biggest performance boost would come from, for the larger resolutions :D
Well, I don't have the knowledge over the tilemap so I dunno. I don't even know the structure of map data and the tilemap lol

If anyone want to rewrite my script can add tilemap optimization, that would be great.
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
Heres a base structure :)

https://raw.githubusercontent.com/CaptainJet/RM-StarRuby/master/ruby/class/Tilemap.rb

FYI - that base is just as efficient as the default setup - so it could very well be an exact replica for all we know ^_^

Edit:

Just had a good look thought that code and again - it seems to come back to the plane class.. I wonder if RM will ever be fully 'issue free' :p

Obviously those extensive Tilemap calc during each update wont be helping things either :D
 
Last edited by a moderator:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,619
Reaction score
5,259
First Language
Indonesian
Primarily Uses
RMVXA
I guess that's why they limit the resuliton to 640 x 480 at maximum since it's seems the maximum efficiency of the engine can handle. When the resolution is absurbly large, it would be problematic.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
Just had a good look thought that code and again - it seems to come back to the plane class.. I wonder if RM will ever be fully 'issue free' :p

Obviously those extensive Tilemap calc during each update wont be helping things either :D
The plane is not necessary. It's only used to support looping.

Code:
The Plane class. Planes are special sprites that tile bitmap patterns across the entire screen and are used to display parallax backgrounds and so on.
If you don't need looping, don't use a Plane.
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,329
First Language
Binary
Primarily Uses
RMMV
Yea, I personally have no need for the loop, but some folks would.  Suppose it would be easy enough to add some sorta check for that and then create a sprite/plane based on requirements :p
 

MisterTorgue

Explosioooooooons!
Veteran
Joined
Nov 4, 2014
Messages
326
Reaction score
54
First Language
Explosions!
Primarily Uses
The anti lag seems to work pretty darn well with the KHAS lighting system!

I had to try to minimize lighting events without making the maps dark at night time, however now it seems like there is no lag in the big cities when I have a lot of events running.

thank you Theo :)
 

SerpentRose

Veteran
Veteran
Joined
Nov 17, 2014
Messages
46
Reaction score
12
First Language
English
Primarily Uses
Very nice! I was having lag in a small city sector with just lighting events and this cleared that up. Compatible with my long, ever-growing list of scripts, too.
 

MisterTorgue

Explosioooooooons!
Veteran
Joined
Nov 4, 2014
Messages
326
Reaction score
54
First Language
Explosions!
Primarily Uses
Very nice! I was having lag in a small city sector with just lighting events and this cleared that up. Compatible with my long, ever-growing list of scripts, too.
I can second that, I have a lot of scripts currently (trying to remove ones that I dont need) but all lag issues I was having have cleared up due to this it seems!
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,497
Reaction score
12,778
First Language
English
Primarily Uses
RMVXA
So far so good! My biggest map (150 x 150, about 400 events, no lighting scripts yet) ran 59 - 60 FPS (the oddball 59 FPS occurs on my laptop from time to time on empty maps even though).
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,619
Reaction score
5,259
First Language
Indonesian
Primarily Uses
RMVXA
Thank you guys for trying and reporting that this has good compatibility among various scripts.

However, it's known that it has incompatibility with Falcao ABS as some people reported to me.

Just let you to know.
 
Last edited by a moderator:

MisterTorgue

Explosioooooooons!
Veteran
Joined
Nov 4, 2014
Messages
326
Reaction score
54
First Language
Explosions!
Primarily Uses
Hi Theo,

Just found an issue with this script.

When its on it seems to let me actually walk through moving events (still ones it doesn't)

Not sure why?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,619
Reaction score
5,259
First Language
Indonesian
Primarily Uses
RMVXA
It's actually how default script works. I'm sure this is what you mean



For example, when event move from (3,3) to (3,4), now (3,3) will be passable and (3,4) will not
Actual event position is (3,4), but the graphics may late.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I've noticed that the website has changed a lot since I left in August last year...
One of my kitties after a long, tiring day of being adorable.
We have good wifi here now thanks to a guy who had the audacity to tell the Director "Sir, the wifi sucks. Make it faster and increase the bandwidth" in this arrogant tone. The Director is a complete sweetheart so he did just that. So you may see me around often now, being disturbing as usual.
To compensate for me feeling too sick to interact properly, have an old recording of me calming you with Zelda's Lullaby. https://vocaroo.com/jqTcbzdQTw5 :kaojoy:
Finally found someone to make battlers for me. Just wants $50 for a small one. And $75 for a big one. So who wants to help me make a GoFundMe page? Scratch that. How much can I get for a kidney on the black market?

Forum statistics

Threads
93,361
Messages
911,669
Members
122,853
Latest member
Ordan
Top