Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Maniacs Battle Common Events #3307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/scene_battle_rpg2k3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <lcf/reader_util.h>
#include "scene_gameover.h"
#include "utils.h"
Expand Down Expand Up @@ -971,6 +973,16 @@
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()) {
Expand Down Expand Up @@ -1113,6 +1125,23 @@
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) {

Check failure on line 1131 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

'class lcf::rpg::CommonEvent' has no member named 'Trigger_battle_begin'

Check failure on line 1131 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

'class lcf::rpg::CommonEvent' has no member named '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) {

Check failure on line 1136 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

'class lcf::rpg::CommonEvent' has no member named 'Trigger_battle_parallel'; did you mean 'Trigger_parallel'?

Check failure on line 1136 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

'class lcf::rpg::CommonEvent' has no member named 'Trigger_battle_parallel'; did you mean 'Trigger_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,
Expand Down Expand Up @@ -1152,6 +1181,7 @@
EndNotification();
UpdateEnemiesDirection();
UpdateActorsDirection();
CallBattleBeginCommonEvents();
SetSceneActionSubState(eUpdateEvents);
return SceneActionReturn::eContinueThisFrame;
}
Expand Down
5 changes: 5 additions & 0 deletions src/scene_battle_rpg2k3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -260,6 +262,9 @@ class Scene_Battle_Rpg2k3 : public Scene_Battle {
int GetNextReadyActor();

std::vector<int> atb_order;

std::vector<Game_CommonEvent*> battle_parallel_events;
Game_Interpreter_Battle parallel_interpreter;
};

#endif
Loading