Skip to content

Commit

Permalink
Battle 2k3: Implement in-battle row command
Browse files Browse the repository at this point in the history
The in-battle row command has been added now.
  • Loading branch information
rueter37 committed Sep 6, 2020
1 parent 3544a6c commit 3193a7a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 37 deletions.
111 changes: 74 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++;
}
}
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,14 @@ 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 {
for_battler->SetLastBattleAction(-1);
}
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

0 comments on commit 3193a7a

Please sign in to comment.