Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Zeriab's Anti Event Lag System ~ Version 1.2

Zeriab

Sponsor

Zeriab's Anti Event Lag System
Version: 1.2b

Introduction

This system changes the design used for controlling the events on the game map as well as reducing the number of character sprites outside of the visible area.
The new design for the events should in most cases give faster collision detection
In certain situations this system should be slightly slower though I doubt it can make any noticeable difference.
This script only makes event collision detection faster in the case where all the events are visible.
The greatest benefit from this script comes from large maps with sparse population of events. Basically, events do no come together loads at a time.

Version history
Version 0.8 -------------------------------------------------- (2007-09-03)
- First release

Version 0.81 ------------------------------------------------- (2007-09-05)
- Overwrote Game_Map's passable? method for faster collision detection

Version 0.9 -------------------------------------------------- (2007-09-12)
- Support for the Non-SDK patch
- Support for defining whether and event will always be updated or never be updated by defining name patterns.

Version 1.0 -------------------------------------------------- (2007-09-24)
- Fixed compatibility issue with Blizzard's Caterpillar script
- Overwrote more methods scanning for events on a specific tile
- Support for defining whether an event will always be updated or never be updated by specifying the event's id and map_id
- Some structural changes.
- Integrated the Non-SDK patch into the main script

Version 1.05 ------------------------------------------------- (2007-11-18)
- Fixed bug where sprites might not be disposed when changing scene.

Version 1.1 -------------------------------------------------- (2008-04-10)
- Added declaration to which common events to update

Version 1.15 ------------------------------------------------- (2008-06-19)
- Added automatic detection of which common events to update (optional)

Version 1.2 -------------------------------------------------- (2008-07-04)
- Fixed a case where an event could be registered twice causing transparent
events to look less transparent.

Version 1.2b ------------------------------------------------- (2008-09-12)
- Fixed a stack error problem caused when pressing F12.

Features

Easy to alter the size of the visible area. (In combination with resolution scripts for example)
Pattern matching on event names to ease determination of events needing special treatment. (Never update and always update)
Specify special update schemes for events by their id and the map they are on.

Screenshots

The screenshot was taking from my test map included as an attachment. There are 662 events on that 500x500 map.



Demo

http://www.sendspace.com/file/0up9up (Mirror)

Script

Zeriab's Anti Event Lag System version 1.2
Note: The comments in the script are aimed at other scripters. Don't be scared by it.

Repository with different versions and the demo

Installation

You don't have to do more than copy and paste the script into the script editor BUT where you paste it matters.
If you are using the SDK 2.0+ paste the script just below the SDK.
If you are are not using the SDK then paste the script just below the default scripts

The structure in the script editor should be like this:
default scripts
(SDK)
Zeriab's Anti Event Lag System
(custom scripts)
main


Pasting the script just above main has caused errors!

You can add [A] to the name of an event if you want it always updated. A typical example is that you want an event outside of the screen to move around properly.
You can add [N] to the name of an event and it will never be updated. Great for non-animated decoration events.
Note that if you have both [A] and [N] in the name of the event the event will never be updated.

If you are not satisfied with the default settings or are curious you can look into the customization possibilities
A little below the big header there is a customization area (line 265-284) which contains:
[rgss]class Game_Map
  ALWAYS_UPDATE = false
  BUFFER_SIZE = 1
  TILES_VERTICAL = 15
  TILES_HORIZONTAL = 20
  LIMIT_COMMON_EVENTS = true
  SPECIFY_COMMON_EVENTS_MANUALLY = false
  # If you want to specify which common events to update
  COMMON_EVENTS_TO_UPDATE = []
  # If you want the script to automatically read the common events and find
  # out which to update. Must be the path to the CommonEvents.rxdata
  COMMON_EVENT_FILEPATH = 'Data/CommonEvents.rxdata'
end
 
class Game_Event
  SPECIAL_UPDATE_IDS = {}
  NEVER_UPDATE_NAME_PATTERNS = ['[N]'] # [N] in the event name => not updated
  ALWAYS_UPDATE_NAME_PATTERNS = ['[A]'] # [A] in the event name => always updated
end
[/rgss]

There are comments on how to use each constant in the script header. Those comments are aimed at other scripters and can therefore be fairly difficult to understand for non-scripters. The examples in the header can useful even if you are not a scripter.
I will explain each constant in a more humane way. (Using this in unison with the instructions in the header might yield the best result)

I'll start by going through class Game_Map.
ALWAYS_UPDATE
Set this to true if you want all events updated. All events will on the map will be updated just like with the default scripts. This is slow, but you will still get the effects of the changed collision detection and sprite management.
I included this option for compatibility reasons more than anything else. Don't use this if you want a few events outside of the screen to be constantly updated. In that case refer to the stuff in Game_Event

BUFFER_SIZE
The buffer size tells how many tiles outside of the visible area should be updated.
If you have many big sprites (for the events) and get the sprites just disappearing or 'freezing' for a moment near the edge of the screen the solution can be to increase the buffer size.
Be aware that increasing the buffer size makes the game slower.

TILES_VERTICAL
Use this to tell how many tiles there on a vertical line across the game screen.
Only change this value if you change the resolution.

TILES_HORIZONTAL
Use this to tell how many tiles there on a horizontal line across the game screen.
Only change this value if you change the resolution.

LIMIT_COMMON_EVENTS
Set this to false if you do not wish to limit which common events are updated.
If you do not limit the common events the next three constants have no effect. (SPECIFY_COMMON_EVENTS_MANUALLY, COMMON_EVENTS_TO_UPDATE, COMMON_EVENT_FILEPATH)

SPECIFY_COMMON_EVENTS_MANUALLY
Set this to true if you want to specify the common events manually. This is not recommended for beginners.
You will have to fill out COMMON_EVENTS_TO_UPDATE if you set this to true. COMMON_EVENT_FILEPATH will have no effect if this is true.
If this is set to false then COMMON_EVENTS_TO_UPDATE will have no use. The script will automatically detect which common events to update if this is set to false.

COMMON_EVENTS_TO_UPDATE
Fill in the array with the common event ids you want updated. (Look in the database for the numbers)
All other common events will not be updated. They can still be called using the call common event command, but they will not be started if they have the autorun or parallel process triggers.

COMMON_EVENT_FILEPATH
The path to where the common events are stored.
Only touch this if you have changed the filename where the common events are stored. If you don't know what this means then chances are that you should not change what is given.


Next we come to class Game_Event which is a bit more complicated to customize.
Typically you can be fine without modifying the following constants. Id y
SPECIAL_UPDATE_IDS
You can use this to say that specific in specific maps must always be updated or never updated.
If an event is always updated it acts just as it does with the default scripts.
If an event is never updated it not move. Neither with Autonomous Movement nor the event command 'Set Move Route...'. You can still to some degree interact with it but in general use the never update feature for decoration events.

NEVER_UPDATE_NAME_PATTERNS
You can use this to specify new patterns to look for in the names of the events.
If the name of an event matches at least one of the patterns it will never be updated.
A pattern can both be what is called a regular expression and a string. If you don't know what a regular expression is or don't understand them then don't try to use regular expressions.
The string is a piece of text and the name of the event will be checked if that piece of text is anywhere in the name. The text have to be surrounded by either 'text' or "text". There is no practical difference in case of this script.
If an event is never updated it not move. Neither with Autonomous Movement nor the event command 'Set Move Route...'. You can still to some degree interact with it but in general use the never update feature for decoration events.

ALWAYS_UPDATE_NAME_PATTERNS
You can use this to specify new patterns to look for in the names of the events.
If the name of an event matches at least one of the patterns it will always be updated.
A pattern can both be what is called a regular expression and a string. If you don't know what a regular expression is or don't understand them then don't try to use regular expressions.
The string is a piece of text and the name of the event will be checked if that piece of text is anywhere in the name. The text have to be surrounded by either 'text' or "text". There is no practical difference in case of this script.
If an event is always updated it acts just as it does with the default scripts.

Q&A's

How can I make sure that an event outside of the screen moves like I told it to?
Change the name of the event so it always updates.
With the default configurations you can do this by adding [A] anywhere in the name.

Compatibility
This is SDK compliant. It is written for SDK version 2.3.
It has not been tested with older versions.
Requires SDK Part 2 or the Non-SDK patch version 1.1

The following methods has been overwritten:
  • Game_Character.passable?
  • Game_Map.passable?
  • Game_Map.update_events
  • Game_Player.check_event_trigger_here
  • Game_Player.check_event_trigger_there
  • Game_Player.check_event_trigger_touch
  • Spriteset_Map.init_characters
  • Spriteset_Map.update_character_sprites

The following methods have been aliased:
  • Game_Event.jump
  • Game_Event.moveto
  • Game_Event.move_down
  • Game_Event.move_left
  • Game_Event.move_right
  • Game_Event.move_up
  • Game_Event.move_lower_left
  • Game_Event.move_lower_right
  • Game_Event.move_upper_left
  • Game_Event.move_upper_right
  • Game_Map.setup

Paste this code in a new section anywhere below Rataime's Sun Effect and above main. (use can press Insert to create a new section)
[rgss]alias Zantilag_XPML_read XPML_read
def XPML_read(markup,event_id,max_param_number=0)
  return if $game_map.events[event_id].nil?
  Zantilag_XPML_read(markup,event_id,max_param_number=0)
end
[/rgss]

Paste this code in a new section anywhere below Near Fantastica's Particle Engine v2 and above main. (use can press Insert to create a new section)
[rgss]class Spriteset_Map
  def update_character_sprites
    nf_particles_spriteset_map_update_character_sprites
    for sprite in @character_event_sprites
      next unless sprite.character.is_a?(Game_Event)
      if sprite.character.pe_refresh == true
        sprite.character.pe_refresh = false
        @particle_engine.remove_effect(sprite.character)
        @particle_engine.add_effect(sprite.character)
      end
    end
  end
end
[/rgss]


Credits and Thanks

Thanks goes to Enterbrain for making this possible.
Special thanks to Blizzard for many suggestions, help and support :3
Special thanks to:
Eilei
Shadow Wolf
Untravaersil
darksora

I would like to thank everyone using their time to try and use my system.
I would like to thank everyone reading this topic.
Thanks.

Terms and Conditions
Copyright (C) 2007 Zeriab

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser Public License for more details.

For the full license see
The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt

Author's Notes

I would be delighted if you report any bug, errors or issues you find.
In fact I would be delighted if you took the time and replied even if you have nothing to report.
Suggestions are more than welcome

And finally: ENJOY!

- Zeriab
 
All I can say is that you made an Event anti-lag system in a different way than the others out there(to the best of my knowledge anyway). I'm awed by your uniqueness 0_o (No, really! You really impressed me!)
 

Untra

Sponsor

scratch that, this script is not compatible with sdk 1.5. Because of so, I would imagine sdk 1.5 and below are not compatible with this script.
 

Zeriab

Sponsor

Thanks for your comments. I'm glad you liked my system ^_^
Sorry for the late reply. I have been a bit busy.

Thanks for telling me that it is not compatible with sdk 1.5 and lower Untra.

*updates to version 0.9*

Enjoy ~
 
Very useful, indeed Zeriab!! Great work. It's very nice to see a lot of characters walking freely in map without lagging. Now, it's possible to make "war scenes".
 

Zeriab

Sponsor

War scenes should run better now ^_^
Just remember that if you have too many events visible at the same time you will still get some lag.
I am not sure how many events do define 'too many'. This would be something you should test ;)

Thanks for the comment
 
This is the first antilag script I have ever used that has actually worked (for me). Brilliant!

Am I allowed to use this in a commercial game? (With credit, of course)
 

Zeriab

Sponsor

I'm glad it works for you ^_^
If there is anything that irritates you or anything that want or think would make it easier to use for you then please do tell.

Now on to your actual question. I have actually already given the answer.
I thank you nonetheless for asking. The license is in the script header.
Code:
#------------------------------------------------------------------------------
# * License :
#
#   Copyright (C) 2007  Zeriab
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Lesser Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Lesser Public License for more details.
#
#   For the full license see <http://www.gnu.org/licenses/> 
#   The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
#   The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
This means that the answer to your question is: Yes, you can use it for commercial products.
I will be sure to include a terms and conditions in the topic with the next version.

~ Zeriab
 
Now I know how to install it without SDK ^_^;

Doesn't help too much (your demo still lags at 8 FPS), even after I combine it with f0tz!baerchen's, but I guess it's my computer to blame, which cannot stand with RMXP power. At least, I like it because it doesn't affect the menu (which other antilag system affect my game somehow). So, I'm using it right now.

Thanks for the script! Awaiting for next versions...
 
I tried the demo purely without f0tz!baerchen's, so I really guess it's my computer :(

As for comparison, Zeriab's will do roughly constant 4 FPS (not 8 as I wrote above). When combines with f0tz!baerchen's, it raises at about 8-10 FPS, but will drop, even worse, to 2-3 FPS when meeting any events. Maybe I must choose which one I should use, rather than both...
 

Zeriab

Sponsor

Hey Exsharaen

Am I correct in assuming that you have not changed the configuration in the demo? (Setting the ALWAYS_UPDATE constant to true will for example make the big map run much slower in the test demo)

I am very interested in knowing your system specifications. Could you tell me what you have in your computer? (cpu, ram, etc.)
Also did you have anything else running at the same time?

It could be that my anti-lag script is slower on small maps. My computer is too fast for me to test it properly.
You should be careful about merging my anti-lag script with other anti-lag scripts. It could easily happen that events stop functioning properly.

I'm trying to make this script as good as possible :)
 
Yes, I use the very default configuration. Is there any configuration I miss so it will be better?

As for my computer specs:
Intel Celeron 1.70 GHz
512 MB RAM
(this one lacks of RMXP power) nVidia GeForce2 MX 100/200, 32 MB VRAM
Display mode when I test: 1024x768 (32 bit)
I think only those play role in playing RMXP games, but if anything is missing, let me know
And yes, I tested it when my Firefox was running, along with a firewall, an antispyware, and an antivirus. I'll shut them off down right now and see if it helps.

The small map runs smoothly. It is the big map that gives me problem. And well, I'll try to find out if f0tz!baerchen and yours used along at the same time will cause any problems (so any other won't do this). Programmatically, they don't interfere (as different classes are used), but I'll inspect more.

Be back in a moment...

EDIT:
Tried it solely without f0tz!baerchen's after anything else was shut down, no change in config. At the big map, it runs better, about 6-12 FPS (constant at 8 FPS). When meeting with a single event (a guy, a fairy, etc.) it drops to 6-8 FPS (constant at 6 FPS). But, as you say, it lags when too many events are all around (drops to 3-4 FPS).

Thanks for your concern. Some people in my country has computer worse than mine, so an antilag is crucial to help play RMXP games smoothly.
 

Zeriab

Sponsor

Sorry for the late response.

Version 1.0 is up ^_^
Version 1.0 -------------------------------------------------- (2007-09-24)
- Fixed compatibility issue with Blizzard's Caterpillar script
- Overwrote more methods scanning for events on a specific tile
- Support for defining whether an event will always be updated or never be updated by specifying the event's id and map_id
- Some structural changes.
- Integrated the Non-SDK patch into the main script

Hmm... f0tz!baerchen's scripts changes the priority of the game. This means that the window system will theoretically use more time on the game at the price of other programs you have running.
I have a dual-core and RMXP is single threaded. This means the feature has little to no effect on my computer.
I could try to integrate the CPU utilization features into my script and see what happens. I will however need your help because I testing it properly is difficult on my computer.
First however I have to ask for permission to use parts of f0tz's script :)
 
Just some info for ya, thought it might be useful:

Main laggy things in this test:
-Mr.Mo's SBABS
-Mr.Mo's Interactive Mouse System
-Map is 200x200 with many events and a max size tileset

(game is set to high priority in all these)
With no antilag scripts: ~18 FPS
With just fotz's antilag script: ~22 FPS
With fotz's and this one: ~23 FPS
With just this one: ~29 FPS
 

Zeriab

Sponsor

@Exsharaen:
That would make me very pleased.
Could you try and see how it runs now with and without f0tz!baerchen's?

@Wyatt:
Thanks a lot Wyatt ^_^

Does the script work fine with Mr.Mo's SBABS?
I have never tried it myself.

@bojox3m:
Like Wyatt said you can press F2 to see the FPS on the game title.
Like with F9 (debug menu) you have to run it from within the editor. It will not work otherwise.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top