C_PetBattles.GetAttackModifier() wants the ability type, not the pet type. Blizzard's code is a bit confusing because they've named the var petType
For example,
Code:
function DumpAbilityStrengths()
local activePetSlot = C_PetBattles.GetActivePet(LE_BATTLE_PET_ALLY)
local enemyPetSlot = C_PetBattles.GetActivePet(LE_BATTLE_PET_ENEMY)
local enemyType = C_PetBattles.GetPetType(LE_BATTLE_PET_ENEMY, enemyPetSlot)
for i=1,3 do -- only need to check the first 3 buttons
local abilityName, abilityType, noHints
_, abilityName, _, _, _, _, abilityType, noHints = C_PetBattles.GetAbilityInfo(LE_BATTLE_PET_ALLY, activePetSlot, i)
if(noHints) then
print(abilityName .. " has no modifier")
else
local modifier = C_PetBattles.GetAttackModifier(abilityType, enemyType)
if(modifier < 1) then
print(abilityName .. " is weak against enemy")
elseif(modifier > 1) then
print(abilityName .. " is strong against enemy")
else
print(abilityName .. " is normal strength against enemy")
end
end
end
end