diff options
| author | megamage <none@none> | 2008-11-21 10:07:11 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2008-11-21 10:07:11 -0600 |
| commit | 71707df1dec2aa77864d9a853c34108bb6021138 (patch) | |
| tree | 2c1825c5965d15a41c6000ae0ddd4dc911713dd2 /src/game/Unit.cpp | |
| parent | 5528b7c512ef7968b11ea93a48364a58b629b18b (diff) | |
*Let creature search nearby target before enter evade mode
*Add function canStartAttack to reduce code in MoveInLineOfSight
*Fix a bug that cancelling bind sight auras may crash the server
--HG--
branch : trunk
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(); |
