We all know too many parallel processing events cause lag. I've been curious as to distinguish some that don't really cause any lag and some which cause a ton. I once used a proximity sound effect script that nearly crashed my computer every time because it was checking positions and changing volume every millisecond. But what about parallel process events that just check to see if x is true? For example a parallel processing common event that checks to see if the player has a specific pair of boots equipped. Is it checking 500 times a second to see if the boots are there and therefore causing significant stress on the system OR is it the case that events that return false immediately (like this one) are relatively unnoticeable?
Parallel Processing Stress
RPG Maker VXAce SupportFollow the bughunting link in my signature to get some background info on parallel processes.
That said, most parallel process lag can be avoided by placing a wait inside the process - it just requires experimenting to find the correct place in the code for the wait and how many waits are really needed.
Too many waits and the process fails its task, too few waits and it will lag.
That said, most parallel process lag can be avoided by placing a wait inside the process - it just requires experimenting to find the correct place in the code for the wait and how many waits are really needed.
Too many waits and the process fails its task, too few waits and it will lag.
It still has to do the check, so it would still take however much processing is required. The "if true" block would only get executed when the condition is met, so has no bearing on how much lag is contributed UNTIL the condition becomes true - then as long as the event continues running, it will affect performance continually, because both the condition AND the "if true" block are being executed repeatedly.
I think the question to ask is "how often is this condition likely to change, and how quickly do I need to react?" If it's something that is going to happen fairly infrequently (like changing equipment) and a half-second response is fine, add a 30 frame wait right at the top of the event.
The other question is "what action could the player take that would cause this condition to change?" The answer, in this case, is they would need to open the equip menu and actually change equipment. If it's something that happens infrequently and is caused by a direction action of the player, I would look at another way of doing the test, rather than a parallel process event that's continually running. In this case I would set it up as a common event set to parallel process, triggered by a switch (and would then turn the switch off at the end of the event). Then I'd do a tiny script mod so that when the Equip window is opened, it turns that switch on. So your event is ONLY going to run when the player actually changes their equipment. No lag at all.
I think the question to ask is "how often is this condition likely to change, and how quickly do I need to react?" If it's something that is going to happen fairly infrequently (like changing equipment) and a half-second response is fine, add a 30 frame wait right at the top of the event.
The other question is "what action could the player take that would cause this condition to change?" The answer, in this case, is they would need to open the equip menu and actually change equipment. If it's something that happens infrequently and is caused by a direction action of the player, I would look at another way of doing the test, rather than a parallel process event that's continually running. In this case I would set it up as a common event set to parallel process, triggered by a switch (and would then turn the switch off at the end of the event). Then I'd do a tiny script mod so that when the Equip window is opened, it turns that switch on. So your event is ONLY going to run when the player actually changes their equipment. No lag at all.
Interesting, will look into having this done. You're right about me not phrasing the question correctly, but I figured you guys (in particular) would figure it out what I meant. I see what you're saying - why waste time with a continuous event when you can localize it to the only time it would ever occur. Great point. Thanks!
@Andar, will look at that now! Thanks
In case the above is exactly what you are trying to do, here is the snippet you'll need to add (to a new script slot) to make it happen:
where n is replaced by the switch number you want to use (no leading zeros).
Code:
Scene_Equip < Scene_MenuBase def return_scene $game_switches[n] = true super endend
This will automatically shut the common event off when i exit the menu? If I read this correctly, it will turn the common event on while in the menu (or more specifically, the equip scene) and then off when i exit?
Thank you, that wasn't necessary and I appreciate it!!
Thank you, that wasn't necessary and I appreciate it!!
You need to turn the switch off at the end of the common event.
All the above will do is tell you that they have accessed the equip menu. They may not have changed any equipment, or they may have changed but not to the equipment you're interested in.
So your common event will be conditioned by that switch, set as a parallel process, and will check to see if the actor (or any actor) has the special pair of boots equipped. Whether they do or not, at the end of the common event, you'll need to turn the switch off again so it only checks once.
All the above will do is tell you that they have accessed the equip menu. They may not have changed any equipment, or they may have changed but not to the equipment you're interested in.
So your common event will be conditioned by that switch, set as a parallel process, and will check to see if the actor (or any actor) has the special pair of boots equipped. Whether they do or not, at the end of the common event, you'll need to turn the switch off again so it only checks once.
Original thread: https://forums.rpgmakerweb.com/threads/parallel-processing-stress.51257/