fix(Core/Spells): Fixed implementation of CAST_FLAG_POWER_LEFT_SELF flag. (#10908)
This commit is contained in:
@@ -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)
|
void Unit::EnergizeBySpell(Unit* victim, uint32 spellID, uint32 damage, Powers powerType)
|
||||||
{
|
{
|
||||||
SendEnergizeSpellLog(victim, spellID, damage, powerType);
|
victim->ModifyPower(powerType, damage, false);
|
||||||
// needs to be called after sending spell log
|
|
||||||
victim->ModifyPower(powerType, damage);
|
|
||||||
|
|
||||||
if (powerType != POWER_HAPPINESS)
|
if (powerType != POWER_HAPPINESS)
|
||||||
{
|
{
|
||||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);
|
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID);
|
||||||
victim->getHostileRefMgr().threatAssist(this, float(damage) * 0.5f, spellInfo);
|
victim->getHostileRefMgr().threatAssist(this, float(damage) * 0.5f, spellInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendEnergizeSpellLog(victim, spellID, damage, powerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Unit::SpellPctDamageModsDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype)
|
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
|
// 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)
|
if (dVal == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -13434,7 +13434,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
|
|||||||
int32 val = dVal + curPower;
|
int32 val = dVal + curPower;
|
||||||
if (val <= 0)
|
if (val <= 0)
|
||||||
{
|
{
|
||||||
SetPower(power, 0);
|
SetPower(power, 0, withPowerUpdate);
|
||||||
return -curPower;
|
return -curPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13442,12 +13442,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
|
|||||||
|
|
||||||
if (val < maxPower)
|
if (val < maxPower)
|
||||||
{
|
{
|
||||||
SetPower(power, val);
|
SetPower(power, val, withPowerUpdate);
|
||||||
gain = val - curPower;
|
gain = val - curPower;
|
||||||
}
|
}
|
||||||
else if (curPower != maxPower)
|
else if (curPower != maxPower)
|
||||||
{
|
{
|
||||||
SetPower(power, maxPower);
|
SetPower(power, maxPower, withPowerUpdate);
|
||||||
gain = maxPower - curPower;
|
gain = maxPower - curPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14814,7 +14814,7 @@ void Unit::SetMaxHealth(uint32 val)
|
|||||||
SetHealth(val);
|
SetHealth(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::SetPower(Powers power, uint32 val)
|
void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/)
|
||||||
{
|
{
|
||||||
if (GetPower(power) == val)
|
if (GetPower(power) == val)
|
||||||
return;
|
return;
|
||||||
@@ -14825,11 +14825,14 @@ void Unit::SetPower(Powers power, uint32 val)
|
|||||||
|
|
||||||
SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
|
SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + power, val);
|
||||||
|
|
||||||
WorldPacket data(SMSG_POWER_UPDATE);
|
if (withPowerUpdate)
|
||||||
data << GetPackGUID();
|
{
|
||||||
data << uint8(power);
|
WorldPacket data(SMSG_POWER_UPDATE);
|
||||||
data << uint32(val);
|
data << GetPackGUID();
|
||||||
SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER);
|
data << uint8(power);
|
||||||
|
data << uint32(val);
|
||||||
|
SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER);
|
||||||
|
}
|
||||||
|
|
||||||
// group update
|
// group update
|
||||||
if (GetTypeId() == TYPEID_PLAYER)
|
if (GetTypeId() == TYPEID_PLAYER)
|
||||||
|
|||||||
@@ -1416,10 +1416,10 @@ public:
|
|||||||
void setPowerType(Powers power);
|
void setPowerType(Powers power);
|
||||||
[[nodiscard]] uint32 GetPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_POWER1) + 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); }
|
[[nodiscard]] uint32 GetMaxPower(Powers power) const { return GetUInt32Value(static_cast<uint16>(UNIT_FIELD_MAXPOWER1) + power); }
|
||||||
void SetPower(Powers power, uint32 val);
|
void SetPower(Powers power, uint32 val, bool withPowerUpdate = true);
|
||||||
void SetMaxPower(Powers power, uint32 val);
|
void SetMaxPower(Powers power, uint32 val);
|
||||||
// returns the change in power
|
// returns the change in power
|
||||||
int32 ModifyPower(Powers power, int32 val);
|
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true);
|
||||||
int32 ModifyPowerPct(Powers power, float pct, bool apply = true);
|
int32 ModifyPowerPct(Powers power, float pct, bool apply = true);
|
||||||
|
|
||||||
[[nodiscard]] uint32 GetAttackTime(WeaponAttackType att) const
|
[[nodiscard]] uint32 GetAttackTime(WeaponAttackType att) const
|
||||||
|
|||||||
@@ -4461,10 +4461,12 @@ void Spell::SendSpellStart()
|
|||||||
|
|
||||||
if (m_spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA))
|
if (m_spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA))
|
||||||
castFlags |= CAST_FLAG_PROJECTILE;
|
castFlags |= CAST_FLAG_PROJECTILE;
|
||||||
if ((m_caster->GetTypeId() == TYPEID_PLAYER ||
|
|
||||||
(m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet()))
|
if ((m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet()))
|
||||||
&& m_spellInfo->PowerType != POWER_HEALTH)
|
&& m_spellInfo->PowerType != POWER_HEALTH && m_powerCost != 0)
|
||||||
|
{
|
||||||
castFlags |= CAST_FLAG_POWER_LEFT_SELF;
|
castFlags |= CAST_FLAG_POWER_LEFT_SELF;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_spellInfo->RuneCostID && m_spellInfo->PowerType == POWER_RUNE)
|
if (m_spellInfo->RuneCostID && m_spellInfo->PowerType == POWER_RUNE)
|
||||||
castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it
|
castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it
|
||||||
@@ -4518,10 +4520,11 @@ void Spell::SendSpellGo()
|
|||||||
if (m_spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA))
|
if (m_spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA))
|
||||||
castFlags |= CAST_FLAG_PROJECTILE; // arrows/bullets visual
|
castFlags |= CAST_FLAG_PROJECTILE; // arrows/bullets visual
|
||||||
|
|
||||||
if ((m_caster->GetTypeId() == TYPEID_PLAYER ||
|
if ((m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet()))
|
||||||
(m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet()))
|
&& m_spellInfo->PowerType != POWER_HEALTH && m_powerCost != 0) // should only be sent to self, but the current messaging doesn't make that possible
|
||||||
&& m_spellInfo->PowerType != POWER_HEALTH)
|
{
|
||||||
castFlags |= CAST_FLAG_POWER_LEFT_SELF; // should only be sent to self, but the current messaging doesn't make that possible
|
castFlags |= CAST_FLAG_POWER_LEFT_SELF;
|
||||||
|
}
|
||||||
|
|
||||||
if ((m_caster->GetTypeId() == TYPEID_PLAYER)
|
if ((m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||||
&& (m_caster->getClass() == CLASS_DEATH_KNIGHT)
|
&& (m_caster->getClass() == CLASS_DEATH_KNIGHT)
|
||||||
@@ -5052,7 +5055,9 @@ void Spell::TakePower()
|
|||||||
|
|
||||||
// Set the five second timer
|
// Set the five second timer
|
||||||
if (PowerType == POWER_MANA && m_powerCost > 0)
|
if (PowerType == POWER_MANA && m_powerCost > 0)
|
||||||
|
{
|
||||||
m_caster->SetLastManaUse(GameTime::GetGameTimeMS().count());
|
m_caster->SetLastManaUse(GameTime::GetGameTimeMS().count());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::TakeAmmo()
|
void Spell::TakeAmmo()
|
||||||
|
|||||||
Reference in New Issue
Block a user