View Single Post
04-11-20, 05:14 AM   #1
Yukka
A Theradrim Guardian
 
Yukka's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 60
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

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
  Reply With Quote