aboutsummaryrefslogtreecommitdiff
path: root/src/game/Creature.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-09 19:55:15 -0500
committermegamage <none@none>2009-06-09 19:55:15 -0500
commit853432b201c6ae5b14c9cae445bb254a4795b4e5 (patch)
tree8c90729c1965ea80196165233a17ecc13f1fc4ba /src/game/Creature.cpp
parent4167ca4f840941b949fd318e4158ecf3cc268647 (diff)
*Fix a bug that creature ignore LOS in assistance case.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Creature.cpp')
-rw-r--r--src/game/Creature.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 7f249b36fbd..4e4cd734d5f 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1646,15 +1646,17 @@ bool Creature::IsWithinSightDist(Unit const* u) const
return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER));
}
-bool Creature::canStartAttack(Unit const* who) const
+bool Creature::canStartAttack(Unit const* who, bool force) const
{
- if(isCivilian() || IsNeutralToAll()
+ if(isCivilian()
|| !who->isInAccessiblePlaceFor(this)
- || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE
- || !IsWithinDistInMap(who, GetAttackDistance(who)))
+ || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return false;
- if(!canAttack(who, false))
+ if(!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who))))
+ return false;
+
+ if(!canAttack(who, force))
return false;
return IsWithinLOSInMap(who);