How do parallel events use resources?

hainsay

Villager
Member
Joined
Dec 2, 2013
Messages
25
Reaction score
7
First Language
English
Primarily Uses
I've typed a fair bit of stuff below, but a simple way to ask the question is actually: Do parallel events run every frame? Probably just the answer to that is all I need.

Imagine I have an event that triggers a cutscene if you go to a certain location while having at least 50 unique items in your inventory.

You can have an event in parallel that checks region and counts unique items, but you can avoid having to calculate the number of items by only running the event page with that on it when you are in the correct region, or you could nest the count script within a conditional branch on the same page.

Would either of those options reduce any lag you would have from parallel events? Is an extra conditional branch that doesn't trigger further calculations a significant drain on resources? What kind of scale of script/events do you need before lag becomes a problem?
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
703
Reaction score
549
First Language
French
Primarily Uses
The important part to remember about lag and parallel events is that it isn't determined by the complexity of the event, but by the number of parallel processes.
You can test it yourself, on my computer 4 empty parallel events at the same time cause a large frame drop.

As a stress test I took a 100 × 100 map, put 100 events in it and had a parallel process check their coordinate and display a baloon animation if the player was in range. No lag at all, except when a lot of baloon were processed at once.

All tests were done with a 1 frame wait at event end.

Of course if you do truly impressive amount of calculations you're going to have some frame drop, if you were calculating pathfinding for those 100 events instead, I think you can guess the result.

Edit: forgot to answer the main question: yes they run every frame.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,081
Reaction score
7,051
First Language
German
Primarily Uses
RMMV
yes, parallel processes run once per frame. This can be somewhat controlled by the wait command (because the wait is really "skip x frames of processing before continuing).

However, the amount of lag created by this is dependend on the event structure of the process - a badly designed parallel process can slow down even the fastest computer, but with a good design there is no problem having a handfull of parallel processes.
But only a handfull at the same time - spamming everything into a parallel process will cause you problems.

That said, I suggest a slight modification to @Astfgl66 's post.

The number of waitframes in a parallel process determines how often it runs and is the key to reduce lag. You should combine functions that run at the same time into one parallel process, because that will save processing. However, if something runs a lot less often than something else then it should be in a different parallel process.
His example of empty parallel processes is correct, but it is not a good one - you never want to have an empty parallel process because it does nothing. And if you place enough waits into a process, there is no problem running many more than four.

The key is to experiment and plan the correct number of waitframes. Too many waits and the process will cause pseudo-lag by waiting on the player. Too few waitframes and the process will cause real lag by running too often.
If you want something checked while moving, the optimal wait is around 5 frames between checks - if you wait too much, you might skip a move when the player is dashing.
If you want to check equipment, then there should be no problem with 30 or 60 waitframes - the player simply can't go into menu and change equipment much faster.
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
703
Reaction score
549
First Language
French
Primarily Uses
Andar is mostly right.
However, for maximum performance I suggest using only a single common event parallel process and with using switches to activate part of it when needed.

My example with empty parallel processes must be taken in light of what I have said: complexity doesn't matter unless for extreme cases.
So you could have 4 parallel processes, one that checks player coordinates, one that checks equipment, one that checks for a key press to bring up a menu and a final one activating a tool on a key press.

In that example you don't want to check coordinates and equipment every frame. So you'd put a mild wait like 5 frames, for the menu you want it to check every frame, so no wait or you'll miss inputs. Same for the final one.

The most efficient solution is to combine all processes in a single parallel process, and use switches to check the parts that you want. You'll end up checking equipment and coordinates more often but that can't really hurt.

You could also combine the same wait time events, by having only 2 parallel processes, like Andar said, but it's less efficient.
 
Last edited:

hainsay

Villager
Member
Joined
Dec 2, 2013
Messages
25
Reaction score
7
First Language
English
Primarily Uses
I learnt far more about it than I thought I would, thank you all. I have definitely taken on board all you said, but I wasn't sure of the meaning in one of them:

Andar is mostly right.
The most efficient solution is to combine all processes in a single parallel process, and use switches to check the parts that you want. You'll end up checking equipment and coordinates more often bit that can't really hurt.
Do you mean using self switches so that you cycle between pages?
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
703
Reaction score
549
First Language
French
Primarily Uses
No.
I mean have a single parallell process that is always running. Inside have your processes contained inside conditonals.

For example:
The event is a parallel process that always runs.
If switch: check coordinates is ok
-Check coordinates
End
If switch: check button input ok
-check button input
End

And so on, adding parts to it wrapped in conditionnals until you no longer need it.
 
Last edited:

hainsay

Villager
Member
Joined
Dec 2, 2013
Messages
25
Reaction score
7
First Language
English
Primarily Uses
Got it, thanks
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
703
Reaction score
549
First Language
French
Primarily Uses
This method of dealing with parallel processes also has the big advantage of letting you know exactly when each thing is executed.
If you use two different parallell processes at the same time, you don't know which will be executed first. It's the same reason as for why for cutscenes the recommendation is to use a single autorun event.

I used Andar's method for a long while (several years of game making), until I started experimenting quite a bit, and this method is the best I could come up with in terms of performance. It only really matters for very complex eventing anyway. I came up with it while trying to event an ABS.
That was before I switched to scripting things, which is obviously much more efficient anyway.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Stream will be live shortly with a session of the Interactive Text Adventure! Feel free to drop by!
Am I allowed to make a recruitment thread NOT for RPG Maker stuff?

Like for a group project?
(NOT RPG Maker project.)
If the new RPG Maker's character generator produces full busts and can match the art styles of previous RPG Makers, that might be a big incentive to buy it. An easier way to craft custom map tile sheets though would probably be an even bigger game changer.
Note to self: One lemon is enough to flavor my drink.
'I'm not homophobic, I'm not scared of me house.' - Peter Kay xD

Forum statistics

Threads
98,196
Messages
950,291
Members
129,498
Latest member
Mangas
Top