Ok guys. Got some bit of code for you profile writers that do Hunter Profiles
Read over it and let me know what you think about it. It will most likely be used in KickmyDog's later release of his hunter profiles, not 100% sure though
Functions Code:
Code:
local petatt = {
16827, --Claw
17253, --Bite
49966 --Smack
}
function PQR_PetAttack(unit)
for i=1,#petatt do
local spell = select(2,GetSpellBookItemInfo(tostring(GetSpellInfo(petatt[i]))))
local range = IsSpellInRange(select(1,GetSpellInfo(petatt[i])),unit)
local spellCD = GetSpellCooldown(GetSpellInfo(petatt[i]))
if spell == 16827 and spellCD == 0 and range ~= 0 or nil then
return Claw
elseif spell == 17253 and spellCD == 0 and range ~= 0 or nil then
return Bite
elseif spell == 49966 and spellCD == 0 and range ~= 0 or nil then
return Smack
end
end
end
Ability Code:
Name: -- Pet Abilities --
SpellID: 0
Delay: 0
Code:
--Spell Known Checks
local knownGrowl = IsSpellKnown(2649,true)
local knownProwl = IsSpellKnown(24450,true)
local knownDash = IsSpellKnown(61684,true)
local knownCower = IsSpellKnown(1742,true)
--Spell Range Checks
local rangeGrowl = IsSpellInRange(select(1,GetSpellInfo(2649)),"Target")
--Target Checks
local petTarget = UnitIsEnemy("Target","Pet")
local pTarget = UnitExists("Target")
local isEnemy = UnitIsEnemy("Target","Player")
--Combat Checks
local inCombat = UnitAffectingCombat("Player")
local inCombatPet = UnitAffectingCombat("Pet")
--Misc
local petHealth = UnitHealth("Pet") / UnitHealthMax("Pet") * 100
local petFocus = 100 * UnitPower("Pet") / UnitPowerMax("Pet")
local petActive = HasPetSpells()
local PetAttack = PQR_PetAttack("Target")
local Prowl = UnitBuffID("Pet", 24450)
--Spell Checks
local petSlot4 = select(7,GetPetActionInfo(4))
local petSlot5 = select(7,GetPetActionInfo(5))
local petSlot6 = select(7,GetPetActionInfo(6))
local petSlot7 = select(7,GetPetActionInfo(7))
----Stance Locals
local Assist = select(5,GetPetActionInfo(8))
local Defensive = select(5,GetPetActionInfo(9))
local Passive = select(5,GetPetActionInfo(10))
--Puts Pet in Assist or Passive Mode Depending on Combat State.
if (inCombat and inCombatPet) == 1 then
if Assist == nil then
PetAssistMode()
end
elseif (inCombat and inCombatPet) == nil then
if Passive == nil then
PetPassiveMode()
end
end
--Toggles Active Pet Bar Abilities Off.
if petSlot4 ~= nil and (inCombat or inCombatPet) == nil and petActive ~= nil then
TogglePetAutocast(4)
end
if petSlot5 ~= nil and (inCombat or inCombatPet) == nil and petActive ~= nil then
TogglePetAutocast(5)
end
if petSlot6 ~= nil and (inCombat or inCombatPet) == nil and petActive ~= nil then
TogglePetAutocast(6)
end
if petSlot7 ~= nil and (inCombat or inCombatPet) == nil and petActive ~= nil then
TogglePetAutocast(7)
end
--Claw/Bite/Smack Code.
if petFocus > 90 and (inCombat or inCombatPet) ~= nil then
if PetAttack == Claw then
CastSpellByID(16827)
elseif PetAttack == Bite then
CastSpellByID(17253)
elseif PetAttack == Smack then
CastSpellByID(49966)
end
end
--Dash if far enough away from target.
if knownGrowl == true and knownDash == true and (inCombat or inCombatPet) ~= nil and rangeGrowl ~= 1 or nil then
CastSpellByID(61684)
end
--Prowl if not in combat.
if Prowl ~= nil then
return false
elseif (inCombat or inCombatPet) == nil and knownProwl == true then
CastSpellByID(24450)
end
--Cower if Pet Health is lower than 40%.
if petHealth < 40 and knownCower == true and Passive == nil then
CastSpellByID(1742)
PetPassiveMode()
end
Error free and works 100% ( I hope. From my testings, it was fully functional).
- Changelog:
- Turns all active Pet Bar Abilities off ( no check for abilities in Pet Spell-book)
- Puts Pet in Passive Mode and goes into Prowl (If Known by Pet) when not in combat.
- When in combat, automatically puts pet in assist mode
- When in combat, if the Player changes target's, the pet will Automatically switch to the Player's new Target.
- Will use Dash (if known by pet) to get to enemy quicker (Uses growl as range check, so will not use Dash if Growl not known).
- Will use Cower and put Pet in Passive Mode if Pet Health is lower than 40%.
- Uses Claw/Bite/Smash (Universal Over All Client's, Locales, and Pets!!) when pet Focus is above 90 and in Combat.
Feel free to use it in your profiles. +Rep appreciated if you use the code