Thread Tools Display Modes
07-11-10, 04:42 PM   #1
MaXiMiUS
A Murloc Raider
Join Date: Apr 2008
Posts: 9
Pet Leashing

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)

Last edited by MaXiMiUS : 07-11-10 at 04:54 PM.
  Reply With Quote
07-11-10, 04:55 PM   #2
Morwrath
A Murloc Raider
 
Morwrath's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 5
Exclamation

PetFollow() is a protected Blizzard function and can only be called by Blizzard UIs.
  Reply With Quote
07-11-10, 05:08 PM   #3
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
This is exactly why Blizzard has protected their functions like CastSpell and StopCasting. The AddOn you are wiring could be flagged as a botting AddOn of some sort. Blizzard does not want AddOns to make decisions for you. What you could do is write a range tracker for your pet to see how far away it is for you, so you can use the keybinding to call your pet back.
  Reply With Quote
07-11-10, 05:18 PM   #4
MaXiMiUS
A Murloc Raider
Join Date: Apr 2008
Posts: 9
Well.. for anyone looking for something similar to this, I figured out something that works decently through macros:

/petattack [nomod]
/petstay [nomod,noharm]
/petfollow [mod][nocombat]

How to use:
Target an enemy
Spam this macro until the enemy is dead

What this will do:
Your pet will go over to the enemy and kill it, then STAY there (but only if you're still in combat), and not run back to you.

How to recall your pet if you want them to follow you again:
Just activate this macro with any modifier (ie: shift).

I also don't entirely understand the reasoning behind protecting PetFollow/PetWait, there are tons of addons that "make decisions for you", those two functions don't really seem any more like botting than, say, QuestHelper, or any reasonably advanced macro. Protecting PetAttack, sure, that makes sense I guess, but PetFollow/PetWait? That's just silly.

Last edited by MaXiMiUS : 07-11-10 at 05:50 PM.
  Reply With Quote
07-11-10, 05:29 PM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
An AddOn could partially control your pet with it. Blizzard wants YOU to look after your pet. As a hunter you should love your pet to internity and not let an AddOn decide if it needs to be withdrawn out of a fire or not. Imagine a 0.05% wipe on a boss if your pet was called back by you... Would you really not want your cute Mazzranache deal the killing blow and die after that?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Pet Leashing

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