mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
fix(Core/Players): Fixed sending power regen update to nearby players. (#14043)
This commit is contained in:
@@ -15449,16 +15449,28 @@ void Unit::SetMaxHealth(uint32 val)
|
||||
SetHealth(val);
|
||||
}
|
||||
|
||||
void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/)
|
||||
void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/, bool fromRegenerate /* = false */)
|
||||
{
|
||||
if (GetPower(power) == val)
|
||||
if (!fromRegenerate && GetPower(power) == val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 maxPower = GetMaxPower(power);
|
||||
if (maxPower < val)
|
||||
{
|
||||
val = maxPower;
|
||||
}
|
||||
|
||||
SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
|
||||
if (fromRegenerate)
|
||||
{
|
||||
UpdateUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
|
||||
}
|
||||
|
||||
if (withPowerUpdate)
|
||||
{
|
||||
@@ -15474,10 +15486,14 @@ void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/)
|
||||
{
|
||||
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())
|
||||
{
|
||||
@@ -15485,12 +15501,16 @@ void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/)
|
||||
{
|
||||
Unit* owner = GetOwner();
|
||||
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1460,7 +1460,7 @@ public:
|
||||
void setPowerType(Powers power);
|
||||
[[nodiscard]] uint32 GetPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power); }
|
||||
[[nodiscard]] uint32 GetMaxPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_MAXPOWER1) + power); }
|
||||
void SetPower(Powers power, uint32 val, bool withPowerUpdate = true);
|
||||
void SetPower(Powers power, uint32 val, bool withPowerUpdate = true, bool fromRegenerate = false);
|
||||
void SetMaxPower(Powers power, uint32 val);
|
||||
// returns the change in power
|
||||
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true);
|
||||
|
||||
Reference in New Issue
Block a user