Quantcast

Dry-coded support for equipped mainhand and offhand weapon combinations

James Whitehead II [08-16-08 - 11:03]
Dry-coded support for equipped mainhand and offhand weapon combinations
Filename
DressToKill.lua
diff --git a/DressToKill.lua b/DressToKill.lua
index 9ef5785..ce38e62 100644
--- a/DressToKill.lua
+++ b/DressToKill.lua
@@ -146,31 +146,40 @@ local function scanFunction(weightFunction)
 		blacklist[mh_mask] = true

 		if mh_equipped then
-			-- Try to equip each off-hand weapon to compliment this one
-			for oh_mask,item in pairs(slotAvail[offslot]) do
-				local oh_equipped = DressToKill:EquipItem(offslot, oh_mask, oh_stash)
-
-				local mh_link = GetInventoryItemLink("player", mainslot)
-				local mh_score = weightFunction(mh_link, mainslot) - weapon_base
-				local score = mh_score
-
-				-- If we equipped offhand, then score it too
-				if oh_equipped then
-					local oh_link = GetInventoryItemLink("player", offslot) or linen_shirt
-					local oh_score = weightFunction(oh_link, offslot) - weapon_base
-					score = mh_score + oh_score
-				end
+			local mh_link = GetInventoryItemLink("player", mainslot)
+			local mh_score = weightFunction(mh_link, mainslot) - weapon_base
+			local score = mh_score
+
+			if not IsEquippedItemType("Two-Hand") then
+				-- Try to equip each off-hand weapon to compliment this one
+				for oh_mask,item in pairs(slotAvail[offslot]) do
+					local oh_equipped = DressToKill:EquipItem(offslot, oh_mask, oh_stash)
+
+					-- If we equipped offhand, then score it too
+					if oh_equipped then
+						local oh_link = GetInventoryItemLink("player", offslot) or linen_shirt
+						local oh_score = weightFunction(oh_link, offslot) - weapon_base
+						score = score + oh_score
+					end

-				debug("Got score of %s for %s and %s", score, mh_link, oh_link or "empty")
+					debug("Got score of %s for %s and %s", score, mh_link, oh_link or "empty")
+					if score >= weapon_max then
+						weapon_max = score
+						weapon_win.mh = mh_mask
+						weapon_win.oh = oh_equipped and oh_mask or nil
+					end
+
+					-- Unequip the offhand item
+					if oh_equipped then
+						DressToKill:UnequipItem(offslot, oh_mask, oh_stash)
+					end
+				end
+			else
+				debug("Got score of %s for %s", score, mh_link)
 				if score >= weapon_max then
 					weapon_max = score
 					weapon_win.mh = mh_mask
-					weapon_win.oh = oh_equipped and oh_mask or nil
-				end
-
-				-- Unequip the offhand item
-				if oh_equipped then
-					DressToKill:UnequipItem(offslot, oh_mask, oh_stash)
+					weapon_win.oh = nil
 				end
 			end