aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2019-07-13 17:57:07 +0200
committerccrs <ccrs@users.noreply.github.com>2019-07-13 17:57:07 +0200
commitd1dc0e2dc1fbd692eeda90ae2ab82ae07e2cae0e (patch)
treeb7b8fa8e078c95eb94f97f1435024014e6be0028 /src/server/game/Entities
parent8c16f318fe072709fc40c61987570dba8f5b6483 (diff)
Scripts/DK: correctly handle Blood Tap
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Player/Player.cpp74
-rw-r--r--src/server/game/Entities/Player/Player.h6
2 files changed, 58 insertions, 22 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 355c1de617c..54f48802077 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -22596,6 +22596,8 @@ void Player::SendInitialPacketsBeforeAddToMap()
// SMSG_UPDATE_WORLD_STATE
// SMSG_POWER_UPDATE
+ ResyncRunes();
+
SetMovedUnit(this);
}
@@ -24514,46 +24516,73 @@ void Player::SetRuneCooldown(uint8 index, uint32 cooldown, bool casted /*= false
m_runes->runes[index].Cooldown = cooldown;
m_runes->SetRuneState(index, (cooldown == 0) ? true : false);
+
+ ResyncRunes();
}
void Player::SetRuneConvertAura(uint8 index, AuraEffect const* aura)
{
- m_runes->runes[index].ConvertAura = aura;
+ m_runes->runes[index].ConvertAuras.insert(aura);
+}
+
+void Player::RemoveRuneConvertAura(uint8 index, AuraEffect const* aura)
+{
+ m_runes->runes[index].ConvertAuras.erase(aura);
}
void Player::AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura)
{
- SetRuneConvertAura(index, aura); ConvertRune(index, newType);
+ SetRuneConvertAura(index, aura);
+ ConvertRune(index, newType);
}
void Player::RemoveRunesByAuraEffect(AuraEffect const* aura)
{
- for (uint8 i = 0; i < MAX_RUNES; ++i)
+ for (uint8 itr = 0; itr < MAX_RUNES; ++itr)
{
- if (m_runes->runes[i].ConvertAura == aura)
- {
- ConvertRune(i, GetBaseRune(i));
- SetRuneConvertAura(i, nullptr);
- }
+ RemoveRuneConvertAura(itr, aura);
+
+ if (m_runes->runes[itr].ConvertAuras.empty())
+ ConvertRune(itr, GetBaseRune(itr));
}
}
void Player::RestoreBaseRune(uint8 index)
{
- AuraEffect const* aura = m_runes->runes[index].ConvertAura;
- // If rune was converted by a non-passive aura that still active we should keep it converted
- if (aura && !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_PASSIVE))
+ std::unordered_set<AuraEffect const*>& auras = m_runes->runes[index].ConvertAuras;
+
+ AuraEffect const* aura = nullptr;
+ for (auto itr = auras.begin(); itr != auras.end() && !aura;)
+ {
+ if (AuraEffect const* temp = *itr)
+ {
+ if (temp->GetSpellInfo()->HasAttribute(SPELL_ATTR0_PASSIVE))
+ {
+ aura = temp;
+ auras.erase(itr);
+ }
+ else
+ ++itr;
+ }
+ else
+ itr = auras.erase(itr);
+ }
+
+ if (!auras.empty())
return;
+
ConvertRune(index, GetBaseRune(index));
- SetRuneConvertAura(index, nullptr);
+
// Don't drop passive talents providing rune convertion
if (!aura || aura->GetAuraType() != SPELL_AURA_CONVERT_RUNE)
return;
- for (uint8 i = 0; i < MAX_RUNES; ++i)
+
+ for (uint8 itr = 0; itr < MAX_RUNES; ++itr)
{
- if (aura == m_runes->runes[i].ConvertAura)
+ if (m_runes->runes[itr].ConvertAuras.find(aura) != m_runes->runes[itr].ConvertAuras.end())
return;
}
+
aura->GetBase()->Remove();
}
@@ -24567,14 +24596,19 @@ void Player::ConvertRune(uint8 index, RuneType newType)
SendDirectMessage(&data);
}
-void Player::ResyncRunes(uint8 count) const
+void Player::ResyncRunes() const
{
- WorldPacket data(SMSG_RESYNC_RUNES, 4 + count * 2);
- data << uint32(count);
- for (uint32 i = 0; i < count; ++i)
+ if (GetClass() != CLASS_DEATH_KNIGHT)
+ return;
+
+ WorldPacket data(SMSG_RESYNC_RUNES, 4 + MAX_RUNES * 2);
+ data << uint32(MAX_RUNES);
+ for (uint32 itr = 0; itr < MAX_RUNES; ++itr)
{
- data << uint8(GetCurrentRune(i)); // rune type
- data << uint8(255 - (GetRuneCooldown(i) * 51)); // passed cooldown time (0-255)
+ data << uint8(GetCurrentRune(itr)); // rune type
+
+ uint32 value = uint32(255) - ((GetRuneCooldown(itr) * uint32(255)) / uint32(RUNE_BASE_COOLDOWN));
+ data << uint8(value); // passed cooldown time (0-255)
}
SendDirectMessage(&data);
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 00ee3aa2bf8..16a90dc7e23 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -32,6 +32,7 @@
#include "QuestDef.h"
#include <memory>
#include <queue>
+#include <unordered_set>
struct AccessRequirement;
struct AchievementEntry;
@@ -276,7 +277,7 @@ struct RuneInfo
uint8 BaseRune;
uint8 CurrentRune;
uint32 Cooldown;
- AuraEffect const* ConvertAura;
+ std::unordered_set<AuraEffect const*> ConvertAuras;
};
struct Runes
@@ -2118,11 +2119,12 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
void SetRuneCooldown(uint8 index, uint32 cooldown, bool casted = false);
void SetRuneConvertAura(uint8 index, AuraEffect const* aura);
+ void RemoveRuneConvertAura(uint8 index, AuraEffect const* aura);
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura);
void RemoveRunesByAuraEffect(AuraEffect const* aura);
void RestoreBaseRune(uint8 index);
void ConvertRune(uint8 index, RuneType newType);
- void ResyncRunes(uint8 count) const;
+ void ResyncRunes() const;
void AddRunePower(uint8 index) const;
void InitRunes();