diff options
Diffstat (limited to 'src/game/Unit.cpp')
| -rw-r--r-- | src/game/Unit.cpp | 10 | 
1 files changed, 10 insertions, 0 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 9a78c50857f..94f647cdd46 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8542,6 +8542,9 @@ bool Unit::canAttack(Unit const* target) const  {      assert(target); +    if(!IsHostileTo(target)) +        return false; +      if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED))          return false; @@ -9126,6 +9129,13 @@ bool Unit::SelectHostilTarget()          }      } +    // search nearby enemy before enter evade mode +    if(Unit *target = ((Creature*)this)->SelectNearestTarget()) +    { +        ((Creature*)this)->AI()->AttackStart(target); +        return true; +    } +      // enter in evade mode in other case      ((Creature*)this)->AI()->EnterEvadeMode();  | 
