void Scene_Battle_Rpg2k::SelectNextActor() { std::vector<Game_Actor*> allies = Main_Data::game_party->GetActors(); if ((size_t)actor_index == allies.size()) { // All actor actions decided, player turn ends SetState(State_Battle); CreateEnemyActions(); CreateExecutionOrder(); NextTurn(); Game_Battle::RefreshEvents(); return; } active_actor = allies[actor_index]; status_window->SetIndex(actor_index); actor_index++; if (active_actor->IsDead()) { SelectNextActor(); return; } Game_Battler* random_target = NULL; if (active_actor->CanAct()) { switch (active_actor->GetSignificantRestriction()) { case RPG::State::Restriction_attack_ally: random_target = Main_Data::game_party->GetRandomActiveBattler(); break; case RPG::State::Restriction_attack_enemy: random_target = Main_Data::game_enemyparty->GetRandomActiveBattler(); break; } } else { active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::NoMove>(active_actor)); battle_actions.push_back(active_actor); SelectNextActor(); return; } if (random_target || auto_battle || active_actor->GetAutoBattle()) { if (!random_target) { random_target = Main_Data::game_enemyparty->GetRandomActiveBattler(); } // ToDo: Auto battle logic is dumb active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(active_actor, random_target)); battle_actions.push_back(active_actor); SelectNextActor(); return; } SetState(Scene_Battle::State_SelectCommand); }
void Scene_Battle_Rpg2k::Escape() { static bool escaping = true; static bool escape_success = false; if (escaping) { battle_message_window->Clear(); Game_BattleAlgorithm::Escape escape_alg = Game_BattleAlgorithm::Escape(&(*Main_Data::game_party)[0]); escape_success = escape_alg.Execute(); escape_alg.Apply(); battle_result_messages.clear(); escape_alg.GetResultMessages(battle_result_messages); battle_message_window->Push(battle_result_messages[0]); escaping = false; } else { static int counter = 0; ++counter; if (counter > 60) { escaping = true; counter = 0; if (escape_success) { Game_Temp::battle_result = Game_Temp::BattleEscape; Scene::Pop(); } else { SetState(State_Battle); CreateEnemyActions(); CreateExecutionOrder(); NextTurn(); } } } }
void Scene_Battle_Rpg2k::Escape() { if (begin_escape) { battle_message_window->Clear(); Game_BattleAlgorithm::Escape escape_alg = Game_BattleAlgorithm::Escape(&(*Main_Data::game_party)[0]); escape_success = escape_alg.Execute(); escape_alg.Apply(); battle_result_messages.clear(); escape_alg.GetResultMessages(battle_result_messages); battle_message_window->Push(battle_result_messages[0]); begin_escape = false; } else { ++escape_counter; if (escape_counter > 60) { begin_escape = true; escape_counter = 0; if (escape_success) { Game_Temp::battle_result = Game_Temp::BattleEscape; Scene::Pop(); } else { SetState(State_Battle); CreateEnemyActions(); CreateExecutionOrder(); NextTurn(); Game_Battle::RefreshEvents(); } } } }