MCPcopy Create free account
hub / github.com/EasyRPG/Player / CommandShowBattleAnimation

Method CommandShowBattleAnimation

src/game_interpreter_battle.cpp:467–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467bool Game_Interpreter_Battle::CommandShowBattleAnimation(lcf::rpg::EventCommand const& com) {
468 int animation_id = com.parameters[0];
469 int target = com.parameters[1];
470 bool waiting_battle_anim = com.parameters[2] != 0;
471 bool allies = false;
472
473 if (Player::IsRPG2k3() && com.parameters.size() > 3) {
474 allies = com.parameters[3] != 0;
475 }
476
477 int frames = 0;
478
479 if (target < 0) {
480 std::vector<Game_Battler*> v;
481
482 if (allies) {
483 Main_Data::game_party->GetBattlers(v);
484 } else {
485 Main_Data::game_enemyparty->GetBattlers(v);
486 }
487 auto iter = std::remove_if(v.begin(), v.end(),
488 [](auto* target) { return !(target->Exists() || (target->GetType() == Game_Battler::Type_Ally && target->IsDead())); });
489 v.erase(iter, v.end());
490
491 frames = Game_Battle::ShowBattleAnimation(animation_id, v, false);
492 }
493 else {
494 Game_Battler* battler_target = nullptr;
495
496 if (allies) {
497 // Allies counted from 1
498 target -= 1;
499 if (target >= 0 && target < Main_Data::game_party->GetBattlerCount()) {
500 battler_target = &(*Main_Data::game_party)[target];
501 }
502 }
503 else {
504 if (target < Main_Data::game_enemyparty->GetBattlerCount()) {
505 battler_target = &(*Main_Data::game_enemyparty)[target];
506 }
507 }
508
509 if (battler_target) {
510 frames = Game_Battle::ShowBattleAnimation(animation_id, { battler_target });
511 }
512 }
513
514 if (waiting_battle_anim) {
515 _state.wait_time = frames;
516 }
517
518 return true;
519}
520
521bool Game_Interpreter_Battle::CommandTerminateBattle(lcf::rpg::EventCommand const& /* com */) {
522 _async_op = AsyncOp::MakeTerminateBattle(static_cast<int>(BattleResult::Abort));

Callers

nothing calls this directly

Calls 8

GetBattlersMethod · 0.80
IsDeadMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ExistsMethod · 0.45
GetTypeMethod · 0.45
GetBattlerCountMethod · 0.45

Tested by

no test coverage detected