Don't allow units to enter combat upon death

This commit is contained in:
trickerer
2013-12-11 09:38:24 +07:00
parent eddf1b5a64
commit 91ebea4a77
3 changed files with 8 additions and 7 deletions
+6 -5
View File
@@ -12393,6 +12393,9 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
void Unit::setDeathState(DeathState s)
{
// Death state needs to be updated before RemoveAllAurasOnDeath() is called, to prevent entering combat
m_deathState = s;
if (s != ALIVE && s != JUST_RESPAWNED)
{
CombatStop();
@@ -12441,8 +12444,6 @@ void Unit::setDeathState(DeathState s)
}
else if (s == JUST_RESPAWNED)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground)
m_deathState = s;
}
/*########################################
@@ -12450,14 +12451,14 @@ void Unit::setDeathState(DeathState s)
######## AGGRO SYSTEM ########
######## ########
########################################*/
bool Unit::CanHaveThreatList() const
bool Unit::CanHaveThreatList(bool skipAliveCheck) const
{
// only creatures can have threat list
if (GetTypeId() != TYPEID_UNIT)
return false;
// only alive units can have threat list
if (!IsAlive() || isDying())
if (!skipAliveCheck && !IsAlive())
return false;
// totems can not have threat list
@@ -12500,7 +12501,7 @@ void Unit::AddThreat(Unit* victim, float fThreat, SpellSchoolMask schoolMask, Sp
void Unit::DeleteThreatList()
{
if (CanHaveThreatList() && !m_ThreatManager.isThreatListEmpty())
if (CanHaveThreatList(true) && !m_ThreatManager.isThreatListEmpty())
SendClearThreatListOpcode();
m_ThreatManager.clearReferences();
}