diff options
| author | Shauren <shauren.trinity@gmail.com> | 2011-05-11 12:08:08 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2011-05-11 12:08:08 +0200 |
| commit | 572e8f26daa22e321433e0073a133473a12016bd (patch) | |
| tree | fadf655755d31f2468db8edbe1d374454b586b21 /src | |
| parent | def32681e543409b4a951a5f52b50c0747bf4d03 (diff) | |
Core/Spells: Fixed deaths at stat auras removal when at low health (less than 1 percent)
Diffstat (limited to 'src')
| -rwxr-xr-x | src/server/game/Entities/Unit/Unit.h | 14 | ||||
| -rwxr-xr-x | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 17 |
2 files changed, 14 insertions, 17 deletions
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 6502203a83a..da01a11e2e3 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -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); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index b65f8700ddd..26597d693b5 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -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 @@ -5931,7 +5928,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo { if (!target || target->GetTypeId() != TYPEID_PLAYER || aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) return; - + if (target->GetMap()->IsBattleground()) target->ToPlayer()->LeaveBattleground(); break; |
