diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index b275cd77b..6bde809db 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -655,13 +655,10 @@ void Creature::RegenerateMana() // Combat and any controlled creature if (isInCombat() || GetCharmerOrOwnerGuid()) { - if (!IsUnderLastManaUseEffect()) - { - float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA); - float Spirit = GetStat(STAT_SPIRIT); + float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA); + float Spirit = GetStat(STAT_SPIRIT); - addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate); - } + addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate); } else addvalue = maxValue / 3; diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index cc5f9c34e..51f51276c 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -1093,7 +1093,7 @@ uint32 GetTalentTreeRolesMask(uint32 talentTree) { TalentTreeRolesMap::const_iterator itr = sTalentTreeRolesMap.find(talentTree); if (itr == sTalentTreeRolesMap.end()) - return NULL; + return 0; return itr->second; } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 9045bdc09..92e1c1f8c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1326,8 +1326,7 @@ void Player::Update(uint32 update_diff, uint32 p_time) if (isAlive()) { - // if no longer casting, set regen power as soon as it is up. - if (!IsUnderLastManaUseEffect() && !HasAuraType(SPELL_AURA_STOP_NATURAL_MANA_REGEN)) + if (!HasAuraType(SPELL_AURA_STOP_NATURAL_MANA_REGEN)) SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); if (!m_regenTimer) @@ -2102,9 +2101,9 @@ void Player::Regenerate(Powers power, uint32 diff) { if (HasAuraType(SPELL_AURA_STOP_NATURAL_MANA_REGEN)) break; - bool recentCast = IsUnderLastManaUseEffect(); float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA); - if (recentCast) + + if (isInCombat()) { // Mangos Updates Mana in intervals of 2s, which is correct addvalue = GetFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER) * ManaIncreaseRate * 2.00f; @@ -3914,6 +3913,9 @@ bool Player::resetTalents(bool no_cost, bool all_specs) m_resetTalentsTime = time(NULL); } + // Update talent tree role-dependent mana regen + UpdateManaRegen(); + // FIXME: remove pet before or after unlearn spells? for now after unlearn to allow removing of talent related, pet affecting auras RemovePet(PET_SAVE_REAGENTS); /* when prev line will dropped use next line @@ -5246,6 +5248,11 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const float Player::OCTRegenMPPerSpirit() { + // Only healers have regen bonus from spirit. Others regenerate by combat regen. + uint32 rolesMask = GetTalentTreeRolesMask(m_talentsPrimaryTree[m_activeSpec]); + if ((rolesMask & TALENT_ROLE_HEALER) == 0) + return 0.0f; + uint32 level = getLevel(); uint32 pclass = getClass(); @@ -22151,6 +22158,9 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank) if (std::vector const* specSpells = GetTalentTreePrimarySpells(talentInfo->TalentTab)) for (size_t i = 0; i < specSpells->size(); ++i) learnSpell(specSpells->at(i), false); + + // Update talent tree role-dependent mana regen + UpdateManaRegen(); } return true; @@ -22853,6 +22863,9 @@ void Player::ActivateSpec(uint8 specNum) if (m_talentsPrimaryTree[m_activeSpec] && !sTalentTabStore.LookupEntry(m_talentsPrimaryTree[m_activeSpec])) resetTalents(true); + + // Update talent tree role-dependent mana regen + UpdateManaRegen(); } void Player::UpdateSpecCount(uint8 count) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 2f11dab08..f03413037 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4784,10 +4784,6 @@ void Spell::TakePower() } m_caster->ModifyPower(powerType, -(int32)m_powerCost); - - // Set the five second timer - if (powerType == POWER_MANA && m_powerCost > 0) - m_caster->SetLastManaUse(); } SpellCastResult Spell::CheckOrTakeRunePower(bool take) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 97c12f203..cc954030c 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -8752,7 +8752,7 @@ void Aura::HandleAuraStopNaturalManaRegen(bool apply, bool Real) if (!Real) return; - GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER, !apply && !GetTarget()->IsUnderLastManaUseEffect()); + GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER, !apply); } void Aura::HandleAuraMastery(bool apply, bool Real) diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 9dc4d91d6..bd1105deb 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -752,14 +752,15 @@ void Player::ApplyHealthRegenBonus(int32 amount, bool apply) void Player::UpdateManaRegen() { - float Intellect = GetStat(STAT_INTELLECT); + float base_regen = GetCreateMana() * 0.01f; + // Mana regen from spirit and intellect - float power_regen = sqrt(Intellect) * OCTRegenMPPerSpirit(); + float spirit_regen = sqrt(GetStat(STAT_INTELLECT)) * OCTRegenMPPerSpirit(); // Apply PCT bonus from SPELL_AURA_MOD_POWER_REGEN_PERCENT aura on spirit base regen - power_regen *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_POWER_REGEN_PERCENT, POWER_MANA); + spirit_regen *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_POWER_REGEN_PERCENT, POWER_MANA); // Mana regen from SPELL_AURA_MOD_POWER_REGEN aura - float power_regen_mp5 = (GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) + m_baseManaRegen) / 5.0f; + float power_regen_mp5 = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) / 5.0f; // Get bonus from SPELL_AURA_MOD_MANA_REGEN_FROM_STAT aura AuraList const& regenAura = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_FROM_STAT); @@ -773,9 +774,9 @@ void Player::UpdateManaRegen() int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); if (modManaRegenInterrupt > 100) modManaRegenInterrupt = 100; - SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, power_regen_mp5 + power_regen * modManaRegenInterrupt / 100.0f); - SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, power_regen_mp5 + power_regen); + SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, base_regen + power_regen_mp5 + spirit_regen * modManaRegenInterrupt / 100.0f); + SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, base_regen + 0.001f + power_regen_mp5 + spirit_regen); } void Player::UpdateMasteryAuras() diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index cb7fad5df..acd305faa 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -535,7 +535,6 @@ Unit::Unit() : m_baseSpellCritChance = 5; m_CombatTimer = 0; - m_lastManaUseTimer = 0; // m_victimThreat = 0.0f; for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) @@ -595,14 +594,6 @@ void Unit::Update(uint32 update_diff, uint32 p_time) CleanupDeletedAuras(); - if (m_lastManaUseTimer) - { - if (update_diff >= m_lastManaUseTimer) - m_lastManaUseTimer = 0; - else - m_lastManaUseTimer -= update_diff; - } - if (CanHaveThreatList()) getThreatManager().UpdateForClient(update_diff); diff --git a/src/game/Unit.h b/src/game/Unit.h index 586861227..a46200c31 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1857,15 +1857,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject return SPELL_AURA_PROC_CANT_TRIGGER; } - void SetLastManaUse() - { - if (GetTypeId() == TYPEID_PLAYER && !IsUnderLastManaUseEffect()) - RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); - - m_lastManaUseTimer = 5000; - } - bool IsUnderLastManaUseEffect() const { return m_lastManaUseTimer; } - uint32 GetRegenTimer() const { return m_regenTimer; } void SetContestedPvP(Player* attackedPlayer = NULL); @@ -2010,7 +2001,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 m_reactiveTimer[MAX_REACTIVE]; uint32 m_regenTimer; - uint32 m_lastManaUseTimer; VehicleInfo* m_vehicleInfo; void DisableSpline(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4868f589d..044112a18 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12208" + #define REVISION_NR "12209" #endif // __REVISION_NR_H__