From 1fbfc6da645058a6da3073dafde0e6bca621e31c Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 12 Mar 2009 14:15:44 -0600 Subject: *Assign possessed AI and pet AI to charmed creatures. --HG-- branch : trunk --- src/game/CreatureAI.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/game/CreatureAI.cpp') diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index fa512fce726..2d7eeeb18ff 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) { -- cgit v1.2.3