3 Commits
Author SHA1 Message Date
luis 7708d53437 sniff 2026-11-02 19:20:01 -03:00
luis b6401479fe sniff data omnium folio 2026-11-02 12:33:05 -03:00
luis be8abea2a1 Core/Auras: Implemented new spell attribute for tracking each aura stack duration separately 2026-11-02 12:29:51 -03:00
7 changed files with 973 additions and 10 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -96,7 +96,7 @@ public:
void shrink_to_fit() { _storage.shrink_to_fit(); }
friend std::strong_ordering operator<=>(FlatSet const& left, FlatSet const& right) = default;
friend auto operator<=>(FlatSet const& left, FlatSet const& right) { return left <=> right; }
friend bool operator==(FlatSet const& left, FlatSet const& right) = default;
private:
@@ -998,7 +998,7 @@ enum SpellAttr15 : uint32
SPELL_ATTR15_UNK7 = 0x00000080, // TITLE Unknown attribute 7@Attr15
SPELL_ATTR15_UNK8 = 0x00000100, // TITLE Unknown attribute 8@Attr15
SPELL_ATTR15_UNK9 = 0x00000200, // TITLE Unknown attribute 9@Attr15
SPELL_ATTR15_UNK10 = 0x00000400, // TITLE Unknown attribute 10@Attr15
SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS = 0x00000400, // TITLE Aura has separate stack durations
SPELL_ATTR15_UNK11 = 0x00000800, // TITLE Unknown attribute 11@Attr15
SPELL_ATTR15_UNK12 = 0x00001000, // TITLE Unknown attribute 12@Attr15
SPELL_ATTR15_UNK13 = 0x00002000, // TITLE Unknown attribute 13@Attr15
@@ -2222,7 +2222,7 @@ namespace Trinity::Impl::EnumUtilsImpl
case SPELL_ATTR15_UNK7: return { "SPELL_ATTR15_UNK7", "Unknown attribute 7@Attr15", "" };
case SPELL_ATTR15_UNK8: return { "SPELL_ATTR15_UNK8", "Unknown attribute 8@Attr15", "" };
case SPELL_ATTR15_UNK9: return { "SPELL_ATTR15_UNK9", "Unknown attribute 9@Attr15", "" };
case SPELL_ATTR15_UNK10: return { "SPELL_ATTR15_UNK10", "Unknown attribute 10@Attr15", "" };
case SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS: return { "SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS", "Aura has separate stack durations", "" };
case SPELL_ATTR15_UNK11: return { "SPELL_ATTR15_UNK11", "Unknown attribute 11@Attr15", "" };
case SPELL_ATTR15_UNK12: return { "SPELL_ATTR15_UNK12", "Unknown attribute 12@Attr15", "" };
case SPELL_ATTR15_UNK13: return { "SPELL_ATTR15_UNK13", "Unknown attribute 13@Attr15", "" };
@@ -2266,7 +2266,7 @@ namespace Trinity::Impl::EnumUtilsImpl
case 7: return SPELL_ATTR15_UNK7;
case 8: return SPELL_ATTR15_UNK8;
case 9: return SPELL_ATTR15_UNK9;
case 10: return SPELL_ATTR15_UNK10;
case 10: return SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS;
case 11: return SPELL_ATTR15_UNK11;
case 12: return SPELL_ATTR15_UNK12;
case 13: return SPELL_ATTR15_UNK13;
@@ -2307,7 +2307,7 @@ namespace Trinity::Impl::EnumUtilsImpl
case SPELL_ATTR15_UNK7: return 7;
case SPELL_ATTR15_UNK8: return 8;
case SPELL_ATTR15_UNK9: return 9;
case SPELL_ATTR15_UNK10: return 10;
case SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS: return 10;
case SPELL_ATTR15_UNK11: return 11;
case SPELL_ATTR15_UNK12: return 12;
case SPELL_ATTR15_UNK13: return 13;
+70 -4
View File
@@ -495,8 +495,10 @@ m_lastProcAttemptTime(GameTime::Now() - Seconds(10)), m_lastProcSuccessTime(Game
m_timeCla = 1 * IN_MILLISECONDS;
}
m_maxDuration = CalcMaxDuration(createInfo.Caster);
m_duration = m_maxDuration;
m_maxDuration = CalcMaxDuration(createInfo.Caster);
m_duration = m_maxDuration;
if (GetSpellInfo()->HasAttribute(SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS))
m_stackDropTimes.insert({ .DropTime = GameTime::Now() + Milliseconds(m_maxDuration), .StackAmount = m_stackAmount });
m_procCharges = CalcMaxCharges(createInfo.Caster);
m_isUsingCharges = m_procCharges != 0;
// m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
@@ -879,6 +881,17 @@ void Aura::Update(uint32 diff, Unit* caster)
if (m_duration < 0)
m_duration = 0;
if (!IsExpired() && !m_stackDropTimes.empty())
{
TimePoint now = GameTime::Now();
auto itr = m_stackDropTimes.begin();
while (itr != m_stackDropTimes.end() && itr->DropTime <= now)
{
ModStackAmount(-itr->StackAmount, AURA_REMOVE_BY_EXPIRE); // erases from m_stackDropTimes
itr = m_stackDropTimes.begin();
}
}
// handle manaPerSecond/manaPerSecondPerLevel
if (m_timeCla)
{
@@ -965,6 +978,9 @@ void Aura::SetDuration(int32 duration, bool withMods)
modOwner->ApplySpellMod(GetSpellInfo(), SpellModOp::Duration, duration);
m_duration = duration;
if (GetSpellInfo()->HasAttribute(SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS))
SetLastStackDuration(duration);
SetNeedClientUpdateForTargets();
}
@@ -1010,6 +1026,42 @@ void Aura::RefreshTimers(bool resetPeriodicTimer)
aurEff->CalculatePeriodic(caster, resetPeriodicTimer, false);
}
void Aura::AddStackDropTime(TimePoint dropTime, int32 stacks)
{
auto [itr, isNew] = m_stackDropTimes.insert({ .DropTime = dropTime, .StackAmount = stacks });
if (!isNew)
itr->StackAmount += stacks;
}
void Aura::RemoveStackDropTime(int32 stacksToRemove)
{
do
{
auto oldestStacksItr = m_stackDropTimes.begin();
if (stacksToRemove < oldestStacksItr->StackAmount)
{
oldestStacksItr->StackAmount -= stacksToRemove;
stacksToRemove = 0;
}
else
{
stacksToRemove -= oldestStacksItr->StackAmount;
m_stackDropTimes.erase(oldestStacksItr);
}
} while (stacksToRemove > 0);
}
void Aura::SetLastStackDuration(int32 duration)
{
if (m_stackDropTimes.empty())
return;
auto latestStacksItr = m_stackDropTimes.begin() + (std::ssize(m_stackDropTimes) - 1);
int32 stackAmount = latestStacksItr->StackAmount;
m_stackDropTimes.erase(latestStacksItr);
AddStackDropTime(GameTime::Now() + Milliseconds(duration), stackAmount);
}
void Aura::SetCharges(uint8 charges)
{
if (m_procCharges == charges)
@@ -1111,7 +1163,8 @@ uint32 Aura::CalcMaxStackAmount() const
bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode /*= AURA_REMOVE_BY_DEFAULT*/, bool resetPeriodicTimer /*= true*/)
{
int32 stackAmount = m_stackAmount + num;
int32 oldStackAmount = m_stackAmount;
int32 stackAmount = oldStackAmount + num;
int32 maxStackAmount = int32(CalcMaxStackAmount());
// limit the stack amount (only on stack increase, stack amount may be changed manually)
@@ -1130,11 +1183,24 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode /*= AURA_REMOVE_B
return true;
}
bool refresh = stackAmount >= GetStackAmount() && (m_spellInfo->StackAmount || (!m_spellInfo->HasAttribute(SPELL_ATTR1_AURA_UNIQUE) && !m_spellInfo->HasAttribute(SPELL_ATTR5_AURA_UNIQUE_PER_CASTER)));
bool refresh = stackAmount >= oldStackAmount && (m_spellInfo->StackAmount || (!m_spellInfo->HasAttribute(SPELL_ATTR1_AURA_UNIQUE) && !m_spellInfo->HasAttribute(SPELL_ATTR5_AURA_UNIQUE_PER_CASTER)));
// Update stack amount
SetStackAmount(stackAmount);
if (GetSpellInfo()->HasAttribute(SPELL_ATTR15_AURA_HAS_SEPARATE_STACK_DURATIONS))
{
if (num > 0)
{
AddStackDropTime(GameTime::Now() + Milliseconds(m_maxDuration), std::clamp(num, 1, maxStackAmount));
int32 overflowStacks = oldStackAmount + num - stackAmount;
if (overflowStacks > 0)
RemoveStackDropTime(overflowStacks);
}
else
RemoveStackDropTime(-num);
}
if (refresh)
{
RefreshTimers(resetPeriodicTimer);
+14 -1
View File
@@ -166,6 +166,14 @@ struct AuraLoadEffectInfo
std::array<SpellEffectValue, MAX_SPELL_EFFECTS> BaseAmounts;
};
struct AuraStackDropInfo
{
TimePoint DropTime;
int32 StackAmount;
friend std::strong_ordering operator<=>(AuraStackDropInfo const& left, AuraStackDropInfo const& right) { return left.DropTime <=> right.DropTime; }
};
class TC_GAME_API Aura
{
friend class Unit;
@@ -228,6 +236,10 @@ class TC_GAME_API Aura
bool IsExpired() const { return !GetDuration() && !m_dropEvent; }
bool IsPermanent() const { return GetMaxDuration() == -1; }
void AddStackDropTime(TimePoint dropTime, int32 stacks);
void RemoveStackDropTime(int32 stacksToRemove);
void SetLastStackDuration(int32 duration);
uint8 GetCharges() const { return m_procCharges; }
void SetCharges(uint8 charges);
uint8 CalcMaxCharges(Unit* caster) const;
@@ -406,8 +418,9 @@ class TC_GAME_API Aura
int32 m_maxDuration; // Max aura duration
int32 m_duration; // Current time
int32 m_timeCla; // Timer for power per sec calcultion
Trinity::Containers::FlatSet<AuraStackDropInfo> m_stackDropTimes;
std::vector<SpellPowerEntry const*> m_periodicCosts;// Periodic costs
int32 m_timeCla; // Timer for power per sec calculation
int32 m_updateTargetMapInterval; // Timer for UpdateTargetMapOfEffect
uint8 const m_casterLevel; // Aura level (store caster level for correct show level dep amount)