diff options
author | megamage <none@none> | 2008-11-26 11:41:03 -0600 |
---|---|---|
committer | megamage <none@none> | 2008-11-26 11:41:03 -0600 |
commit | 77b753b45260b24f846d51c5527c90fffd1cf3d5 (patch) | |
tree | f0fdd06ee0810584606af757be037cb980e3ecfa /src/game/Unit.cpp | |
parent | 9e3c9124f2b63e048e7a62a44c1ea36249e9a85a (diff) |
*Fix the bug that neutral creatures do not fight back.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0ff6aacb5ef..571ff991147 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8557,11 +8557,16 @@ bool Unit::isTargetableForAttack() const return isAttackableByAOE() && !hasUnitState(UNIT_STAT_DIED); } -bool Unit::canAttack(Unit const* target) const +bool Unit::canAttack(Unit const* target, bool force) const { assert(target); - if(!IsHostileTo(target)) + if(force) + { + if(IsFriendlyTo(target)) + return false; + } + else if(!IsHostileTo(target)) return false; if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) |