mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 18:40:28 +00:00
fix(Core/Player): smooth energy regeneration with SPELL_AURA_MOD_POWER_REGEN_PERCENT mods (#22041)
Co-authored-by: r4dish <ovitnez@gmail.com>
This commit is contained in:
@@ -15618,29 +15618,23 @@ void Unit::SetMaxHealth(uint32 val)
|
||||
void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/, bool fromRegenerate /* = false */)
|
||||
{
|
||||
if (!fromRegenerate && GetPower(power) == val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 maxPower = GetMaxPower(power);
|
||||
if (maxPower < val)
|
||||
{
|
||||
val = maxPower;
|
||||
}
|
||||
|
||||
if (fromRegenerate)
|
||||
{
|
||||
UpdateUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
|
||||
UpdateUInt32Value(UNIT_FIELD_POWER1 + AsUnderlyingType(power), val);
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
|
||||
}
|
||||
SetStatInt32Value(UNIT_FIELD_POWER1 + AsUnderlyingType(power), val);
|
||||
|
||||
if (withPowerUpdate)
|
||||
{
|
||||
WorldPacket data(SMSG_POWER_UPDATE);
|
||||
WorldPacket data(SMSG_POWER_UPDATE, 8 + 1 + 4);
|
||||
data << GetPackGUID();
|
||||
data << uint8(power);
|
||||
data << uint32(val);
|
||||
@@ -15652,14 +15646,10 @@ void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/, b
|
||||
{
|
||||
Player* player = ToPlayer();
|
||||
if (getPowerType() == power && player->NeedSendSpectatorData())
|
||||
{
|
||||
ArenaSpectator::SendCommand_UInt32Value(FindMap(), GetGUID(), "CPW", power == POWER_RAGE || power == POWER_RUNIC_POWER ? val / 10 : val);
|
||||
}
|
||||
|
||||
if (player->GetGroup())
|
||||
{
|
||||
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER);
|
||||
}
|
||||
}
|
||||
else if (Pet* pet = ToCreature()->ToPet())
|
||||
{
|
||||
@@ -15667,16 +15657,12 @@ void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/, b
|
||||
{
|
||||
Unit* owner = GetOwner();
|
||||
if (owner && (owner->IsPlayer()) && owner->ToPlayer()->GetGroup())
|
||||
{
|
||||
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the pet's character sheet with happiness damage bonus
|
||||
if (pet->getPetType() == HUNTER_PET && power == POWER_HAPPINESS)
|
||||
{
|
||||
pet->UpdateDamagePhysical(BASE_ATTACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user