All player GUIDs are unique and do not change as long as the character does not change faction or realm. I'm pretty sure they stick if you only name change, but I could be wrong.
All other GUIDs are designated on spawn. Every single object, item, npc, anything else in the game receives a unique GUID upon spawn, including your pet, since it's a controllable npc. When your pet disappears, it will get a new GUID when you see it again.
Use the event UNIT_PET with the first arg being "player" to get the new GUID each time.
Also, you were missing an end, you need to make playerGUID and petGUID a local to prevent other addons from changing them, and the entering world event has login and reload boolean payloads so you don't have to unregister that event.
Lua Code:
local playerGUID, petGUID
local function DummyFrame_OnEvent(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then
local login, reload = ...
if login or reload then
playerGUID = UnitGUID("player")
petGUID = UnitGUID("pet")
end
elseif event == "UNIT_PET" then
local unit = ...
if unit == "player" then
petGUID = UnitGUID("pet")
end
elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
local timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = CombatLogGetCurrentEventInfo()
if (sourceGUID == playerGUID or sourceGUID == petGUID) and (destGUID ~= petGUID) and (destGUID ~= playerGUID) then
print("sourceGUID "..sourceGUID)
print("destGUID "..destGUID)
print(timestamp.."|n")
end
end
end
DummyFrame:SetScript("OnEvent", DummyFrame_OnEvent)