Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 129dbc1ecbad58972c29cdb9c12e03b478b6cddc 1 parent 0fddae0
Yohann Ferreira authored
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/modes/battle/battle_command.cpp
View
20 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;
Please sign in to comment.
Something went wrong with that request. Please try again.