From 853432b201c6ae5b14c9cae445bb254a4795b4e5 Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 9 Jun 2009 19:55:15 -0500 Subject: *Fix a bug that creature ignore LOS in assistance case. --HG-- branch : trunk --- src/game/Creature.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/game/Creature.cpp') 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); -- cgit v1.2.3