Core/Movement: interrupt a creature's current cast when fleeing for assistance, and (if spell is not castable while moving) when running random/fleeing movement generators. (#17271)

Also make sure the creature is alive before updating.

Fixes #12823.
This commit is contained in:
SnapperRy
2016-06-10 21:03:30 +02:00
committed by Aokromes
parent b917eb955f
commit f7ac30867f
3 changed files with 16 additions and 0 deletions

View File

@@ -531,6 +531,7 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z)
TC_LOG_DEBUG("misc", "Creature (Entry: %u GUID: %u) seek assistance (X: %f Y: %f Z: %f)",
_owner->GetEntry(), _owner->GetGUID().GetCounter(), x, y, z);
_owner->AttackStop();
_owner->CastStop();
_owner->ToCreature()->SetReactState(REACT_PASSIVE);
Mutate(new AssistanceMovementGenerator(x, y, z), MOTION_SLOT_ACTIVE);
}

View File

@@ -38,6 +38,12 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T* owner)
if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
return;
if (owner->HasUnitState(UNIT_STATE_CASTING) && !owner->CanMoveDuringChannel())
{
owner->CastStop();
return;
}
owner->AddUnitState(UNIT_STATE_FLEEING_MOVE);
float x, y, z;

View File

@@ -29,6 +29,12 @@
template<>
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
{
if (creature->HasUnitState(UNIT_STATE_CASTING) && !creature->CanMoveDuringChannel())
{
creature->CastStop();
return;
}
float respX, respY, respZ, respO, destX, destY, destZ, travelDistZ;
creature->GetHomePosition(respX, respY, respZ, respO);
Map const* map = creature->GetBaseMap();
@@ -141,6 +147,9 @@ void RandomMovementGenerator<Creature>::DoFinalize(Creature* creature)
template<>
bool RandomMovementGenerator<Creature>::DoUpdate(Creature* creature, const uint32 diff)
{
if (!creature || !creature->IsAlive())
return false;
if (creature->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
{
i_nextMoveTime.Reset(0); // Expire the timer