[12752] Partially fixed death knight runes cooldown

issues: cooldown synchronizes with all other runes (in next commit cooldown will splitted correctly)
This commit is contained in:
sanctum32 2013-12-21 18:54:51 +02:00 committed by Antz
parent 04786e7ee8
commit 9decc79dd0
3 changed files with 48 additions and 64 deletions

View file

@ -2173,18 +2173,21 @@ void Player::Regenerate(Powers power, uint32 diff)
if (getClass() != CLASS_DEATH_KNIGHT) if (getClass() != CLASS_DEATH_KNIGHT)
break; break;
for (uint32 rune = 0; rune < MAX_RUNES; ++rune) for (uint8 rune = 0; rune < MAX_RUNES; rune += 2)
{
if (uint16 cd = GetRuneCooldown(rune)) // if we have cooldown, reduce it...
{ {
uint32 cd_diff = diff; uint32 cd_diff = diff;
AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); uint8 runeToRegen = rune;
for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) uint32 cd = GetRuneCooldown(rune);
if ((*i)->GetModifier()->m_miscvalue == int32(power) && (*i)->GetMiscBValue() == GetCurrentRune(rune)) uint32 secondRuneCd = GetRuneCooldown(rune + 1);
cd_diff = cd_diff * ((*i)->GetModifier()->m_amount + 100) / 100; // Regenerate second rune of the same type only after first rune is off the cooldown
if (secondRuneCd && (cd > secondRuneCd || !cd))
SetRuneCooldown(rune, (cd < cd_diff) ? 0 : cd - cd_diff); {
++runeToRegen;
cd = secondRuneCd;
} }
if (cd)
SetRuneCooldown(rune, (cd < cd_diff) ? 0 : cd - cd_diff);
} }
break; break;
} }
@ -22072,7 +22075,7 @@ void Player::ResyncRunes()
for (uint32 i = 0; i < MAX_RUNES; ++i) for (uint32 i = 0; i < MAX_RUNES; ++i)
{ {
data << uint8(GetCurrentRune(i)); // rune type data << uint8(GetCurrentRune(i)); // rune type
data << uint8(255 - ((GetRuneCooldown(i) / REGEN_TIME_FULL) * 51)); // passed cooldown time (0-255) data << uint8(255 - (GetRuneCooldown(i) * 51)); // passed cooldown time (0-255)
} }
GetSession()->SendPacket(&data); GetSession()->SendPacket(&data);
} }

View file

@ -4724,28 +4724,22 @@ SpellCastResult Spell::CheckOrTakeRunePower(bool take)
return SPELL_CAST_OK; return SPELL_CAST_OK;
SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID); SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID);
if (!src || (src->NoRuneCost() && (!take || src->NoRunicPowerGain())))
if (!src)
return SPELL_CAST_OK;
if (src->NoRuneCost() && (!take || src->NoRunicPowerGain()))
return SPELL_CAST_OK; return SPELL_CAST_OK;
if (take) if (take)
m_runesState = plr->GetRunesState(); // store previous state m_runesState = plr->GetRunesState(); // store previous state
// at this moment for rune cost exist only no cost mods, and no percent mods
int32 runeCostMod = 10000;
if (Player* modOwner = plr->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCostMod, this);
if (runeCostMod > 0)
{
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
// init cost data and apply mods // init cost data and apply mods
for (uint32 i = 0; i < RUNE_DEATH; ++i) for (uint32 i = 0; i < RUNE_DEATH; ++i)
runeCost[i] = runeCostMod > 0 ? src->RuneCost[i] : 0; {
runeCost[i] = src->RuneCost[i];
if (Player* modOwner = plr->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], this);
}
runeCost[RUNE_DEATH] = 0; // calculated later runeCost[RUNE_DEATH] = 0; // calculated later
@ -4753,18 +4747,12 @@ SpellCastResult Spell::CheckOrTakeRunePower(bool take)
for (uint32 i = 0; i < MAX_RUNES; ++i) for (uint32 i = 0; i < MAX_RUNES; ++i)
{ {
RuneType rune = plr->GetCurrentRune(i); RuneType rune = plr->GetCurrentRune(i);
if (runeCost[rune] <= 0) if (!plr->GetRuneCooldown(i) && runeCost[rune] > 0)
continue; {
// already used
if (plr->GetRuneCooldown(i) != 0)
continue;
if (take)
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
--runeCost[rune]; --runeCost[rune];
} }
}
// collect all not counted rune costs to death runes cost // collect all not counted rune costs to death runes cost
for (uint32 i = 0; i < RUNE_DEATH; ++i) for (uint32 i = 0; i < RUNE_DEATH; ++i)
@ -4774,30 +4762,23 @@ SpellCastResult Spell::CheckOrTakeRunePower(bool take)
// scan death runes // scan death runes
if (runeCost[RUNE_DEATH] > 0) if (runeCost[RUNE_DEATH] > 0)
{ {
for (uint32 i = 0; i < MAX_RUNES && runeCost[RUNE_DEATH]; ++i) for (uint32 i = 0; i < MAX_RUNES; ++i)
{ {
RuneType rune = plr->GetCurrentRune(i); RuneType rune = plr->GetCurrentRune(i);
if (rune != RUNE_DEATH) if (plr->GetRuneCooldown(i) && rune == RUNE_DEATH)
continue; {
// already used
if (plr->GetRuneCooldown(i) != 0)
continue;
if (take)
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
runeCost[rune]--;
--runeCost[rune];
if (take) if (take)
plr->ConvertRune(i, plr->GetBaseRune(i)); plr->ConvertRune(i, plr->GetBaseRune(i));
} }
} }
if (!take && runeCost[RUNE_DEATH] > 0)
return SPELL_FAILED_NO_POWER; // not sure if result code is correct
} }
if (runeCost[RUNE_DEATH] == 0)
return SPELL_FAILED_NO_POWER; // not sure if result code is correct
if (take) if (take)
{ {
// you can gain some runic power when use runes // you can gain some runic power when use runes

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 "12751" #define REVISION_NR "12752"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__