Hello everyone,
I play hunter and I'm trying to do an addon that alerts me with a sound when my pet have low life or is dead. Here is what I already did but as usual it dont work so I come towards you crying for help
I would like to play a sound when the pet has 50% life and another sound when he has 0% life (dead).
I also wish my pet automaticaly come back to me when he is too far from me, like 80 meters. Is this possible?
Lua Code:
function PetLowHPAlert_OnUpdate_default()
if (hpPct > 0.5) then
-- HP < 50%
LastHealth = 0
return
elseif (hpPct > 0.25) then
if (LastHealth == 0) then
if (sounds) then PlaySoundFile("Interface\\AddOns\\PetLowHPAlert\\50.mp3", "master") end
end
LastHealth = 1
return
-- HP < 0%
elseif (LastHealth ~= 2) then
if (sounds) then PlaySoundFile("Interface\\AddOns\\LowHPAlert\\0.mp3", "master") end
end
LastHealth = 2
end