Quantcast
Hunter pet low life & death alert + auto come back - WoWInterface
Thread Tools Display Modes
04-11-20, 05:14 AM   #1
Yukka
A Deviate Faerie Dragon
 
Yukka's Avatar
Join Date: Feb 2020
Posts: 17
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
__________________
Don't mind me I'm a noob
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hunter pet low life & death alert + auto come back

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off