Simple iLevel

Simple iLevel

1M Downloads

Gear Score bug with Heart of Azeroth

Torsin opened this issue Β· 20 comments

commented

Since the Heart of Azeroth is an Artifact, aka itemRarity 6, it is getting left out of the gear score. I went ahead and just added the following to line 631/632:

elseif i == INVSLOT_NECK then
	totalScore = totalScore + itemLevel;

That fixed it up.

commented

Also, since weapons are no longer Artifact weapons two-handed weapons are altering the gear score since they fall into the else statement. modified and added:

if itemRarity == 6 then
    -- Bypass caching in LibItemUpgradeInfo-1 if need be
    self:Debug('Artifact!', i, itemLink, itemLevel, itemLevelBlizz);
    if not items[INVSLOT_OFFHAND] and i == INVSLOT_MAINHAND then
        totalScore = totalScore + itemLevel * 2;
        totalItems = totalItems + 1;
        self:Debug("There is NO offhand, using mainhand", itemLevel);
    elseif i == INVSLOT_MAINHAND then
        if (itemLevel >= select(4, GetItemInfo(items[INVSLOT_OFFHAND]))) then
            totalScore = totalScore + (itemLevel * 2);
            self:Debug('mainHandItemLevel > offHandItemLevel, using score from mainHand.');
        else
            totalScore = totalScore + (select(4, GetItemInfo(items[INVSLOT_OFFHAND])) * 2);
            self:Debug('mainHandItemLevel < offHandItemLevel, using score from offHand.');
        end
    elseif i == INVSLOT_NECK then
        totalScore = totalScore + itemLevel;
    end
else
    if not items[INVSLOT_OFFHAND] and i == INVSLOT_MAINHAND then
        totalScore = totalScore + itemLevel * 2;
        totalItems = totalItems + 1;
        self:Debug("There is NO offhand, using mainhand", itemLevel);
    else
        -- Normal item
        self:Debug('Normal: ', i, itemLink, itemLevel, itemLevelBlizz);
        totalScore = totalScore + itemLevel;
    end
end
commented

Actually there's another bug with drop items. I've got several items coming back as quite a bit different item level from the API then what they show in game. So I end up 10 item levels high.

Example, my waist comes back as 287 itemLevel, 172 itemLevelBlizz, and it's actually 269. Multiple that by 3 or 4 more items similarly off, it adds up.

https://worldofwarcraft.com/en-us/character/deathwing/Zaphon is my toon. Probably a separate issue, actually probably with the library that does this scanning.

commented

That issue is due to how item drops scale with level. I assume the library is reading your current level and applying that as the bonus, instead of using a value on the item that locked that level scaling bonus when you picked it up.

For example, you loot an item at 114, and it’s ilevel shows as 269, now you are 118 and if you looted that exact same item it would be 287. The library is using the level 118 value for the modifier instead of the 114 when you actually received it.

commented

Makes sense.

commented

I just did your current Wow Calculation by hand, based on the armory, which shows an average of 278:

300+300+285+254+300+281+281+277+281+265+281+280+265+259+273+268 = 4450
Dividing 4450 by 16, and we get 278.125.

If we instead did your number 3 calculation and took the highest iLevel weapon and applied it to both slots we would get 4455, which when divided by 16 is 278.4375.

Now for your weapons the Salty Dog's Harpoon you received when you were at level 117, making it iLevel 268 and the Trogg Saurolisk-Breaker when you were 119 making it iLevel 273. Now if you had received your off-hand weapon when you were 119 it would have given you a 286 iLevel version, which if that is tossed into the calculations instead of 268 then your average would come out to 279.25. I figure @scotepi is pretty busy with life outside of WoW, the good news is that the changes I made make it accurate once all your gear is received at 120. I seem to recall that blizzard doesn't expose the level modifier piece when we pull the 'upgrades' using the API, but I could be wrong.

The reason we had to take the highest iLevel for Artifact weapons was for classes/specs that had a dual wield weapon, such as Monk Windwalkers. The Main hand would display the proper iLevel of say 945, but the offhand would always return 750, this is due to how Artifact weapons were implemented in game. The kicker class was the Prot warrior where the Shield was the artifact, which is in the Offhand slot, so we had to ensure we were always taking the highest iLevel then duplicating it. For regular weapons and offhands this should no longer be the case and we can simply add the weapons proper iLevel, once the author @scotepi figures a solution for the library and/or wow returning a higher ilevel for item bonuses.

commented

So I just logged in and looked.. Here is a screenshot of my debug output plus the last line is from the following command -

/run print(("Average Item level: %.2f; Equipped item level: %.2f"):format(GetAverageItemLevel()))

screen shot 2018-08-21 at 8 25 34 pm

So as you can see, when it added up it used the higher weapon twice, so came up with a total of 4455, which when divided by 16 = 278.4375 which matches exactly the output I get from Blizzard's API call GetAverageItemLevel() when rounded to two decimal places.

I went ahead and ran the above command again changing the %.2f to %.8f and it does come back as 278.4375 as I expected.

Now maybe this is specific to Fury warrior (let me logon my rogue and check)..

As I expected, my rogue is a bit different, and has some additional problems. Let me try and figure it out by hand.. It's coming up as 234.9375 via the in-game API.

When I add up the items by hand, it comes up to 3759 which is exactly 234.9375 when divided by 16. Man what I would give to read Blizzard's API code, this makes no sense. Why would Titan's Grip Warriors have a special case??

So far in all my testing, this only occurs on Titan's Grip warriors when using dual 2-handers, single handers, sword and board, rogues, enhance shamans, etc. all just add up. But for whatever reason, the double highest iLvL weapon is used for TItan's Grip (and yes I've tried swapping main / off hands thinking it doubled the main hand).

commented

FYI I did a lot of hacking this morning and fixed this (at least for my fury warrior). However, I'm not sure it's the right fix, but here's a rundown of what I did.

  1. In LibItemUpgradeInfo (Core.lua) - Near the bottom of ScanTip where it calls math.min(c.ilevel,itemLevel) I commented this call out. I have cases where the itemLevel returned is HIGHER than the tooltip on 2 of my pieces of gear. So I use the tooltip provided value unless it can't find one.

  2. Similarly I made the same fix in SimpleILevel.lua in GearSum where I commented out the 3 lines for if itemLevelBlizz > itemLevel since there's something going on here new to BFA. So I just assume the one coming back from the Library is proper.

  3. Because I was still off by a very small value, I had to make some changes to the mainhand/offhand calculations to figure out which weapon has the higher itemLevel (similar to the artifact process), and double the highest iLvL. However, I had to replace the calls to GetItemInfo with the call to the GetUpgradedItemLevel function.

Long story short, it now calculates the itemLevel for my fury warrior perfectly, however I have no idea if it works for other classes / specs. I can attach my nasty hacks if you want, but I figured I'd rather spell out what I did vs how I did it.

What it doesn't do is properly handle if you have no weapons in mainhand or offhand, which Blizzard still counts as zero (it appears they divide by a fixed count of gear, no matter how much you have on). But I don't really care about this, how many times do you scan someone who doesn't have all their gear on?

patch.zip

Patch atttached just in case..

commented

So further changing and I believe I have this working in most cases at least on my army of alts (there's a few odd edge cases this may not cover, but should cover the vast majority of cases)..

patch.zip

I also verified I can actually apply this patch to a clean download of 3.3.16-beta. Yes I did this on a Mac, so everything is using unix diff and patch.

commented

So I went another route and figured out that Blizz added to the Item API can the following will get the proper item level for most gear, or Blizz's item level is correct:

-- New GetCurrentItemLevel
local owningItemSource = AzeriteEmpoweredItemDataSource:CreateFromFromItemLink(itemLink);
local sourceItem = owningItemSource:GetItem();
local equippedItemLocation = ItemLocation:CreateFromEquipmentSlot(sourceItem:GetInventoryType());
local equippedItemSource = AzeriteEmpoweredItemDataSource:CreateFromItemLocation(equippedItemLocation);
local equippedItem = equippedItemSource:GetItem(equippedItemLocation);
local currentItemLevel = equippedItem:GetCurrentItemLevel();

I have seen a few items that this comes back wrong for, which are pre bfa items. would need to test and figure out why. It would be great if blizz just fixed one of the methods to return it properly 100% of the time.

commented

Yeah, I wish Blizzard would just expose whatever API they use for all this. Having to jump through so many hoops to get the true item level of an item is silly, especially given that they clearly have an API to do so since the ToolTip always displays correctly.

commented

But the tooltip.lua is available, if you don't extract the interface code files yourself, here is a version online:
https://github.com/tomrus88/BlizzardInterfaceCode/blob/master/Interface/FrameXML/GameTooltip.lua

commented

Yeah I have it and looked through it as well, and it's about as clear as Mud (hence your 6 lines above to go from itemLink to an ItemLevel)

commented

Yea, there's another call that goes from 1 itemlink to itemLevel...but it didn't give the proper iLevel.

commented

Has the owner abandoned this? I really appreciate you guys trying to get this working. I had no idea how much I actually used this until it stopped working.

commented

@maddhacker24 nope he updated it a few weeks ago, but it's not necessarily a quick fix.

commented

Yeah, as Torsin said there is a lot going on here specifically around BFA changes. Blizzard goes to great lengths to make this tricky, and if you read through this thread you can see some of the complications. I did a ton of work to get this working for one particular class/spec, and then it didn't work for other classes/specs. Then I got that working, and I got some upgrades and it stopped. It's going to take time for the dust to settle from BFA and for more developers to figure out all the things Blizzard did, especially in this scenario.

commented

How about making a fork of this repo with all the BFA related things and maybe submit that to curse as "based on" addon?

commented

I found that with the above patches it still wasn't calculating right for my hunter, due to ranged weapons. So i added a few lines between 641 and 650, that fixed it.

		elseif i == INVSLOT_MAINHAND and InvType == "INVTYPE_RANGEDRIGHT" then
			totalScore = totalScore + itemLevel * 2;
                        totalItems = totalItems + 1;
                        self:Debug("There is NO offhand, using mainhand", itemLevel);
		elseif i == INVSLOT_MAINHAND and InvType == "INVTYPE_RANGED" then
			totalScore = totalScore + itemLevel * 2;
                        totalItems = totalItems + 1;
                        self:Debug("There is NO offhand, using mainhand", itemLevel);
commented

This should be resolved as of e0556bc 3.4.0-alpha, that code was drastically cleaned up and converted to use GetDetailedItemLevel witch should always return the right thing. I just need to test in a scaled area.

commented

Resolved in 3.4.x