Quantcast

Fixed the scoring for mainhand/offhand weapons, at least I think

James Whitehead II [08-17-08 - 13:26]
Fixed the scoring for mainhand/offhand weapons, at least I think
Filename
DressToKill.lua
diff --git a/DressToKill.lua b/DressToKill.lua
index ead09bd..6a3884a 100644
--- a/DressToKill.lua
+++ b/DressToKill.lua
@@ -164,6 +164,7 @@ local function scanFunction(weightFunction)
 	debug(L["Weapon base score: %s"], mh_base)

 	-- Try on each mainhand weapon
+	local score
 	for mh_mask,item in pairs(mh_avail) do
 		local name, link = GetItemInfo(item)
 		debug(L["Equipping mainhand weapon: %s"], link)
@@ -175,7 +176,6 @@ local function scanFunction(weightFunction)
 			debug(L["Successfully equipped %s"], link)
 			local mh_link = GetInventoryItemLink("player", mainslot)
 			local mh_score = weightFunction(mh_link, mainslot) - mh_base
-			local score = mh_score
 			debug(L["Mainhand score: %d"], score)

 			if not IsEquippedItemType("Two-Hand") then
@@ -183,6 +183,7 @@ local function scanFunction(weightFunction)
 				-- Try to equip each off-hand weapon to compliment this one
 				for oh_mask,item in pairs(oh_avail) do
 					if not blacklist[oh_mask] then
+						score = mh_score
 						local name, link = GetItemInfo(item)

 						debug(L["Equipping offhand weapon: %s"], link)
@@ -192,7 +193,7 @@ local function scanFunction(weightFunction)
 						if oh_equipped then
 							local oh_link = GetInventoryItemLink("player", offslot) or linen_shirt
 							local oh_score = weightFunction(oh_link, offslot)
-							score = oh_score
+							score = score + oh_score
 							debug(L["Got score of %s for %s/%s"], score, mh_link, oh_link)
 						else
 							debug(L["Failed to equip %s"], link)
@@ -212,6 +213,7 @@ local function scanFunction(weightFunction)
 					end
 				end
 			else
+				score = mh_score
 				debug("Got score of %s for %s", score, mh_link)
 				if score >= weapon_max then
 					weapon_max = score