Skip to content

Commit

Permalink
Use NoMove action for dead actors
Browse files Browse the repository at this point in the history
Dead actors in 2k battle still have their AGI calculated
and get a turn. To see this, perform the following test:

* Actor1 AGI: 300
* Enemy1 AGI: 200
* Actor2 AGI: 100

* Set Enemy1 to always use an attack that inflicts confuse
  on all.
* Make Actor2 easily succeptible to confuse
* Make Turn 0 battle event that inflicts death on Actor2

Start Battle Actions:
* Turn0 kills actor2
* Actor1 use a revive item on actor2

What happens:
* Actor1 goes first, revivies actor2,
* Enemy1 uses confuse skill, Actor2 is confused
* Actor2 now randomly attacks ally <- Doesn't happen before this PR
  • Loading branch information
fmatthew5876 committed Dec 8, 2018
1 parent 9c32aba commit 053d063
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
6 changes: 0 additions & 6 deletions src/scene_battle.cpp
Expand Up @@ -436,12 +436,6 @@ void Scene_Battle::UpdateBattlerActions() {
}

auto* battler = battle_actions.front();
if (battler->IsDead()) {
RemoveCurrentAction();
UpdateBattlerActions();
return;
}

if (!battler->CanAct()) {
battler->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::NoMove>(battler));
battler->SetCharged(false);
Expand Down
25 changes: 13 additions & 12 deletions src/scene_battle_rpg2k.cpp
Expand Up @@ -371,6 +371,11 @@ void Scene_Battle_Rpg2k::ProcessActions() {
}

bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase* action) {
// Immediately quit for dead actors no move. Prevents any animations or delays.
if (action->GetType() == Game_BattleAlgorithm::Type::NoMove && action->GetSource()->IsDead()) {
return true;
}

// Order of execution of BattleActionState:
// ConditionHeal > Execute > Apply > (ResultPop > ResultPush) > Death > Finished.
if (action == nullptr) {
Expand Down Expand Up @@ -837,28 +842,24 @@ void Scene_Battle_Rpg2k::SelectNextActor() {
status_window->SetIndex(actor_index);
actor_index++;

if (active_actor->IsDead()) {
Game_Battler* random_target = NULL;

if (!active_actor->CanAct()) {
active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::NoMove>(active_actor));
battle_actions.push_back(active_actor);
SelectNextActor();
return;
}

Game_Battler* random_target = NULL;

if (active_actor->CanAct()) {
switch (active_actor->GetSignificantRestriction()) {
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;
default:
break;
}

if (random_target || auto_battle || active_actor->GetAutoBattle()) {
Expand Down
5 changes: 5 additions & 0 deletions src/scene_battle_rpg2k3.cpp
Expand Up @@ -593,6 +593,11 @@ void Scene_Battle_Rpg2k3::ProcessActions() {
}

bool Scene_Battle_Rpg2k3::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase* action) {
// Immediately quit for dead actors no move. Prevents any animations or delays.
if (action->GetType() == Game_BattleAlgorithm::Type::NoMove && action->GetSource()->IsDead()) {
return true;
}

if (Game_Battle::IsBattleAnimationWaiting()) {
return false;
}
Expand Down

0 comments on commit 053d063

Please sign in to comment.