View Single Post
03-11-13, 02:28 PM   #8
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
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

Last edited by ravagernl : 03-11-13 at 02:39 PM. Reason: Fail!
  Reply With Quote