| 150 | } |
| 151 | |
| 152 | int Game_Battle::ShowBattleAnimation(int animation_id, std::vector<Game_Battler*> targets, bool only_sound, int cutoff, bool invert) { |
| 153 | const lcf::rpg::Animation* anim = lcf::ReaderUtil::GetElement(lcf::Data::animations, animation_id); |
| 154 | if (!anim) { |
| 155 | Output::Warning("ShowBattleAnimation Many: Invalid animation ID {}", animation_id); |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | const auto main_type = targets.empty() ? Game_Battler::Type_Ally : targets.front()->GetType(); |
| 160 | std::vector<Game_Battler*> alt_targets; |
| 161 | |
| 162 | for (auto iter = targets.begin(); iter != targets.end();) { |
| 163 | if ((*iter)->GetType() == main_type) { |
| 164 | ++iter; |
| 165 | } else { |
| 166 | alt_targets.push_back(*iter); |
| 167 | iter = targets.erase(iter); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | auto& main_anim = main_type == Game_Battler::Type_Ally ? animation_actors : animation_enemies; |
| 172 | auto& alt_anim = main_type == Game_Battler::Type_Ally ? animation_enemies : animation_actors; |
| 173 | |
| 174 | main_anim.reset(new BattleAnimationBattle(*anim, std::move(targets), only_sound, cutoff, invert)); |
| 175 | auto main_frames = main_anim->GetFrames(); |
| 176 | main_frames = cutoff >= 0 ? std::min(main_frames, cutoff) : main_frames; |
| 177 | |
| 178 | auto alt_frames = 0; |
| 179 | if (!alt_targets.empty()) { |
| 180 | alt_anim.reset(new BattleAnimationBattle(*anim, std::move(alt_targets), only_sound, cutoff, invert)); |
| 181 | auto alt_frames = alt_anim->GetFrames(); |
| 182 | alt_frames = cutoff >= 0 ? std::min(alt_frames, cutoff) : alt_frames; |
| 183 | } |
| 184 | |
| 185 | return std::max(main_frames, alt_frames); |
| 186 | } |
| 187 | |
| 188 | bool Game_Battle::IsBattleAnimationWaiting() { |
| 189 | return bool(animation_actors) || bool(animation_enemies); |