mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 11:25:42 +00:00
fix(Core/Movement): creatures should not cast while moving (#9141)
- Closes #8843
This commit is contained in:
@@ -121,8 +121,11 @@ void ConfusedMovementGenerator<T>::DoReset(T* unit)
|
||||
template<class T>
|
||||
bool ConfusedMovementGenerator<T>::DoUpdate(T* unit, uint32 diff)
|
||||
{
|
||||
if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
|
||||
if (unit->HasUnitState(UNIT_STATE_NOT_MOVE) || unit->IsMovementPreventedByCasting())
|
||||
{
|
||||
unit->StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i_nextMoveTime.Passed())
|
||||
{
|
||||
|
||||
@@ -50,9 +50,9 @@ bool EscortMovementGenerator<T>::DoUpdate(T* unit, uint32 /*diff*/)
|
||||
if (!unit)
|
||||
return false;
|
||||
|
||||
if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
|
||||
if (unit->HasUnitState(UNIT_STATE_NOT_MOVE) || unit->IsMovementPreventedByCasting())
|
||||
{
|
||||
unit->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
unit->StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T* owner)
|
||||
if (!owner)
|
||||
return;
|
||||
|
||||
if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_setMoveData(owner))
|
||||
return;
|
||||
@@ -346,9 +348,9 @@ bool FleeingMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
|
||||
if (!owner || !owner->IsAlive())
|
||||
return false;
|
||||
|
||||
if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting())
|
||||
{
|
||||
owner->ClearUnitState(UNIT_STATE_FLEEING_MOVE);
|
||||
owner->StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -385,9 +387,9 @@ bool TimedFleeingMovementGenerator::Update(Unit* owner, uint32 time_diff)
|
||||
if (!owner->IsAlive())
|
||||
return false;
|
||||
|
||||
if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting())
|
||||
{
|
||||
owner->ClearUnitState(UNIT_STATE_FLEEING_MOVE);
|
||||
owner->StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
template<class T>
|
||||
void PointMovementGenerator<T>::DoInitialize(T* unit)
|
||||
{
|
||||
if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
|
||||
if (unit->HasUnitState(UNIT_STATE_NOT_MOVE) || unit->IsMovementPreventedByCasting())
|
||||
{
|
||||
// the next line is to ensure that a new spline is created in DoUpdate() once the unit is no longer rooted/stunned
|
||||
// todo: rename this flag to something more appropriate since it is set to true even without speed change now.
|
||||
@@ -98,9 +98,9 @@ bool PointMovementGenerator<T>::DoUpdate(T* unit, uint32 /*diff*/)
|
||||
if (!unit)
|
||||
return false;
|
||||
|
||||
if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
|
||||
if (unit->HasUnitState(UNIT_STATE_NOT_MOVE) || unit->IsMovementPreventedByCasting())
|
||||
{
|
||||
unit->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
unit->StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,10 +260,10 @@ void RandomMovementGenerator<Creature>::DoFinalize(Creature* creature)
|
||||
template<>
|
||||
bool RandomMovementGenerator<Creature>::DoUpdate(Creature* creature, const uint32 diff)
|
||||
{
|
||||
if (creature->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
|
||||
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting())
|
||||
{
|
||||
_nextMoveTime.Reset(0); // Expire the timer
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
creature->StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -275,23 +275,6 @@ bool RandomMovementGenerator<Creature>::DoUpdate(Creature* creature, const uint3
|
||||
return true;
|
||||
}
|
||||
|
||||
// prevent movement while casting spells with cast time or channel time
|
||||
if (creature->HasUnitState(UNIT_STATE_CASTING))
|
||||
{
|
||||
bool stop = true;
|
||||
if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
|
||||
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
|
||||
stop = false;
|
||||
|
||||
if (stop)
|
||||
{
|
||||
if (!creature->IsStopped())
|
||||
creature->StopMoving();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (creature->movespline->Finalized())
|
||||
{
|
||||
_nextMoveTime.Update(diff);
|
||||
|
||||
@@ -145,8 +145,10 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
|
||||
}
|
||||
|
||||
// xinef: do not initialize motion if we got stunned in movementinform
|
||||
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE))
|
||||
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
WaypointData const* node = i_path->at(i_currentNode);
|
||||
|
||||
@@ -204,11 +206,13 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
|
||||
{
|
||||
// Waypoint movement can be switched on/off
|
||||
// This is quite handy for escort quests and other stuff
|
||||
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE))
|
||||
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting())
|
||||
{
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
creature->StopMoving();
|
||||
Stop(1000);
|
||||
return true;
|
||||
}
|
||||
|
||||
// prevent a crash at empty waypoint path.
|
||||
if (!i_path || i_path->empty())
|
||||
return false;
|
||||
@@ -217,23 +221,6 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
|
||||
if (!creature->IsAlive())
|
||||
return false;
|
||||
|
||||
// prevent movement while casting spells with cast time or channel time
|
||||
if (creature->HasUnitState(UNIT_STATE_CASTING))
|
||||
{
|
||||
bool stop = true;
|
||||
if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
|
||||
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
|
||||
stop = false;
|
||||
|
||||
if (stop)
|
||||
{
|
||||
Stop(1000);
|
||||
if (!creature->IsStopped())
|
||||
creature->StopMoving();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Stopped())
|
||||
{
|
||||
if (CanMove(diff))
|
||||
|
||||
Reference in New Issue
Block a user