Core/Combat: Properly unset engagement flag on death.

This commit is contained in:
Treeston
2019-07-31 13:17:32 +02:00
parent 5378fc4500
commit 9c603ea87f
4 changed files with 11 additions and 6 deletions

View File

@@ -61,7 +61,7 @@ void GuardAI::EnterEvadeMode(EvadeReason /*why*/)
return;
}
TC_LOG_TRACE("scritps.ai", "GuardAI::EnterEvadeMode: %s enters evade mode.", me->GetGUID().ToString().c_str());
TC_LOG_TRACE("scripts.ai", "GuardAI::EnterEvadeMode: %s enters evade mode.", me->GetGUID().ToString().c_str());
me->RemoveAllAuras();
me->CombatStop(true);

View File

@@ -240,6 +240,12 @@ bool CreatureAI::UpdateVictim()
if (!IsEngaged())
return false;
if (!me->IsAlive())
{
EngagementOver();
return false;
}
if (!me->HasReactState(REACT_PASSIVE))
{
if (Unit* victim = me->SelectVictim())

View File

@@ -702,6 +702,9 @@ void Creature::Update(uint32 diff)
if (m_deathState != CORPSE)
break;
if (IsEngaged())
Unit::AIUpdateTick(diff);
if (m_groupLootTimer && lootingGroupLowGUID)
{
if (m_groupLootTimer <= diff)
@@ -788,8 +791,6 @@ void Creature::Update(uint32 diff)
}
}
// do not allow the AI to be changed during update
Unit::AIUpdateTick(diff);
// creature can be dead after UpdateAI call
@@ -3272,7 +3273,7 @@ void Creature::AtDisengage()
Unit::AtDisengage();
ClearUnitState(UNIT_STATE_ATTACK_PLAYER);
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
if (IsAlive() && HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
SetUInt32Value(UNIT_DYNAMIC_FLAGS, GetCreatureTemplate()->dynamicflags);
if (IsPet() || IsGuardian()) // update pets' speed for catchup OOC speed

View File

@@ -10950,8 +10950,6 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
if (!creature->IsPet())
{
creature->GetThreatManager().ClearAllThreat();
// must be after setDeathState which resets dynamic flags
if (!creature->loot.isLooted())
creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);