fix(Core/Spells): Fixed implementation of CAST_FLAG_POWER_LEFT_SELF flag. (#10908)

This commit is contained in:
UltraNix
2022-03-27 06:22:29 +02:00
committed by GitHub
parent a5cb274222
commit 7796cdee33
3 changed files with 30 additions and 22 deletions

View File

@@ -10724,15 +10724,15 @@ void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellID, uint32 damage, Pow
void Unit::EnergizeBySpell(Unit* victim, uint32 spellID, uint32 damage, Powers powerType)
{
SendEnergizeSpellLog(victim, spellID, damage, powerType);
// needs to be called after sending spell log
victim->ModifyPower(powerType, damage);
victim->ModifyPower(powerType, damage, false);
if (powerType != POWER_HAPPINESS)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);
victim->getHostileRefMgr().threatAssist(this, float(damage) * 0.5f, spellInfo);
}
SendEnergizeSpellLog(victim, spellID, damage, powerType);
}
float Unit::SpellPctDamageModsDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype)
@@ -13422,7 +13422,7 @@ int32 Unit::GetHealthGain(int32 dVal)
}
// returns negative amount on power reduction
int32 Unit::ModifyPower(Powers power, int32 dVal)
int32 Unit::ModifyPower(Powers power, int32 dVal, bool withPowerUpdate /*= true*/)
{
if (dVal == 0)
return 0;
@@ -13434,7 +13434,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
int32 val = dVal + curPower;
if (val <= 0)
{
SetPower(power, 0);
SetPower(power, 0, withPowerUpdate);
return -curPower;
}
@@ -13442,12 +13442,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
if (val < maxPower)
{
SetPower(power, val);
SetPower(power, val, withPowerUpdate);
gain = val - curPower;
}
else if (curPower != maxPower)
{
SetPower(power, maxPower);
SetPower(power, maxPower, withPowerUpdate);
gain = maxPower - curPower;
}
@@ -14814,7 +14814,7 @@ void Unit::SetMaxHealth(uint32 val)
SetHealth(val);
}
void Unit::SetPower(Powers power, uint32 val)
void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/)
{
if (GetPower(power) == val)
return;
@@ -14825,11 +14825,14 @@ void Unit::SetPower(Powers power, uint32 val)
SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
WorldPacket data(SMSG_POWER_UPDATE);
data << GetPackGUID();
data << uint8(power);
data << uint32(val);
SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER);
if (withPowerUpdate)
{
WorldPacket data(SMSG_POWER_UPDATE);
data << GetPackGUID();
data << uint8(power);
data << uint32(val);
SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER);
}
// group update
if (GetTypeId() == TYPEID_PLAYER)