View Single Post
04-30-21, 10:00 AM   #2
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
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:
  1. local f = CreateFrame("Frame")
  2. f:RegisterUnitEvent("UNIT_HEALTH", "pet")
  3. f:RegisterUnitEvent("UNIT_PET", "player")
  4. f:SetScript("OnEvent", function()
  5.   if not UnitExists("pet") or UnitHealth("pet") == 0 then
  6.     PlaySound(SOUNDKIT.LOOT_WINDOW_COIN_SOUND)
  7.   end
  8. end)

Change the soundkit for something on this list (I just took the first one):
https://github.com/Gethe/wow-ui-sour...tConstants.lua
  Reply With Quote