diff options
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 9 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 | ||||
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 37 |
3 files changed, 11 insertions, 36 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 4c4cf20e1f2..77d71e21f00 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -8217,15 +8217,6 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) return gain; } -// returns negative amount on power reduction -int32 Unit::ModifyPowerPct(Powers power, float pct, bool apply) -{ - float amount = (float)GetMaxPower(power); - ApplyPercentModFloatVar(amount, pct, apply); - - return ModifyPower(power, (int32)amount - GetMaxPower(power)); -} - bool Unit::IsAlwaysVisibleFor(WorldObject const* seer) const { if (WorldObject::IsAlwaysVisibleFor(seer)) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index f156d3bfaab..26e8b03ef3e 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1055,7 +1055,6 @@ class TC_GAME_API Unit : public WorldObject void SetMaxPower(Powers power, int32 val); // returns the change in power int32 ModifyPower(Powers power, int32 val); - int32 ModifyPowerPct(Powers power, float pct, bool apply = true); uint32 GetBaseAttackTime(WeaponAttackType att) const; void SetBaseAttackTime(WeaponAttackType att, uint32 val); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 66fbb32fd2a..ab73f37f8ea 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -3706,15 +3706,7 @@ void AuraEffect::HandleAuraModIncreaseEnergy(AuraApplication const* aurApp, uint return; Unit* target = aurApp->GetTarget(); - Powers powerType = Powers(GetMiscValue()); - // do not check power type, we can always modify the maximum - // as the client will not see any difference - // also, placing conditions that may change during the aura duration - // inside effect handlers is not a good idea - //if (int32(powerType) != GetMiscValue()) - // return; - UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); target->HandleStatModifier(unitMod, TOTAL_VALUE, float(GetAmount()), apply); @@ -3728,26 +3720,19 @@ void AuraEffect::HandleAuraModIncreaseEnergyPercent(AuraApplication const* aurAp Unit* target = aurApp->GetTarget(); Powers powerType = Powers(GetMiscValue()); - // do not check power type, we can always modify the maximum - // as the client will not see any difference - // also, placing conditions that may change during the aura duration - // inside effect handlers is not a good idea - //if (int32(powerType) != GetMiscValue()) - // return; - UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); - float amount = float(GetAmount()); - if (apply) - { - target->HandleStatModifier(unitMod, TOTAL_PCT, amount, apply); - target->ModifyPowerPct(powerType, amount, apply); - } - else - { - target->ModifyPowerPct(powerType, amount, apply); - target->HandleStatModifier(unitMod, TOTAL_PCT, amount, apply); - } + // Save old powers for further calculation + int32 oldPower = int32(target->GetPower(powerType)); + int32 oldMaxPower = int32(target->GetMaxPower(powerType)); + + // Handle aura effect for max power + target->HandleStatModifier(unitMod, TOTAL_PCT, float(GetAmount()), apply); + + // Calculate the current power change + int32 change = target->GetMaxPower(powerType) - oldMaxPower; + change = (oldPower + change) - target->GetPower(powerType); + target->ModifyPower(powerType, change); } void AuraEffect::HandleAuraModIncreaseHealthPercent(AuraApplication const* aurApp, uint8 mode, bool apply) const |
