Permalink
Browse files

Strenghten again the target selection logic in battle.

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...
1 parent 0fddae0 commit 129dbc1ecbad58972c29cdb9c12e03b478b6cddc Yohann Ferreira committed Sep 15, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/modes/battle/battle_command.cpp
@@ -866,21 +866,21 @@ 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();
return false;

0 comments on commit 129dbc1

Please sign in to comment.