From fe3ee9d1df27f69a22643c5ecc6bf99f9444809f Mon Sep 17 00:00:00 2001 From: Dino Suvalic <82914521+MakoInfused@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:05:23 -0500 Subject: [PATCH 1/3] implemented maniacs battle common event triggers --- src/scene_battle_rpg2k3.cpp | 30 ++++++++++++++++++++++++++++++ src/scene_battle_rpg2k3.h | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/src/scene_battle_rpg2k3.cpp b/src/scene_battle_rpg2k3.cpp index 32c2d0fee5..3990e08c19 100644 --- a/src/scene_battle_rpg2k3.cpp +++ b/src/scene_battle_rpg2k3.cpp @@ -34,11 +34,13 @@ #include "game_party.h" #include "game_enemy.h" #include "game_enemyparty.h" +#include "game_map.h" #include "game_message.h" #include "game_battle.h" #include "game_interpreter_battle.h" #include "game_battlealgorithm.h" #include "game_screen.h" +#include "game_switches.h" #include #include "scene_gameover.h" #include "utils.h" @@ -972,6 +974,16 @@ void Scene_Battle_Rpg2k3::vUpdate() { break; } + if (state != State_Victory && state != State_Defeat) { + parallel_interpreter.Update(); + if (!parallel_interpreter.IsRunning()) { + for (auto common_event : battle_parallel_events) + { + parallel_interpreter.Push(common_event); + } + } + } + // this is checked separately because we want normal events to be processed // just not sub-events called by maniacs battle hooks. if (state != State_Victory && state != State_Defeat && Game_Battle::ManiacProcessSubEvents()) { @@ -1114,6 +1126,23 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneAction() return SceneActionReturn::eWaitTillNextFrame; } +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))) { + if (data_common_event.trigger == data_common_event.Trigger_battle_begin) { + Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID); + + Game_Battle::GetInterpreterBattle().Push(common_event); + } + else if (data_common_event.trigger == data_common_event.Trigger_battle_parallel) { + Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID); + + battle_parallel_events.push_back(common_event); + } + } + } +} + Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionStart() { enum SubState { eStartMessage, @@ -1153,6 +1182,7 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionSt EndNotification(); UpdateEnemiesDirection(); UpdateActorsDirection(); + CallBattleBeginCommonEvents(); SetSceneActionSubState(eUpdateEvents); return SceneActionReturn::eContinueThisFrame; } diff --git a/src/scene_battle_rpg2k3.h b/src/scene_battle_rpg2k3.h index 8bd1391633..e2171152e3 100644 --- a/src/scene_battle_rpg2k3.h +++ b/src/scene_battle_rpg2k3.h @@ -164,6 +164,8 @@ class Scene_Battle_Rpg2k3 : public Scene_Battle { void SetSceneActionSubState(int substate); void ReturnToMainBattleState(); + void CallBattleBeginCommonEvents(); + // SceneAction State Machine Driver SceneActionReturn ProcessSceneAction(); @@ -260,6 +262,9 @@ class Scene_Battle_Rpg2k3 : public Scene_Battle { int GetNextReadyActor(); std::vector atb_order; + + std::vector battle_parallel_events; + Game_Interpreter_Battle parallel_interpreter; }; #endif From e575a1d5b7c5db931c3c2410116072cd3eb1c4af Mon Sep 17 00:00:00 2001 From: Dino Suvalic <82914521+MakoInfused@users.noreply.github.com> Date: Sat, 13 Dec 2025 21:44:25 -0500 Subject: [PATCH 2/3] resolved differences after rebasing from master --- src/scene_battle_rpg2k3.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scene_battle_rpg2k3.cpp b/src/scene_battle_rpg2k3.cpp index 3990e08c19..a3bb32db6e 100644 --- a/src/scene_battle_rpg2k3.cpp +++ b/src/scene_battle_rpg2k3.cpp @@ -979,7 +979,7 @@ void Scene_Battle_Rpg2k3::vUpdate() { if (!parallel_interpreter.IsRunning()) { for (auto common_event : battle_parallel_events) { - parallel_interpreter.Push(common_event); + parallel_interpreter.Push(common_event); } } } @@ -1129,12 +1129,12 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneAction() 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))) { - if (data_common_event.trigger == data_common_event.Trigger_battle_begin) { + if (data_common_event.trigger == data_common_event.Trigger_maniac_battle_start) { Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID); - Game_Battle::GetInterpreterBattle().Push(common_event); + Game_Battle::GetInterpreterBattle().Push(common_event); } - else if (data_common_event.trigger == data_common_event.Trigger_battle_parallel) { + else if (data_common_event.trigger == data_common_event.Trigger_maniac_battle_parallel) { Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID); battle_parallel_events.push_back(common_event); From 4ac69ceefc83c3fc567e1a4e1ea572e4b39fb1fd Mon Sep 17 00:00:00 2001 From: Dino Suvalic <82914521+MakoInfused@users.noreply.github.com> Date: Sat, 13 Dec 2025 22:18:05 -0500 Subject: [PATCH 3/3] fixing battle parallel event calls after merge resolution --- src/game_interpreter.h | 1 + src/scene_battle_rpg2k3.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game_interpreter.h b/src/game_interpreter.h index e42c44462f..b8ac31b407 100644 --- a/src/game_interpreter.h +++ b/src/game_interpreter.h @@ -411,6 +411,7 @@ inline void Game_Interpreter::Push(Game_Event* ev, const lcf::rpg::EventPage* pa template inline void Game_Interpreter::Push(Game_CommonEvent* ev) { static_assert(type_ex == InterpreterExecutionType::AutoStart || type_ex == InterpreterExecutionType::Parallel + || type_ex == InterpreterExecutionType::BattleStart || type_ex == InterpreterExecutionType::BattleParallel || type_ex == InterpreterExecutionType::Call || type_ex == InterpreterExecutionType::DeathHandler || type_ex == InterpreterExecutionType::DebugCall || type_ex == InterpreterExecutionType::ManiacHook, "Unexpected ExecutionType for CommonEvent" ); diff --git a/src/scene_battle_rpg2k3.cpp b/src/scene_battle_rpg2k3.cpp index a3bb32db6e..b7827aa7ee 100644 --- a/src/scene_battle_rpg2k3.cpp +++ b/src/scene_battle_rpg2k3.cpp @@ -979,7 +979,7 @@ void Scene_Battle_Rpg2k3::vUpdate() { if (!parallel_interpreter.IsRunning()) { for (auto common_event : battle_parallel_events) { - parallel_interpreter.Push(common_event); + parallel_interpreter.Push(common_event); } } } @@ -1132,7 +1132,7 @@ void Scene_Battle_Rpg2k3::CallBattleBeginCommonEvents() { if (data_common_event.trigger == data_common_event.Trigger_maniac_battle_start) { Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID); - Game_Battle::GetInterpreterBattle().Push(common_event); + Game_Battle::GetInterpreterBattle().Push(common_event); } else if (data_common_event.trigger == data_common_event.Trigger_maniac_battle_parallel) { Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID);