aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2011-04-07 23:13:35 +0200
committerShauren <shauren.trinity@gmail.com>2011-04-07 23:13:35 +0200
commit0ae5aca55e91e7af7cd6c8ad6479aec0f93f7b3c (patch)
treefa3b1d34ea82e13b55de95a2bfe871389061db4b /src
parent35645abfc6bda9828df1e682ac14b8123f67f1f0 (diff)
Core/Spells: Apply only 1.5 second cooldown to DK runes when spell misses its target
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp2
-rwxr-xr-xsrc/server/game/Entities/Player/Player.h7
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp66
-rwxr-xr-xsrc/server/game/Spells/Spell.h2
4 files changed, 44 insertions, 33 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index d27f54efca5..75ceee34f0b 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -22911,7 +22911,7 @@ void Player::RemoveGlobalCooldown(SpellEntry const *spellInfo)
uint32 Player::GetRuneBaseCooldown(uint8 index)
{
uint8 rune = GetBaseRune(index);
- uint32 cooldown = RUNE_COOLDOWN;
+ uint32 cooldown = RUNE_BASE_COOLDOWN;
AuraEffectList const& regenAura = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
for (AuraEffectList::const_iterator i = regenAura.begin();i != regenAura.end(); ++i)
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 03f09fcf3be..d22054f1791 100755
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -289,7 +289,12 @@ struct Areas
};
#define MAX_RUNES 6
-#define RUNE_COOLDOWN 10000
+
+enum RuneCooldowns
+{
+ RUNE_BASE_COOLDOWN = 10000,
+ RUNE_MISS_COOLDOWN = 1500, // cooldown applied on runes when the spell misses
+};
enum RuneType
{
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index b9e81d01bdc..1bfcb00bf31 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -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()
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index e6351e4626a..85428beb57d 100755
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -427,7 +427,7 @@ class Spell
void TakePower();
void TakeAmmo();
- void TakeRunePower();
+ void TakeRunePower(bool didHit);
void TakeReagents();
void TakeCastItem();