Core/Spells: Fixed deaths at stat auras removal when at low health (less than 1 percent)

This commit is contained in:
Shauren
2011-05-11 12:08:08 +02:00
parent def32681e5
commit 572e8f26da
2 changed files with 14 additions and 17 deletions
+7 -7
View File
@@ -1265,13 +1265,13 @@ class Unit : public WorldObject
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
inline bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
inline bool HealthBelowPct(int32 pct) const { return GetHealth() * (uint64)100 < GetMaxHealth() * (uint64)pct; }
inline bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return (int32(GetHealth()) - damage) * (int64)100 < GetMaxHealth() * (int64)pct; }
inline bool HealthAbovePct(int32 pct) const { return GetHealth() * (uint64)100 > GetMaxHealth() * (uint64)pct; }
inline float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
inline uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePctN(GetMaxHealth(), pct); }
inline uint32 CountPctFromCurHealth(int32 pct) const { return CalculatePctN(GetHealth(), pct); }
bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
bool HealthBelowPct(int32 pct) const { return GetHealth() * (uint64)100 < GetMaxHealth() * (uint64)pct; }
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return (int32(GetHealth()) - damage) * (int64)100 < GetMaxHealth() * (int64)pct; }
bool HealthAbovePct(int32 pct) const { return GetHealth() * (uint64)100 > GetMaxHealth() * (uint64)pct; }
float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePctN(GetMaxHealth(), pct); }
uint32 CountPctFromCurHealth(int32 pct) const { return CalculatePctN(GetHealth(), pct); }
void SetHealth(uint32 val);
void SetMaxHealth(uint32 val);
@@ -4906,9 +4906,9 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const * aurApp, uint8
return;
}
//save current and max HP before applying aura
uint32 curHPValue = target->GetHealth();
uint32 maxHPValue = target->GetMaxHealth();
// save current health state
float healthPct = target->GetHealthPct();
bool alive = target->isAlive();
for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
{
@@ -4916,16 +4916,13 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const * aurApp, uint8
{
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(GetAmount()), apply);
if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->isPet())
target->ApplyStatPercentBuffMod(Stats(i), (float)GetAmount(), apply);
target->ApplyStatPercentBuffMod(Stats(i), float(GetAmount()), apply);
}
}
//recalculate current HP/MP after applying aura modifications (only for spells with SPELL_ATTR0_UNK4 0x00000010 flag)
if ((GetMiscValue() == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & SPELL_ATTR0_UNK4))
{
uint32 newHPValue = target->CountPctFromMaxHealth(int32(100.0f * curHPValue / maxHPValue));
target->SetHealth(newHPValue);
}
if (GetMiscValue() == STAT_STAMINA && (m_spellProto->Attributes & SPELL_ATTR0_UNK4))
target->SetHealth(std::max<uint32>(uint32(healthPct * target->GetMaxHealth() * 0.01f), (alive ? 1 : 0)));
}
void AuraEffect::HandleAuraModResistenceOfStatPercent(AuraApplication const * aurApp, uint8 mode, bool /*apply*/) const