Message
| The other thing I tried to do with my inventory window months ago, was assess a weapon's usefulness by trying to evaluate if it was good "for its level". By comparison, in WoW, items like weapons are colour-coded, so a gray item is considered pretty useless, white is about average for its level, green is above average, blue is very good, and so on.
Thus, a simple glance can show whether you should throw away, sell, or use, an item that might have dropped from a mob.
My preliminary code used a table of the damage that a certain level *should* cause, like this:
-- see: http://www.aardwolf.com/builders/index.php?option=content&task=view&id=210&Itemid=134
avg_weapon_points = {
3.0, 3.0, 3.0, 4.5, 4.5, 6.0, 6.0, 6.0, 6.0, 8.0, -- 1 to 10
8.0, 10.0, 10.0, 10.0, 10.0, 10.0, 12.0, 12.5, 12.5, 14.0, -- 11 to 20
14.0, 14.0, 15.0, 16.0, 16.0, 16.0, 16.0, 18.0, 18.0, 20.0, -- 21 to 30
21.0, 22.5, 24.5, 27.0, 28.0, 28.0, 28.0, 32.0, 32.0, 35.0, -- 31 to 40
35.0, 36.0, 36.0, 38.5, 40.5, 40.0, 39.0, 42.0, 42.0, 45.0, -- 41 to 50
45.0, 48.0, 48.0, 49.5, 49.5, 50.0, 52.0, 52.0, 52.0, 52.0, -- 51 to 60
55.0, 55.0, 58.5, 58.5, 58.5, 58.5, 60.5, 60.5, 63.0, 63.0, -- 61 to 70
63.0, 65.0, 66.0, 66.0, 67.5, 70.0, 75.0, 77.0, 76.5, 80.0, -- 71 to 80
84.5, 90.0, 96.0, 96.0, 98.0, 102.0, 110.5, 120.0, 120.0, 128.0, -- 81 to 90
135.0, 144.0, 144.5, 160.0, 165.0, 162.0, 171.0, 180.0, 190.0, 190.0, -- 91 to 100
192.5, 192.5, 200.0, 200.0, 207.0, 207.0, 211.5, 211.5, 214.5, 214.5, -- 101 to 110
220.0, 220.0, 222.0, 222.0, 220.5, 220.5, 245.0, 245.0, 231.0, 231.0, -- 111 to 120
238.5, 238.5, 242.0, 242.0, 242.0, 242.0, 253.0, 253.0, 255.0, 255.0, -- 121 to 130
253.0, 253.0, 259.0, 259.0, 266.5, 266.5, 272.0, 272.0, 276.0, 276.0, -- 131 to 140
280.0, 280.0, 280.0, 280.0, 285.0, 285.0, 288.0, 288.0, 294.5, 294.5, -- 141 to 150
297.0, 297.0, 304.0, 304.0, 308.0, 308.0, 313.5, 313.5, 315.0, 315.0, -- 151 to 160
320.0, 320.0, 323.0, 323.0, 324.0, 324.0, 325.0, 325.0, 330.0, 330.0, -- 161 to 170
332.5, 332.5, 333.5, 333.5, 336.0, 336.0, 338.0, 338.0, 330.0, 330.0, -- 171 to 180
346.5, 346.5, 350.0, 350.0, 351.0, 351.0, 356.5, 356.5, 360.0, 360.0, -- 181 to 199
362.5, 362.5, 368.0, 368.0, 372.0, 372.0, 377.0, 377.0, 384.0, 384.0, -- 191 to 200
390.0, -- 201
} -- end of avg_weapon_points
Thus, for example, a level 10 weapon might be expected to do 8 damage.
Now we can work out how good a weapon is, for example a level 10 weapon that did 12 damage could be classed as quite good, because from the table, you need a level 17 weapon to do 12 damage. Likewise, a level 10 weapon that did 4.5 damage could be regarded as quite poor.
The code below, which is probably not at all perfect, tried to "walk" the table and work out which was the closest level that matched the actual damage the weapon did (bearing in mind some levels have the same damage in the table), and see how far away from its actual level it is:
local avg_damage = avg_weapon_points [item.level] or 1
local rating = 0
local L = item.level
local new_points
if item.weapon.avgdamage > avg_damage then
repeat
L = L + 1
if L > #avg_weapon_points then
break -- end of table
end -- if
if avg_weapon_points [L] > item.weapon.avgdamage then
break
end -- if
new_points = avg_weapon_points [L]
rating = rating + 1
until false
-- drop back to first weapon that had this rating
if new_points then
rating = rating + 1
while avg_weapon_points [L - 1] == new_points do
L = L - 1
rating = rating - 1
end -- while
end -- if
elseif item.weapon.avgdamage < avg_damage then
repeat
L = L - 1
if L < 1 then
break -- start of table
end -- if
if avg_weapon_points [L] < item.weapon.avgdamage then
break
end -- if
new_points = avg_weapon_points [L]
rating = rating - 1
until false
-- go forwards to first weapon that had this rating
if new_points then
rating = rating - 1
while avg_weapon_points [L + 1] == new_points do
L = L + 1
rating = rating + 1
end -- while
end -- if
end -- if
if rating > 0 then
infoline (string.format ("Rating: +%i", rating), "lime")
elseif rating < 0 then -- minus sign will be shown anyway
infoline (string.format ("Rating: %i", rating), "slategray")
end -- if
The end result was an information message, if the weapon's rating was not zero, showing either a +level or a -level from the current level (and a colour code).
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|