[12753] Fixed Death knight runes

TODO: add specific cooldown timer for runes if player misses
This commit is contained in:
sanctum32 2013-12-21 21:01:13 +02:00 committed by Antz
parent 7bfa13761a
commit fb14bce9c9
2 changed files with 28 additions and 15 deletions

View file

@ -4706,7 +4706,7 @@ void Spell::TakePower()
if (powerType == POWER_RUNE) if (powerType == POWER_RUNE)
{ {
CheckOrTakeRunePower(true); CheckOrTakeRunePower(hit);
return; return;
} }
@ -4727,13 +4727,12 @@ SpellCastResult Spell::CheckOrTakeRunePower(bool take)
if (!src || (src->NoRuneCost() && (!take || src->NoRunicPowerGain()))) if (!src || (src->NoRuneCost() && (!take || src->NoRunicPowerGain())))
return SPELL_CAST_OK; return SPELL_CAST_OK;
if (take) m_runesState = plr->GetRunesState(); // store previous state
m_runesState = plr->GetRunesState(); // store previous state
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 (uint8 i = 0; i < RUNE_DEATH; ++i)
{ {
runeCost[i] = src->RuneCost[i]; runeCost[i] = src->RuneCost[i];
if (Player* modOwner = plr->GetSpellModOwner()) if (Player* modOwner = plr->GetSpellModOwner())
@ -4741,44 +4740,58 @@ SpellCastResult Spell::CheckOrTakeRunePower(bool take)
} }
runeCost[RUNE_DEATH] = 0; // calculated later runeCost[RUNE_DEATH] = MAX_RUNES; // calculated later
// scan non-death runes (death rune not used explicitly in rune costs) // scan non-death runes (death rune not used explicitly in rune costs)
for (uint32 i = 0; i < MAX_RUNES; ++i) for (uint8 i = 0; i < MAX_RUNES; ++i)
{ {
// already used
if (plr->GetRuneCooldown(i) != 0)
continue;
RuneType rune = plr->GetCurrentRune(i); RuneType rune = plr->GetCurrentRune(i);
if (!plr->GetRuneCooldown(i) && runeCost[rune] > 0) if (plr->GetRuneCooldown(i) == 0 && runeCost[rune] > 0)
{ {
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec RuneType rune = plr->GetCurrentRune(i);
if (runeCost[rune] <= 0)
continue;
// already used
if (plr->GetRuneCooldown(i) != 0)
continue;
if (take)
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 (uint8 i = 0; i < RUNE_DEATH; ++i)
if (runeCost[i] > 0) if (runeCost[i] > 0)
runeCost[RUNE_DEATH] += runeCost[i]; runeCost[RUNE_DEATH] += runeCost[i];
// scan death runes // scan death runes
if (runeCost[RUNE_DEATH] > 0) if (runeCost[RUNE_DEATH] > 0)
{ {
for (uint32 i = 0; i < MAX_RUNES; ++i) for (uint8 i = 0; i < MAX_RUNES; ++i)
{ {
RuneType rune = plr->GetCurrentRune(i); RuneType rune = plr->GetCurrentRune(i);
if (plr->GetRuneCooldown(i) && rune == RUNE_DEATH) if (!plr->GetRuneCooldown(i) && rune == RUNE_DEATH)
{ {
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 (runeCost[RUNE_DEATH] == 0)
return SPELL_FAILED_NO_POWER;
} }
} }
} }
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 "12752" #define REVISION_NR "12753"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__