Skip to content

Conversation

@MakoInfused
Copy link
Contributor

When using maniacs patch and we have a "Battle Begin" trigger set in the editor like this:
image

In battle we now have it get triggered like this:
image

When we use a "Battle (Parallel)" trigger in the editor like this:
image

In battle it will result in a repeated common event getting triggered every 5 seconds (since that is what my wait time it set to in the above image) like this:
EasyRPG-ManiacsBattleCommonEvents

@Ghabry
Copy link
Member

Ghabry commented Nov 27, 2024

The way how you do parallel process updating looks completely different to how it is done on the map.

For the map the common events all have a parallel process directly attached to them:

Player/src/game_map.cpp

Lines 1283 to 1308 in d9dd9be

bool Game_Map::UpdateCommonEvents(MapUpdateAsyncContext& actx) {
int resume_ce = actx.GetParallelCommonEvent();
for (Game_CommonEvent& ev : common_events) {
bool resume_async = false;
if (resume_ce != 0) {
// If resuming, skip all until the event to resume from ..
if (ev.GetIndex() != resume_ce) {
continue;
} else {
resume_ce = 0;
resume_async = true;
}
}
auto aop = ev.Update(resume_async);
if (aop.IsActive()) {
// Suspend due to this event ..
actx = MapUpdateAsyncContext::FromCommonEvent(ev.GetIndex(), aop);
return false;
}
}
actx = {};
return true;
}

(ignore the async stuff for now)


Maybe add UpdateBattle and IsWaitingBattleBackgroundExecution to the common events and do it via these functions?


What needs to be tested:

On the map parallel processes can be suspended and they will continue where they stopped. Does Maniac Patch do this in battle? To test this run two parallel processes:

PP1 (has run condition S1 = ON):

ShowMessage A
Set Switch S2 = ON
Set Switch S1 = OFF
ShowMessage B

PP2 (has run condition S2 = ON):

ShowMessage C
Set Switch S1 = ON
Set Switch S2 = OFF
ShowMessage D

The expected message output is A, C, B. D never shown.

At least when battle pps are like map pps.


Also worth testing if they keep the progress across battles:

For this simply do something like

PP1:

ShowMessage A
Abort Battle
ShowMessage B

When it resets it will always show A. When it remembers the state it will show B when a 2nd battle starts.


Also parallel processes can run... in parallel.

So you can do stuff like this:

PP1:

ShowMessage A
Wait 0
ShowMessage C

PP2:

ShowMessage B
Wait 0
ShowMessage D

I think the output should be A, B, C, D.

@Ghabry Ghabry added this to the 0.8.1 milestone Nov 29, 2024
@MakoInfused
Copy link
Contributor Author

MakoInfused commented Nov 30, 2024

@Ghabry I tested all of the exact scenarios as you outlined them and here are the results!

On the map parallel processes can be suspended and they will continue where they stopped. Does Maniac Patch do this in battle?

No. It seems to work in a much more simple/diferent way.

Suspension Test:
Map PP expected output: A, C, B. D never shown.
Maniacs Battle PP actual output: A, B, C, D.
My Implementation output: A, B. C. D is never shown.
Seems I'll need to fix this is as the events aren't all running in parallel to match Maniacs.

Resume Test:
Map PP expected output: When it remembers the state it will show B when a 2nd battle starts.
Maniacs Battle PP actual output: It resets and never shows anything except A.
My Implementation output: Works the same as Maniacs.

Parallel Test:
Map PP expected output: I think the output should be A, B, C, D.
Maniacs Battle PP actual output: A, B, C, A, D, C (repeats from beginning)
My Implementation output: B, D, A, C (repeated from beginning)
Seems this doesn't work the same either and will also need to be changed to match Maniacs.

@Ghabry Ghabry modified the milestones: 0.8.1, 0.8.2 Dec 10, 2024
@Ghabry Ghabry force-pushed the ManiacBattleCommonEvents branch from 927aeed to 742ac35 Compare March 18, 2025 13:53
@Ghabry
Copy link
Member

Ghabry commented Dec 14, 2025

Please don't create merge commits. They result in a mess as you can see here with these >200 commits.

Instead do a rebase:

git fetch upstream
git rebase upstream/master

During the rebase their will be conflicts. Fix the conflicts and git commit, then git rebase --continue until the rebase is successful.

(rebasing can be tricky, look for a guide in case you need assistance or ask in the chat)

@MakoInfused
Copy link
Contributor Author

Please don't create merge commits. They result in a mess as you can see here with these >200 commits.

Instead do a rebase:

git fetch upstream
git rebase upstream/master

During the rebase their will be conflicts. Fix the conflicts and git commit, then git rebase --continue until the rebase is successful.

(rebasing can be tricky, look for a guide in case you need assistance or ask in the chat)

Ah yeah, sorry about that-- I had forgotten about that part. I'll get this fixed up.

@MakoInfused MakoInfused force-pushed the ManiacBattleCommonEvents branch from 64c449b to 4ac69ce Compare December 14, 2025 16:43
@MakoInfused
Copy link
Contributor Author

All fixed up, won't happen again. Thanks for the heads up.


void Scene_Battle_Rpg2k3::CallBattleBeginCommonEvents() {
for (auto data_common_event : lcf::Data::commonevents) {
if ((!data_common_event.switch_flag || Main_Data::game_switches->Get(data_common_event.switch_id))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: condition could be inverted to reduce indenting:

Suggested change
if ((!data_common_event.switch_flag || Main_Data::game_switches->Get(data_common_event.switch_id))) {
if (data_common_event.switch_flag && !Main_Data::game_switches->Get(data_common_event.switch_id)) continue;

@Ghabry Ghabry removed the Has PR Dependencies This PR depends on another PR label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants