Events only working when Player is near?

Hey!

I'm working on an open world RPG with very large maps - they will have a lot of events as there will be NPCs, monsters, quests etc.

I'm afraid that having tons of events will make the game stutter.

Is there a way to make events work only when Player is near and the rest of the events are dormant until Player comes close?

What is the solution to have an open world game with large maps and many events and not have the game lag / stutter?

Thanks!
that is the default behaviour when using autonomous movement - the events wil only move by autonomous movement when within 10 tiles of the screen or so.
set move route overrides that, those movements happen anywhere on the map

At least that is how it worked in older makers, I haven't tested that in MZ.

However (and especially if you leave the map) it is usually better to simulate the effects because on leaving the map all events of that map are lost and reset on re-entering the map.
There's NRP EventLightLoad. The plugin file has English instructions

And there's another one by Sasuke Kannazuki
I don't remember the exact script call, but for MV there is a script along the lines of
Code:
isNearScreen
You can probably google search that and get the result you need if you want to build it out the thing I'll talk about below, and find the MZ equivalent (which is likely the same)

For a time, I had used this script as an event culler; it would set parallel events to self switch A, changing the event's active page to an action button page when they are not near the screen. When the events are near the screen it would turn the self switch off, changing them to the event page that is a parallel event.

I stopped using this not because it wasn't useful - actually it worked really well - but largely became obsolete due to changes in my games, and making events more efficient and relying less on parallel events.

So, with that being said: an event by itself doesn't cause lag. Technically speaking there is negligible usage of ram used per event, but it is so small it's not even worth considering.
What is going to be the bigger concern are the things your game needs to process per frame, and where this tends to happen is with parallel events and common events.
Try not to rely on parallel events, and if you have to use them, make sure to use wait frames so they aren't processing their data as frequently.
isNearScreen
I think you are referring to Game_CharacterBase, correct?
Spoiler
JavaScript:
Game_CharacterBase.prototype.isNearTheScreen = function() {
    var gw = Graphics.width;
    var gh = Graphics.height;
    var tw = $gameMap.tileWidth();
    var th = $gameMap.tileHeight();
    var px = this.scrolledX() * tw + tw / 2 - gw / 2;
    var py = this.scrolledY() * th + th / 2 - gh / 2;
    return px >= -gw && px <= gw && py >= -gh && py <= gh;
};
I believe MV/MZ has the function called inside of the Game_Event.prototype.updateSelfMovement function.
I think you are referring to Game_CharacterBase, correct?
Spoiler
JavaScript:
Game_CharacterBase.prototype.isNearTheScreen = function() {
    var gw = Graphics.width;
    var gh = Graphics.height;
    var tw = $gameMap.tileWidth();
    var th = $gameMap.tileHeight();
    var px = this.scrolledX() * tw + tw / 2 - gw / 2;
    var py = this.scrolledY() * th + th / 2 - gh / 2;
    return px >= -gw && px <= gw && py >= -gh && py <= gh;
};
I believe MV/MZ has the function called inside of the Game_Event.prototype.updateSelfMovement function.
I mean... Maybe? I was just referring to the script call, I'm not sure what the rest of it is.
I double checked exactly what I used and it is this:

Code:
!$gameMap.event(event ID).isNearTheScreen();

Original thread: https://forums.rpgmakerweb.com/threads/events-only-working-when-player-is-near.173297/