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

Implemented Maniacs Command 3011: ChangeBattleCommandEx #3290

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
35 changes: 33 additions & 2 deletions src/game_interpreter_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "game_map.h"
#include "spriteset_battle.h"
#include <cassert>
#include <scene_battle.h>
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved

enum BranchBattleSubcommand {
eOptionBranchBattleElse = 1
Expand Down Expand Up @@ -605,12 +606,42 @@ bool Game_Interpreter_Battle::CommandManiacControlAtbGauge(lcf::rpg::EventComman
return true;
}

bool Game_Interpreter_Battle::CommandManiacChangeBattleCommandEx(lcf::rpg::EventCommand const&) {
bool Game_Interpreter_Battle::CommandManiacChangeBattleCommandEx(lcf::rpg::EventCommand const& com) {
if (!Player::IsPatchManiac()) {
return true;
}

Output::Warning("Maniac Patch: Command ChangeBattleCommandEx not supported");
// 1 row removed
bool actorCommandFlags = com.parameters[0];
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved

lcf::Data::battlecommands.easyrpg_disable_row_feature = actorCommandFlags;

// 10000 lose added
// 01000 win added
// 00100 escape removed
// 00010 auto removed
// 00001 fight removed
int partyCommandFlags = com.parameters[1];

lcf::Data::system.easyrpg_battle_options.clear();
for (size_t i = 0; i < Scene_Battle::BattleOptionType::Lose + 1; i++)
{
bool partyCommandFlag = partyCommandFlags & (1 << i);
bool flagIsSet = i > 2;

if (partyCommandFlag == flagIsSet)
{
lcf::Data::system.easyrpg_battle_options.push_back(i);
}
}

auto& scene = Scene::instance;
Scene_Battle* sceneBattle = dynamic_cast<Scene_Battle*>(scene.get());
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved

if (sceneBattle) {
sceneBattle->CreateOptions();
}

return true;
}

Expand Down
20 changes: 16 additions & 4 deletions src/scene_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,18 @@ void Scene_Battle::DrawBackground(Bitmap& dst) {
dst.Clear();
}

void Scene_Battle::CreateUi() {
void Scene_Battle::CreateOptions() {
std::vector<std::string> commands;

for (auto option: lcf::Data::system.easyrpg_battle_options) {
battle_options.clear();

for (auto option : lcf::Data::system.easyrpg_battle_options) {
battle_options.push_back((BattleOptionType)option);
}

// Add all menu items
for (auto option: battle_options) {
switch(option) {
for (auto option : battle_options) {
switch (option) {
case Battle:
commands.push_back(ToString(lcf::Data::terms.battle_fight));
break;
Expand All @@ -208,13 +210,23 @@ void Scene_Battle::CreateUi() {
case Escape:
commands.push_back(ToString(lcf::Data::terms.battle_escape));
break;
case Win:
commands.push_back("Win");
break;
case Lose:
commands.push_back("Lose");
break;
}
}

options_window.reset(new Window_Command(commands, option_command_mov));
options_window->SetHeight(80);
options_window->SetX(Player::menu_offset_x);
options_window->SetY(Player::menu_offset_y + MENU_HEIGHT - 80);
}

void Scene_Battle::CreateUi() {
CreateOptions();

help_window.reset(new Window_Help(Player::menu_offset_x, Player::menu_offset_y, MENU_WIDTH, 32));
help_window->SetVisible(false);
Expand Down
6 changes: 5 additions & 1 deletion src/scene_battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class Scene_Battle : public Scene {

void Start() override;

void CreateOptions();

void UpdateScreen();
void UpdateBattlers();
void UpdateUi();
Expand Down Expand Up @@ -125,7 +127,9 @@ class Scene_Battle : public Scene {
enum BattleOptionType {
Battle,
AutoBattle,
Escape
Escape,
Win,
Lose
};

static void SelectionFlash(Game_Battler* battler);
Expand Down
20 changes: 17 additions & 3 deletions src/scene_battle_rpg2k3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,21 +1155,25 @@
ResetWindows(true);
target_window->SetIndex(-1);

if (lcf::Data::battlecommands.battle_type == lcf::rpg::BattleCommands::BattleType_traditional || ((std::find(battle_options.begin(), battle_options.end(), AutoBattle) == battle_options.end()) && !IsEscapeAllowedFromOptionWindow())) {
if (lcf::Data::battlecommands.battle_type == lcf::rpg::BattleCommands::BattleType_traditional
|| ((std::find(battle_options.begin(), battle_options.end(), AutoBattle) == battle_options.end()) && (std::find(battle_options.begin(), battle_options.end(), Win) == battle_options.end()) && (std::find(battle_options.begin(), battle_options.end(), Lose) == battle_options.end()) && !IsEscapeAllowedFromOptionWindow())) {
if (lcf::Data::battlecommands.battle_type != lcf::rpg::BattleCommands::BattleType_traditional) MoveCommandWindows(Player::menu_offset_x - options_window->GetWidth(), 1);
SetState(State_SelectActor);
return SceneActionReturn::eContinueThisFrame;
} else if (battle_options.size() == 1 && (std::find(battle_options.begin(), battle_options.end(), AutoBattle) != battle_options.end())) {
if (lcf::Data::battlecommands.battle_type != lcf::rpg::BattleCommands::BattleType_traditional) MoveCommandWindows(Player::menu_offset_x - options_window->GetWidth(), 1);
SetState(State_AutoBattle);
return SceneActionReturn::eContinueThisFrame;
}

options_window->SetActive(true);

auto it = std::find(battle_options.begin(), battle_options.end(), Escape);
if (IsEscapeAllowedFromOptionWindow()) {
auto it = std::find(battle_options.begin(), battle_options.end(), Escape);
if (it != battle_options.end()) {
options_window->EnableItem(std::distance(battle_options.begin(), it));
}
} else {
auto it = std::find(battle_options.begin(), battle_options.end(), Escape);
if (it != battle_options.end()) {
options_window->DisableItem(std::distance(battle_options.begin(), it));
}
Expand Down Expand Up @@ -1217,6 +1221,16 @@
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Buzzer));
}
break;
case Win: // Win
for each (Game_Enemy* enemy in Main_Data::game_enemyparty->GetEnemies())

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

expected '(' before 'each'

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

expected primary-expression before '*' token

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

'enemy' was not declared in this scope

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

'each' was not declared in this scope

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

expected '(' before 'each'

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

expected primary-expression before '*' token

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

'enemy' was not declared in this scope

Check failure on line 1225 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

'each' was not declared in this scope
MakoInfused marked this conversation as resolved.
Show resolved Hide resolved
{
enemy->Kill();
}
SetState(State_Victory);

Check failure on line 1229 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

could not convert '((Scene_Battle_Rpg2k3*)this)->Scene_Battle_Rpg2k3::SetState(Scene_Battle::State_Victory)' from 'void' to 'bool'

Check failure on line 1229 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

expected ')' before 'break'

Check failure on line 1229 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

could not convert '((Scene_Battle_Rpg2k3*)this)->Scene_Battle_Rpg2k3::SetState(Scene_Battle::State_Victory)' from 'void' to 'bool'

Check failure on line 1229 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

expected ')' before 'break'
break;

Check failure on line 1230 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / ubuntu:22.04

expected primary-expression before 'break'

Check failure on line 1230 in src/scene_battle_rpg2k3.cpp

View workflow job for this annotation

GitHub Actions / debian:12

expected primary-expression before 'break'
case Lose: // Lose
SetState(State_Defeat);
break;
}
}
return SceneActionReturn::eWaitTillNextFrame;
Expand Down
Loading