Skip to content

Commit 1149f4f

Browse files
committed
trader tool: option to use current implicits and enchants
1 parent 7d02e1e commit 1149f4f

3 files changed

Lines changed: 61 additions & 35 deletions

File tree

src/Classes/ItemsTab.lua

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,14 +1585,14 @@ function ItemsTabClass:DeleteItem(item, deferUndoState)
15851585
end
15861586
end
15871587

1588-
local function copyAnointsAndEldritchImplicits(newItem, activeItemSet, items)
1589-
local newItemType = newItem.base.type
1590-
if activeItemSet[newItemType] then
1591-
local currentItem = activeItemSet[newItemType].selItemId and items[activeItemSet[newItemType].selItemId]
1588+
function ItemsTabClass:CopyAnointsAndEldritchImplicits(newItem, migrateEldritchImplicits, overwrite)
1589+
local newItemType = newItem.base.weapon and "Weapon 1" or newItem.base.type
1590+
if self.activeItemSet[newItemType] then
1591+
local currentItem = self.activeItemSet[newItemType].selItemId and self.items[self.activeItemSet[newItemType].selItemId]
15921592
-- if you don't have an equipped item that matches the type of the newItem, no need to do anything
15931593
if currentItem then
15941594
-- if the new item is anointable and does not have an anoint and your current respective item does, apply that anoint to the new item
1595-
if isAnointable(newItem) and #newItem.enchantModLines == 0 and activeItemSet[newItemType].selItemId > 0 then
1595+
if isAnointable(newItem) and (#newItem.enchantModLines == 0 or overwrite) and self.activeItemSet[newItemType].selItemId > 0 then
15961596
local currentAnoint = currentItem.enchantModLines
15971597
if currentAnoint and #currentAnoint == 1 then -- skip if amulet has more than one anoint e.g. Stranglegasp
15981598
newItem.enchantModLines = currentAnoint
@@ -1607,12 +1607,24 @@ local function copyAnointsAndEldritchImplicits(newItem, activeItemSet, items)
16071607
return
16081608
end
16091609
end
1610-
if main.migrateEldritchImplicits and isValueInTable(eldritchBaseTypes, newItem.base.type) and isValueInTable(eldritchRarities, newItem.rarity)
1611-
and #newItem.implicitModLines == 0 and not newItem.corrupted and (currentItem.cleansing or currentItem.tangle) and currentItem.implicitModLines then
1610+
1611+
local modifiableItem = not (newItem.corrupted or newItem.mirrored)
1612+
if migrateEldritchImplicits and isValueInTable(eldritchBaseTypes, newItem.base.type) and isValueInTable(eldritchRarities, newItem.rarity)
1613+
and (#newItem.implicitModLines == 0 or overwrite) and modifiableItem and (currentItem.cleansing or currentItem.tangle) and currentItem.implicitModLines then
16121614
newItem.implicitModLines = currentItem.implicitModLines
16131615
newItem.tangle = currentItem.tangle
16141616
newItem.cleansing = currentItem.cleansing
16151617
end
1618+
1619+
-- harvest and heist enchantments on modifiable body armour or weapons
1620+
if newItem.base.weapon or newItem.base.type == "Body Armour"
1621+
and (#newItem.enchantModLines == 0 or overwrite)
1622+
and self.activeItemSet[newItemType].selItemId > 0
1623+
and modifiableItem and currentItem.enchantModLines
1624+
then
1625+
newItem.enchantModLines = currentItem.enchantModLines
1626+
end
1627+
16161628
newItem:BuildAndParseRaw()
16171629
end
16181630
end
@@ -1622,7 +1634,7 @@ end
16221634
function ItemsTabClass:CreateDisplayItemFromRaw(itemRaw, normalise)
16231635
local newItem = new("Item", itemRaw)
16241636
if newItem.base then
1625-
copyAnointsAndEldritchImplicits(newItem, self.activeItemSet, self.items)
1637+
self:CopyAnointsAndEldritchImplicits(newItem, main.migrateEldritchImplicits, false)
16261638
if normalise then
16271639
newItem:NormaliseQuality()
16281640
newItem:BuildModList()

src/Classes/TradeQuery.lua

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,23 @@ Highest Stat Value / Price - Sorts from highest to lowest Stat Value per currenc
357357
Lowest Price - Sorts from lowest to highest price of retrieved items
358358
Highest Weight - Displays the order retrieved from trade]]
359359
self.controls.itemSortSelection:SetSel(self.pbItemSortSelectionIndex)
360-
self.controls.itemSortSelectionLabel = new("LabelControl", {"TOPRIGHT", self.controls.itemSortSelection, "TOPLEFT"}, {-4, 0, 60, 16}, "^7Sort By:")
361-
362-
-- Use Enchant in DPS sorting
363-
self.controls.enchantInSort = new("CheckBoxControl", {"TOPRIGHT",self.controls.fetchCountEdit,"TOPLEFT"}, {-8, 0, row_height}, "Include Enchants:", function(state)
364-
self.enchantInSort = state
365-
for row_idx, _ in pairs(self.resultTbl) do
366-
self:UpdateControlsWithItems(row_idx)
367-
end
368-
end)
369-
self.controls.enchantInSort.tooltipText = "This includes enchants in sorting that occurs after trade results have been retrieved"
360+
self.controls.itemSortSelectionLabel = new("LabelControl", {"TOPRIGHT", self.controls.itemSortSelection, "TOPLEFT"}, {-4, 0, 56, 16}, "^7Sort By:")
361+
362+
-- Implicit mod and enchant behaviour in searching and sorting
363+
local eldritchTooltip =
364+
[[Controls how eldritch implicits and enchants are treated.
365+
Copy Current: current implicit modifiers and enchants are copied to the item before sorting, and eldritch weights are not used in the search.
366+
Include Weights: eldritch mod weights are used for searching items and the results are not edited.
367+
Ignored: eldritch mod weights are not used, enchants and eldritch implicits are removed before sorting.
368+
Note that the search filter limit might make results with implicit weights misleading.]]
369+
local eldritchOptions = { "Copy Current", "Include Weights", "Ignored" }
370+
self.controls.eldritchEnchantMode = new("DropDownControl", { "TOPRIGHT", self.controls.fetchCountEdit, "TOPLEFT" },
371+
{ -4, 0, 120, row_height },
372+
eldritchOptions, function(state) self.lastEldritchEnchantMode = state end, eldritchTooltip)
373+
self.controls.eldritchEnchantMode:SetSel(self.lastEldritchEnchantMode or 1)
374+
self.controls.eldritchEnchantLabel = new("LabelControl", { "RIGHT", self.controls.eldritchEnchantMode, "LEFT" },
375+
{ -4, 0, 50, 16 },
376+
"^7Implicits and Enchants:")
370377

371378
-- Realm selection
372379
self.controls.realmLabel = new("LabelControl", {"LEFT", self.controls.setSelect, "RIGHT"}, {18, 0, 20, row_height - 4}, "^7Realm:")
@@ -762,10 +769,17 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
762769
table.sort(result.evaluation, function(a, b) return a.weight > b.weight end)
763770
else
764771
local item = new("Item", result.item_string)
765-
if not self.enchantInSort then -- Calc item DPS without anoint or enchant as these can generally be added after.
766-
item.enchantModLines = { }
772+
773+
-- if applicable: apply same eldritch implicits or anoints as equipped
774+
if self.controls.eldritchEnchantMode:GetSelValue() == "Copy Current" then
775+
self.itemsTab:CopyAnointsAndEldritchImplicits(item, true, true)
776+
elseif self.controls.eldritchEnchantMode:GetSelValue() == "Ignored" then
777+
item.enchantModLines = {}
767778
item:BuildAndParseRaw()
768779
end
780+
-- edit the item string so that the user can see what was evaluated
781+
result.item_string = item:BuildRaw()
782+
769783
local output = self:ReduceOutput(calcFunc({ repSlotName = slotName, repItem = item }))
770784
local weight = self.tradeQueryGenerator.WeightedRatioOutputs(baseOutput, output, self.statSortSelectionList)
771785
result.evaluation = {{ output = output, weight = weight }}

src/Classes/TradeQueryGenerator.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -924,13 +924,17 @@ function TradeQueryGeneratorClass:ExecuteQuery()
924924
if self.calcContext.options.includeScourge then
925925
self:GenerateModWeights(self.modData["Scourge"])
926926
end
927-
if self.calcContext.options.includeEldritch then
927+
if self.calcContext.options.includeEldritch and
928+
-- skip weights if we need an influenced item as they can produce really
929+
-- bad results due to the filter limit
930+
self.calcContext.options.influence1 == 1 and
931+
self.calcContext.options.influence2 == 1 then
928932
self:GenerateModWeights(self.modData["Eater"])
929933
self:GenerateModWeights(self.modData["Exarch"])
930934
end
931-
if self.calcContext.options.includeSynthesis then
932-
self:GenerateModWeights(self.modData["Synthesis"])
933-
end
935+
-- if self.calcContext.options.includeSynthesis then
936+
-- self:GenerateModWeights(self.modData["Synthesis"])
937+
-- end
934938
end
935939

936940
function TradeQueryGeneratorClass:addMoreWEMods()
@@ -1184,7 +1188,7 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
11841188
local isAmuletSlot = slot and slot.slotName == "Amulet"
11851189
local isEldritchModSlot = slot and eldritchModSlots[slot.slotName] == true
11861190

1187-
controls.includeCorrupted = new("CheckBoxControl", {"TOP",nil,"TOP"}, {-40, 30, 18}, "Corrupted Mods:", function(state) end)
1191+
controls.includeCorrupted = new("CheckBoxControl", {"TOP",nil,"TOP"}, {-40, 30, 18}, "Corrupted Mods:", function(state) end, "Includes corruption implicit modifiers in the weighted sum. Note that there is a maximum search filter count which means this might cause other weights to not be included.")
11881192
controls.includeCorrupted.state = not context.slotTbl.alreadyCorrupted and (self.lastIncludeCorrupted == nil or self.lastIncludeCorrupted == true)
11891193
controls.includeCorrupted.enabled = not context.slotTbl.alreadyCorrupted
11901194

@@ -1214,7 +1218,7 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
12141218
if not isJewelSlot and not isAbyssalJewelSlot and includeScourge then
12151219
controls.includeScourge = new("CheckBoxControl", {"TOPRIGHT",lastItemAnchor,"BOTTOMRIGHT"}, {0, 5, 18}, "Scourge Mods:", function(state) end)
12161220
controls.includeScourge.state = (self.lastIncludeScourge == nil or self.lastIncludeScourge == true)
1217-
updateLastAnchor(controls.includeScourge)
1221+
updateLastAnchor(controls.includrecteScourge)
12181222
end
12191223

12201224
if isAmuletSlot then
@@ -1223,12 +1227,6 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
12231227
updateLastAnchor(controls.includeTalisman)
12241228
end
12251229

1226-
if isEldritchModSlot then
1227-
controls.includeEldritch = new("CheckBoxControl", {"TOPRIGHT",lastItemAnchor,"BOTTOMRIGHT"}, {0, 5, 18}, "Eldritch Mods:", function(state) end)
1228-
controls.includeEldritch.state = (self.lastIncludeEldritch == true)
1229-
updateLastAnchor(controls.includeEldritch)
1230-
end
1231-
12321230
if isJewelSlot and context.slotTbl.slotName ~= "Watcher's Eye" then
12331231
controls.jewelType = new("DropDownControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 100, 18}, { "Any", "Base", "Abyss" }, function(index, value) end)
12341232
controls.jewelType.selIndex = self.lastJewelType or 1
@@ -1315,16 +1313,18 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
13151313
main:ClosePopup()
13161314

13171315
self.tradeTypeIndex = context.controls.tradeTypeSelection.selIndex
1316+
options.includeEldritch = context.controls.eldritchEnchantMode:GetSelValue() == "Include Weights"
1317+
options.useCurrentEnchantsImplicits = context.controls.eldritchEnchantMode:GetSelValue() == "Copy Current"
13181318

13191319
if controls.includeMirrored then
13201320
self.lastIncludeMirrored, options.includeMirrored = controls.includeMirrored.state, controls.includeMirrored.state
13211321
end
13221322
if controls.includeCorrupted then
13231323
self.lastIncludeCorrupted, options.includeCorrupted = controls.includeCorrupted.state, controls.includeCorrupted.state
13241324
end
1325-
if controls.includeSynthesis then
1326-
self.lastIncludeSynthesis, options.includeSynthesis = controls.includeSynthesis.state, controls.includeSynthesis.state
1327-
end
1325+
-- if controls.includeSynthesis then
1326+
-- self.lastIncludeSynthesis, options.includeSynthesis = controls.includeSynthesis.state, controls.includeSynthesis.state
1327+
-- end
13281328
if controls.includeEldritch then
13291329
self.lastIncludeEldritch, options.includeEldritch = controls.includeEldritch.state, controls.includeEldritch.state
13301330
end

0 commit comments

Comments
 (0)