I don't play hunter, so I'm not quite sure if a dead pet is a 'corpse' (zero health, would trigger UNIT_HEALTH) or despawns (no longer exists, would trigger UNIT_PET).
This code is just a guess -- I haven't tested it -- to cover both possible cases.
Lua Code:
local f = CreateFrame("Frame")
f:RegisterUnitEvent("UNIT_HEALTH", "pet")
f:RegisterUnitEvent("UNIT_PET", "player")
f:SetScript("OnEvent", function()
if not UnitExists("pet") or UnitHealth("pet") == 0 then
PlaySound(SOUNDKIT.LOOT_WINDOW_COIN_SOUND)
end
end)
Change the soundkit for something on this list (I just took the first one):
https://github.com/Gethe/wow-ui-sour...tConstants.lua