Let's Anti Event Lag!By Woratana [woratana@hotmail.com]
29/01/2008
I believe that most of experienced RPG Maker users definitely have a problem with lag in their game before. There are many things that can cause lag, and they have different ways to decrease its lag. This article will focus in lag that happens by events (which is the simple thing that most of RPG Maker user starts with).
First, we will take a look about what are the causes of lag from events, then I will tell you about how to reduce the lag.
Causes of Lag from Events1. Parallel Process Events/Common Events: When you are setting trigger of an event, there is 2 choices that will automatically run. They are "Parallel Process" and "Autorun". Autorun will not affect your game as much as Parallel Process, because Autorun will stop other events before run its process, but Parallel Process will run its process in the same time that other events are running their process. So Parallel Process will run every frame and can cause lag if you don't organize it.
2. Too many events:The events on map will update all the time, so they can make game lag if there's too many events in one map.
3. Low RAM:If the player's computer has low RAM, this can make the game easier to lag. I suggest to take a look at RPG Maker's minimum system requirement.
Minimum system requirement for RMXP: http://www.enterbrain.co.jp/tkool/RPG_XP/eng/Minimum system requirement for RMVX: http://www.tkool.jp/products/rpgvx/eng/If the player's computer has lower system than requirement, it will make the game easier to lag. The lag that purely happens because of player's computer system is hardest to solve. However, I found out that RMVX game is harder to lag than RMXP game.
Ways to Reduce Lag1. Add event command "Wait":This is one of the best ways to reduce lag. At the end of "event command list" in your Parallel Process event, add event command "Wait" a few frames below it. This will make the Parallel event don't run at every frame. I always use wait 1 frame, but it's a good idea to use more than 1 frame in case if that Parallel Process event don't important enough to run all the time.
Don't be afraid that "Wait" a few frames will cause bug in your game system, because there is 40 frames per second in normal RMXP game, and 60 frames per second in normal RMVX game. So this way will normally not disturb your game system a lot.
And it's good idea to put "Wait" only below or top of event command list. It may cause bug if you put it in the middle of event command list.
2. Use Anti-Lag Script:You may heard or used Anti-Lag script before, and someone may misunderstand that Anti-Lag script can reduce any lag. In fact, what Anti-Lag script does is to stop update event that is not on the screen. However, Parallel Process and Autorun event still update even though they're not on the screen.
The Anti-Lag script will good to use if there are many non-Parallel Process events in map, and keep in mind that it will not help if many events all pack on the screen. It will work best if events are place on different part of the map.
The 2 popular Anti-Lag scripts are Near Fantastica's and Zeriab's. You can find Zeriab's Anti Event Lag System here:
http://rpgrevolution.com/script/1/3. Use Switch/Condition to Control Parallel Process events:If there is some Parallel Process events that you don't really need it to run all the time, it is good idea to run/stop it by switch, so you can control when it should run and when it shouldn't. This will probably decrease lag if you turn it off in appropriate time.
The other way to make events not run all the time is make condition. For example, do something if variable [hp] lower than 10, or do something if player press button C. This will make the event don't have to process its hard work every frame. And I suggest to add "Wait" a few frame under the condition branch.
4. Try this easy & short Anti-Lag script:I found the Easy-setup Anti-Lag Script by Angelix that I think it will help a lot. This script works different from normal Anti-Lag script that I considered before. What this script does is it will stop update events that you use for decorate map. The "event for decorate map" means the event that has no reaction with the player (for example, the tree that use character set).
Angelix's Anti-Lag Script and How to Use1. Go to Script Editor, in Game_Event. Find this lines:
CODE
attr_reader :starting # starting flag
Add this line below it:
CODE
attr_reader :event
2. Go to Game_Map, find these lines:
QUOTE
for event in @events.values
event.update
end
Replace line
event.update with:
CODE
event.update if event.event.name != "#"
3. Change name for all the "event for decorate map" to be
#Finish!========================================
If there is a question or suggestion, feel free to post~^^