aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMorgoporc <j.fraisse45@laposte.net>2014-09-22 01:05:13 +0100
committerDDuarte <dnpd.dd@gmail.com>2014-09-22 01:05:13 +0100
commitec59c3ab0377f4077a2d63e7b242f2a3693dd2d4 (patch)
tree0238645a8170d8f6141eee7ec5284620a15f9487 /src
parent84efd8b92bec4af04263eb7b86a598572164a20b (diff)
Core/Players/DK: Implement Rune Grace Period mechanic
Closes #11736 Fixes #6122
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp51
-rw-r--r--src/server/game/Entities/Player/Player.h10
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp12
-rw-r--r--src/server/game/Spells/Spell.cpp4
4 files changed, 69 insertions, 8 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index b0c844c82ba..0a2dc3366d7 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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);
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 1deb21fb01b..8ed561bc95b 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -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;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index c4569887abf..a3b8adf85d0 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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())
{
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index aedfeb149eb..31aecbb65a0 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -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]--;