Core/Player: fixed logic for determining fully depleted runes - these are runes at max cooldown that hasn't started recovering yet

This commit is contained in:
Ovahlord
2024-12-20 18:22:08 +01:00
parent a5d4a0c9d7
commit 2087f75871
4 changed files with 29 additions and 10 deletions

View File

@@ -25306,13 +25306,26 @@ Powers Player::GetPowerTypeForBaseRune(uint8 index) const
}
}
bool Player::IsRuneFullyDepleted(RuneType runeType) const
bool Player::IsRuneFullyDepleted(uint8 index) const
{
for (uint8 i = 0; i < MAX_RUNES; ++i)
if (GetBaseRune(i) == runeType && G3D::fuzzyEq(GetRuneCooldown(i), 0.0f))
return false;
return G3D::fuzzyEq(GetRuneCooldown(index), RUNE_BASE_COOLDOWN);
}
return true;
bool Player::HasFullyDepletedRune(RuneType runeType) const
{
if (!m_runes)
return false;
for (uint8 i = 0; i < MAX_RUNES; ++i)
{
if (GetBaseRune(i) != runeType)
continue;
if (IsRuneFullyDepleted(i))
return true;
}
return false;
}
void Player::SetRuneConvertAura(uint8 index, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo)

View File

@@ -412,6 +412,8 @@ struct RuneInfo
AuraEffect const* ConvertAura;
AuraType ConvertAuraType;
SpellInfo const* ConvertAuraInfo;
bool IsFullyDepleted() const;
};
struct Runes
@@ -2604,12 +2606,13 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->_Runes[index].CurrentRune); }
Powers GetPowerTypeForBaseRune(uint8 index) const;
float GetRuneCooldown(uint8 index) const { return m_runes->_Runes[index].Cooldown; }
bool IsRuneFullyDepleted(uint8 index) const;
/// <summary>
/// Iterates over all player runes and checks if all base runes of the specified type are on cooldown.
/// Checks if there is a fully depleted rune. A rune is considered fully depleted when it's on cooldown and isn't recovering yet ('waiting' for another rune to finish regenerating)
/// </summary>
/// <param name="runeType">The kind of base rune that is being checked (Blood, Unholy, Frost). Death Runes are no base rune and can't be checked with this method. Use the underlying base rune instead.</param>
/// <returns>true when all base runes of the specified type are on cooldown</returns>
bool IsRuneFullyDepleted(RuneType runeType) const;
/// <returns>true when there is a fully depleted rune</returns>
bool HasFullyDepletedRune(RuneType runeType) const;
RuneType GetLastUsedRune() { return m_runes->LastUsedRune; }
uint8 GetLastUsedRuneMask() { return m_runes->LastUsedRuneMask; }
void ClearLastUsedRuneMask() { m_runes->LastUsedRuneMask = 0; }

View File

@@ -5946,7 +5946,10 @@ void Spell::EffectActivateRune()
for (uint32 i = 0; i < MAX_RUNES && count > 0; ++i)
{
// We will check for base and current rune because some spell effects also activate Death Runes while specifying Blood Runes in their misc value
if ((player->GetBaseRune(i) == runeType || player->GetCurrentRune(i) == runeType) && G3D::fuzzyNe(player->GetRuneCooldown(i), 0.0f))
if (player->GetBaseRune(i) != runeType && player->GetCurrentRune(i) != runeType)
continue;
if (player->IsRuneFullyDepleted(i))
{
player->SetRuneCooldown(i, 0.0f);
--count;

View File

@@ -128,7 +128,7 @@ class spell_dk_runic_empowerment : public AuraScript
for (RuneType runeType : { RuneType::Blood, RuneType::Unholy, RuneType::Frost })
{
if (player->IsRuneFullyDepleted(runeType))
if (player->HasFullyDepletedRune(runeType))
{
switch (runeType)
{