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

Method PrepareBattleAction

src/scene_battle.cpp:529–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527}
528
529void Scene_Battle::PrepareBattleAction(Game_Battler* battler) {
530 if (battler->GetBattleAlgorithm() == nullptr) {
531 return;
532 }
533
534 if (!battler->CanAct()) {
535 if (battler->GetBattleAlgorithm()->GetType() != Game_BattleAlgorithm::Type::None) {
536 battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::None>(battler));
537 }
538 return;
539 }
540
541 if (battler->GetSignificantRestriction() == lcf::rpg::State::Restriction_attack_ally) {
542 Game_Battler *target = battler->GetType() == Game_Battler::Type_Enemy ?
543 Main_Data::game_enemyparty->GetRandomActiveBattler() :
544 Main_Data::game_party->GetRandomActiveBattler();
545
546 battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(battler, target));
547 return;
548 }
549
550 if (battler->GetSignificantRestriction() == lcf::rpg::State::Restriction_attack_enemy) {
551 Game_Battler *target = battler->GetType() == Game_Battler::Type_Ally ?
552 Main_Data::game_enemyparty->GetRandomActiveBattler() :
553 Main_Data::game_party->GetRandomActiveBattler();
554
555 battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(battler, target));
556 return;
557 }
558
559 // If we can no longer perform the action (no more items, ran out of SP, etc..)
560 if (!battler->GetBattleAlgorithm()->ActionIsPossible()) {
561 battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::None>(battler));
562 }
563}
564
565void Scene_Battle::RemoveCurrentAction() {
566 battle_actions.front()->SetBattleAlgorithm(nullptr);

Callers

nothing calls this directly

Calls 7

GetBattleAlgorithmMethod · 0.80
CanActMethod · 0.80
SetBattleAlgorithmMethod · 0.80
ActionIsPossibleMethod · 0.60
GetTypeMethod · 0.45

Tested by

no test coverage detected