fix(Core/Movement): creatures should not cast while moving (#9141)

- Closes #8843
This commit is contained in:
UltraNix 2021-11-15 14:39:36 +01:00 committed by GitHub
parent 006ee3b7e2
commit 70fbaefa8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 52 deletions

View file

@ -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))