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

Battle 2k3: Implement in-battle row command #2322

Merged
merged 2 commits into from Sep 10, 2020
Merged
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
118 changes: 81 additions & 37 deletions src/scene_battle_rpg2k3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ void Scene_Battle_Rpg2k3::CreateBattleCommandWindow() {
}
++i;
}
commands.push_back(ToString(lcf::Data::terms.row));
}

command_window.reset(new Window_Command(commands, option_command_mov));
Expand Down Expand Up @@ -1198,43 +1199,49 @@ void Scene_Battle_Rpg2k3::OptionSelected() {
}

void Scene_Battle_Rpg2k3::CommandSelected() {
const lcf::rpg::BattleCommand* command = active_actor->GetBattleCommands()[command_window->GetIndex()];

switch (command->type) {
case lcf::rpg::BattleCommand::Type_attack:
AttackSelected();
break;
case lcf::rpg::BattleCommand::Type_defense:
DefendSelected();
break;
case lcf::rpg::BattleCommand::Type_escape:
if (!IsEscapeAllowedFromActorCommand()) {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
}
else {
int index = command_window->GetIndex();
// Row command always uses the last index
if (index < command_window->GetRowMax() - 1) {
const lcf::rpg::BattleCommand* command = active_actor->GetBattleCommands()[index];

switch (command->type) {
case lcf::rpg::BattleCommand::Type_attack:
AttackSelected();
break;
case lcf::rpg::BattleCommand::Type_defense:
DefendSelected();
break;
case lcf::rpg::BattleCommand::Type_escape:
if (!IsEscapeAllowedFromActorCommand()) {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
}
else {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
active_actor->SetAtbGauge(0);
SetState(State_Escape);
}
break;
case lcf::rpg::BattleCommand::Type_item:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
SetState(State_SelectItem);
break;
case lcf::rpg::BattleCommand::Type_skill:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
skill_window->SetSubsetFilter(0);
sp_window->SetBattler(*active_actor);
SetState(State_SelectSkill);
break;
case lcf::rpg::BattleCommand::Type_special:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
SpecialSelected();
break;
case lcf::rpg::BattleCommand::Type_subskill:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
active_actor->SetAtbGauge(0);
SetState(State_Escape);
SubskillSelected();
break;
}
break;
case lcf::rpg::BattleCommand::Type_item:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
SetState(State_SelectItem);
break;
case lcf::rpg::BattleCommand::Type_skill:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
skill_window->SetSubsetFilter(0);
sp_window->SetBattler(*active_actor);
SetState(State_SelectSkill);
break;
case lcf::rpg::BattleCommand::Type_special:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
SpecialSelected();
break;
case lcf::rpg::BattleCommand::Type_subskill:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
SubskillSelected();
break;
} else {
RowSelected();
}
}

Expand Down Expand Up @@ -1277,6 +1284,30 @@ void Scene_Battle_Rpg2k3::SpecialSelected() {
ActionSelectedCallback(active_actor);
}

void Scene_Battle_Rpg2k3::RowSelected() {
// Switching rows is only possible if in back row or
// if at least 2 party members are in front row
int current_row = active_actor->GetBattleRow();
int front_row_battlers = 0;
if (current_row == active_actor->IsDirectionFlipped()) {
for (auto& actor: Main_Data::game_party->GetActors()) {
if (actor->GetBattleRow() == actor->IsDirectionFlipped()) front_row_battlers++;
}
}
Copy link
Contributor

@fmatthew5876 fmatthew5876 Sep 6, 2020

Choose a reason for hiding this comment

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

This case doesn't appear to handle back attacks etc..

I checked in RE tools and found that RPG_RT counts the number of actors which row == mirrored and then allows the row command if count >= 2 || current_hero.row != current_hero.mirrored

Copy link
Author

Choose a reason for hiding this comment

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

Did the change as requested and tested it. I have amended the commit and force pushed it because I assume you want this in one commit.

if (current_row != active_actor->IsDirectionFlipped() || front_row_battlers >= 2) {
if (active_actor->GetBattleRow() == Game_Actor::RowType::RowType_front) {
active_actor->SetBattleRow(Game_Actor::RowType::RowType_back);
} else {
active_actor->SetBattleRow(Game_Actor::RowType::RowType_front);
}
active_actor->SetBattlePosition(Game_Battle::Calculate2k3BattlePosition(*active_actor));
active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::NoMove>(active_actor));
ActionSelectedCallback(active_actor);
} else {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
}
}

void Scene_Battle_Rpg2k3::Escape(bool force_allow) {
if (force_allow || TryEscape()) {
// There is no success text for escape in 2k3
Expand Down Expand Up @@ -1461,8 +1492,21 @@ void Scene_Battle_Rpg2k3::ActionSelectedCallback(Game_Battler* for_battler) {
for_battler->SetAtbGauge(0);

if (for_battler->GetType() == Game_Battler::Type_Ally) {
const lcf::rpg::BattleCommand* command = static_cast<Game_Actor*>(for_battler)->GetBattleCommands()[command_window->GetIndex()];
for_battler->SetLastBattleAction(command->ID);
int index = command_window->GetIndex();
// Row command always uses the last index
if (index < command_window->GetRowMax() - 1) {
const lcf::rpg::BattleCommand* command = static_cast<Game_Actor*>(for_battler)->GetBattleCommands()[index];
for_battler->SetLastBattleAction(command->ID);
} else {
// RPG_RT behavior: If the row command is used,
// then check if the actor has at least 6 battle commands.
// If yes, then set -1 as last battle action, otherwise 0.
if (static_cast<Game_Actor*>(for_battler)->GetBattleCommands().size() >= 6) {
for_battler->SetLastBattleAction(-1);
} else {
for_battler->SetLastBattleAction(0);
}
}
status_window->SetIndex(-1);
}

Expand Down
1 change: 1 addition & 0 deletions src/scene_battle_rpg2k3.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class Scene_Battle_Rpg2k3 : public Scene_Battle {
void AttackSelected() override;
void SubskillSelected();
void SpecialSelected();
void RowSelected();

void Escape(bool force_allow = false);

Expand Down