| 76 | } |
| 77 | |
| 78 | void Scene_Battle::Start() { |
| 79 | if (Scene::Find(Scene::Map) == nullptr) { |
| 80 | // Battletest mode - need to initialize screen |
| 81 | Main_Data::game_screen->InitGraphics(); |
| 82 | Main_Data::game_pictures->InitGraphics(); |
| 83 | } |
| 84 | |
| 85 | // RPG_RT will cancel any active screen flash from the map, including |
| 86 | // wiping out all flash LSD chunks. |
| 87 | Main_Data::game_screen->FlashOnce(0, 0, 0, 0, 0); |
| 88 | |
| 89 | const lcf::rpg::Troop* troop = lcf::ReaderUtil::GetElement(lcf::Data::troops, troop_id); |
| 90 | |
| 91 | if (!troop) { |
| 92 | Output::Warning("Invalid Monster Party ID {}", troop_id); |
| 93 | EndBattle(BattleResult::Victory); |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | autobattle_algos.push_back(AutoBattle::CreateAlgorithm(AutoBattle::RpgRtCompat::name)); |
| 98 | autobattle_algos.push_back(AutoBattle::CreateAlgorithm(AutoBattle::RpgRtImproved::name)); |
| 99 | autobattle_algos.push_back(AutoBattle::CreateAlgorithm(AutoBattle::AttackOnly::name)); |
| 100 | enemyai_algos.push_back(EnemyAi::CreateAlgorithm(EnemyAi::RpgRtCompat::name)); |
| 101 | enemyai_algos.push_back(EnemyAi::CreateAlgorithm(EnemyAi::RpgRtImproved::name)); |
| 102 | |
| 103 | if (lcf::Data::system.easyrpg_default_actorai == -1 || (Player::debug_flag && !Player::player_config.autobattle_algo.Get().empty())) { |
| 104 | if (Player::player_config.autobattle_algo.Get().empty()) { |
| 105 | Player::player_config.autobattle_algo.Set(ToString(autobattle_algos[0]->GetName())); |
| 106 | } |
| 107 | for (auto& algo : autobattle_algos) { |
| 108 | if (algo->GetName() == Player::player_config.autobattle_algo.Get()) { |
| 109 | default_autobattle_algo = algo->GetId(); |
| 110 | break; |
| 111 | } |
| 112 | } |
| 113 | } else { |
| 114 | default_autobattle_algo = lcf::Data::system.easyrpg_default_actorai; |
| 115 | } |
| 116 | if (lcf::Data::system.easyrpg_default_enemyai == -1 || (Player::debug_flag && !Player::player_config.enemyai_algo.Get().empty())) { |
| 117 | if (Player::player_config.enemyai_algo.Get().empty()) { |
| 118 | Player::player_config.enemyai_algo.Set(ToString(enemyai_algos[0]->GetName())); |
| 119 | } |
| 120 | for (auto& algo : enemyai_algos) { |
| 121 | if (algo->GetName() == Player::player_config.enemyai_algo.Get()) { |
| 122 | default_enemyai_algo = algo->GetId(); |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | } else { |
| 127 | default_enemyai_algo = lcf::Data::system.easyrpg_default_enemyai; |
| 128 | } |
| 129 | |
| 130 | Output::Debug("Starting battle {} ({}): algos=({}/{})", troop_id, troop->name, autobattle_algos[default_autobattle_algo]->GetName(), enemyai_algos[default_enemyai_algo]->GetName()); |
| 131 | |
| 132 | Game_Battle::Init(troop_id); |
| 133 | |
| 134 | CreateUi(); |
| 135 |
nothing calls this directly
no test coverage detected