Skip to content

Commit

Permalink
Strenghten again the target selection logic in battle.
Browse files Browse the repository at this point in the history
Now the logic will search for the next target in the list if the previous one
failed, if that fails also because it can if the target was invalidated
within the same battle loop, if will then search for a completely
new target.

This fixes the last (and quite rare) case where one character
can't select an attack target anymore.
  • Loading branch information
Yohann Ferreira committed Sep 15, 2012
1 parent 0fddae0 commit 129dbc1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/modes/battle/battle_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,20 +866,20 @@ bool CommandSupervisor::_SetInitialTarget() {

bool permit_dead_targets = (_selected_target.GetType() == GLOBAL_TARGET_ALLY_EVEN_DEAD);

// If the target type is invalid that means that there is no previous target so grab the initial target
if (_selected_target.GetType() == GLOBAL_TARGET_INVALID) {
if (!_selected_target.SetInitialTarget(user, target_type)) {
// No more target of that type, let's go back to the command state
_selected_target.InvalidateTarget();
BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
return false;
}
}
// Otherwise if the last target is no longer valid, select the next valid target
else if (!_selected_target.IsValid(permit_dead_targets)) {
if (!_selected_target.IsValid(permit_dead_targets)) {
// Party targets should always be valid and attack points on actors do not disappear, so only the actor
// must be invalid
if (!_selected_target.SelectNextActor(user, permit_dead_targets)) {
// No more target of that type, let's go back to the command state
// Invalidate the target so that one can get a completely new one
_selected_target.InvalidateTarget();
}
}

// If the target type is invalid that means that there is no previous target so grab the initial target
if (_selected_target.GetType() == GLOBAL_TARGET_INVALID) {
if (!_selected_target.SetInitialTarget(user, target_type)) {
// No more target of that type, let's go back to the command state
_selected_target.InvalidateTarget();
BattleMode::CurrentInstance()->GetMedia().cancel_sound.Play();
Expand Down

0 comments on commit 129dbc1

Please sign in to comment.