I'm trying to figure out a way to keep my Hunter pet at a reasonable distance (35-45 yards) while I'm fighting. I thought I could use these functions if I called it from a hotkey, but apparently not.
This is the code I have currently, it doesn't work due to protected function calls
Code:
local PetLeash = LibStub("AceAddon-3.0"):NewAddon("PetLeash")
local HasPetAttacked = false
local IsPetAttacking = false
local InCombat = false
function PetLeash:OnInitialize()
end
function PetLeash:OnEnable()
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PET_ATTACK_START")
self:RegisterEvent("PET_ATTACK_STOP")
end
function PetLeash:OnDisable()
end
function PetLeash:PLAYER_REGEN_ENABLED()
HasPetAttacked = false
InCombat = false
end
function PetLeash:PLAYER_REGEN_DISABLED()
InCombat = true
end
function PetLeash:PET_ATTACK_START()
HasPetAttacked = true
IsPetAttacking = true
end
function PetLeash:PET_ATTACK_STOP()
IsPetAttacking = false
end
SLASH_PETLEASH1, SLASH_PETLEASH2 = '/petleash', '/leash'
SlashCmdList["PETLEASH"] =
function(msg, editbox)
if InCombat then
if (not IsSpellInRange("Mend Pet", "pet")) or (not IsPetAttacking) then
PetFollow() -- Pet is out of range or hasn't attacked yet, tell pet to follow
elseif HasPetAttacked then
PetWait() -- Pet has attacked and is still in combat, tell pet to stay there
end
else
PetFollow() -- Tell pet to follow out of combat
end
end
Is there any way to do something like this? I'm sick of the idiotic movement patterns my pet chooses (running back to me after every single kill, and chasing mobs 100 yards away like an idiot)