diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 28 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 13 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 4 |
7 files changed, 31 insertions, 44 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 5b923fc5a3f..237e19149d8 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -776,8 +776,8 @@ void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags, Playe *data << uint8((1 << MAX_RUNES) - 1); *data << uint8(player->GetRunesState()); *data << uint32(MAX_RUNES); - for (uint32 i = 0; i < MAX_RUNES; ++i) - *data << uint8(player->GetRuneCooldown(i) * uint32(255) / uint32(RUNE_BASE_COOLDOWN)); + for (uint8 i = 0; i < MAX_RUNES; ++i) + *data << uint8((1.0f - player->GetRuneCooldown(i)) * uint32(255)); } if (HasActionButtons) { diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 13d91494f1f..4704ba291db 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1631,21 +1631,23 @@ void Player::RegenerateAll() for (uint8 i = 0; i < MAX_RUNES; i += 2) { uint8 runeToRegen = i; - uint32 runeCooldown = GetRuneCooldown(i); - uint32 secondRuneCd = GetRuneCooldown(i + 1); + float runeCooldown = GetRuneCooldown(i); + float secondRuneCd = GetRuneCooldown(i + 1); - //float cdmod = m_unitData->PowerRegenFlatModifier[GetPowerIndex(GetPowerTypeForBaseRune(runeToRegen))] * 10.0f; // Regenerate second rune of the same type only after first rune is off the cooldown - if (secondRuneCd && (runeCooldown > secondRuneCd || !runeCooldown)) + if (G3D::fuzzyNe(secondRuneCd, 0.0f) && (runeCooldown > secondRuneCd || G3D::fuzzyEq(runeCooldown, 0.0f))) { runeToRegen = i + 1; runeCooldown = secondRuneCd; } - if (runeCooldown > m_regenTimer) - SetRuneCooldown(runeToRegen, runeCooldown - m_regenTimer); + PowerTypeEntry const* powerTypeEntry = sDB2Manager.GetPowerTypeEntry(POWER_RUNES); + + float cdDiff = (powerTypeEntry->RegenPeace + m_unitData->PowerRegenFlatModifier[GetPowerIndex(GetPowerTypeForBaseRune(runeToRegen))]) * 0.001f * m_regenTimer; + if (runeCooldown > cdDiff) + SetRuneCooldown(runeToRegen, runeCooldown - cdDiff); else - SetRuneCooldown(runeToRegen, 0); + SetRuneCooldown(runeToRegen, 0.0f); } } @@ -1674,7 +1676,6 @@ void Player::Regenerate(Powers power) int32 curValue = GetPower(power); - // TODO: updating haste should update UnitData::PowerRegenFlatModifier for certain power types PowerTypeEntry const* powerType = sDB2Manager.GetPowerTypeEntry(power); if (!powerType) return; @@ -25656,7 +25657,7 @@ void Player::ResyncRunes() const data.Runes.Cooldowns.reserve(MAX_RUNES); for (uint8 i = 0; i < MAX_RUNES; ++i) - data.Runes.Cooldowns.push_back(uint8(GetRuneCooldown(i) * uint32(255) / uint32(RUNE_BASE_COOLDOWN))); + data.Runes.Cooldowns.push_back((1.0f - GetRuneCooldown(i)) * uint32(255)); SendDirectMessage(data.Write()); } @@ -25692,14 +25693,11 @@ void Player::InitRunes() { SetBaseRune(i, runeSlotTypes[i]); // init base types SetCurrentRune(i, runeSlotTypes[i]); // init current types - SetRuneCooldown(i, 0); // reset cooldowns + SetRuneCooldown(i, 0.0f); // reset cooldowns SetRuneConvertAura(i, nullptr, SPELL_AURA_NONE, nullptr); m_runes->SetRuneState(i); } - for (uint8 i = 0; i < MAX_RUNES; ++i) - SetRuneCooldown(i, 0); // reset cooldowns - for (Powers rune : { POWER_RUNE_BLOOD, POWER_RUNE_FROST, POWER_RUNE_UNHOLY }) { int32 powerIndex = GetPowerIndex(rune); @@ -25726,7 +25724,7 @@ Powers Player::GetPowerTypeForBaseRune(uint8 index) const bool Player::IsBaseRuneSlotsOnCooldown(RuneType runeType) const { for (uint8 i = 0; i < MAX_RUNES; ++i) - if (GetBaseRune(i) == runeType && GetRuneCooldown(i) == 0) + if (GetBaseRune(i) == runeType && G3D::fuzzyEq(GetRuneCooldown(i), 0.0f)) return false; return true; @@ -25745,7 +25743,7 @@ void Player::AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const ConvertRune(index, newType); } -void Player::SetRuneCooldown(uint8 index, uint32 cooldown) +void Player::SetRuneCooldown(uint8 index, float cooldown) { m_runes->_Runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index aede357aefb..e3a388fa47c 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -398,11 +398,8 @@ struct Areas constexpr uint8 MAX_RUNES = 6; -enum RuneCooldowns -{ - RUNE_BASE_COOLDOWN = 10000, - RUNE_MISS_COOLDOWN = 1500 // cooldown applied on runes when the spell misses -}; +constexpr float RUNE_BASE_COOLDOWN = 1.0f; +constexpr float RUNE_MISS_COOLDOWN = 0.15f; // cooldown applied on runes when the spell misses enum class RuneType : uint8 { @@ -417,7 +414,7 @@ struct RuneInfo { RuneType BaseRune; RuneType CurrentRune; - uint32 Cooldown; + float Cooldown; AuraEffect const* ConvertAura; AuraType ConvertAuraType; SpellInfo const* ConvertAuraInfo; @@ -2657,7 +2654,7 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player> RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->_Runes[index].BaseRune); } RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->_Runes[index].CurrentRune); } Powers GetPowerTypeForBaseRune(uint8 index) const; - uint32 GetRuneCooldown(uint8 index) const { return m_runes->_Runes[index].Cooldown; } + float GetRuneCooldown(uint8 index) const { return m_runes->_Runes[index].Cooldown; } bool IsBaseRuneSlotsOnCooldown(RuneType runeType) const; RuneType GetLastUsedRune() { return m_runes->LastUsedRune; } uint8 GetLastUsedRuneMask() { return m_runes->LastUsedRuneMask; } @@ -2668,7 +2665,7 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player> void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->_Runes[index].CurrentRune = currentRune; } void SetRuneConvertAura(uint8 index, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo); void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo); - void SetRuneCooldown(uint8 index, uint32 cooldown); + void SetRuneCooldown(uint8 index, float cooldown); void RemoveRunesByAuraEffect(AuraEffect const* aura); void RestoreBaseRune(uint8 index); void ConvertRune(uint8 index, RuneType newType); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index bf3b0cb4778..f051842bc79 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6667,9 +6667,9 @@ void Unit::EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damag int32 runesToEnergize = damage; for (uint32 i = 0; i < MAX_RUNES && runesToEnergize > 0; ++i) { - if (player->GetPowerTypeForBaseRune(i) == powerType && player->GetRuneCooldown(i)) + if (player->GetPowerTypeForBaseRune(i) == powerType && G3D::fuzzyNe(player->GetRuneCooldown(i), 0.0f)) { - player->SetRuneCooldown(i, 0); + player->SetRuneCooldown(i, 0.0f); --runesToEnergize; } } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 805c5c9ffa3..ae121c44628 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -6412,7 +6412,7 @@ void AuraEffect::HandleConvertRune(AuraApplication const* aurApp, uint8 mode, bo if (RuneType(GetMiscValue()) != playerTarget->GetCurrentRune(i)) continue; - if (!playerTarget->GetRuneCooldown(i)) + if (G3D::fuzzyEq(playerTarget->GetRuneCooldown(i), 0.0f)) { playerTarget->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this, GetAuraType(), GetSpellInfo()); --runesToConvert; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 370acf14178..5fe1f4a00d1 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4776,11 +4776,7 @@ void Spell::SendSpellStart() castData.RemainingRunes->Start = m_runesState; // runes state before castData.RemainingRunes->Count = player->GetRunesState(); // runes state after for (uint8 i = 0; i < MAX_RUNES; ++i) - { - // float casts ensure the division is performed on floats as we need float result - float baseCd = float(RUNE_BASE_COOLDOWN); - castData.RemainingRunes->Cooldowns.push_back((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed - } + castData.RemainingRunes->Cooldowns.push_back((1.0f - player->GetRuneCooldown(i)) * uint32(255)); // rune cooldown passed } else { @@ -4882,11 +4878,7 @@ void Spell::SendSpellGo() castData.RemainingRunes->Start = m_runesState; // runes state before castData.RemainingRunes->Count = player->GetRunesState(); // runes state after for (uint8 i = 0; i < MAX_RUNES; ++i) - { - // float casts ensure the division is performed on floats as we need float result - float baseCd = float(RUNE_BASE_COOLDOWN); - castData.RemainingRunes->Cooldowns.push_back((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed - } + castData.RemainingRunes->Cooldowns.push_back((1.0f - player->GetRuneCooldown(i)) * uint32(255)); // rune cooldown passed } if (castFlags & CAST_FLAG_ADJUST_MISSILE) @@ -5514,7 +5506,7 @@ SpellCastResult Spell::CheckRuneCost() const for (uint32 i = 0; i < MAX_RUNES; ++i) { RuneType rune = player->GetCurrentRune(i); - if ((player->GetRuneCooldown(i) == 0) && (runeCost[AsUnderlyingType(rune)] > 0)) + if (G3D::fuzzyEq(player->GetRuneCooldown(i), 0.0f) && (runeCost[AsUnderlyingType(rune)] > 0)) runeCost[AsUnderlyingType(rune)]--; } @@ -5568,7 +5560,7 @@ void Spell::TakeRunePower(bool didHit) RuneType rune = player->GetCurrentRune(i); if (!player->GetRuneCooldown(i) && runeCost[AsUnderlyingType(rune)] > 0) { - player->SetRuneCooldown(i, didHit ? uint32(RUNE_BASE_COOLDOWN) : uint32(RUNE_MISS_COOLDOWN)); + player->SetRuneCooldown(i, didHit ? RUNE_BASE_COOLDOWN : RUNE_MISS_COOLDOWN); player->SetLastUsedRune(rune); player->SetLastUsedRuneIndex(i); --runeCost[AsUnderlyingType(rune)]; @@ -5583,9 +5575,9 @@ void Spell::TakeRunePower(bool didHit) for (uint8 i = 0; i < MAX_RUNES; ++i) { RuneType rune = player->GetCurrentRune(i); - if (!player->GetRuneCooldown(i) && rune == RuneType::Death) + if (G3D::fuzzyEq(player->GetRuneCooldown(i), 0.0f) && rune == RuneType::Death) { - player->SetRuneCooldown(i, didHit ? uint32(RUNE_BASE_COOLDOWN) : uint32(RUNE_MISS_COOLDOWN)); + player->SetRuneCooldown(i, didHit ? RUNE_BASE_COOLDOWN : RUNE_MISS_COOLDOWN); player->SetLastUsedRune(rune); player->SetLastUsedRuneIndex(i); runeCost[AsUnderlyingType(rune)]--; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 94be6998143..7fff92db04b 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -5975,9 +5975,9 @@ void Spell::EffectActivateRune() for (uint32 i = 0; i < MAX_RUNES && count > 0; ++i) { - if ((1 << AsUnderlyingType(player->GetCurrentRune(i))) & miscValue && player->GetRuneCooldown(i)) + if ((1 << AsUnderlyingType(player->GetCurrentRune(i))) & miscValue && G3D::fuzzyNe(player->GetRuneCooldown(i), 0.0f)) { - player->SetRuneCooldown(i, 0); + player->SetRuneCooldown(i, 0.0f); --count; } } |