Core/Players/DK: Implement Rune Grace Period mechanic

Closes #11736
Fixes #6122
This commit is contained in:
Morgoporc
2014-09-22 01:05:13 +01:00
committed by DDuarte
parent 84efd8b92b
commit ec59c3ab03
4 changed files with 69 additions and 8 deletions
+47 -4
View File
@@ -735,6 +735,13 @@ Player::Player(WorldSession* session): Unit(true)
m_DailyQuestChanged = false;
m_lastDailyQuestTime = 0;
// Init rune flags
for (uint8 i = 0; i < MAX_RUNES; ++i)
{
SetRuneTimer(i, 0xFFFFFFFF);
SetLastRuneGraceTimer(i, 0);
}
for (uint8 i=0; i < MAX_TIMERS; i++)
m_MirrorTimer[i] = DISABLED_MIRROR_TIMER;
@@ -1846,6 +1853,26 @@ void Player::Update(uint32 p_time)
}
}
if (getClass() == CLASS_DEATH_KNIGHT)
{
// Update rune timers
for (uint8 i = 0; i < MAX_RUNES; ++i)
{
uint32 timer = GetRuneTimer(i);
// Don't update timer if rune is disabled
if (GetRuneCooldown(i))
continue;
// Timer has began
if (timer < 0xFFFFFFFF)
{
timer += p_time;
SetRuneTimer(i, std::min(uint32(2500), timer));
}
}
}
// group update
SendUpdateToOutOfRangeGroupMembers();
@@ -24724,8 +24751,22 @@ uint32 Player::GetRuneBaseCooldown(uint8 index)
return cooldown;
}
void Player::SetRuneCooldown(uint8 index, uint32 cooldown)
void Player::SetRuneCooldown(uint8 index, uint32 cooldown, bool casted /*= false*/)
{
uint32 gracePeriod = GetRuneTimer(index);
if (casted && IsInCombat())
{
if (gracePeriod < 0xFFFFFFFF && cooldown > 0)
{
uint32 lessCd = std::min(uint32(2500), gracePeriod);
cooldown = (cooldown > lessCd) ? (cooldown - lessCd) : 0;
SetLastRuneGraceTimer(index, lessCd);
}
SetRuneTimer(index, 0);
}
m_runes->runes[index].Cooldown = cooldown;
m_runes->SetRuneState(index, (cooldown == 0) ? true : false);
}
@@ -24822,9 +24863,11 @@ void Player::InitRunes()
for (uint8 i = 0; i < MAX_RUNES; ++i)
{
SetBaseRune(i, runeSlotTypes[i]); // init base types
SetCurrentRune(i, runeSlotTypes[i]); // init current types
SetRuneCooldown(i, 0); // reset cooldowns
SetBaseRune(i, runeSlotTypes[i]); // init base types
SetCurrentRune(i, runeSlotTypes[i]); // init current types
SetRuneCooldown(i, 0); // reset cooldowns
SetRuneTimer(i, 0xFFFFFFFF); // Reset rune flags
SetLastRuneGraceTimer(i, 0);
SetRuneConvertAura(i, NULL);
m_runes->SetRuneState(i);
}
+9 -1
View File
@@ -1828,6 +1828,10 @@ class Player : public Unit, public GridObject<Player>
void ApplyHealthRegenBonus(int32 amount, bool apply);
void UpdateManaRegen();
void UpdateRuneRegen(RuneType rune);
uint32 GetRuneTimer(uint8 index) const { return m_runeGraceCooldown[index]; }
void SetRuneTimer(uint8 index, uint32 timer) { m_runeGraceCooldown[index] = timer; }
uint32 GetLastRuneGraceTimer(uint8 index) const { return m_lastRuneGraceTimers[index]; }
void SetLastRuneGraceTimer(uint8 index, uint32 timer) { m_lastRuneGraceTimers[index] = timer; }
ObjectGuid GetLootGUID() const { return m_lootGuid; }
void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; }
@@ -2284,7 +2288,7 @@ class Player : public Unit, public GridObject<Player>
void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; }
void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; }
void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
void SetRuneCooldown(uint8 index, uint32 cooldown);
void SetRuneCooldown(uint8 index, uint32 cooldown, bool casted = false);
void SetRuneConvertAura(uint8 index, AuraEffect const* aura);
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura);
void RemoveRunesByAuraEffect(AuraEffect const* aura);
@@ -2634,6 +2638,10 @@ class Player : public Unit, public GridObject<Player>
uint8 m_MirrorTimerFlagsLast;
bool m_isInWater;
// Rune type / Rune timer
uint32 m_runeGraceCooldown[MAX_RUNES];
uint32 m_lastRuneGraceTimers[MAX_RUNES];
// Current teleport data
WorldLocation m_teleport_dest;
uint32 m_teleport_options;
+11 -1
View File
@@ -7604,7 +7604,7 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
player->GetBaseRune(i) != RUNE_BLOOD)
continue;
}
if (player->GetRuneCooldown(i) != player->GetRuneBaseCooldown(i))
if (player->GetRuneCooldown(i) != (player->GetRuneBaseCooldown(i) - player->GetLastRuneGraceTimer(i)))
continue;
--runesLeft;
@@ -11760,6 +11760,16 @@ void Unit::ClearInCombat()
m_CombatTimer = 0;
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
// Reset rune flags after combat
if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_DEATH_KNIGHT)
{
for (uint8 i = 0; i < MAX_RUNES; ++i)
{
ToPlayer()->SetRuneTimer(i, 0xFFFFFFFF);
ToPlayer()->SetLastRuneGraceTimer(i, 0);
}
}
// Player's state will be cleared in Player::UpdateContestedPvP
if (Creature* creature = ToCreature())
{
+2 -2
View File
@@ -4445,7 +4445,7 @@ void Spell::TakeRunePower(bool didHit)
RuneType rune = player->GetCurrentRune(i);
if (!player->GetRuneCooldown(i) && runeCost[rune] > 0)
{
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN));
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true);
player->SetLastUsedRune(rune);
runeCost[rune]--;
}
@@ -4460,7 +4460,7 @@ void Spell::TakeRunePower(bool didHit)
RuneType rune = player->GetCurrentRune(i);
if (!player->GetRuneCooldown(i) && rune == RUNE_DEATH)
{
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN));
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true);
player->SetLastUsedRune(rune);
runeCost[rune]--;