View Single Post
03-11-13, 02:42 PM   #9
jlrm365
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 113
Originally Posted by ravagernl View Post
In case you want to unsummon your pet when entering stealth/prowl/camouflage:

lua Code:
  1. local petName = "White Kitten"
  2.  
  3. local _, class = UnitClass("player")
  4. local stealthBuff = class == "ROGUE" and GetSpellInfo(1784) -- Stealth
  5.     or class == "DRUID" and GetSpellInfo(5215) -- Prowl
  6.     or class == "HUNTER" and GetSpellInfo(51753) -- Camouflage
  7. --  or class == "MAGE" and GetSpellInfo(66) -- Invisibility (not sure if minipet also turns invisible??)
  8.  
  9. local function CheckAndSummonPet()
  10.     if stealthBuff and UnitBuff("player", stealthBuff) and C_PetJournal.GetSummonedPetGUID() then
  11.         -- You have a stealth buff and you have a companion out.
  12.         DismissCompanion("CRITTER") -- I'm assuming this function still works and is available in combat??
  13.         return
  14.     end
  15.    
  16.     if InCombatLockdown() then
  17.         -- You can't summon a pet in combat from insecure code.
  18.         return
  19.     end
  20.  
  21.     if C_PetJournal.GetSummonedPetGUID() then
  22.         -- You already have a summoned pet.
  23.         return
  24.     end
  25.  
  26.     local _, petGUID = C_PetJournal.FindPetIDByName(petName)
  27.     if petGUID then
  28.         -- Summon the desired pet:
  29.         C_PetJournal.SummonPetByGUID(petGUID)
  30.     end
  31. end
  32.  
  33. hooksecurefunc("MoveBackwardStart", CheckAndSummonPet)
  34. hooksecurefunc("MoveForwardStart", CheckAndSummonPet)
  35. hooksecurefunc("StrafeLeftStart", CheckAndSummonPet)
  36. hooksecurefunc("StrafeRightStart", CheckAndSummonPet)
Note: this is untested
Cool.
I've got the latest from Phanx in my folder.
I'll see how that goes and then try yours out another time.
If you happen to test it yourself, in the meantime, please do let us know how it went.

Thanks for the contribution, as that appears to be a nice tweak.
  Reply With Quote