From 7be7ceaef14c3f6db7aedb0e32715103dafd8ae0 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Sat, 16 Aug 2008 11:03:33 +0000 Subject: [PATCH] Dry-coded support for equipped mainhand and offhand weapon combinations --- DressToKill.lua | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) 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 -- 1.7.9.5