mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Core/Player: merged some rune regeneration related changes from all arround the world
This commit is contained in:
@@ -25571,40 +25571,28 @@ uint32 Player::GetRuneTypeBaseCooldown(RuneType /*runeType*/) const
|
||||
return RUNE_BASE_COOLDOWN;
|
||||
}
|
||||
|
||||
void Player::SetRuneCooldown(uint8 index, uint32 cooldown, bool casted /*= false*/)
|
||||
void Player::SetRuneConvertAura(uint8 index, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo)
|
||||
{
|
||||
uint32 gracePeriod = GetRuneTimer(index);
|
||||
m_runes->runes[index].ConvertAura = aura;
|
||||
m_runes->runes[index].ConvertAuraType = auraType;
|
||||
m_runes->runes[index].ConvertAuraInfo = spellInfo;
|
||||
}
|
||||
|
||||
// Improved Blood Presence
|
||||
void Player::AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo)
|
||||
{
|
||||
SetRuneConvertAura(index, aura, auraType, spellInfo);
|
||||
ConvertRune(index, newType);
|
||||
}
|
||||
|
||||
void Player::SetRuneCooldown(uint8 index, uint32 cooldown)
|
||||
{
|
||||
if (AuraEffect* aurEff = GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_GENERIC, 2636, EFFECT_2))
|
||||
cooldown *= 1.0 - CalculatePct(aurEff->GetAmount(), 1);
|
||||
|
||||
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);
|
||||
}
|
||||
cooldown *= 1.0 - (aurEff->GetAmount() / 100);
|
||||
|
||||
m_runes->runes[index].Cooldown = cooldown;
|
||||
m_runes->SetRuneState(index, (cooldown == 0) ? true : false);
|
||||
}
|
||||
|
||||
void Player::SetRuneConvertAura(uint8 index, AuraEffect const* aura)
|
||||
{
|
||||
m_runes->runes[index].ConvertAura = aura;
|
||||
}
|
||||
|
||||
void Player::AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura)
|
||||
{
|
||||
SetRuneConvertAura(index, aura); ConvertRune(index, newType);
|
||||
}
|
||||
|
||||
void Player::RemoveRunesByAuraEffect(AuraEffect const* aura)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
@@ -25612,35 +25600,28 @@ void Player::RemoveRunesByAuraEffect(AuraEffect const* aura)
|
||||
if (m_runes->runes[i].ConvertAura == aura)
|
||||
{
|
||||
ConvertRune(i, GetBaseRune(i));
|
||||
SetRuneConvertAura(i, nullptr);
|
||||
SetRuneConvertAura(i, nullptr, SPELL_AURA_NONE, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
return;
|
||||
SpellInfo const* spellInfo = m_runes->runes[index].ConvertAuraInfo;
|
||||
AuraType type = m_runes->runes[index].ConvertAuraType;
|
||||
// If rune was converted by a non-pasive aura that still active we should keep it converted
|
||||
if (spellInfo)
|
||||
{
|
||||
if (!(spellInfo->Attributes & SPELL_ATTR0_PASSIVE))
|
||||
return;
|
||||
|
||||
// Don't even convert aura for passive convertion
|
||||
if (aura && aura->GetBase()->IsPassive() && aura->GetAuraType() == SPELL_AURA_CONVERT_RUNE)
|
||||
return;
|
||||
// Don't even convert aura for passive convertion
|
||||
if (spellInfo->IsPassive() && type == SPELL_AURA_CONVERT_RUNE)
|
||||
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)
|
||||
{
|
||||
if (aura == m_runes->runes[i].ConvertAura)
|
||||
return;
|
||||
}
|
||||
aura->GetBase()->Remove();
|
||||
SetRuneConvertAura(index, NULL, SPELL_AURA_NONE, NULL);
|
||||
}
|
||||
|
||||
void Player::ConvertRune(uint8 index, RuneType newType)
|
||||
@@ -25650,10 +25631,10 @@ void Player::ConvertRune(uint8 index, RuneType newType)
|
||||
WorldPacket data(SMSG_CONVERT_RUNE, 2);
|
||||
data << uint8(index);
|
||||
data << uint8(newType);
|
||||
SendDirectMessage(&data);
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Player::ResyncRunes(uint8 count) const
|
||||
void Player::ResyncRunes(uint8 count)
|
||||
{
|
||||
WorldPacket data(SMSG_RESYNC_RUNES, 4 + count * 2);
|
||||
data << uint32(count);
|
||||
@@ -25662,14 +25643,14 @@ void Player::ResyncRunes(uint8 count) const
|
||||
data << uint8(GetCurrentRune(i)); // rune type
|
||||
data << uint8(255 - (GetRuneCooldown(i) * 51)); // passed cooldown time (0-255)
|
||||
}
|
||||
SendDirectMessage(&data);
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
void Player::AddRunePower(uint8 index) const
|
||||
void Player::AddRunePower(uint8 mask)
|
||||
{
|
||||
WorldPacket data(SMSG_ADD_RUNE_POWER, 4);
|
||||
data << uint32(1 << index); // mask (0x00-0x3F probably)
|
||||
SendDirectMessage(&data);
|
||||
data << uint32(mask); // mask (0x00-0x3F probably)
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
static RuneType runeSlotTypes[MAX_RUNES] =
|
||||
@@ -25691,15 +25672,14 @@ void Player::InitRunes()
|
||||
|
||||
m_runes->runeState = 0;
|
||||
m_runes->lastUsedRune = RUNE_BLOOD;
|
||||
m_runes->lastUsedRuneMask = 0;
|
||||
|
||||
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
|
||||
SetRuneTimer(i, 0xFFFFFFFF); // Reset rune flags
|
||||
SetLastRuneGraceTimer(i, 0);
|
||||
SetRuneConvertAura(i, nullptr);
|
||||
SetBaseRune(i, runeSlotTypes[i]); // init base types
|
||||
SetCurrentRune(i, runeSlotTypes[i]); // init current types
|
||||
SetRuneCooldown(i, 0); // reset cooldowns
|
||||
SetRuneConvertAura(i, NULL, SPELL_AURA_NONE, NULL);
|
||||
m_runes->SetRuneState(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -341,6 +341,8 @@ struct RuneInfo
|
||||
uint8 CurrentRune;
|
||||
uint32 Cooldown;
|
||||
AuraEffect const* ConvertAura;
|
||||
AuraType ConvertAuraType;
|
||||
SpellInfo const* ConvertAuraInfo;
|
||||
};
|
||||
|
||||
struct Runes
|
||||
@@ -348,6 +350,7 @@ struct Runes
|
||||
RuneInfo runes[MAX_RUNES];
|
||||
uint8 runeState; // mask of available runes
|
||||
RuneType lastUsedRune;
|
||||
uint8 lastUsedRuneMask;
|
||||
|
||||
void SetRuneState(uint8 index, bool set = true)
|
||||
{
|
||||
@@ -2274,6 +2277,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
bool isAllowedToLoot(Creature const* creature);
|
||||
|
||||
DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
|
||||
|
||||
uint8 GetRunesState() const { return m_runes->runeState; }
|
||||
RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); }
|
||||
RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->runes[index].CurrentRune); }
|
||||
@@ -2281,18 +2285,21 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
uint32 GetRuneBaseCooldown(uint8 index) const { return GetRuneTypeBaseCooldown(GetBaseRune(index)); }
|
||||
uint32 GetRuneTypeBaseCooldown(RuneType runeType) const;
|
||||
bool IsBaseRuneSlotsOnCooldown(RuneType runeType) const;
|
||||
RuneType GetLastUsedRune() const { return m_runes->lastUsedRune; }
|
||||
RuneType GetLastUsedRune() { return m_runes->lastUsedRune; }
|
||||
uint8 GetLastUsedRuneMask() { return m_runes->lastUsedRuneMask; }
|
||||
void ClearLastUsedRuneMask() { m_runes->lastUsedRuneMask = 0; }
|
||||
void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; }
|
||||
void SetLastUsedRuneIndex(uint8 index) { m_runes->lastUsedRuneMask |= (1 << index); }
|
||||
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, bool casted = false);
|
||||
void SetRuneConvertAura(uint8 index, AuraEffect const* aura);
|
||||
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura);
|
||||
void SetRuneConvertAura(uint8 index, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo);
|
||||
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura, AuraType auraType, SpellInfo const* spellInfo);
|
||||
void SetRuneCooldown(uint8 index, uint32 cooldown);
|
||||
void RemoveRunesByAuraEffect(AuraEffect const* aura);
|
||||
void RestoreBaseRune(uint8 index);
|
||||
void ConvertRune(uint8 index, RuneType newType);
|
||||
void ResyncRunes(uint8 count) const;
|
||||
void AddRunePower(uint8 index) const;
|
||||
void ResyncRunes(uint8 count);
|
||||
void AddRunePower(uint8 mask);
|
||||
void InitRunes();
|
||||
|
||||
void SendRespondInspectAchievements(Player* player) const;
|
||||
|
||||
@@ -770,7 +770,7 @@ void Player::ApplyHealthRegenBonus(int32 amount, bool apply)
|
||||
|
||||
void Player::UpdateManaRegen()
|
||||
{
|
||||
if (getPowerType() == POWER_MANA)
|
||||
if (getPowerType() == POWER_MANA || getClass() == CLASS_DRUID)
|
||||
{
|
||||
// Mana regen from spirit
|
||||
float spirit_regen = OCTRegenMPPerSpirit();
|
||||
|
||||
@@ -4878,7 +4878,7 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode
|
||||
continue;
|
||||
if (!player->GetRuneCooldown(i))
|
||||
{
|
||||
player->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this);
|
||||
player->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this, GetAuraType(), GetSpellInfo());
|
||||
--runes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4800,6 +4800,7 @@ void Spell::TakeRunePower(bool didHit)
|
||||
|
||||
Player* player = m_caster->ToPlayer();
|
||||
m_runesState = player->GetRunesState(); // store previous state
|
||||
player->ClearLastUsedRuneMask();
|
||||
|
||||
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
|
||||
|
||||
@@ -4815,43 +4816,22 @@ void Spell::TakeRunePower(bool didHit)
|
||||
// - Death rune, originally a Frost rune
|
||||
// - Death rune, any kind
|
||||
runeCost[RUNE_DEATH] = 0; // calculated later
|
||||
|
||||
for (uint32 i = 0; i < MAX_RUNES; ++i)
|
||||
{
|
||||
RuneType rune = player->GetCurrentRune(i);
|
||||
if (!player->GetRuneCooldown(i) && runeCost[rune] > 0)
|
||||
{
|
||||
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true);
|
||||
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN));
|
||||
player->SetLastUsedRune(rune);
|
||||
player->SetLastUsedRuneIndex(i);
|
||||
runeCost[rune]--;
|
||||
}
|
||||
}
|
||||
|
||||
// Find a Death rune where the base rune matches the one we need
|
||||
runeCost[RUNE_DEATH] = runeCost[RUNE_BLOOD] + runeCost[RUNE_UNHOLY] + runeCost[RUNE_FROST];
|
||||
if (runeCost[RUNE_DEATH] > 0)
|
||||
{
|
||||
for (uint32 i = 0; i < MAX_RUNES; ++i)
|
||||
{
|
||||
RuneType rune = player->GetCurrentRune(i);
|
||||
RuneType baseRune = player->GetBaseRune(i);
|
||||
if (!player->GetRuneCooldown(i) && rune == RUNE_DEATH && runeCost[baseRune] > 0)
|
||||
{
|
||||
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN), true);
|
||||
player->SetLastUsedRune(rune);
|
||||
runeCost[baseRune]--;
|
||||
runeCost[rune]--;
|
||||
|
||||
// keep Death Rune type if missed
|
||||
if (didHit)
|
||||
player->RestoreBaseRune(i);
|
||||
|
||||
if (runeCost[RUNE_DEATH] == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Grab any Death rune
|
||||
if (runeCost[RUNE_DEATH] > 0)
|
||||
{
|
||||
for (uint32 i = 0; i < MAX_RUNES; ++i)
|
||||
@@ -4859,8 +4839,9 @@ 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), true);
|
||||
player->SetRuneCooldown(i, didHit ? player->GetRuneBaseCooldown(i) : uint32(RUNE_MISS_COOLDOWN));
|
||||
player->SetLastUsedRune(rune);
|
||||
player->SetLastUsedRuneIndex(i);
|
||||
runeCost[rune]--;
|
||||
|
||||
// keep Death Rune type if missed
|
||||
|
||||
Reference in New Issue
Block a user