In case you want to unsummon your pet when entering stealth/prowl/camouflage:
lua Code:
local petName = "White Kitten"
local _, class = UnitClass("player")
local stealthBuff = class == "ROGUE" and GetSpellInfo(1784) -- Stealth
or class == "DRUID" and GetSpellInfo(5215) -- Prowl
or class == "HUNTER" and GetSpellInfo(51753) -- Camouflage
-- or class == "MAGE" and GetSpellInfo(66) -- Invisibility (not sure if minipet also turns invisible??)
local function CheckAndSummonPet()
if stealthBuff and UnitBuff("player", stealthBuff) and C_PetJournal.GetSummonedPetGUID() then
-- You have a stealth buff and you have a companion out.
DismissCompanion("CRITTER") -- I'm assuming this function still works and is available in combat??
return
end
if InCombatLockdown() then
-- You can't summon a pet in combat from insecure code.
return
end
if C_PetJournal.GetSummonedPetGUID() then
-- You already have a summoned pet.
return
end
local _, petGUID = C_PetJournal.FindPetIDByName(petName)
if petGUID then
-- Summon the desired pet:
C_PetJournal.SummonPetByGUID(petGUID)
end
end
hooksecurefunc("MoveBackwardStart", CheckAndSummonPet)
hooksecurefunc("MoveForwardStart", CheckAndSummonPet)
hooksecurefunc("StrafeLeftStart", CheckAndSummonPet)
hooksecurefunc("StrafeRightStart", CheckAndSummonPet)
Note: this is untested