Question about avoiding future lag.

My game has no random encounters, and I've made a respawn system off of counting variables.

With each monster requiring a variable being counted, will this cause lag in the future when my monster count reaches into the hundreds?

edit: I've considered having every monster run off one timer, but I'd like to avoid having monsters come back all at once, and more based on time killed.
A variable counter shouldn't cause much of an issue no matter what it holds. It's just a number, and programming languages (like Ruby) depend on the quick changing and comparison of values for speed, so it shouldn't cause any issue.

As for the timers, it may make a bit more of stress on the game to run them, but it really shouldn't be anything bad.
I guess the problem would be having ~100 variable counters counting at all times even when not in the current zone. This won't lag with all other game processes working away?
Yes you're going to run into performance issues.


Most people lag just by having 100 events on the screen that aren't doing anything (so it's just a sprite update every frame).


Imagine sprite update along with the game interpreter running?
As Tsukihime said, having one counter for each monster will create a larger lag.

However, there are ways around that with a bit of planning...

Only events on the current map can lag. If you keep the maps small enough that there are less than a dozen enemy events per map, then the lag problem isn't as bad as if you're having a hundred enemies on a large map.

You don't need every monster to reappear on a different time. I agree that the monsters of one map (and perhaps the monsters of adjacent maps) should not appear at once, but having 10 counters and reuse them for monsters on different maps or that are far away from each other should be enough. That works because you don't have to remember the exact time a monster was slain - the player won't remember that this specific monster was slain twenty seconds earlier than the time loop for that group of monsters tell them to respawn...
Thanks for the input. I guess I'll just have map counters cycling from adjacent map to the next, and maybe even shared per map, but less than 10 variables counting at once. Thanks for the help 🙂

edit: I have a further question.

Does anyone know of a simple way for an event to track a variable from a seperate map?

IE: my variable strikes 0, im in a house at the time, when I leave it would have reset the variable already and the monster wasn't spawned in. Any ideas?
The problem about lag is that you really must test to be certain.

I once played around with the number of variables in the database and had no trouble at all with 100k variables existing. Mind you, most were not used. Only a few was ever used at the same time.

Still... I didn't really encounter any problems until around half a million where I remember game acting funny. This test being in RPG Maker XP we cannot know whether the same

We have data that graphical representation of events is heavy on the performance.

I haven't heard about any performance data on having 100 counters being counted in events. My personal guess is that it won't be particular significant, and furthermore it seems they don't require being counted every frame so you can break down the update to say 25 counters being updated every frames. (Thus each counter is being updated every 4 frames)

I don't have any performance data so be aware that I can be totally wrong. Without testing we cannot know.

*hugs*
Does anyone know of a simple way for an event to track a variable from a seperate map?
No, that is not possible because events are only processed on the current map.

I once had the logic to handle such a case, forcing the respawn of the enemy upon entering if the delay was passed while the player was on another map.

Unfortunately it's late here and I can't concentrate enough to remember the exact handling, I only remember that it basically required two additional event pages and one switch per map to make those respawns happen. Perhaps I'll remember tomorrow...
You could use my event timers script to just set a timer and turn on a self switch when a monster is defeated, and when the timer goes off, turn the self switch back off again.


No need for lots of variables, no need for events just to count things. It WOULD mean you could have quite a few timers to check each frame, but it would be limited to only those that are waiting to respawn.


Extended Game Timers
If you have a variable per monster I guess you could just leave it at 0 or 1 or something like that once it is reached.

Once you go to the map you can then check the variable.
If you have a variable per monster I guess you could just leave it at 0 or 1 or something like that once it is reached.

Once you go to the map you can then check the variable.
This is currently how I have it set. Though to have the timer checking outside of the map it's something like 

branch

variable timer > 0

control variable timer + 1

branch timer = 60

enemy1=0

enemy2=0

enemy3=0

enemy4=0

enemy5=0

etc.

then in the event page instead of self switch it's checking the variable. end of fight variable set to 1. timer ticks enemy pops back up.

The problem is the way the timer is handled on a parallel process, I'm worried once I get upwards of 200 enemies and it's controlling those variables (or even doing nothing) it will crap bricks

edit: It's running on a common event*

edit2: Shaz that actually looks very helpful. How many timers at once have you tested succesfully?
Shaz that timer works wonders!

This can be closed 🙂
Awesome! If you do get a lot of them running at once and you find it starting to lag, please go back to that thread and let me know 🙂


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/question-about-avoiding-future-lag.16907/