WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Hunter pet low life & death alert + auto come back (https://www.wowinterface.com/forums/showthread.php?t=57928)

Yukka 04-11-20 05:14 AM

Hunter pet low life & death alert + auto come back
 
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 :D

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:
  1. function PetLowHPAlert_OnUpdate_default()
  2.     if (hpPct > 0.5) then
  3.      -- HP < 50%
  4.         LastHealth = 0
  5.         return
  6.     elseif (hpPct > 0.25) then
  7.         if (LastHealth == 0) then
  8.             if (sounds) then PlaySoundFile("Interface\\AddOns\\PetLowHPAlert\\50.mp3", "master") end
  9.         end
  10.         LastHealth = 1
  11.         return
  12.      -- HP < 0%
  13.     elseif (LastHealth ~= 2) then
  14.         if (sounds) then PlaySoundFile("Interface\\AddOns\\LowHPAlert\\0.mp3", "master") end
  15.     end
  16.     LastHealth = 2
  17. end


All times are GMT -6. The time now is 07:07 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI