[12209] Update mana regen to 4.x

Signed-off-by: Yaki Khadafi <elsoldollo@gmail.com>
This commit is contained in:
Yaki Khadafi 2012-09-09 21:54:56 +03:00 committed by Antz
parent 378aaa4daf
commit 832f9b1a46
9 changed files with 30 additions and 42 deletions

View file

@ -655,13 +655,10 @@ void Creature::RegenerateMana()
// Combat and any controlled creature // Combat and any controlled creature
if (isInCombat() || GetCharmerOrOwnerGuid()) 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 else
addvalue = maxValue / 3; addvalue = maxValue / 3;

View file

@ -1093,7 +1093,7 @@ uint32 GetTalentTreeRolesMask(uint32 talentTree)
{ {
TalentTreeRolesMap::const_iterator itr = sTalentTreeRolesMap.find(talentTree); TalentTreeRolesMap::const_iterator itr = sTalentTreeRolesMap.find(talentTree);
if (itr == sTalentTreeRolesMap.end()) if (itr == sTalentTreeRolesMap.end())
return NULL; return 0;
return itr->second; return itr->second;
} }

View file

@ -1326,8 +1326,7 @@ void Player::Update(uint32 update_diff, uint32 p_time)
if (isAlive()) if (isAlive())
{ {
// if no longer casting, set regen power as soon as it is up. if (!HasAuraType(SPELL_AURA_STOP_NATURAL_MANA_REGEN))
if (!IsUnderLastManaUseEffect() && !HasAuraType(SPELL_AURA_STOP_NATURAL_MANA_REGEN))
SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
if (!m_regenTimer) if (!m_regenTimer)
@ -2102,9 +2101,9 @@ void Player::Regenerate(Powers power, uint32 diff)
{ {
if (HasAuraType(SPELL_AURA_STOP_NATURAL_MANA_REGEN)) if (HasAuraType(SPELL_AURA_STOP_NATURAL_MANA_REGEN))
break; break;
bool recentCast = IsUnderLastManaUseEffect();
float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA); float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA);
if (recentCast)
if (isInCombat())
{ {
// Mangos Updates Mana in intervals of 2s, which is correct // Mangos Updates Mana in intervals of 2s, which is correct
addvalue = GetFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER) * ManaIncreaseRate * 2.00f; 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); 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 // 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); RemovePet(PET_SAVE_REAGENTS);
/* when prev line will dropped use next line /* when prev line will dropped use next line
@ -5246,6 +5248,11 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
float Player::OCTRegenMPPerSpirit() 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 level = getLevel();
uint32 pclass = getClass(); uint32 pclass = getClass();
@ -22151,6 +22158,9 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank)
if (std::vector<uint32> const* specSpells = GetTalentTreePrimarySpells(talentInfo->TalentTab)) if (std::vector<uint32> const* specSpells = GetTalentTreePrimarySpells(talentInfo->TalentTab))
for (size_t i = 0; i < specSpells->size(); ++i) for (size_t i = 0; i < specSpells->size(); ++i)
learnSpell(specSpells->at(i), false); learnSpell(specSpells->at(i), false);
// Update talent tree role-dependent mana regen
UpdateManaRegen();
} }
return true; return true;
@ -22853,6 +22863,9 @@ void Player::ActivateSpec(uint8 specNum)
if (m_talentsPrimaryTree[m_activeSpec] && !sTalentTabStore.LookupEntry(m_talentsPrimaryTree[m_activeSpec])) if (m_talentsPrimaryTree[m_activeSpec] && !sTalentTabStore.LookupEntry(m_talentsPrimaryTree[m_activeSpec]))
resetTalents(true); resetTalents(true);
// Update talent tree role-dependent mana regen
UpdateManaRegen();
} }
void Player::UpdateSpecCount(uint8 count) void Player::UpdateSpecCount(uint8 count)

View file

@ -4784,10 +4784,6 @@ void Spell::TakePower()
} }
m_caster->ModifyPower(powerType, -(int32)m_powerCost); 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) SpellCastResult Spell::CheckOrTakeRunePower(bool take)

View file

@ -8752,7 +8752,7 @@ void Aura::HandleAuraStopNaturalManaRegen(bool apply, bool Real)
if (!Real) if (!Real)
return; 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) void Aura::HandleAuraMastery(bool apply, bool Real)

View file

@ -752,14 +752,15 @@ void Player::ApplyHealthRegenBonus(int32 amount, bool apply)
void Player::UpdateManaRegen() void Player::UpdateManaRegen()
{ {
float Intellect = GetStat(STAT_INTELLECT); float base_regen = GetCreateMana() * 0.01f;
// Mana regen from spirit and intellect // 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 // 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 // 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 // Get bonus from SPELL_AURA_MOD_MANA_REGEN_FROM_STAT aura
AuraList const& regenAura = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_FROM_STAT); 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); int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT);
if (modManaRegenInterrupt > 100) if (modManaRegenInterrupt > 100)
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() void Player::UpdateMasteryAuras()

View file

@ -535,7 +535,6 @@ Unit::Unit() :
m_baseSpellCritChance = 5; m_baseSpellCritChance = 5;
m_CombatTimer = 0; m_CombatTimer = 0;
m_lastManaUseTimer = 0;
// m_victimThreat = 0.0f; // m_victimThreat = 0.0f;
for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) for (int i = 0; i < MAX_SPELL_SCHOOL; ++i)
@ -595,14 +594,6 @@ void Unit::Update(uint32 update_diff, uint32 p_time)
CleanupDeletedAuras(); CleanupDeletedAuras();
if (m_lastManaUseTimer)
{
if (update_diff >= m_lastManaUseTimer)
m_lastManaUseTimer = 0;
else
m_lastManaUseTimer -= update_diff;
}
if (CanHaveThreatList()) if (CanHaveThreatList())
getThreatManager().UpdateForClient(update_diff); getThreatManager().UpdateForClient(update_diff);

View file

@ -1857,15 +1857,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
return SPELL_AURA_PROC_CANT_TRIGGER; 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; } uint32 GetRegenTimer() const { return m_regenTimer; }
void SetContestedPvP(Player* attackedPlayer = NULL); void SetContestedPvP(Player* attackedPlayer = NULL);
@ -2010,7 +2001,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
uint32 m_reactiveTimer[MAX_REACTIVE]; uint32 m_reactiveTimer[MAX_REACTIVE];
uint32 m_regenTimer; uint32 m_regenTimer;
uint32 m_lastManaUseTimer;
VehicleInfo* m_vehicleInfo; VehicleInfo* m_vehicleInfo;
void DisableSpline(); void DisableSpline();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12208" #define REVISION_NR "12209"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__