mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user