Maybe there are people that need 5000 events on the map because they just want to have a 500x500 "world map". Compared to 250000 tiles, that's a relatively small amount of events.
Except the bottleneck is not with the tiles themselves. In comparison to Sprites, the tilemap class is actually very efficient. Increasing my 13 x 17 map to 2000 by 2000 (by manipulating the data table before tilemap is created) offers no noticeable drop in framerate. This is likely because we only have a single Ruby handler for this object (plus one for each of the bitmaps it is constructed from). Sprites have one Ruby handler each, and have shown performance drops at a geometric rate past a certain point.
Optimizing for 500 events can be done by just disabling sprite updates and event updates. Sprite updates can be ignored safely because, well, if you don't see it on the screen, why does it need to update anyways? In some 2.5D or 3D games, they wouldn't even bother rendering anything that's behind a wall if you can't see past it.
Event updates should be managed very carefully, because we can already see that the decision to make autonomous movement stop when the event is not "near the screen" is already causing a lot of headache. That really should be given the option to enable or disable on a per-event or per-event-page basis, which can be easily added of course using scripts and event comments.
Every anti-lag script I have ever seen is constructed like this. The general strategy is to not update things that don't need to be updated because they are off screen. The overhead is that at least some calculation needs to be done to determine if near_the_screen? (usually determined either each frame, or on the fly). If you are in a large map where most of the events are spread out, great, otherwise, you won't see much of a difference.
I've also seen the comment tag thing to determine if the event should be updated or not. I've seen some that add tags that prevent sprite association (for graphicless autoruns) or event updates (for background style sprites that never move). This works great with little overhead, but it also requires much more setup.
There is room for optimization in the way that events are handled and also within the update methods themselves. When I did some tests in VX a while back, I the update and all associated Sprite_Character methods using pretty much the same structure but only got about 5-10% performance increase for maps that were already running at < 30 FPS for me. There is much, much more sloppy iteration in Game_Map that would take some heavy provisioning or rewrites to get around.
Basically, if you are going to use 1000+ events on any one map the creator should probably rethink how they are doing things. Even 500 events is pushing it, really, but sprites in general are used frequently both by the base scripts and many scripters. Even just counting the map screen, you have to consider weather, pictures, the timer, all the character sprites, any animation playing on any one of the characters, shadow, as well as the Tilemap, Plane, 3 Viewports, and the message windows which are all operating on similar bottlenecks. The code for this is
much improved in ACE over VX in regard to weather, pictures, and animations, but character sprites are pretty much the same (granted, with a much better method layout). They are set up for maximum flexibility, not speed, you could, say, trivially show a balloon over your airship if you wanted.
This computer quickly drops in framerate due to event bloat at far less than 100 events, though, and given that I am still well within the system requirements for RPG Maker VX ACE, discussion on the matter is always useful to make more games playable by a broader audience.
@Shaz-
events_xy is I believe the method that you are referring to. There is an optimized version of this in ACE used for referencing events on a tile through the interpreter, and events_xy is only used by Game_Player to check for events and trigger one. For events, the event simply checks if the player is in the spot they are checking. It isn't optimized, but it's not exactly a bottleneck in this instance. There are other, similar methods to determine where things are for collision that also iterate over every single event, and those are done on any collision test.