remove spellId from duration events as it isn't accessible yet

This commit is contained in:
avitasia
2026-02-09 12:54:53 -08:00
parent 983ea93c71
commit 5ee9e492a4
3 changed files with 3870 additions and 3878 deletions
+7 -6
View File
@@ -251,6 +251,8 @@ end
### BUFF_UPDATE_DURATION_SELF and DEBUFF_UPDATE_DURATION_SELF
Fire when the client updates the duration of a buff or debuff on the active player. This happens when the server refreshes an aura's duration (e.g., reapplying a buff that already exists). Only fires for the active player's own auras.
**Note:** This event fires before the aura is actually added to the unit fields, so for newly added auras the spellId will not yet be present in the unit data at the time of the event. Use the BUFF/DEBUFF_ADDED_SELF events or `GetPlayerAuraDuration(auraSlot)` after the aura is applied to look up the spellId.
Events:
```
BUFF_UPDATE_DURATION_SELF -- aura slot 0-31
@@ -259,18 +261,17 @@ DEBUFF_UPDATE_DURATION_SELF -- aura slot 32-47
Parameters:
1. int auraSlot - the raw 0-based aura slot index (0-31 for buffs, 32-47 for debuffs). This is not the slot used by GetPlayerBuff that has its own sorting, this is the raw aura slot index which is consistent with the unit data fields and the internal aura storage.
2. int spellId - the spell ID occupying this aura slot
3. int durationMs - the updated duration in milliseconds
4. int expirationTimeMs - the calculated expiration time (GetWowTimeMs() + durationMs), or 0 if no duration
2. int durationMs - the updated duration in milliseconds
3. int expirationTimeMs - the calculated expiration time (GetWowTimeMs() + durationMs), or 0 if no duration
Example:
```lua
local function onDurationUpdate(auraSlot, spellId, durationMs, expirationTimeMs)
local function onDurationUpdate(auraSlot, durationMs, expirationTimeMs)
local isBuff = auraSlot < 32
local type = isBuff and "Buff" or "Debuff"
DEFAULT_CHAT_FRAME:AddMessage(string.format(
"[%s] slot=%d spell=%d duration=%dms expires=%d",
type, auraSlot, spellId, durationMs, expirationTimeMs
"[%s] slot=%d duration=%dms expires=%d",
type, auraSlot, durationMs, expirationTimeMs
))
end
+3851 -3851
View File
File diff suppressed because it is too large Load Diff
+12 -21
View File
@@ -133,35 +133,26 @@ namespace Nampower {
void CGBuffBar_UpdateDurationHook(hadesmem::PatchDetourBase *detour, uint8_t auraSlot, int durationMs) {
auto const updateDuration = detour->GetTrampolineT<CGBuffBar_UpdateDurationT>();
// Call the original function
updateDuration(auraSlot, durationMs);
// Store expiration time indexed by aura slot
if (auraSlot < MAX_AURA_SLOTS) {
auto now = static_cast<uint32_t>(GetWowTimeMs() & 0xFFFFFFFF);
uint32_t expirationTime = durationMs > 0 ? now + durationMs : 0;
gAuraExpirationTime[auraSlot] = expirationTime;
// Get player unit to read spellId from aura fields
auto playerGuid = game::ClntObjMgrGetActivePlayerGuid();
auto *playerUnit = game::GetObjectPtr(playerGuid);
if (playerUnit) {
auto *unitFields = *reinterpret_cast<game::UnitFields **>(playerUnit + 68);
uint32_t spellId = unitFields->aura[auraSlot];
bool isBuff = auraSlot < 32;
game::Events eventToTrigger = isBuff ? game::BUFF_UPDATE_DURATION_SELF : game::DEBUFF_UPDATE_DURATION_SELF;
bool isBuff = auraSlot < 32;
game::Events eventToTrigger = isBuff ? game::BUFF_UPDATE_DURATION_SELF : game::DEBUFF_UPDATE_DURATION_SELF;
static char format[] = "%d%d%d%d";
((int (__cdecl *)(int, char *, uint32_t, uint32_t, int, uint32_t)) Offsets::SignalEventParam)(
eventToTrigger,
format,
auraSlot,
spellId,
durationMs,
expirationTime);
}
static char format[] = "%d%d%d";
((int (__cdecl *)(int, char *, uint32_t, int, uint32_t)) Offsets::SignalEventParam)(
eventToTrigger,
format,
auraSlot,
durationMs,
expirationTime);
}
// Call the original function
updateDuration(auraSlot, durationMs);
}
void UnitCombatLogUnitDeadHook(hadesmem::PatchDetourBase *detour, uint64_t guid) {