include spellId in UPDATE_DURATION events to indicate refreshes

fix guid in GetCastInfo
This commit is contained in:
avitasia
2026-02-10 20:54:49 -08:00
parent b45185317c
commit a7d2cd4fa6
7 changed files with 4046 additions and 4035 deletions
+6 -4
View File
@@ -278,7 +278,7 @@ 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.
**Note:** This event fires before the aura is actually added to the unit fields, so for newly added auras the spellId will be 0. It will only have a value for auras that are being refreshed (i.e., the aura already exists in the slot). Use the BUFF/DEBUFF_ADDED_SELF events for tracking newly applied auras.
Events:
```
@@ -290,15 +290,17 @@ 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 durationMs - the updated duration in milliseconds
3. int expirationTimeMs - the calculated expiration time (GetWowTimeMs() + durationMs), or 0 if no duration
4. int spellId - the spell ID of the aura in this slot. Will be 0 for newly added buffs/debuffs (the slot hasn't been populated yet). Will only have a value for refreshed auras that already exist in the slot.
Example:
```lua
local function onDurationUpdate(auraSlot, durationMs, expirationTimeMs)
local function onDurationUpdate(auraSlot, durationMs, expirationTimeMs, spellId)
local isBuff = auraSlot < 32
local type = isBuff and "Buff" or "Debuff"
local refreshed = spellId > 0
DEFAULT_CHAT_FRAME:AddMessage(string.format(
"[%s] slot=%d duration=%dms expires=%d",
type, auraSlot, durationMs, expirationTimeMs
"[%s] slot=%d duration=%dms expires=%d spellId=%d refreshed=%s",
type, auraSlot, durationMs, expirationTimeMs, spellId, tostring(refreshed)
))
end
+1 -1
View File
@@ -760,7 +760,7 @@ A Lua table reference with the following fields, or nil if no cast is active:
- `castId` (number): Unique identifier for this cast
- `spellId` (number): The spell ID being cast
- `guid` (number): Target GUID (0 if no explicit target)
- `guid` (string): Target GUID as a hex string e.g. "0x0000000000000000" ("0x0000000000000000" if no explicit target)
- `castType` (number): Type of cast - 0=NORMAL, 3=CHANNEL, 4=TARGETING
- `castStartS` (number): When the cast started in WoW time (seconds with decimals, e.g., 1234567.890)
- `castEndS` (number): When the cast will end in WoW time (seconds with decimals)
+4023 -4023
View File
File diff suppressed because it is too large Load Diff
+11 -3
View File
@@ -147,13 +147,21 @@ namespace Nampower {
bool isBuff = auraSlot < 32;
game::Events eventToTrigger = isBuff ? game::BUFF_UPDATE_DURATION_SELF : game::DEBUFF_UPDATE_DURATION_SELF;
static char format[] = "%d%d%d";
((int (__cdecl *)(int, char *, uint32_t, int, uint32_t)) Offsets::SignalEventParam)(
auto playerUnit = game::GetObjectPtr(game::ClntObjMgrGetActivePlayerGuid());
uint32_t spellId = 0;
if (playerUnit) {
auto *unitFields = *reinterpret_cast<game::UnitFields **>(playerUnit + 68);
spellId = unitFields->aura[auraSlot];
}
static char format[] = "%d%d%d%d";
((int (__cdecl *)(int, char *, uint32_t, int, uint32_t, uint32_t)) Offsets::SignalEventParam)(
eventToTrigger,
format,
auraSlot,
durationMs,
expirationTime);
expirationTime,
spellId);
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Nampower {
constexpr uint32_t DISENCHANT_QUALITY_PURPLE = 0x04; // Epic
constexpr uint32_t MAJOR_VERSION = 2;
constexpr uint32_t MINOR_VERSION = 32;
constexpr uint32_t MINOR_VERSION = 33;
constexpr uint32_t PATCH_VERSION = 0;
constexpr int32_t LUA_REGISTRYINDEX = -10000;
+1 -1
View File
@@ -140,7 +140,7 @@ namespace Nampower {
// Add fields to table
PushTableValue(luaState, LuaFields::castId, castParams->castId);
PushTableValue(luaState, LuaFields::spellId, castParams->spellId);
PushTableValue(luaState, LuaFields::guid, castParams->guid);
PushTableValue(luaState, LuaFields::guid, ConvertGuidToString(castParams->guid));
PushTableValue(luaState, LuaFields::castType, static_cast<uint32_t>(castParams->castType));
PushTableValue(luaState, LuaFields::castStartS, castStartTimeWow);
PushTableValue(luaState, LuaFields::castEndS, castEndTimeWow);
+3 -2
View File
@@ -496,6 +496,7 @@ namespace Nampower {
}
auto const currentTargetGuid = game::GetCurrentTargetGuid();
auto const guidForHistory = (guid != 0) ? guid : currentTargetGuid;
if (spellIsChanneling) {
auto casterGuid = game::UnitGetGuid(casterUnit);
@@ -554,7 +555,7 @@ namespace Nampower {
currentTime, ON_SWING, 0);
gCastHistory.pushFront({
gNextCastId, casterUnit, spellId, item, guid,
gNextCastId, casterUnit, spellId, item, guidForHistory,
spell->StartRecoveryCategory,
castTime,
currentTime,
@@ -824,7 +825,7 @@ namespace Nampower {
}
gCastHistory.pushFront({
gNextCastId, casterUnit, spellId, item, guid,
gNextCastId, casterUnit, spellId, item, guidForHistory,
spell->StartRecoveryCategory,
castTime,
currentTime,