Quantcast WoWInterface - View Single Post - Battle Pet revive / bandage macro
View Single Post
01-23-16, 06:42 PM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Paste this into addon.bool.no to create an addon:
Lua Code:
  1. local button, REVIVE_BATTLE_PETS = CreateFrame('button', 'SmartRez', nil, 'SecureActionButtonTemplate'), GetSpellInfo(125439)
  2. button:SetAttribute('type', 'macro')
  3. button:SetScript('PreClick', function(self)
  4.     if InCombatLockdown() then return end
  5.    
  6.     local injured = false
  7.     for i = 1, 3 do -- Determine whether any pet in our loadout is actually injured
  8.         local guid = C_PetJournal.GetPetLoadOutInfo(i)
  9.         if guid then
  10.             local health, maxHealth = C_PetJournal.GetPetStats(guid)
  11.             if health < maxHealth then
  12.                 injured = true
  13.                 break
  14.             end
  15.         end
  16.     end
  17.     if not injured then
  18.         DEFAULT_CHAT_FRAME:AddMessage('Pets are already at full health!', 1, 1, 0)
  19.         self:SetAttribute('macrotext', nil)
  20.         return
  21.     end
  22.    
  23.     if GetSpellCooldown(125439) == 0 then -- "Revive Battle Pets" is off cooldown, cast that
  24.         self:SetAttribute('macrotext', '/cast ' .. REVIVE_BATTLE_PETS)
  25.     else
  26.         self:SetAttribute('macrotext', '/use item:86143')
  27.     end
  28. end)

Once you've loaded that, make a macro like this to use it:
Lua Code:
  1. #showtooltip Revive Battle Pets
  2. /click [nocombat] SmartRez
  3. /cast [combat] Revive Battle Pets

It will use the spell if it's off cooldown or if you're in combat, otherwise it will use a bandage. I'm not going to bother including code to update the icon based on what it's going to cast since it's largely unnecessary and probably more useful to see the remaining cooldown of Revive Battle Pets instead.

Last edited by semlar : 01-23-16 at 07:00 PM.
  Reply With Quote