Slightly mis-calculating when using a 2-handed weapon
Torsin opened this issue ยท 4 comments
When using a two-handed weapon we are only calculating using 15 items, however blizz appears to double count the item and use 16 items.
This means that the ilevel shown from simpleiLevel is reported higher than the blizz ui.
As a fix I changed the SIL:GearSum(items, level) function slightly, starting on line 612:
local itemEquipLoc = select(9, GetItemInfo(itemLink));
if not items[INVSLOT_OFFHAND] and i == INVSLOT_MAINHAND and (itemEquipLoc == "INVTYPE_2HWEAPON" or itemEquipLoc == "INVTYPE_RANGED") then
totalScore = totalScore + effectiveILvl * 2;
totalItems = totalItems + 1;
self:Debug("There is NO offhand, using mainhand which is a 2 handed weapon", effectiveILvl);
else
totalScore = totalScore + effectiveILvl;
end
What this does is keep the current line 611 that adds 1 to the total for each item. Then it gets the ninth return from GetItemInfo, which in a few blizzard UI pieces is shown as itemEquipLoc, We then check that we don't have an offhand equipped, that we are currently looking at the main hand item that is equipped and that the item equipped is a 2 handed weapon, if it is then we add the ilevel twice and add another item to the score.
I'm not sure if 'INVTYPE_RANGEDRIGHT' is also duplicated in that way by blizz, on one of my lower level characters it is not.
By specifically checking that the offhand is not occupied and that the item is a 2-handed weapon we then properly calculate specs that can dual-wield 2-handed weapons.
Think the 3.4.3 is still missing a piece or two on this, shouldn't it be:
-- Thanks to Torsin for fix, Issue #9
if i == INVSLOT_MAINHAND and not items[INVSLOT_OFFHAND] then
if itemEquipLoc == "INVTYPE_2HWEAPON" or itemEquipLoc == "INVTYPE_RANGED" then
totalScore = totalScore + effectiveILvl * 2;
totalItems = totalItems + 1;
self:Debug("GearSum", "MissingOffhand", "Mainhand * 2", effectiveILvl, itemEquipLoc);
else
totalScore = totalScore + effectiveILvl;
totalItems = totalItems + 1;
self:Debug("GearSum", "MissingOffhand", "Mainhand is 1h", effectiveILvl, itemEquipLoc);
end
else
totalScore = totalScore + effectiveILvl;
end
Can you post a screenshot of your character sheet and the output of /sil debug on your gear scan? I have many characters with 1h/off-hand and 2h and I am unable to reproduce this. When I try the code as posted my numbers are off and no longer match what the client thinks I have for an equipped score.
@scotepi
Sorry for not seeing this sooner, anyway it's after the pre-patch and probably a good time anyway. Essentially Blizz is always doing a division by 16, I assume they think that any slot not populated is counted as a 0 when adding up and dividing by the total slots.
tldr: I think this portion really should look like the following, although we may need to tweak the totalitems addition here or just always set it to 16, it's hard to tell:
if i == INVSLOT_MAINHAND and not items[INVSLOT_OFFHAND] then
totalItems = totalItems + 1;
if itemEquipLoc == "INVTYPE_2HWEAPON" or itemEquipLoc == "INVTYPE_RANGED" then
totalScore = totalScore + effectiveILvl * 2;
self:Debug("GearSum", "MissingOffhand", "Mainhand * 2", effectiveILvl, itemEquipLoc);
else
totalScore = totalScore + effectiveILvl;
self:Debug("GearSum", "MissingOffhand", "Mainhand is 1h", effectiveILvl, itemEquipLoc);
end
else
totalScore = totalScore + effectiveILvl;
end
Longer entries here as I'm adding a more detailed debug too
Monk Torsin:
Staff (Incorrect):
SIL Debug: GearSum 1 120 [Superior Gearspun Goggles] Running Total: 120 Total Items: 1
SIL Debug: GearSum 2 149 [Heart of Azeroth] Running Total: 269 Total Items: 2
SIL Debug: GearSum 3 120 [Deathstalker's Shoulderpads] Running Total: 389 Total Items: 3
SIL Debug: GearSum 5 120 [Type II Bomber Jacket] Running Total: 509 Total Items: 4
SIL Debug: GearSum 6 125 [Waistguard of the Insatiable Maw] Running Total: 634 Total Items: 5
SIL Debug: GearSum 7 120 [Trousers of the Insatiable Maw] Running Total: 754 Total Items: 6
SIL Debug: GearSum 8 120 [Footwraps of the Insatiable Maw] Running Total: 874 Total Items: 7
SIL Debug: GearSum 9 125 [Bindings of the Insatiable Maw] Running Total: 999 Total Items: 8
SIL Debug: GearSum 10 120 [Handwraps of the Insatiable Maw] Running Total: 1119 Total Items: 9
SIL Debug: GearSum 11 125 [Ring of Cosmic Potential] Running Total: 1244 Total Items: 10
SIL Debug: GearSum 12 115 [Lurking Schemer's Band] Running Total: 1359 Total Items: 11
SIL Debug: GearSum 13 100 [Kezan Stamped Bijou] Running Total: 1459 Total Items: 12
SIL Debug: GearSum 14 125 [Lingering Psychic Shell] Running Total: 1584 Total Items: 13
SIL Debug: GearSum 15 155 [Ashjra'kamas, Shroud of Resolve] Running Total: 1739 Total Items: 14
SIL Debug: GearSum MissingOffhand Mainhand * 2 100 INVTYPE_2HWEAPON
SIL Debug: GearSum 16 100 [Zandalari Warstaff] Running Total: 1839 Total Items: 15
SIL Debug: SetScore Torsin 122.6 15 0
If I switch to a one-handed weapon, without equiping an off-hand it doesn't add the one-handed ilevel in:
One-hand, no offhand (Incorrect):
SIL Debug: GearSum 1 120 [Superior Gearspun Goggles] Running Total: 120 Total Items: 1
SIL Debug: GearSum 2 149 [Heart of Azeroth] Running Total: 269 Total Items: 2
SIL Debug: GearSum 3 120 [Deathstalker's Shoulderpads] Running Total: 389 Total Items: 3
SIL Debug: GearSum 5 120 [Type II Bomber Jacket] Running Total: 509 Total Items: 4
SIL Debug: GearSum 6 125 [Waistguard of the Insatiable Maw] Running Total: 634 Total Items: 5
SIL Debug: GearSum 7 120 [Trousers of the Insatiable Maw] Running Total: 754 Total Items: 6
SIL Debug: GearSum 8 120 [Footwraps of the Insatiable Maw] Running Total: 874 Total Items: 7
SIL Debug: GearSum 9 125 [Bindings of the Insatiable Maw] Running Total: 999 Total Items: 8
SIL Debug: GearSum 10 120 [Handwraps of the Insatiable Maw] Running Total: 1119 Total Items: 9
SIL Debug: GearSum 11 125 [Ring of Cosmic Potential] Running Total: 1244 Total Items: 10
SIL Debug: GearSum 12 115 [Lurking Schemer's Band] Running Total: 1359 Total Items: 11
SIL Debug: GearSum 13 100 [Kezan Stamped Bijou] Running Total: 1459 Total Items: 12
SIL Debug: GearSum 14 125 [Lingering Psychic Shell] Running Total: 1584 Total Items: 13
SIL Debug: GearSum 15 155 [Ashjra'kamas, Shroud of Resolve] Running Total: 1739 Total Items: 14
SIL Debug: GearSum MissingOffhand Mainhand is 1h 100 INVTYPE_WEAPON
SIL Debug: GearSum 16 100 [Salt Coast Headcracker] Running Total: 1739 Total Items: 15
SIL Debug: SetScore Torsin 115.9 15 0
After making the change above we see that now it matches blizz's calculation:
Two-handed Main (Corrected)
SIL Debug: GearSum 1 120 [Superior Gearspun Goggles] Running Total: 120 Total Items: 1
SIL Debug: GearSum 2 149 [Heart of Azeroth] Running Total: 269 Total Items: 2
SIL Debug: GearSum 3 120 [Deathstalker's Shoulderpads] Running Total: 389 Total Items: 3
SIL Debug: GearSum 5 120 [Type II Bomber Jacket] Running Total: 509 Total Items: 4
SIL Debug: GearSum 6 125 [Waistguard of the Insatiable Maw] Running Total: 634 Total Items: 5
SIL Debug: GearSum 7 120 [Trousers of the Insatiable Maw] Running Total: 754 Total Items: 6
SIL Debug: GearSum 8 120 [Footwraps of the Insatiable Maw] Running Total: 874 Total Items: 7
SIL Debug: GearSum 9 125 [Bindings of the Insatiable Maw] Running Total: 999 Total Items: 8
SIL Debug: GearSum 10 120 [Handwraps of the Insatiable Maw] Running Total: 1119 Total Items: 9
SIL Debug: GearSum 11 125 [Ring of Cosmic Potential] Running Total: 1244 Total Items: 10
SIL Debug: GearSum 12 115 [Lurking Schemer's Band] Running Total: 1359 Total Items: 11
SIL Debug: GearSum 13 100 [Kezan Stamped Bijou] Running Total: 1459 Total Items: 12
SIL Debug: GearSum 14 125 [Lingering Psychic Shell] Running Total: 1584 Total Items: 13
SIL Debug: GearSum 15 155 [Ashjra'kamas, Shroud of Resolve] Running Total: 1739 Total Items: 14
SIL Debug: GearSum MissingOffhand Mainhand * 2 100 INVTYPE_2HWEAPON
SIL Debug: GearSum 16 100 [Zandalari Warstaff] Running Total: 1939 Total Items: 16
SIL Debug: SetScore Torsin 121.2 16 0
One-handed Main, no Off-hand (Corrected)
SIL Debug: GearSum 1 120 [Superior Gearspun Goggles] Running Total: 120 Total Items: 1
SIL Debug: GearSum 2 149 [Heart of Azeroth] Running Total: 269 Total Items: 2
SIL Debug: GearSum 3 120 [Deathstalker's Shoulderpads] Running Total: 389 Total Items: 3
SIL Debug: GearSum 5 120 [Type II Bomber Jacket] Running Total: 509 Total Items: 4
SIL Debug: GearSum 6 125 [Waistguard of the Insatiable Maw] Running Total: 634 Total Items: 5
SIL Debug: GearSum 7 120 [Trousers of the Insatiable Maw] Running Total: 754 Total Items: 6
SIL Debug: GearSum 8 120 [Footwraps of the Insatiable Maw] Running Total: 874 Total Items: 7
SIL Debug: GearSum 9 125 [Bindings of the Insatiable Maw] Running Total: 999 Total Items: 8
SIL Debug: GearSum 10 120 [Handwraps of the Insatiable Maw] Running Total: 1119 Total Items: 9
SIL Debug: GearSum 11 125 [Ring of Cosmic Potential] Running Total: 1244 Total Items: 10
SIL Debug: GearSum 12 115 [Lurking Schemer's Band] Running Total: 1359 Total Items: 11
SIL Debug: GearSum 13 100 [Kezan Stamped Bijou] Running Total: 1459 Total Items: 12
SIL Debug: GearSum 14 125 [Lingering Psychic Shell] Running Total: 1584 Total Items: 13
SIL Debug: GearSum 15 155 [Ashjra'kamas, Shroud of Resolve] Running Total: 1739 Total Items: 14
SIL Debug: GearSum MissingOffhand Mainhand is 1h 100 INVTYPE_WEAPON
SIL Debug: GearSum 16 100 [Zem'lan Slicer] Running Total: 1839 Total Items: 16
SIL Debug: SetScore Torsin 114.9 16 0