diff options
author | megamage <none@none> | 2009-03-12 14:22:59 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-12 14:22:59 -0600 |
commit | 16ee4a46c271bd7c234ffa7579f5f90cf2007772 (patch) | |
tree | 6d547d8228472fcc97ead5dfcdd8a9aaf8f70233 /src/game/CreatureAI.cpp | |
parent | 6e12d3f1b9f40f3f95390245f3fcbb30fbd8657f (diff) | |
parent | 1fbfc6da645058a6da3073dafde0e6bca621e31c (diff) |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'src/game/CreatureAI.cpp')
-rw-r--r-- | src/game/CreatureAI.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 06b2d382d8f..0fa85a4d9e2 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -36,11 +36,34 @@ void UnitAI::AttackStart(Unit *victim) } } +void UnitAI::DoMeleeAttackIfReady() +{ + //Make sure our attack is ready and we aren't currently casting before checking distance + if (me->isAttackReady() && !me->hasUnitState(UNIT_STAT_CASTING)) + { + //If we are within range melee the target + if (me->IsWithinMeleeRange(me->getVictim())) + { + me->AttackerStateUpdate(me->getVictim()); + me->resetAttackTimer(); + } + } + if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK) && !me->hasUnitState(UNIT_STAT_CASTING)) + { + //If we are within range melee the target + if (me->IsWithinMeleeRange(me->getVictim())) + { + me->AttackerStateUpdate(me->getVictim(), OFF_ATTACK); + me->resetAttackTimer(OFF_ATTACK); + } + } +} + //Enable PlayerAI when charmed void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; } //Disable CreatureAI when charmed -void CreatureAI::OnCharmed(bool apply) { me->IsAIEnabled = !apply; } +void CreatureAI::OnCharmed(bool apply) { /*me->IsAIEnabled = !apply;*/ } void CreatureAI::MoveInLineOfSight(Unit *who) { |