[RGSS] [RMVX] Anti-Lag

Script made by Anaryu. Posted with his permission.
Contact info: [email hidden]

If you have any questions or concerns, please contact Anaryu, not me!
I did not work on this at all. I'm just an artist, not a programmer.


//---Post by Anaryu---//
//================//

RMVX Anti-Lag

Welcome to the second script I've bothered to release, this one is rather unique and fixes the problem that both RMXP and RMVX share: serious lag as the amount of events on a map is increased.

Version History:
1.0 (March 3rd, 2008): Initial version released.
1.1 (March 4th, 2008): Added "DOSPRITE" and "DOLOC" and "DOUPDATE" tag checking from event name to allow users to ensure an event's location (x/y), update function, and/or sprite are created and used regardless of the auto-parsing features.
1.2 (March 5th, 2008): Added a big update for efficiency for tons of moving events and character events (doors, NPCs, etc) fixed several potential annoyances and bugs.
1.2a (March 6th, 2008): Changed screen size check for on_screen function to use Graphics instead of static values.
1.2b (March 7th, 2008): Changed Game_Player to use the standard set/get functions and changed check for empty array to use emtpy? function.
1.2c (March 10th, 2008): Updated events that used a tile and a character on multiple pages to be drawn as a sprite correctly. (eugene)
1.2d March 14th 4:12am EST: Fixed errors with vehicles, passability, and airship landing.
1.2e (March 18th, 2008): Fixed tileset and passability errors with multi-page events.
1.2f (June 9th 4:34pm EST): Fixed errors with diagonal movement having the turn_ok setting passed in while the original functions didn't use it.
1.2g (June 20th 7:49pm EST): Fixed bugs regarding diagonal movement for events (last update was just player!) and fixed bug with jump function not updating location.
1.2h (September 20th 10:35am EST): Added a check so changing graphics on a blank event from another event, or using Show Animation or Show Bubble will activate the event automatically and set it to be in use. Also added two new globals to allow you to choose how far off-screen updates will still be performed (see below.) Also fixed efficiency loss by having several math functions in the on_screen function (called constantly) and moved those to initialize function instead.

How to use it:

To use it, just copy the "AS: Anti Lag" from the Script Editor to your own project below "Materials" (you know the drill!)

What this will help with: (and a rating on a scale of 1 (a little) to 10 (complete elmination) of how much it will help)

1. (10) Lots of events used as tileset graphics (event graphic is a tile)
2. (10) Lots of events that don't have a graphic but do something
3. (8) Lots of events that don't do anything
4. (8) Lots of moving events/characters on a large map (many offscreen at a time)
5. (3) Lots of moving events/characters on screen at the same time

NEW:
You can increase how many squares off-screen the system will update events (see instructions at the top of the script). You can use this to keep large sprites from ghosting on the screen edge.

If you have any scripts that use an event based on a comment and do so with blank events, for example a jumping script that keeps players from jumping over any squares with a blank event with a "NOJUMP" comment or such, you can use these special tags to ensure the system isn't ignoring those events.

Put the tag in the event's name box: (can have all three together)
DOSPRITE: Ensures that the event will have a sprite regardless.
DOUPDATE: Ensures the udpate calls will always be called.
DOLOC: Ensures the events location is recorded.

If you wanted all three on at once, an event name could be: Door5DOSPRITEDOLOCDOUPDATE or Door3DOSPRITE-DOLOC-DOUPDATE, etc.

If you're not sure what good these are, you probably won't need to use them!

Anything neat?

You can now paste as many events that are single tiles (not characters, but map tiles that don't change) and have NO extra lag (it acts like a third layer instead of an event).

How it works for scripters:

For those with scripting knowledge, this first takes the awful loop out of everything (no more for event in $game_map.events) and instead uses a hash to track event locations.

It will take all events that are tile graphics that don't change (either all pages are the same or it only has one page) and create another tilemap and add those events and set them to not generate a Sprite (events become another layer instead of X amount of sprites to be updated.)

It also takes all events that never have a graphic, and eliminates the creation of a sprite (big efficiency gain).

It takes events that are never run and only have comments (to support other scripts that require comments on events) and will ignore the update command on them.

(It also combines all of these gains, so a blank event with a comment on it that is just used to say display a particle or mark something will work but not cause the system to process it or create a sprite to process.)

Disclaimer:

I've done some testing with this, but it's only been light testing and the changes are pretty low-level, so please report if this is causing weird conflicts, I will try to keep this one supported a bit, but I also will NOT promise compatability with other scripts. (This might be a non-issue thanks to VX's amazing organization of script methods.)

Download:
http://anamei.net/files/AntiLag.zip

Screenshot:

This image is of the "lag" on a map 25x25 filled on all squares but 1 (player start point) with events that have a single tile set for their graphic as well as a moving character and a couple test chests. (Total of 624 events on the map)

The map the kid transports you to has 221 Parallel events that do nothing but Wait 1 frame over and over.

If you want to see the difference in lag, make a copy and then delete the "AS: Anti Lag" script and then run the game again to see what your standard FPS is without it!

http://anamei.net/files/images/al/ALScreen1.jpg[/img]
THX This is very helpful. 🙂 🙂 🙂
Can i post this script in an german board?
I will say that all credits go to you.

When in fact all credits should go to Anaryu : ) - arevulopapo

Oh i dont have seen it. Can someone say were i can find him?
I love you. This is brilliant. Absaloutley amazing.
*nabs*
eugene222 wrote:
THX This is very helpful. 🙂 🙂 🙂
Can i post this script in an german board?
I will say that all credits go to you.

When in fact all credits should go to Anaryu : ) - arevulopapo

Oh i dont have seen it. Can someone say were i can find him?



Script made by Anaryu. Posted with his permission.
Contact info: [email hidden]


Please don't credit me at -all- for this.
All credits go to Anaryu!

Please feel free to contact him via e-mail.
I will also ask him when he gets home (we're husband/wife).
Family business, isn't it? :D Good to have such a script, although the new RM is much more powerfull, so it will handle many times more events than XP.
arevulopapo wrote:
Family business, isn't it? :D Good to have such a script, although the new RM is much more powerfull, so it will handle many times more events than XP.


It still lagged pretty bad. Trust me. I saw him test it.
Newer version released:
Added a big update for efficiency for tons of moving events and character events (doors, NPCs, etc) fixed several potential annoyances and bugs.
were i can download new version?
Use the link provided in the topic :/
http://anamei.net/files/AntiLag.zip

It's nice a good anti lag script came so soon after the release of RMVX ^^
oh i know i have think, that this was the older version
It was the link for the old version before it was updated. In case of any future updates I would expect the link to stay the same ;)
ok
I seriously feel like strangling you for putting it into a demo and not in the actual post itself.

But, wow.
eugene222 wrote:
oh i know i have think, that this was the older version


No no. Every time he updates it with a newer version, he just replaces the file that link goes to. It will always be the latest edition, each time the post is updated.


VGMasterIII wrote:
I seriously feel like strangling you for putting it into a demo and not in the actual post itself.

But, wow.


What are you talking about? And please, strangle my husband Anaryu, not me. 🙂
it has still bugs.
For example if i do an event with the graphic in page 1 and then a self switch in patch two and an other grafik,
then the event has both graphics in game.
And there are still other
eugene222 wrote:
it has still bugs.
For example if i do an event with the graphic in page 1 and then a self switch in patch two and an other grafik,
then the event has both graphics in game.
And there are still other


Thanks for pointing that out. There's a newer version out now.
thank you very much :)
still some bugs for (me at least)
1 random crash on a loaded game (Stack level too deep)
and I have an event that has a move event for itself, and it doesn't move.
besides that it's working very nice, no more lags on my maps. =)
I have an issue with vehicles. When I try to ride a ship, instead of riding the water, it rides land. Same with a boat.
Also having vehicle issues using VX.

When riding the airship, it won't dismount while the script is active.
He's looking into the bugs now. Thanks so much for telling us about them.

Fixed & Updated!
1.2d March 14th 4:12am EST: Fixed errors with vehicles, passability, and airship landing.
Newest Update!
1.2e (March 18th, 2008): Fixed tileset and passability errors with multi-page events.
First: my newest project wouldn't be possible without this script! Keep up the good work  :thumb:


Bug report:
I noticed that the game crashes when events are set to move diagonally! (when the anti-lag script is implementated)
Same with scripts that allow the player to move in 8 directions.

Hope Anaryu can fix that  🙂
Xaiko wrote:
Bug report:
I noticed that the game crashes when events are set to move diagonally! (when the anti-lag script is implementated)
Same with scripts that allow the player to move in 8 directions.

Hope Anaryu can fix that  🙂


I fixed that in the 8-way movement script here.  The way the anti-lag script functions, it's easier to fix it in the other script.
Kylock wrote:
I fixed that in the 8-way movement script here.  The way the anti-lag script functions, it's easier to fix it in the other script.


Thanks for the fix. If there are ever any other compatibility issues with other scripts, please feel free to let us know.
Yaoumei wrote:
VGMasterIII wrote:
I seriously feel like strangling you for putting it into a demo and not in the actual post itself.

But, wow.


What are you talking about? And please, strangle my husband Anaryu, not me. 🙂

He means that in order to obtain the script, one has to download the demo, which can take a while.  It's much easier if the script is provided in the first post under a spoiler.

~Guardian1239
Guardian1239 wrote:
He means that in order to obtain the script, one has to download the demo, which can take a while.  It's much easier if the script is provided in the first post under a spoiler.

~Guardian1239


I think the point of people being able to download the demo is so people can view what the particles do, but that's just my guess. I didn't work on it.
Yaoumei wrote:
Guardian1239 wrote:
He means that in order to obtain the script, one has to download the demo, which can take a while.  It's much easier if the script is provided in the first post under a spoiler.

~Guardian1239


I think the point of people being able to download the demo is so people can view what the particles do, but that's just my guess. I didn't work on it.

No, the demo is OK.  It's just that the script is usually given directly so people don't have to download the demo every time the script is updated.  I'll show you what I mean.  I'll put the script in a spoiler.

AS: AntiLag Script Spoiler
Script goes here.


This way, people can use the script without having to download the demo.  It is really long, though, so the spoiler would extend a lot.

~Guardian1239
It's also used to prevent people that pirate the program from using the script. Think, and get permission before you do things like this V_V
Twilight wrote:
It's also used to prevent people that pirate the program from using the script. Think, and get permission before you do things like this V_V

I'm not really sure what you mean.  If they want the script, they can just download the demo to get it.  Either way, I changed it.  I'm sorry if I did something wrong.

~Guardian1239

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=42383