aboutsummaryrefslogtreecommitdiff
path: root/src/game/CreatureAI.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-04-15 12:05:59 -0500
committermegamage <none@none>2009-04-15 12:05:59 -0500
commit8e910aca6b84f407d16f8db9cbe6d3ec093ba57f (patch)
treee6e3307c4d8ec7e83aec79347818afab1704e512 /src/game/CreatureAI.cpp
parent80892196951a0bd6559341d03dde764c88c4d296 (diff)
parent57b33b244f281119e41f83f8b8655bb0042ec24d (diff)
*Merge.
--HG-- branch : trunk
Diffstat (limited to 'src/game/CreatureAI.cpp')
-rw-r--r--src/game/CreatureAI.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index fdd145737ab..59df2e866f2 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -23,6 +23,7 @@
#include "Player.h"
#include "Pet.h"
#include "SpellAuras.h"
+#include "World.h"
void UnitAI::AttackStart(Unit *victim)
{
@@ -104,22 +105,15 @@ void CreatureAI::DoZoneInCombat(Unit* pUnit)
void CreatureAI::MoveInLineOfSight(Unit *who)
{
- if(!me->getVictim() && me->canStartAttack(who))
- AttackStart(who);
+ if(me->getVictim())
+ return;
- if (who->isInCombat() && who->getVictim() && me->GetCreatureType()==CREATURE_TYPE_HUMANOID && me->IsFriendlyTo(who))
- {
- if (me->GetDistanceZ(who) <= 2 && me->IsWithinLOSInMap(who))
- {
- float attackRadius = (me->GetAttackDistance(who) *0.5);
- if (me->IsWithinDistInMap(who, attackRadius))
- {
- Unit* target = NULL;
- target = who->getVictim();
- AttackStart(target);
- }
- }
- }
+ if(me->canStartAttack(who))
+ AttackStart(who);
+ else if(who->getVictim() && me->IsFriendlyTo(who)
+ && me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
+ && me->canAttack(who->getVictim()))
+ AttackStart(who->getVictim());
}
bool CreatureAI::UpdateVictim()