Fixed ACTION_T_COMBAT_MOVEMENT preventing waypoint movement in OOC state.

--HG--
branch : trunk
This commit is contained in:
Xanadu
2010-03-11 01:56:47 +01:00
parent d8520c04e8
commit 4c7e599802
+26 -7
View File
@@ -575,20 +575,39 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
//Allow movement (create new targeted movement gen only if idle) //Allow movement (create new targeted movement gen only if idle)
if (CombatMovementEnabled) if (CombatMovementEnabled)
{ {
if(action.combat_movement.melee && m_creature->isInCombat()) Unit* victim = m_creature->getVictim();
if(Unit* victim = m_creature->getVictim()) if (m_creature->isInCombat() && victim)
{
if (action.combat_movement.melee)
{
m_creature->addUnitState(UNIT_STAT_MELEE_ATTACKING);
m_creature->SendMeleeAttackStart(victim); m_creature->SendMeleeAttackStart(victim);
}
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE)
{
//m_creature->GetMotionMaster()->Clear(false);
m_creature->GetMotionMaster()->MoveChase(victim, AttackDistance, AttackAngle); // Targeted movement generator will start melee automatically, no need to send it explicitly
}
}
} }
else else
{ {
if(action.combat_movement.melee && m_creature->isInCombat()) if (m_creature->isInCombat())
if(Unit* victim = m_creature->getVictim()) {
Unit* victim = m_creature->getVictim();
if (action.combat_movement.melee && victim)
{
m_creature->clearUnitState(UNIT_STAT_MELEE_ATTACKING);
m_creature->SendMeleeAttackStop(victim); m_creature->SendMeleeAttackStop(victim);
}
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE)
{
//m_creature->StopMoving();
//m_creature->GetMotionMaster()->Clear(false);
m_creature->GetMotionMaster()->MoveIdle(); m_creature->GetMotionMaster()->MoveIdle();
} }
}
}
break; break;
case ACTION_T_SET_PHASE: case ACTION_T_SET_PHASE:
Phase = action.set_phase.phase; Phase = action.set_phase.phase;