Skip to content

Commit 742ac35

Browse files
MakoInfusedGhabry
authored andcommitted
implemented maniacs battle common event triggers
1 parent 62bc789 commit 742ac35

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/scene_battle_rpg2k3.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434
#include "game_party.h"
3535
#include "game_enemy.h"
3636
#include "game_enemyparty.h"
37+
#include "game_map.h"
3738
#include "game_message.h"
3839
#include "game_battle.h"
3940
#include "game_interpreter_battle.h"
4041
#include "game_battlealgorithm.h"
4142
#include "game_screen.h"
43+
#include "game_switches.h"
4244
#include <lcf/reader_util.h>
4345
#include "scene_gameover.h"
4446
#include "utils.h"
@@ -971,6 +973,16 @@ void Scene_Battle_Rpg2k3::vUpdate() {
971973
break;
972974
}
973975

976+
if (state != State_Victory && state != State_Defeat) {
977+
parallel_interpreter.Update();
978+
if (!parallel_interpreter.IsRunning()) {
979+
for (auto common_event : battle_parallel_events)
980+
{
981+
parallel_interpreter.Push(common_event);
982+
}
983+
}
984+
}
985+
974986
// this is checked separately because we want normal events to be processed
975987
// just not sub-events called by maniacs battle hooks.
976988
if (state != State_Victory && state != State_Defeat && Game_Battle::ManiacProcessSubEvents()) {
@@ -1113,6 +1125,23 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneAction()
11131125
return SceneActionReturn::eWaitTillNextFrame;
11141126
}
11151127

1128+
void Scene_Battle_Rpg2k3::CallBattleBeginCommonEvents() {
1129+
for (auto data_common_event : lcf::Data::commonevents) {
1130+
if ((!data_common_event.switch_flag || Main_Data::game_switches->Get(data_common_event.switch_id))) {
1131+
if (data_common_event.trigger == data_common_event.Trigger_battle_begin) {
1132+
Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID);
1133+
1134+
Game_Battle::GetInterpreterBattle().Push(common_event);
1135+
}
1136+
else if (data_common_event.trigger == data_common_event.Trigger_battle_parallel) {
1137+
Game_CommonEvent* common_event = lcf::ReaderUtil::GetElement(Game_Map::GetCommonEvents(), data_common_event.ID);
1138+
1139+
battle_parallel_events.push_back(common_event);
1140+
}
1141+
}
1142+
}
1143+
}
1144+
11161145
Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionStart() {
11171146
enum SubState {
11181147
eStartMessage,
@@ -1152,6 +1181,7 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionSt
11521181
EndNotification();
11531182
UpdateEnemiesDirection();
11541183
UpdateActorsDirection();
1184+
CallBattleBeginCommonEvents();
11551185
SetSceneActionSubState(eUpdateEvents);
11561186
return SceneActionReturn::eContinueThisFrame;
11571187
}

src/scene_battle_rpg2k3.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ class Scene_Battle_Rpg2k3 : public Scene_Battle {
164164
void SetSceneActionSubState(int substate);
165165
void ReturnToMainBattleState();
166166

167+
void CallBattleBeginCommonEvents();
168+
167169
// SceneAction State Machine Driver
168170
SceneActionReturn ProcessSceneAction();
169171

@@ -260,6 +262,9 @@ class Scene_Battle_Rpg2k3 : public Scene_Battle {
260262
int GetNextReadyActor();
261263

262264
std::vector<int> atb_order;
265+
266+
std::vector<Game_CommonEvent*> battle_parallel_events;
267+
Game_Interpreter_Battle parallel_interpreter;
263268
};
264269

265270
#endif

0 commit comments

Comments
 (0)