WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How do I get a spec's weapon skills? (https://www.wowinterface.com/forums/showthread.php?t=59439)

pasiv 01-06-23 11:59 PM

How do I get a spec's weapon skills?
 
I'm trying to make an addon to help equip gearSets, and it seems to work, except that it will try to equip items that the current spec can't actually equip. For armor, I'm just getting the subclass of the item with GetItemInfo(itemId) and comparing it to a kind of comparison table. I only did it that way because I was trying to get a working prototype, but I don't think that method is viable when it comes to weapon subtypes vs spec.

Does anyone have a solution for me, please? I suppose the underlying question here is, how do I check if an item is actually able to be equipped by the player with the current class and spec?

briskman3000 01-07-23 12:43 AM

IsEquippableItem() will tell you if you can equip something.

pasiv 01-07-23 01:23 AM

Hmmm... That sort of solves part of my problem, but not completely.

According to this https://wowpedia.fandom.com/wiki/API_IsEquippableItem

An that will return true even if you're on a class that doesn't meet the requirements. So like a piece of plate armor is technically an equippable item, but you can't actually equip it if you're a druid.

briskman3000 01-07-23 03:48 AM

Well that's just a dumb api call then.

You can use the item subclassID from GetItemInfo() on weapons too, if you go the way of building hard coded comparison tables as the 13th output from that call does output a valid ID number to use with Enum.ItemWeaponSubclass

pasiv 01-07-23 06:05 AM

haha damn. I was afraid it would come to that.

Xrystal 01-07-23 09:18 AM

This one looks interesting but might be for a specific use
https://wowpedia.fandom.com/wiki/API...ValidForPlayer

And this one sounds useful and might be what you need
https://wowpedia.fandom.com/wiki/API...cToPlayerClass

This function is used on Weekly Rewards by Blizzard
https://github.com/Gethe/wow-ui-sour...wards.lua#L347


Might be easier than building a database of data up .. but if you have already done that keep this for your next code overhaul :)

pasiv 01-07-23 04:04 PM

I made my big ol table ��and then went to sleep. But I'll play around with those. Thanks!

How does the game decide whether that item you have will actually get equipped when you click it?


These are the results. Not sure whether I can use them. I'm testing whether a paladin can equip a plat helm that is already equipped.
Lua Code:
  1. local slot,id = 1,nil
  2. local itemLoc = ItemLocation:CreateFromEquipmentSlot(INVSLOT_HEAD)
  3. if itemLoc:IsValid() then
  4.    id = C_Item.GetItemID(itemLoc)
  5. end
  6.  
  7. print(id) --157961
  8. print(IsEquippableItem(id)) --true, although it would be true for any class
  9. print(C_Item.IsItemSpecificToPlayerClass(id)) --false.
  10. --print(C_Item.IsItemSpecificToPlayerClass(GetItemInfo(id))) --also false.  Not sure what I'm doing wrong.
  11. print(C_Item.IsItemConvertibleAndValidForPlayer(itemLoc)) --false

This might be the solution to my problem. Neeeds more testing

Lua Code:
  1. local table = GetItemSpecInfo(id)
  2. for k,v in pairs(table) do
  3.    print(k,v)
  4. end
  5. --Output
  6. --1, 65 -- PaladinHoly
  7. --2, 66 -- PaladinProtection
  8. --3, 70 -- Paladin Ret

Far as I can tell this only show true for armor + back (but haven't tried with weapons yet.)


All times are GMT -6. The time now is 05:39 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI