mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[8477] Implemented "on demand" regeneration of power in Spell::CheckPower (limited to 500ms frequency).
Correctly set UNIT_FLAG2_REGENERATE_POWER to notify client to stop/start regen in bar. thx. also for nos4r2zod From original patch was removed usage of getMSTime() and rewrited this part. Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
parent
7a2df3c309
commit
dffa5d43bd
6 changed files with 63 additions and 32 deletions
|
|
@ -1242,7 +1242,12 @@ void Player::Update( uint32 p_time )
|
|||
|
||||
if (isAlive())
|
||||
{
|
||||
RegenerateAll();
|
||||
// if no longer casting, set regen power as soon as it is up.
|
||||
if (!IsUnderLastManaUseEffect())
|
||||
SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
|
||||
|
||||
if (!m_regenTimer)
|
||||
RegenerateAll();
|
||||
}
|
||||
|
||||
if (m_deathState == JUST_DIED)
|
||||
|
|
@ -1903,36 +1908,33 @@ void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attack
|
|||
ModifyPower(POWER_RAGE, uint32(addRage*10));
|
||||
}
|
||||
|
||||
void Player::RegenerateAll()
|
||||
void Player::RegenerateAll(uint32 diff)
|
||||
{
|
||||
if (m_regenTimer != 0)
|
||||
return;
|
||||
uint32 regenDelay = 2000;
|
||||
|
||||
// Not in combat or they have regeneration
|
||||
if( !isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) ||
|
||||
if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) ||
|
||||
HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT) || IsPolymorphed() )
|
||||
{
|
||||
RegenerateHealth();
|
||||
RegenerateHealth(diff);
|
||||
if (!isInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN))
|
||||
{
|
||||
Regenerate(POWER_RAGE);
|
||||
Regenerate(POWER_RAGE, diff);
|
||||
if(getClass() == CLASS_DEATH_KNIGHT)
|
||||
Regenerate(POWER_RUNIC_POWER);
|
||||
Regenerate(POWER_RUNIC_POWER, diff);
|
||||
}
|
||||
}
|
||||
|
||||
Regenerate( POWER_ENERGY );
|
||||
Regenerate(POWER_ENERGY, diff);
|
||||
|
||||
Regenerate( POWER_MANA );
|
||||
Regenerate(POWER_MANA, diff);
|
||||
|
||||
if(getClass() == CLASS_DEATH_KNIGHT)
|
||||
Regenerate( POWER_RUNE );
|
||||
if (getClass() == CLASS_DEATH_KNIGHT)
|
||||
Regenerate(POWER_RUNE, diff);
|
||||
|
||||
m_regenTimer = regenDelay;
|
||||
m_regenTimer = REGEN_TIME_FULL;
|
||||
}
|
||||
|
||||
void Player::Regenerate(Powers power)
|
||||
// diff contains the time in milliseconds since last regen.
|
||||
void Player::Regenerate(Powers power, uint32 diff)
|
||||
{
|
||||
uint32 curValue = GetPower(power);
|
||||
uint32 maxValue = GetMaxPower(power);
|
||||
|
|
@ -1971,8 +1973,10 @@ void Player::Regenerate(Powers power)
|
|||
case POWER_RUNE:
|
||||
{
|
||||
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
||||
if(uint8 cd = GetRuneCooldown(i)) // if we have cooldown, reduce it...
|
||||
SetRuneCooldown(i, cd - 1); // ... by 2 sec (because update is every 2 sec)
|
||||
{
|
||||
if(uint16 cd = GetRuneCooldown(i)) // if we have cooldown, reduce it...
|
||||
SetRuneCooldown(i, (cd < diff) ? 0 : cd - diff);
|
||||
}
|
||||
} break;
|
||||
case POWER_FOCUS:
|
||||
case POWER_HAPPINESS:
|
||||
|
|
@ -1990,6 +1994,9 @@ void Player::Regenerate(Powers power)
|
|||
addvalue *= ((*i)->GetModifier()->m_amount + 100) / 100.0f;
|
||||
}
|
||||
|
||||
// addvalue computed on a 2sec basis. => update to diff time
|
||||
addvalue *= float(diff) / REGEN_TIME_FULL;
|
||||
|
||||
if (power != POWER_RAGE && power != POWER_RUNIC_POWER)
|
||||
{
|
||||
curValue += uint32(addvalue);
|
||||
|
|
@ -2006,7 +2013,7 @@ void Player::Regenerate(Powers power)
|
|||
SetPower(power, curValue);
|
||||
}
|
||||
|
||||
void Player::RegenerateHealth()
|
||||
void Player::RegenerateHealth(uint32 diff)
|
||||
{
|
||||
uint32 curValue = GetHealth();
|
||||
uint32 maxValue = GetMaxHealth();
|
||||
|
|
@ -2043,6 +2050,8 @@ void Player::RegenerateHealth()
|
|||
if(addvalue < 0)
|
||||
addvalue = 0;
|
||||
|
||||
addvalue *= (float)diff / REGEN_TIME_FULL;
|
||||
|
||||
ModifyHealth(int32(addvalue));
|
||||
}
|
||||
|
||||
|
|
@ -19614,7 +19623,7 @@ void Player::ResyncRunes(uint8 count)
|
|||
for(uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
data << uint8(GetCurrentRune(i)); // rune type
|
||||
data << uint8(255 - (GetRuneCooldown(i) * 51)); // passed cooldown time (0-255)
|
||||
data << uint8(255 - ((GetRuneCooldown(i) / REGEN_TIME_FULL) * 51)); // passed cooldown time (0-255)
|
||||
}
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue