*Fix a bug that creature ignore LOS in assistance case.
--HG-- branch : trunk
This commit is contained in:
@@ -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);
|
||||
|
||||
+1
-1
@@ -643,7 +643,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
||||
|
||||
bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList = false, bool is3dDistance = true) const;
|
||||
bool IsWithinSightDist(Unit const* u) const;
|
||||
bool canStartAttack(Unit const* u) const;
|
||||
bool canStartAttack(Unit const* u, bool force) const;
|
||||
float GetAttackDistance(Unit const* pl) const;
|
||||
|
||||
Unit* SelectNearestTarget(float dist = 0) const;
|
||||
|
||||
@@ -100,11 +100,11 @@ void CreatureAI::MoveInLineOfSight(Unit *who)
|
||||
if(me->getVictim())
|
||||
return;
|
||||
|
||||
if(me->canStartAttack(who))
|
||||
if(me->canStartAttack(who, false))
|
||||
AttackStart(who);
|
||||
else if(who->getVictim() && me->IsFriendlyTo(who)
|
||||
&& me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
|
||||
&& me->canAttack(who->getVictim()))
|
||||
&& me->canStartAttack(who->getVictim(), true))
|
||||
AttackStart(who->getVictim());
|
||||
}
|
||||
|
||||
|
||||
@@ -957,11 +957,12 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
|
||||
}
|
||||
}
|
||||
|
||||
//if (m_creature->isCivilian() && m_creature->IsNeutralToAll())
|
||||
// return;
|
||||
|
||||
if(me->canStartAttack(who))
|
||||
if(me->canStartAttack(who, false))
|
||||
AttackStart(who);
|
||||
else if(who->getVictim() && me->IsFriendlyTo(who)
|
||||
&& me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
|
||||
&& me->canStartAttack(who->getVictim(), true))
|
||||
AttackStart(who->getVictim());
|
||||
}
|
||||
|
||||
void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
|
||||
|
||||
@@ -997,7 +997,7 @@ namespace Trinity
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!m_creature->canStartAttack(u))
|
||||
if(!m_creature->canStartAttack(u, false))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user