diff options
author | megamage <none@none> | 2009-01-31 13:58:33 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-01-31 13:58:33 -0600 |
commit | d20eaef1d6c7b8d629347b51583cbcf954ff96ed (patch) | |
tree | 0387ea5eed3569d49ffcac9553ada179fba645f0 /src/game/CreatureAI.cpp | |
parent | be27bd230cbefc8241ab8704bef8894252403ea2 (diff) | |
parent | 1f2292af796d4b424bf45711ae8c50e764cf0d61 (diff) |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'src/game/CreatureAI.cpp')
-rw-r--r-- | src/game/CreatureAI.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 66c9d5af0b0..8682bf064a5 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -20,17 +20,39 @@ #include "CreatureAI.h" #include "Creature.h" +#include "Player.h" #include "Pet.h" #include "SpellAuras.h" -CreatureAI::~CreatureAI() +void UnitAI::AttackStart(Unit *victim) { + if(!victim) + return; + + if(me->Attack(victim, true)) + { + //DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", me->GetName(), victim->GetGUIDLow()); + me->GetMotionMaster()->MoveChase(victim); + } } -void CreatureAI::EnterEvadeMode() +void CreatureAI::MoveInLineOfSight(Unit *who) { - if(!me) return; + if(!me->getVictim() && me->canStartAttack(who)) + AttackStart(who); +} +bool CreatureAI::UpdateVictim() +{ + if(!me->isInCombat()) + return false; + if(Unit *victim = me->SelectVictim()) + AttackStart(victim); + return me->getVictim(); +} + +void CreatureAI::EnterEvadeMode() +{ me->RemoveAllAuras(); me->DeleteThreatList(); me->CombatStop(); @@ -62,12 +84,5 @@ void SimpleCharmedAI::UpdateAI(const uint32 /*diff*/) Unit *target = me->getVictim(); if(!target || !charmer->canAttack(target)) - { - target = charmer->SelectNearestTarget(); - if(!target) - return; - - me->GetMotionMaster()->MoveChase(target); - me->Attack(target, true); - } + AttackStart(charmer->SelectNearestTarget()); } |