Optimizing enemy encounters

Hey, I was wondering if somebody knew of a plugin or a better way to write this.

Problem:
I have my on-screen enemies turn into a parallel event once defeated. Worried about lag as this generates a lot of parallel events.

My current logic:
The game has a clock and counts the days. Once an enemy is defeated it has a self variable (Yep_Self variables) that keeps track of what day it was defeated. Once it has been greater than 7 days the self switch is turned off and the enemy respawns.

My Goal:
To be able to keep the spawning after 8 days but not have the enemy set as a parallel event to check the current day. I could have everything as a global variable for each enemy but since there are 1000's of enemies I would just eat through all my variables.




1697844051786.png

1697844125886.png
I would suggest you take a look at @Trihan's tutorial on respawning events.

He wrote it thinking of mining nodes, but the exact same system could be used to reset your enemy events. They all go into one variable that's an array, and there's only one event that tracks the timing.

Thanks this was exactly what I was looking for! I use the same system for mining and crops too as well so it should work with everything.
the solution to this is the same solution that takes care of ticking states in combat.

there's another approach as done in Rimworld: on action, put the event in a list as "Now + NextTime", and count ticks up. In the counter, check for "Now == TimeOfNextEvent". On match, trigger and remove from list.

all you need to make this work is the list to keep track of events.
as you have it, it's multiple counters... this way, it would be one counter.
for states, time counts down... for this, time counts up.
Galv Event Spawn Timers should be able to do it
thanks for the options. I decided to go with the first one and it's working great for me. But good to know if anyone else has the same problem

Original thread: https://forums.rpgmakerweb.com/threads/optimizing-enemy-encounters.162222/