Automatically Un/Equip Safari Hat (Outfitter)

100 Blood Elf Paladin
18885
UPDATED 12/19/12 TO WORK WITH BOTH WILD BATTLES AND PET TAMERS.**

Outfitter is required for this to work. If there is demand, I can make a tiny addon that does this too.

1. Open your Character Screen (C) and hit the Outfitter button in the top right to open Outfitter's panel.
2. At the bottom-right, click "New Outfit".
3. For the name, type in "Safari Hat" (or whatever). Leave Automation set to "None". Under "Build", make sure to select "Create Empty Outfit".
4. Now select your new outfit in the list (make sure it has a checkbox next to it) and drag your Safari Hat into the Helmet slot on your Character Sheet.
5. Click on the down arrow next to your new outfit's entry in the list and go to "Script (None)" --> "Custom ..." (under the Automation header) and click on it.
6. Copy the following code and paste it into the Script window. Then press Okay.
-- $EVENTS PLAYER_TARGET_CHANGED GOSSIP_CONFIRM PET_BATTLE_CLOSE
-- $DESC Equips your outfit when pet battling.

local tamerlist = { 66741, 66136, 66635, 65656, 66557, 66815, 66819, 68463, 66422, 66738, 66135, 66478, 66512, 66520, 66412, 65655, 66518, 66734, 68462, 66822, 66436, 66639, 66730, 67370, 64330, 66452, 66515, 65651, 66522, 66675, 66372, 66733, 66553, 66552, 66636, 66550, 66824, 66638, 65648, 66551, 66918, 63194, 66466, 68465, 66352, 66739, 68464, 66442, 66137, 66126, }

if event == "PLAYER_TARGET_CHANGED" then
if not InCombatLockdown() and HasFullControl() then
if UnitIsWildBattlePet("target") then
equip = true
elseif didEquip and not C_PetBattles.IsInBattle() then
equip = false
end
end
elseif event == "GOSSIP_CONFIRM" then
if UnitExists("target") and not InCombatLockdown() and HasFullControl() then
for i = 1, #tamerlist do
if tonumber(UnitGUID("target"):sub(6, 10), 16) == tamerlist[i] then equip = true break end
end
elseif not InCombatLockdown() and HasFullControl() then
equip = true
end
elseif event == "PET_BATTLE_CLOSE" then
equip = false
end


7. Lastly, select your normal outfit (so that the Safari Hat one gets unselected) and you're good to go.

** Note that this is not 100% perfect, only 99% perfect. Sometimes it will break and I don't want to over-complicate an already absurdly complicated script.
Edited by Simca on 12/19/2012 1:33 PM PST
Reply Quote
94 Draenei Shaman
19265
It's not working for me. Outfitter 5.7.
Reply Quote
100 Blood Elf Paladin
18885
12/12/2012 06:25 PMPosted by Kiamato
It's not working for me. Outfitter 5.7.


Hmm. Using same Outfitter version.

Let me try making it use a slightly different event, I think it might be trying to trigger the swap when your character does not have control yet (during battle intro sequence).
Reply Quote
90 Human Hunter
13645
They really just need to make the pet battle exp bonus just be an in the bags bonus like the Pandaren Mining Pick, etc.
Reply Quote
100 Blood Elf Paladin
18885
Derp. I fixed it now (added "HasFullControl()" check).

Should work perfect now. Might make an addon version anyway (friend is interested but does not want to learn Outfitter).
Edited by Simca on 12/12/2012 11:05 PM PST
Reply Quote
94 Draenei Shaman
19265
12/12/2012 09:54 PMPosted by Reinhilde
They really just need to make the pet battle exp bonus just be an in the bags bonus like the Pandaren Mining Pick, etc.


I agree. So many times I forgot to use the hat during pet battles and so many times I forgot to change the hat in a raid.
Reply Quote
94 Draenei Shaman
19265
I found the problem. On Outfitter there is an option "Disable automatic changes". Now it works.
Thank you.

P.S.
IMO Outfitter is better than Blizzard's feature.
Edited by Kiamato on 12/12/2012 11:19 PM PST
Reply Quote
100 Blood Elf Paladin
18885
Edit: Testing the Safari Hat itself now to make sure it works the way I think it works.

Edit 2: Hat works fine while weaing it normally, but with the outfitter swap it does not give bonus EXP. I can only guess I'm Unequipping it a second too late or maybe it has to be equipped for 100% of the fight.
Edited by Simca on 12/13/2012 12:15 AM PST
Reply Quote
94 Draenei Shaman
19265
It works now. Just need to uncheck "Disable automatic changes" option.
Reply Quote
100 Blood Elf Paladin
18885
Updated the Outfitter script in the OP to truly give the EXP bonus now (I had to adjust the time that it equips/unequips it). However, it only works for wild pets.

What I did is pretty outside the scope of Outfitter, so I'll make an addon for it separately later this week. Should be a neat project.
Edited by Simca on 12/13/2012 12:32 AM PST
Reply Quote
100 Gnome Warrior
12795
If you're writing an addon you may look into hooksecurefunc("TurnOrActionStart") or "TurnOrActionStop" to get the moment just before you "right click" a wild pet. So targeting a critter and then getting aggro beforehand won't equip a hat too soon (not that it should make a huge difference).

For those reluctant to install outfitter, this is a simple macro to toggle the hat:

/run local o,s=GetItemInfo(GetInventoryItemLink("player",1)) s=o~="Safari Hat" EquipItemByName(s and "Safari Hat" or OldHat) ShowHelm(s) OldHat=o

If a Safari Hat isn't worn, it equips it and turns the helm graphic on.
If it's not worn, it equips whatever you had previous and turns the helm graphic off.
Reply Quote
85 Orc Mage
13080
That's great. Thank you for this.
Reply Quote
100 Blood Elf Paladin
18885
12/13/2012 01:34 AMPosted by Ro
If you're writing an addon you may look into hooksecurefunc("TurnOrActionStart") or "TurnOrActionStop" to get the moment just before you "right click" a wild pet. So targeting a critter and then getting aggro beforehand won't equip a hat too soon (not that it should make a huge difference).


Hmm, interesting function but I'm not sure it does the job. It provides no arguments when hooked and after its execution it clears mouseover, so secure hooking it wouldn't be an option if I wanted to check mouseover + target (since you can initiate a pet battle without a mouseover by using the "interact with target" key and you can initiate a pet battle without a target by right-clicking before left-clicking).

I could just use a regular insecure hook (so I could get mouseover before that was called), but I always worry about using those on major game functions (such as this) because it could cause some obscure taint.
Edited by Simca on 12/13/2012 12:20 PM PST
Reply Quote
100 Gnome Warrior
12795
Sadly TurnOrActionStop et al aren't unsecurely hookable (without breaking stuff in a big way). The changes in 1.10 and 1.11 were some of my prouder accomplishments in the addon community.

You can work around it:
local f=CreateFrame("Frame")
f:Hide()
f:SetScript("OnUpdate",function(self)
if UnitName("mouseover") and UnitIsWildBattlePet("mouseover") then
print(UnitName("mouseover"),"is under the mouse.")
self:Hide()
end
end)
hooksecurefunc("TurnOrActionStop",function()
f:Show()
end)


But with interact with target and pet tamers, a more economical approach is probably fine.
Reply Quote
100 Blood Elf Paladin
18885
I've been busy with other addons so I haven't had time to convert this into one yet, but I just updated the script in the first post to now work with Wild Battle Pets AND Pet Tamers.

Update to the new script and enjoy 100% automated Safari Hat goodness!

Edit: Updated again 12/19/12. It works but is only 99% perfect. Working on an addon version for that reason.
Edited by Simca on 12/19/2012 1:34 PM PST
Reply Quote
88 Tauren Death Knight
7285
You may already be aware of it, but there's a mod that does something similar - Iron Chef. It would automatically equip your chef's hat if it was in your bag when the cooking window was opened. I know the mechanics of pet battles are different (and that mod hasn't been updated in a long time), but you might get some ideas on how to program the Safari Hat mod.
It's not on Curse anymore, but it's on WoW interface:
http://www.wowinterface.com/downloads/info14317-IronChef.html
Reply Quote
100 Blood Elf Paladin
18885
I actually did end up making this a week ago or so for myself, but I never published it because I was just so busy with my other two addons.

I should do that tonight.
Reply Quote
100 Blood Elf Paladin
18885
Published the addon today (well, actually over a day ago but Curse staff was busy because of New Years I'm sure).

Forum thread for the addon: http://us.battle.net/wow/en/forum/topic/7415156093

Curse link: http://www.curse.com/addons/wow/auto-safari-hat
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]