Fixed DK runes and runic power

This commit is contained in:
hondacrx
2017-11-13 14:12:42 -05:00
parent a5f7add4d6
commit 02535a0d47
9 changed files with 80 additions and 130 deletions
+12
View File
@@ -2942,6 +2942,18 @@ namespace Game.Entities
SetUInt32Value(UnitFields.Power + loadedPowers, 0);
SetPower(PowerType.LunarPower, 0);
// Init rune recharge
if (GetPowerIndex(PowerType.Runes) != (int)PowerType.Max)
{
int runes = GetPower(PowerType.Runes);
int maxRunes = GetMaxPower(PowerType.Runes);
uint runeCooldown = GetRuneBaseCooldown();
while (runes < maxRunes)
{
SetRuneCooldown((byte)runes, runeCooldown, false);
++runes;
}
}
Log.outDebug(LogFilter.Player, "The value of player {0} after load item and aura is: ", GetName());
+4 -7
View File
@@ -117,9 +117,6 @@ namespace Game.Entities
MultiMap<uint, uint> m_overrideSpells = new MultiMap<uint, uint>();
public Spell m_spellModTakingSpell;
uint m_oldpetspell;
// Rune type / Rune timer
uint[] m_runeGraceCooldown = new uint[PlayerConst.MaxRunes];
uint[] m_lastRuneGraceTimers = new uint[PlayerConst.MaxRunes];
//Mail
List<Mail> m_mail = new List<Mail>();
@@ -347,14 +344,14 @@ namespace Game.Entities
if (set)
{
RuneState |= (byte)(1 << index); // usable
if (id == 0)
CooldownOrder.Add(index);
if (id != 0)
CooldownOrder.RemoveAt(index);
}
else
{
RuneState &= (byte)~(1 << index); // on cooldown
if (id != 0)
CooldownOrder.Remove(id);
if (id == 0)
CooldownOrder.Add(index);
}
}
+21 -48
View File
@@ -2852,22 +2852,16 @@ namespace Game.Entities
/**********************************/
public void SetRuneCooldown(byte index, uint cooldown, bool casted = false)
{
uint gracePeriod = GetRuneTimer(index);
if (casted && IsInCombat())
{
if (gracePeriod < 0xFFFFFFFF && cooldown > 0)
{
uint lessCd = Math.Min(2500, gracePeriod);
cooldown = (cooldown > lessCd) ? (cooldown - lessCd) : 0;
SetLastRuneGraceTimer(index, lessCd);
}
SetRuneTimer(index, 0);
}
m_runes.Cooldown[index] = cooldown;
m_runes.SetRuneState(index, (cooldown == 0) ? true : false);
uint activeRunes = m_runes.Cooldown[Math.Min(GetMaxPower(PowerType.Runes), (int)PowerType.Max)];
if (activeRunes != GetPower(PowerType.Runes))
SetPower(PowerType.Runes, (int)activeRunes);
}
public byte GetRunesState()
{
return (byte)(m_runes.RuneState & ((1 << GetMaxPower(PowerType.Runes)) - 1));
}
public uint GetRuneBaseCooldown()
@@ -2894,28 +2888,15 @@ namespace Game.Entities
public void ResyncRunes()
{
ResyncRunes data = new ResyncRunes();
data.Runes.Start = 0;
int maxRunes = GetMaxPower(PowerType.Runes);
ResyncRunes data = new ResyncRunes(maxRunes);
data.Runes.Start = (byte)((1 << maxRunes) - 1);
data.Runes.Count = GetRunesState();
for (byte i = 0; i < PlayerConst.MaxRunes; ++i)
data.Runes.Cooldowns.Add((byte)(255 - (GetRuneCooldown(i) * 51)));
// calculate mask of recharging runes
uint regeneratedRunes = 0;
int regenIndex = 0;
while (regeneratedRunes < PlayerConst.MaxRechargingRunes && !m_runes.CooldownOrder.Empty())
{
byte runeToRegen = m_runes.CooldownOrder[regenIndex++];
uint runeCooldown = GetRuneCooldown(runeToRegen);
if (runeCooldown > m_regenTimer)
{
data.Runes.Start |= (byte)(1 << runeToRegen);
++regenIndex;
}
++regeneratedRunes;
}
float baseCd = GetRuneBaseCooldown();
for (byte i = 0; i < maxRunes; ++i)
data.Runes.Cooldowns.Add((byte)((baseCd - GetRuneCooldown(i)) / baseCd * 255));
SendPacket(data);
}
@@ -2940,15 +2921,11 @@ namespace Game.Entities
m_runes.RuneState = 0;
for (byte i = 0; i < PlayerConst.MaxRunes; ++i)
{
SetRuneCooldown(i, 0); // reset cooldowns
SetRuneTimer(i, 0xFFFFFFFF); // Reset rune flags
SetLastRuneGraceTimer(i, 0);
}
// set a base regen timer equal to 10 sec
SetStatFloatValue(UnitFields.PowerRegenFlatModifier + runeIndex, 0.1f);
SetStatFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + runeIndex, 0.1f);
SetStatFloatValue(UnitFields.PowerRegenFlatModifier + runeIndex, 0.0f);
SetStatFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + runeIndex, 0.0f);
}
public void UpdateAllRunesRegen()
@@ -2960,19 +2937,15 @@ namespace Game.Entities
if (runeIndex == (int)PowerType.Max)
return;
PowerTypeRecord runeEntry = Global.DB2Mgr.GetPowerTypeEntry(PowerType.Runes);
uint cooldown = GetRuneBaseCooldown();
SetStatFloatValue(UnitFields.PowerRegenFlatModifier + runeIndex, (float)(1 * Time.InMilliseconds) / cooldown);
SetStatFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + runeIndex, (float)(1 * Time.InMilliseconds) / cooldown);
SetStatFloatValue(UnitFields.PowerRegenFlatModifier + runeIndex, (float)(1 * Time.InMilliseconds) / (float)cooldown - runeEntry.RegenerationPeace);
SetStatFloatValue(UnitFields.PowerRegenInterruptedFlatModifier + runeIndex, (float)(1 * Time.InMilliseconds) / (float)cooldown - runeEntry.RegenerationCombat);
}
public byte GetRunesState() { return m_runes.RuneState; }
public uint GetRuneCooldown(byte index) { return m_runes.Cooldown[index]; }
public uint GetRuneTimer(byte index) { return m_runeGraceCooldown[index]; }
public void SetRuneTimer(byte index, uint timer) { m_runeGraceCooldown[index] = timer; }
public uint GetLastRuneGraceTimer(byte index) { return m_lastRuneGraceTimers[index]; }
public void SetLastRuneGraceTimer(byte index, uint timer) { m_lastRuneGraceTimers[index] = timer; }
public bool CanNoReagentCast(SpellInfo spellInfo)
{
// don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_WHILE_PREP
+3 -30
View File
@@ -66,13 +66,6 @@ namespace Game.Entities
PlayerTalkClass = new PlayerMenu(session);
m_currentBuybackSlot = InventorySlots.BuyBackStart;
// Init rune flags
for (byte i = 0; i < PlayerConst.MaxRunes; ++i)
{
SetRuneTimer(i, 0xFFFFFFFF);
SetLastRuneGraceTimer(i, 0);
}
for (byte i = 0; i < (int)MirrorTimerType.Max; i++)
m_MirrorTimer[i] = -1;
@@ -744,26 +737,6 @@ namespace Game.Entities
}
}
if (GetClass() == Class.Deathknight)
{
// Update rune timers
for (byte i = 0; i < PlayerConst.MaxRunes; ++i)
{
uint timer = GetRuneTimer(i);
// Don't update timer if rune is disabled
if (GetRuneCooldown(i) != 0)
continue;
// Timer has began
if (timer < 0xFFFFFFFF)
{
timer += diff;
SetRuneTimer(i, Math.Min(2500, timer));
}
}
}
// group update
SendUpdateToOutOfRangeGroupMembers();
@@ -3745,9 +3718,9 @@ namespace Game.Entities
{
uint regeneratedRunes = 0;
int regenIndex = 0;
while (regeneratedRunes < PlayerConst.MaxRechargingRunes && !m_runes.CooldownOrder.Empty())
while (regeneratedRunes < PlayerConst.MaxRechargingRunes && m_runes.CooldownOrder.Count > regenIndex)
{
byte runeToRegen = m_runes.CooldownOrder[regenIndex++];
byte runeToRegen = m_runes.CooldownOrder[regenIndex];
uint runeCooldown = GetRuneCooldown(runeToRegen);
if (runeCooldown > m_regenTimer)
{
@@ -3755,7 +3728,7 @@ namespace Game.Entities
++regenIndex;
}
else
SetRuneCooldown((byte)runeCooldown, 0);
SetRuneCooldown(runeToRegen, 0);
++regeneratedRunes;
}