diff options
author | megamage <none@none> | 2009-06-09 19:55:15 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-06-09 19:55:15 -0500 |
commit | 853432b201c6ae5b14c9cae445bb254a4795b4e5 (patch) | |
tree | 8c90729c1965ea80196165233a17ecc13f1fc4ba /src/game | |
parent | 4167ca4f840941b949fd318e4158ecf3cc268647 (diff) |
*Fix a bug that creature ignore LOS in assistance case.
--HG--
branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/Creature.cpp | 12 | ||||
-rw-r--r-- | src/game/Creature.h | 2 | ||||
-rw-r--r-- | src/game/CreatureAI.cpp | 4 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 9 | ||||
-rw-r--r-- | src/game/GridNotifiers.h | 2 |
5 files changed, 16 insertions, 13 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); diff --git a/src/game/Creature.h b/src/game/Creature.h index 6c966f50aea..155ba3e8dd8 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -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; diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 143dfec99d3..1c3179b2e23 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -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()); } diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 834741fd2ae..3eb3a75c874 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -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) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 667891c0e38..5418bd09b16 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -997,7 +997,7 @@ namespace Trinity } else { - if(!m_creature->canStartAttack(u)) + if(!m_creature->canStartAttack(u, false)) return false; } |