Core/Spells: Fixed deaths at stat auras removal when at low health (less than 1 percent)
This commit is contained in:
@@ -1265,13 +1265,13 @@ class Unit : public WorldObject
|
|||||||
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
|
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
|
||||||
uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
|
uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
|
||||||
|
|
||||||
inline bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
|
bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
|
||||||
inline bool HealthBelowPct(int32 pct) const { return GetHealth() * (uint64)100 < GetMaxHealth() * (uint64)pct; }
|
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; }
|
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; }
|
bool HealthAbovePct(int32 pct) const { return GetHealth() * (uint64)100 > GetMaxHealth() * (uint64)pct; }
|
||||||
inline float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
|
float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
|
||||||
inline uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePctN(GetMaxHealth(), pct); }
|
uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePctN(GetMaxHealth(), pct); }
|
||||||
inline uint32 CountPctFromCurHealth(int32 pct) const { return CalculatePctN(GetHealth(), pct); }
|
uint32 CountPctFromCurHealth(int32 pct) const { return CalculatePctN(GetHealth(), pct); }
|
||||||
|
|
||||||
void SetHealth(uint32 val);
|
void SetHealth(uint32 val);
|
||||||
void SetMaxHealth(uint32 val);
|
void SetMaxHealth(uint32 val);
|
||||||
|
|||||||
@@ -4906,9 +4906,9 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const * aurApp, uint8
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//save current and max HP before applying aura
|
// save current health state
|
||||||
uint32 curHPValue = target->GetHealth();
|
float healthPct = target->GetHealthPct();
|
||||||
uint32 maxHPValue = target->GetMaxHealth();
|
bool alive = target->isAlive();
|
||||||
|
|
||||||
for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
|
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);
|
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(GetAmount()), apply);
|
||||||
if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->isPet())
|
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)
|
//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))
|
if (GetMiscValue() == STAT_STAMINA && (m_spellProto->Attributes & SPELL_ATTR0_UNK4))
|
||||||
{
|
target->SetHealth(std::max<uint32>(uint32(healthPct * target->GetMaxHealth() * 0.01f), (alive ? 1 : 0)));
|
||||||
uint32 newHPValue = target->CountPctFromMaxHealth(int32(100.0f * curHPValue / maxHPValue));
|
|
||||||
target->SetHealth(newHPValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuraEffect::HandleAuraModResistenceOfStatPercent(AuraApplication const * aurApp, uint8 mode, bool /*apply*/) const
|
void AuraEffect::HandleAuraModResistenceOfStatPercent(AuraApplication const * aurApp, uint8 mode, bool /*apply*/) const
|
||||||
|
|||||||
Reference in New Issue
Block a user