*Fix the fraction loss of power regen. Thanks to HiZed
--HG-- branch : trunk
This commit is contained in:
+29
-9
@@ -483,6 +483,9 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
|
|||||||
sWorld.IncreasePlayerCount();
|
sWorld.IncreasePlayerCount();
|
||||||
|
|
||||||
m_ChampioningFaction = 0;
|
m_ChampioningFaction = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < MAX_POWERS; ++i)
|
||||||
|
m_powerFraction[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player ()
|
Player::~Player ()
|
||||||
@@ -2048,11 +2051,17 @@ void Player::RegenerateAll()
|
|||||||
|
|
||||||
void Player::Regenerate(Powers power)
|
void Player::Regenerate(Powers power)
|
||||||
{
|
{
|
||||||
|
uint32 maxValue = GetMaxPower(power);
|
||||||
|
if(!maxValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint32 curValue = GetPower(power);
|
||||||
|
if(curValue == maxValue)
|
||||||
|
return;
|
||||||
|
|
||||||
// TODO: possible use of miscvalueb instead of amount
|
// TODO: possible use of miscvalueb instead of amount
|
||||||
if (HasAuraTypeWithValue(SPELL_AURA_PREVENT_REGENERATE_POWER, power))
|
if (HasAuraTypeWithValue(SPELL_AURA_PREVENT_REGENERATE_POWER, power))
|
||||||
return;
|
return;
|
||||||
uint32 curValue = GetPower(power);
|
|
||||||
uint32 maxValue = GetMaxPower(power);
|
|
||||||
|
|
||||||
float addvalue = 0.0f;
|
float addvalue = 0.0f;
|
||||||
|
|
||||||
@@ -2107,22 +2116,33 @@ void Player::Regenerate(Powers power)
|
|||||||
addvalue *= ((*i)->GetAmount() + 100) / 100.0f;
|
addvalue *= ((*i)->GetAmount() + 100) / 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addvalue += m_powerFraction[power];
|
||||||
|
uint32 integerValue = (uint32)addvalue;
|
||||||
|
|
||||||
if (power != POWER_RAGE && power != POWER_RUNIC_POWER)
|
if (power != POWER_RAGE && power != POWER_RUNIC_POWER)
|
||||||
{
|
{
|
||||||
if((addvalue-uint32(addvalue)) >= 0.50f)
|
curValue += integerValue;
|
||||||
curValue += uint32(addvalue+1);
|
|
||||||
else
|
|
||||||
curValue += uint32(addvalue);
|
|
||||||
|
|
||||||
if (curValue > maxValue)
|
if (curValue > maxValue)
|
||||||
|
{
|
||||||
curValue = maxValue;
|
curValue = maxValue;
|
||||||
|
m_powerFraction[power] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_powerFraction[power] = addvalue - integerValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(curValue <= uint32(addvalue))
|
if(curValue > integerValue)
|
||||||
curValue = 0;
|
{
|
||||||
|
curValue -= integerValue;
|
||||||
|
m_powerFraction[power] = addvalue - integerValue;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
curValue -= uint32(addvalue);
|
{
|
||||||
|
curValue = 0;
|
||||||
|
m_powerFraction[power] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(m_regenTimerCount >= 2000)
|
if(m_regenTimerCount >= 2000)
|
||||||
SetPower(power, curValue);
|
SetPower(power, curValue);
|
||||||
|
|||||||
@@ -2221,6 +2221,7 @@ Spell * m_spellModTakingSpell;
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
uint32 m_regenTimerCount;
|
uint32 m_regenTimerCount;
|
||||||
|
float m_powerFraction[MAX_POWERS];
|
||||||
uint32 m_contestedPvPTimer;
|
uint32 m_contestedPvPTimer;
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user