Core/Spells: Apply only 1.5 second cooldown to DK runes when spell misses its target
This commit is contained in:
@@ -3931,16 +3931,20 @@ void Spell::SendSpellGo()
|
||||
|
||||
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
|
||||
{
|
||||
uint8 v1 = m_runesState;
|
||||
uint8 v2 = m_caster->ToPlayer()->GetRunesState();
|
||||
data << uint8(v1); // runes state before
|
||||
data << uint8(v2); // runes state after
|
||||
Player* player = m_caster->ToPlayer();
|
||||
uint8 runeMaskInitial = m_runesState;
|
||||
uint8 runeMaskAfterCast = player->GetRunesState();
|
||||
data << uint8(runeMaskInitial); // runes state before
|
||||
data << uint8(runeMaskAfterCast); // runes state after
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
{
|
||||
uint8 m = (1 << i);
|
||||
if (m & v1) // usable before...
|
||||
if (!(m & v2)) // ...but on cooldown now...
|
||||
data << uint8(0); // some unknown byte (time?)
|
||||
uint8 mask = (1 << i);
|
||||
if (mask & runeMaskInitial && !(mask & runeMaskAfterCast)) // usable before andon cooldown now...
|
||||
{
|
||||
// float casts ensure the division is performed on floats as we need float result
|
||||
float baseCd = float(player->GetRuneBaseCooldown(i));
|
||||
data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4364,7 +4368,7 @@ void Spell::TakePower()
|
||||
bool hit = true;
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (m_spellInfo->powerType == POWER_RAGE || m_spellInfo->powerType == POWER_ENERGY)
|
||||
if (m_spellInfo->powerType == POWER_RAGE || m_spellInfo->powerType == POWER_ENERGY || m_spellInfo->powerType == POWER_RUNE)
|
||||
if (uint64 targetGUID = m_targets.getUnitTargetGUID())
|
||||
for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
if (ihit->targetGUID == targetGUID)
|
||||
@@ -4383,9 +4387,9 @@ void Spell::TakePower()
|
||||
|
||||
Powers powerType = Powers(m_spellInfo->powerType);
|
||||
|
||||
if (hit && powerType == POWER_RUNE)
|
||||
if (powerType == POWER_RUNE)
|
||||
{
|
||||
TakeRunePower();
|
||||
TakeRunePower(hit);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4493,28 +4497,28 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
void Spell::TakeRunePower()
|
||||
void Spell::TakeRunePower(bool didHit)
|
||||
{
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
Player *plr = (Player*)m_caster;
|
||||
Player* player = m_caster->ToPlayer();
|
||||
|
||||
if (plr->getClass() != CLASS_DEATH_KNIGHT)
|
||||
if (player->getClass() != CLASS_DEATH_KNIGHT)
|
||||
return;
|
||||
|
||||
SpellRuneCostEntry const *src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID);
|
||||
SpellRuneCostEntry const *runeCostData = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID);
|
||||
|
||||
if (!src || (src->NoRuneCost() && src->NoRunicPowerGain()))
|
||||
if (!runeCostData || (runeCostData->NoRuneCost() && runeCostData->NoRunicPowerGain()))
|
||||
return;
|
||||
|
||||
m_runesState = plr->GetRunesState(); // store previous state
|
||||
m_runesState = player->GetRunesState(); // store previous state
|
||||
|
||||
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
|
||||
|
||||
for (uint32 i = 0; i < RUNE_DEATH; ++i)
|
||||
{
|
||||
runeCost[i] = src->RuneCost[i];
|
||||
runeCost[i] = runeCostData->RuneCost[i];
|
||||
if (Player* modOwner = m_caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], this);
|
||||
}
|
||||
@@ -4523,11 +4527,11 @@ void Spell::TakeRunePower()
|
||||
|
||||
for (uint32 i = 0; i < MAX_RUNES; ++i)
|
||||
{
|
||||
RuneType rune = plr->GetCurrentRune(i);
|
||||
if ((plr->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0))
|
||||
RuneType rune = player->GetCurrentRune(i);
|
||||
if (!player->GetRuneCooldown(i) && runeCost[rune] > 0)
|
||||
{
|
||||
plr->SetRuneCooldown(i, plr->GetRuneBaseCooldown(i));
|
||||
plr->SetLastUsedRune(RuneType(rune));
|
||||
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : RUNE_MISS_COOLDOWN);
|
||||
player->SetLastUsedRune(rune);
|
||||
runeCost[rune]--;
|
||||
}
|
||||
}
|
||||
@@ -4538,14 +4542,16 @@ void Spell::TakeRunePower()
|
||||
{
|
||||
for (uint32 i = 0; i < MAX_RUNES; ++i)
|
||||
{
|
||||
RuneType rune = plr->GetCurrentRune(i);
|
||||
if ((plr->GetRuneCooldown(i) == 0) && (rune == RUNE_DEATH))
|
||||
RuneType rune = player->GetCurrentRune(i);
|
||||
if (!player->GetRuneCooldown(i) && rune == RUNE_DEATH)
|
||||
{
|
||||
plr->SetRuneCooldown(i, plr->GetRuneBaseCooldown(i));
|
||||
plr->SetLastUsedRune(RuneType(rune));
|
||||
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : RUNE_MISS_COOLDOWN);
|
||||
player->SetLastUsedRune(rune);
|
||||
runeCost[rune]--;
|
||||
|
||||
plr->RestoreBaseRune(i);
|
||||
// keep Death Rune type if missed
|
||||
if (didHit)
|
||||
player->RestoreBaseRune(i);
|
||||
|
||||
if (runeCost[RUNE_DEATH] == 0)
|
||||
break;
|
||||
@@ -4554,9 +4560,9 @@ void Spell::TakeRunePower()
|
||||
}
|
||||
|
||||
// you can gain some runic power when use runes
|
||||
float rp = (float)src->runePowerGain;
|
||||
rp *= sWorld->getRate(RATE_POWER_RUNICPOWER_INCOME);
|
||||
plr->ModifyPower(POWER_RUNIC_POWER, (int32)rp);
|
||||
if (didHit)
|
||||
if (int32 rp = int32(runeCostData->runePowerGain * sWorld->getRate(RATE_POWER_RUNICPOWER_INCOME)))
|
||||
player->ModifyPower(POWER_RUNIC_POWER, int32(rp));
|
||||
}
|
||||
|
||||
void Spell::TakeReagents()
|
||||
|
||||
@@ -427,7 +427,7 @@ class Spell
|
||||
void TakePower();
|
||||
void TakeAmmo();
|
||||
|
||||
void TakeRunePower();
|
||||
void TakeRunePower(bool didHit);
|
||||
void TakeReagents();
|
||||
void TakeCastItem();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user