*Fix the bug that neutral creatures do not fight back.
--HG-- branch : trunk
This commit is contained in:
@@ -1576,7 +1576,7 @@ bool Creature::canStartAttack(Unit const* who) const
|
|||||||
|| !IsWithinDistInMap(who, GetAttackDistance(who)))
|
|| !IsWithinDistInMap(who, GetAttackDistance(who)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!canAttack(who))
|
if(!canAttack(who, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return IsWithinLOSInMap(who);
|
return IsWithinLOSInMap(who);
|
||||||
|
|||||||
+7
-2
@@ -8557,11 +8557,16 @@ bool Unit::isTargetableForAttack() const
|
|||||||
return isAttackableByAOE() && !hasUnitState(UNIT_STAT_DIED);
|
return isAttackableByAOE() && !hasUnitState(UNIT_STAT_DIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::canAttack(Unit const* target) const
|
bool Unit::canAttack(Unit const* target, bool force) const
|
||||||
{
|
{
|
||||||
assert(target);
|
assert(target);
|
||||||
|
|
||||||
if(!IsHostileTo(target))
|
if(force)
|
||||||
|
{
|
||||||
|
if(IsFriendlyTo(target))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(!IsHostileTo(target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED))
|
if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED))
|
||||||
|
|||||||
+1
-1
@@ -928,7 +928,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
|||||||
|
|
||||||
bool isTargetableForAttack() const;
|
bool isTargetableForAttack() const;
|
||||||
bool isAttackableByAOE() const;
|
bool isAttackableByAOE() const;
|
||||||
bool canAttack(Unit const* target) const;
|
bool canAttack(Unit const* target, bool force = true) const;
|
||||||
virtual bool IsInWater() const;
|
virtual bool IsInWater() const;
|
||||||
virtual bool IsUnderWater() const;
|
virtual bool IsUnderWater() const;
|
||||||
bool isInAccessiblePlaceFor(Creature const* c) const;
|
bool isInAccessiblePlaceFor(Creature const* c) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user