-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDustman.lua
More file actions
1819 lines (1611 loc) · 68.8 KB
/
Dustman.lua
File metadata and controls
1819 lines (1611 loc) · 68.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
-------------------------------------------------------------------------------
-- Dustman, by Ayantir & iFedix
-------------------------------------------------------------------------------
This software is under : CreativeCommons CC BY-NC-SA 4.0
Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
NonCommercial — You may not use the material for commercial purposes.
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Please read full licence at :
http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
]]
-- Leaked for menu & data
Dustman = {}
Dustman.savedVars = {}
Dustman.globalSavedVars = {}
local ADDON_NAME = "Dustman"
-- Libraries ------------------------------------------------------------------
local LR = LibResearch
local LS = LibSets
-- Local variables ------------------------------------------------------------
local usableIngredients = {}
local hoveredBagId
local hoveredSlotId
local dustmanKeybinds
local hoveredItemCanBeJunked
local hoveredItemCanBeDestroyed
local isItemJunk
local descriptorName = GetString(SI_ITEM_ACTION_MARK_AS_JUNK)
local markedAsJunk = {}
local globalMarkedAsJunk = {}
local requestedScan
local defaults = {
worldname = GetWorldName(),
useGlobalSettings = true,
--equipable items
equipment = {
--weapons/armors
wa = {
notrait = false,
notraitQuality = ITEM_QUALITY_NORMAL,
enabled = false,
equipmentQuality = ITEM_QUALITY_NORMAL,
ornate = true,
ornateQuality = ITEM_QUALITY_MAGIC,
whiteZeroValue = false,
keepIntricate = true,
keepIntricateIfNotMaxed = false,
keepResearchable = true,
keepSetItems = true,
keepLevel = 1,
keepLevelOrnate = false,
keepNirnhoned = true,
keepArenaWeapons = true,
keepMonsterSets = true,
keepBG = true,
keepCrafted = true,
keepCyroA = true,
keepCyroW = true,
keepDungeon = true,
keepIC = true,
keepOverland = true,
keepSpecial = true,
keepTrial = true,
disguises = false,
disguisesDestroy = false,
},
--jewelry
j = {
notrait = false,
notraitQuality = ITEM_QUALITY_NORMAL,
enabled = false,
equipmentQuality = ITEM_QUALITY_NORMAL,
ornate = true,
ornateQuality = ITEM_QUALITY_MAGIC,
whiteZeroValue = false,
keepIntricate = true,
keepIntricateIfNotMaxed = false,
keepResearchable = true,
keepSetItems = true,
keepLevel = 1,
keepLevelOrnate = false,
keepDRandIC = true,
keepBG = true,
keepCrafted = true,
keepCyro = true,
keepDungeon = true,
keepIC = true,
keepOverland = true,
keepSpecial = true,
keepTrial = true,
},
},
--crafting materials
crafting = {
lowLevelBlacksmithingMaterials = false,
lowLevelBlacksmithingRawMaterials = false,
lowLevelClothingMaterials = false,
lowLevelClothingRawMaterials = false,
lowLevelWoodworkingMaterials = false,
lowLevelWoodworkingRawMaterials = false,
lowLevelJewelryMaterials = false,
lowLevelJewelryRawMaterials = false,
},
--provisioning
provisioning = {
recipe = false,
recipeQuality = ITEM_QUALITY_MAGIC,
unusable = false,
all = false,
dish = true,
drink = true,
excludeRareAdditives = true,
fullStack = false,
},
--furnishing
furnishing = {
alchResin = false,
bast = false,
cleanPelt = false,
decWax = false,
heartwood = false,
mundRune = false,
ochre = false,
regulus = false,
},
--glyphs
glyphs = false,
glyphsQuality = ITEM_QUALITY_NORMAL,
keepLevelGlyphs = 1,
--jewelry master writs
jewelryMasterWrits = false,
jewelryMasterWritsQuality = ITEM_QUALITY_ARCANE,
--food/drink
foodAll = false,
foodQuality = ITEM_QUALITY_NORMAL,
--fishing
lure = false,
lureFullStack = false,
lureFullStackBank = false,
trophy = false,
trophies = false,
--daily login items
dailyLoginFood = false,
dailyLoginDrink =false,
dailyLoginPoisons = false,
dailyLoginPotions = false,
dailyLoginRepairKits = false,
dailyLoginSoulGems = false,
-- Enchanting
enchanting = {
enchantingAspect = false,
aspectQuality = ITEM_QUALITY_NORMAL,
aspectFullStack = false,
enchantingEssence = false,
essenceFullStack = false,
essenceRunes = {
[1] = {"45839", false}, --Dekeipa
[2] = {"45833", false}, --Deni
[3] = {"45836", false}, --Denima
[4] = {"45842", false}, --Deteri
[5] = {"68342", false}, --Hakeijo
[6] = {"45841", false}, --Haoko
[7] = {"166045", false}, --Indeko
[8] = {"45849", false}, --Kaderi
[9] = {"45837", false}, --Kuoko
[10] = {"45848", false}, --Makderi
[11] = {"45832", false}, --Makko
[12] = {"45835", false}, --Makkoma
[13] = {"45840", false}, --Meip
[14] = {"45831", false}, --Oko
[15] = {"45834", false}, --Okoma
[16] = {"45843", false}, --Okori
[17] = {"45846", false}, --Oru
[18] = {"45838", false}, --Rakeipa
[19] = {"45847", false}, --Taderi
},
enchantingPotency = false,
potencyFullStack = false,
potencyRunes = {
[1] = {"45812", false}, --Dekeipa
[2] = {"45814", false}, --Derado
[3] = {"45822", false}, --Edode
[4] = {"45809", false}, --Edora
[5] = {"45825", false}, --Hade
[6] = {"45826", false}, --Idode
[7] = {"68340", false}, --Itade
[8] = {"45810", false}, --Jaera
[9] = {"45821", false}, --Jayde
[10] = {"64508", false}, --Jehade
[11] = {"45806", false}, --Jejora
[12] = {"45857", false}, --Jera
[13] = {"45855", false}, --Jora
[14] = {"45828", false}, --Kedeko
[15] = {"45830", false}, --Kude
[16] = {"45816", false}, --Kura
[17] = {"45818", false}, --Notade
[18] = {"45819", false}, --Ode
[19] = {"45807", false}, --Odra
[20] = {"45827", false}, --Pode
[21] = {"45823", false}, --Pojode
[22] = {"45508", false}, --Pojora
[23] = {"45811", false}, --Pora
[24] = {"45856", false}, --Porade
[25] = {"45829", false}, --Rede
[26] = {"64509", false}, --Rejera
[27] = {"45824", false}, --Rekude
[28] = {"45815", false}, --Rekura
[29] = {"68341", false}, --Repora
[30] = {"45813", false}, --Rera
[31] = {"45820", false}, --Tade
}
},
--potions
potions = false,
fullStackBagPotions = false,
fullStackBankPotions = false,
keepPotionsLevel = 1,
--poisons
poisons = false,
fullStackBagPoisons = false,
fullStackBankPoisons = false,
poisonsSolvants = false,
fullStackBagPoisonsSolvants = false,
fullStackBankPoisonsSolvants = false,
keepPoisonsLevel = 1,
-- soul gems
emptyGems = false,
-- treasures
treasures = false,
-- treasure maps
treasureMaps = false,
treasureMapsDestroy = false,
-- museum pieces
museumPieces = false,
museumPiecesDestroy = false,
--style
styleMaterial = {
["33252"] = false, --Adamantite (Altmer)
["46150"] = false, --Argentum (Primal)
["33194"] = false, --Bone (Bosmer)
["46149"] = false, --Copper (Barbaric)
["33256"] = false, --Corundum (Nord)
["46151"] = false, --Daedra Heart (Daedric)
["33150"] = false, --Flint (Argonian)
["33257"] = false, --Manganese (Orc)
["33251"] = false, --Molybdenum (Breton)
["33255"] = false, --Moonstone (Khajiit)
["33254"] = false, --Nickel (Imperial)
["33253"] = false, --Obsidian (Dunmer)
["46152"] = false, --Palladium (Ancient Elf)
["33258"] = false, --Starmetal (Redguard)
},
--traits
traitMaterial = {
--armor traits
["23221"] = false, --Almandine (Well-Fitted)
["30219"] = false, --Bloodstone (Infused)
["23219"] = false, --Diamond (Impenetrable)
["4442"] = false, --Emerald (Training)
["23171"] = false, --Garnet (Exploration)
["4456"] = false, --Quartz (Sturdy)
["23173"] = false, --Sapphire (Divines)
["30221"] = false, --Sardonyx (Reinforced)
--weapon traits
["23204"] = false, --Amethyst (Charged)
["23165"] = false, --Carnelian (Training)
["23203"] = false, --Chysolite (Powered)
["16291"] = false, --Citrine (Weighted)
["23149"] = false, --Fire Opal (Sharpened)
["810"] = false, --Jade (Infused)
["4486"] = false, --Ruby (Precise)
["813"] = false, --Turquoise (Defending)
--jewelry traits
["135156"] = false, --Antimony (Healthy)
["135155"] = false, --Cobalt (Arcane)
["135157"] = false, --Zinc (Robust)
["139412"] = false, --Gilding Wax (Swift)
["139413"] = false, --Dibellium (Harmony)
["139409"] = false, --Dawn-Prism (Triune)
["139414"] = false, --Slaughterstone (Bloodthirsty)
["139410"] = false, --Titanium (Protective)
["139411"] = false, --Aurbic Amber (Infused)
},
itemTraits = {
[ITEM_TRAIT_TYPE_ARMOR_DIVINES] = false,
[ITEM_TRAIT_TYPE_ARMOR_EXPLORATION] = false,
[ITEM_TRAIT_TYPE_ARMOR_IMPENETRABLE] = false,
[ITEM_TRAIT_TYPE_ARMOR_INFUSED] = false,
[ITEM_TRAIT_TYPE_ARMOR_PROSPEROUS] = false,
[ITEM_TRAIT_TYPE_ARMOR_REINFORCED] = false,
[ITEM_TRAIT_TYPE_ARMOR_STURDY] = false,
[ITEM_TRAIT_TYPE_ARMOR_TRAINING] = false,
[ITEM_TRAIT_TYPE_ARMOR_WELL_FITTED] = false,
[ITEM_TRAIT_TYPE_WEAPON_CHARGED] = false,
[ITEM_TRAIT_TYPE_WEAPON_DECISIVE] = false,
[ITEM_TRAIT_TYPE_WEAPON_DEFENDING] = false,
[ITEM_TRAIT_TYPE_WEAPON_INFUSED] = false,
[ITEM_TRAIT_TYPE_WEAPON_POWERED] = false,
[ITEM_TRAIT_TYPE_WEAPON_PRECISE] = false,
[ITEM_TRAIT_TYPE_WEAPON_SHARPENED] = false,
[ITEM_TRAIT_TYPE_WEAPON_TRAINING] = false,
[ITEM_TRAIT_TYPE_WEAPON_WEIGHTED] = false,
[ITEM_TRAIT_TYPE_JEWELRY_ARCANE] = false,
[ITEM_TRAIT_TYPE_JEWELRY_BLOODTHIRSTY] = false,
[ITEM_TRAIT_TYPE_JEWELRY_ROBUST] = false,
[ITEM_TRAIT_TYPE_JEWELRY_HEALTHY] = false,
[ITEM_TRAIT_TYPE_JEWELRY_HARMONY] = false,
[ITEM_TRAIT_TYPE_JEWELRY_INFUSED] = false,
[ITEM_TRAIT_TYPE_JEWELRY_PROTECTIVE] = false,
[ITEM_TRAIT_TYPE_JEWELRY_TRIUNE] = false,
[ITEM_TRAIT_TYPE_JEWELRY_SWIFT] = false,
},
junkTraitSets = false,
styleFullStack = false,
traitFullStack = false,
--destroy items
destroy = false,
destroyExcludeStackable = false,
destroyValue = 0,
destroyQuality = ITEM_QUALITY_NORMAL,
destroyStolenValue = 0,
destroyStolenQuality = ITEM_QUALITY_NORMAL,
--notifications
notifications = {
verbose = false,
found = false,
allItems = true,
total = true,
sellDialog = true,
sell = true,
},
--stolen items
stolen = false,
lowStolen = 1,
excludeStolenClothes = true,
launder = false,
stolenQuality = ITEM_QUALITY_NORMAL,
stolenRecipeQuality = ITEM_QUALITY_NORMAL,
excludeLaunder = {
[ITEMTYPE_SOUL_GEM] = false,
[ITEMTYPE_TOOL] = false,
[ITEMTYPE_POTION_BASE] = false,
[ITEMTYPE_POISON_BASE] = false,
[ITEMTYPE_INGREDIENT] = false,
[ITEMTYPE_STYLE_MATERIAL] = false,
[ITEMTYPE_FOOD] = false,
[ITEMTYPE_DRINK] = false,
[ITEMTYPE_TRASH] = false,
[ITEMTYPE_TREASURE] = false,
[ITEMTYPE_FURNISHING_MATERIAL] = false,
[ITEMTYPE_RECIPE] = false,
[ITEMTYPE_POISON] = false,
[ITEMTYPE_POTION] = false,
},
destroyNonLaundered = false,
--remember user marked junk
memory = false,
useMemoryFirst = false,
housingRecipes = false,
housingRecipesQuality = ITEM_QUALITY_NORMAL,
junkKeybind = false,
destroyKeybind = false,
--continuos scan mode
automaticScan = true,
--bursar of tributes quest giver cwcs
bot = 1,
}
-- Local functions ------------------------------------------------------------
local function MyPrint(message)
CHAT_SYSTEM:AddMessage(message)
end
local function SplitString (inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
local function CanGemifyItem(bagId, slotIndex)
if IsItemFromCrownCrate(bagId, slotIndex) and not IsItemPlayerLocked(bagId, slotIndex) then
local itemsRequired, gemsAwarded = GetNumCrownGemsFromItemManualGemification(bagId, slotIndex)
return gemsAwarded > 0 and itemsRequired > 0
end
return false
end
local function GetEssenceRule(itemId)
for i, k in ipairs(Dustman.GetSettings().enchanting.essenceRunes) do
if k[1]==itemId then return k[2] end
end
end
local function GetPotencyRule(itemId)
for i, k in ipairs(Dustman.GetSettings().enchanting.potencyRunes) do
if k[1]==itemId then return k[2] end
end
end
local function BuildUsableIngredientsList()
local RECIPE_LIST_INDEX_MAX_PROVISIONNER = 16
for recipeListIndex = 1, RECIPE_LIST_INDEX_MAX_PROVISIONNER do -- 16 provisionning, after it's housing
local _, numRecipes = GetRecipeListInfo(recipeListIndex)
for recipeIndex = 1, numRecipes do
local known, _, numIngredients, _, _, _ = GetRecipeInfo(recipeListIndex, recipeIndex)
for ingredientIndex = 1, numIngredients do
local link = GetRecipeIngredientItemLink(recipeListIndex, recipeIndex, ingredientIndex, LINK_STYLE_DEFAULT)
if link ~= "" then
local itemId = select(4, ZO_LinkHandler_ParseLink(link))
if itemId then
usableIngredients[itemId] = known
end
end
end
end
end
end
local function IsFullStackInBag(BackPackSlotId, bagId, itemLink)
local stackCountBackpack, stackCountBank, stackCountCraftBag = GetItemLinkStacks(itemLink)
local _, maxStack = GetSlotStackSize(BAG_BACKPACK, BackPackSlotId)
if bagId == BAG_BACKPACK then
return stackCountBackpack >= maxStack
elseif bagId == BAG_BANK then
return stackCountBank + stackCountCraftBag >= maxStack
end
end
local function IsItemProtected(bagId, slotId)
-- ESOUI
if IsItemPlayerLocked(bagId, slotId) then
return true
end
--Item Saver support
if ItemSaver_IsItemSaved and ItemSaver_IsItemSaved(bagId, slotId) then
return true
end
--FCO ItemSaver support
if FCOIS then
--FCOIS version <1.0.0
if FCOIsMarked then
local FCOiconsToCheck = {}
--Build icons to check table, and don't add the "coin" icon, because these items should be sold
for i=1, FCOIS.numVars.gFCONumFilterIcons, 1 do
if i ~= FCOIS_CON_ICON_SELL then
FCOiconsToCheck[i] = i
end
end
return FCOIsMarked(GetItemInstanceId(bagId, slotId), FCOiconsToCheck)
else
--FCOIS version 1.0.0 and higher
--Check all marker icons but exclude the icon #5 (Coins symbol = item marked to sell) and check dynamic icons if sell is allowed
if FCOIS.IsJunkLocked then
return FCOIS.IsJunkLocked(bagId, slotId)
end
end
end
--FilterIt support
if FilterIt and FilterIt.AccountSavedVariables and FilterIt.AccountSavedVariables.FilteredItems then
local sUniqueId = Id64ToString(GetItemUniqueId(bagId, slotId))
if FilterIt.AccountSavedVariables.FilteredItems[sUniqueId] then
return FilterIt.AccountSavedVariables.FilteredItems[sUniqueId] ~= FILTERIT_VENDOR
end
end
return false
end
local function IsItemNeededForResearch(itemLink)
--CraftStore 3.30 support
if CS and CS.GetTrait and CS.account and CS.account.crafting then
local craft, row, trait = CS.GetTrait(itemLink)
-- Loop all chars known by CS
for char, data in pairs(CS.account.crafting.studies) do
--if a char study this item
if data[craft] and data[craft][row] and (data[craft][row]) then
-- If this char didn't yet researched this item
if CS.account.crafting.research[char][craft] and CS.account.crafting.research[char][craft][row] and CS.account.crafting.research[char][craft][row][trait] == false then
return true
end
end
end
return false
end
--libResearch
local _, isResearchable = LR:GetItemTraitResearchabilityInfo(itemLink)
return isResearchable
end
local function pairsByQuality(bagCache)
local arraySorted = {}
for key, data in pairs(bagCache) do table.insert(arraySorted, data) end
local function sortByPosition(a, b)
return a.quality > b.quality
end
table.sort(arraySorted, sortByPosition)
return arraySorted
end
local function SellJunkItems(isFence)
if GetInteractionType() == INTERACTION_VENDOR then
local total = 0
local count = 0
local transactions = 0
local transactionsMessage = true
local hagglingBonus, hasHagglingBonus
local bagCache = SHARED_INVENTORY:GenerateFullSlotData(nil, BAG_BACKPACK)
if isFence then
hagglingBonus = GetNonCombatBonus(NON_COMBAT_BONUS_HAGGLING)
hasHagglingBonus = hagglingBonus > 0
bagCache = pairsByQuality(bagCache)
end
for slotId, data in pairs(bagCache) do
if transactions < 50 then
if data.isJunk then
if data.stolen == isFence then
if isFence then
local totalSells, sellsUsed = GetFenceSellTransactionInfo()
if sellsUsed == totalSells then
ZO_Alert(UI_ALERT_CATEGORY_ALERT, SOUNDS.NEGATIVE_CLICK, GetString("SI_STOREFAILURE", STORE_FAILURE_AT_FENCE_LIMIT))
if total > 0 and Dustman.GetSettings().notifications.total then
MyPrint(zo_strformat(DUSTMAN_FORMAT_TOTAL, count, total, transactions))
end
return
end
end
local name = GetItemLink(BAG_BACKPACK, data.slotIndex)
if IsItemProtected(BAG_BACKPACK, data.slotIndex) then
SetItemIsJunk(BAG_BACKPACK, data.slotIndex, false)
MyPrint(zo_strformat(DUSTMAN_FORMAT_NOTSOLD, name))
else
SellInventoryItem(BAG_BACKPACK, data.slotIndex, data.stackCount)
local sellPrice = data.sellPrice
if isFence and hasHagglingBonus then
sellPrice = zo_round(sellPrice * (1 + hagglingBonus / 100))
end
if Dustman.GetSettings().notifications.allItems then
local RECEIPT_FORMAT
if sellPrice == 0 then
RECEIPT_FORMAT = GetString(DUSTMAN_FORMAT_ZERO)
else
RECEIPT_FORMAT = GetString(DUSTMAN_FORMAT_GOLD)
end
MyPrint(zo_strformat(RECEIPT_FORMAT, name, data.stackCount, sellPrice * data.stackCount))
end
count = count + data.stackCount
transactions = transactions + 1
total = total + sellPrice * data.stackCount
end
end
end
elseif transactionsMessage then
transactionsMessage = false
MyPrint(GetString(DUSTMAN_ZOS_RESTRICTIONS))
end
end
if total > 0 and Dustman.GetSettings().notifications.total then
MyPrint(zo_strformat(DUSTMAN_FORMAT_TOTAL, count, total, transactions))
end
end
end
local function LaunderingItem(bagCache)
local total = 0
local count = 0
local transactions = 0
local transactionsMessage = true
bagCache = pairsByQuality(bagCache)
for slotId, data in pairs(bagCache) do
if transactions < 50 then
if data.toLaunder then
local totalSells, sellsUsed = GetFenceLaunderTransactionInfo()
if sellsUsed == totalSells then
ZO_Alert(UI_ALERT_CATEGORY_ALERT, SOUNDS.NEGATIVE_CLICK, GetString("SI_ITEMLAUNDERRESULT", ITEM_LAUNDER_RESULT_AT_LIMIT))
if total > 0 and Dustman.GetSettings().notifications.total then
MyPrint(zo_strformat(DUSTMAN_FORMATL_TOTAL, count, total))
end
return
end
local name = GetItemLink(BAG_BACKPACK, data.slotIndex)
if IsItemProtected(BAG_BACKPACK, data.slotIndex) then
MyPrint(zo_strformat(DUSTMAN_FORMATL_NOTSOLD, name))
else
local numFreeSlots = GetNumBagFreeSlots(BAG_BACKPACK)
local qtyToLaunder = math.min(data.stackCount, (totalSells - sellsUsed))
if numFreeSlots > 0 or data.stackCount <= (totalSells - sellsUsed) then
LaunderItem(BAG_BACKPACK, data.slotIndex, qtyToLaunder)
if Dustman.GetSettings().notifications.allItems then
local RECEIPT_FORMAT
if data.launderPrice == 0 then
RECEIPT_FORMAT = GetString(DUSTMAN_FORMATL_ZERO)
else
RECEIPT_FORMAT = GetString(DUSTMAN_FORMATL_GOLD)
end
MyPrint(zo_strformat(RECEIPT_FORMAT, name, qtyToLaunder, data.launderPrice * qtyToLaunder))
end
transactions = transactions + 1
count = count + qtyToLaunder
total = total + data.launderPrice * qtyToLaunder
end
end
end
elseif transactionsMessage then
transactionsMessage = false
MyPrint(GetString(DUSTMAN_ZOS_RESTRICTIONS))
end
end
if total > 0 and Dustman.GetSettings().notifications.total then
MyPrint(zo_strformat(DUSTMAN_FORMATL_TOTAL, count, total))
end
end
local function HandleJunk(bagId, slotId, itemLink, sellPrice, forceDestroy, ruleName, itemCode, special)
if Dustman.GetSettings().destroy or forceDestroy then
local destroy = false
if forceDestroy then
destroy = true
else
if not special then
local quality = GetItemLinkQuality(itemLink)
local isStolen = IsItemLinkStolen(itemLink)
local _, maxStack = GetSlotStackSize(bagId, slotId)
if isStolen then
destroy = quality <= Dustman.GetSettings().destroyStolenQuality and (sellPrice <= Dustman.GetSettings().destroyStolenValue and ((not Dustman.GetSettings().destroyExcludeStackable) or (Dustman.GetSettings().destroyExcludeStackable and maxStack <= 1)))
else
destroy = quality <= Dustman.GetSettings().destroyQuality and (sellPrice == 0 or (sellPrice <= Dustman.GetSettings().destroyValue and ((not Dustman.GetSettings().destroyExcludeStackable) or (Dustman.GetSettings().destroyExcludeStackable and maxStack <= 1))))
end
end
end
if destroy then
DestroyItem(bagId, slotId)
if Dustman.GetSettings().notifications.verbose then
MyPrint(zo_strformat(DUSTMAN_NOTE_DESTROY, itemLink, ruleName))
end
return
end
end
if not IsItemJunk(bagId, slotId) then
local memory = Dustman.GetSettings().memory-- should be deleted, same line next and last
Dustman.GetSettings().memory = false
local junked={}
if Dustman.savedVars.useGlobalSettings then
junked = globalMarkedAsJunk
else
junked = markedAsJunk
end
if not itemCode or (itemCode and junked[itemCode]) then
SetItemIsJunk(bagId, slotId, true) -- We do mark as junk all basic items and those who have been manually set as junk. if they have been moved out from junk by users, no need to re-re-mark them as non junk.
if Dustman.GetSettings().notifications.verbose then
MyPrint(zo_strformat(DUSTMAN_NOTE_JUNK, itemLink, ruleName))
end
end
Dustman.GetSettings().memory = memory
end
end
local function saveBotItemsForQuest(id,itemLink,bagId,slotId)
if id==0 then
return false
elseif id==1 then --"A Matter of Tributes" quest
--5 Cosmetics and Grooming Items
--d("5 Cosmetics and Grooming Items")
local count = GetItemLinkNumItemTags(itemLink)
for i = 1, count do
local text, cat = GetItemLinkItemTagInfo(itemLink, i)
--d("text: "..text)
if cat == TAG_CATEGORY_TREASURE_TYPE then
if text == GetString(DUSTMAN_BOT_COSMETIC) or text == GetString(DUSTMAN_BOT_GROOMING_ITEMS) then
--d("ret true")
return true
end
end
end
elseif id==2 then --"A Matter of Respect" quest
--5 utensils, drinkware, dishes or cookware
--d("5 utensils, drinkware, dishes or cookware")
local count = GetItemLinkNumItemTags(itemLink)
for i = 1, count do
local text, cat = GetItemLinkItemTagInfo(itemLink, i)
--d("text: "..text)
if cat == TAG_CATEGORY_TREASURE_TYPE then
if text == GetString(DUSTMAN_BOT_UTENSILS) or text == GetString(DUSTMAN_BOT_DAC) or text == GetString(DUSTMAN_BOT_DRINKWARE) then
--d("ret true")
return true
end
end
end
elseif id==3 then --"A Matter of Leisure" quest
--5 toys, dolls or games
--d("5 toys, dolls or games")
local count = GetItemLinkNumItemTags(itemLink)
for i = 1, count do
local text, cat = GetItemLinkItemTagInfo(itemLink, i)
--d("text: "..text)
if cat == TAG_CATEGORY_TREASURE_TYPE then
if text == GetString(DUSTMAN_BOT_CT) or text == GetString(DUSTMAN_BOT_DOLLS) or text == GetString(DUSTMAN_BOT_GAMES) then
--d("ret true")
return true
end
end
end
elseif id==4 then --"Glitter and Gleam" quest
--3 pieces of armor with the ornate trait
--d("3 pieces of armor with the ornate trait")
itemType, _ = GetItemLinkItemType(itemLink)
if itemType == ITEMTYPE_ARMOR then
if GetItemTrait(bagId, slotId) == ITEM_TRAIT_TYPE_ARMOR_ORNATE then
--d("ret true")
return true
end
end
elseif id==5 then --"Morsels and Pecks" quest
--2 Elemental Essence, 3 Supple Roots, 3 Ectoplasm
--d("2 Elemental Essence, 3 Supple Roots, 3 Ectoplasm")
itemId = select(4, ZO_LinkHandler_ParseLink(itemLink))
if itemId=="54385" or itemId=="54388" or itemId=="54384" then
--d("ret true")
return true
end
elseif id==6 then --"Nibbles and Bits" quest
--4 Carapaces, 3 Foul Hide, 5 Daedra Husks
--d("4 Carapaces, 3 Foul Hide, 5 Daedra Husks")
if itemId=="54382" or itemId=="54381" or itemId=="54383" then
--d("ret true")
return true
end
end
--d("ret false")
return false
end
local function saveAllBotItems(itemLink,bagId,slotId)
res = false
for i=1,6 do
res = res or saveBotItemsForQuest(i,itemLink,bagId,slotId)
end
return res
end
local function botItems(itemLink, bagId, slotId)
--d("BOT: "..tostring(Dustman.GetSettings().bot))
if Dustman.GetSettings().bot == 1 then return false end
if Dustman.GetSettings().bot == 2 then
return saveAllBotItems(itemLink,bagId,slotId)
else
local id = 0
for questIndex = 1, MAX_JOURNAL_QUESTS do
questName = GetJournalQuestName(questIndex)
if questName == GetString(DUSTMAN_BOT_QUEST_NAME_1) then id=1
elseif questName == GetString(DUSTMAN_BOT_QUEST_NAME_2) then id=2
elseif questName == GetString(DUSTMAN_BOT_QUEST_NAME_3) then id=3
elseif questName == GetString(DUSTMAN_BOT_QUEST_NAME_4) then id=4
elseif questName == GetString(DUSTMAN_BOT_QUEST_NAME_5) then id=5
elseif questName == GetString(DUSTMAN_BOT_QUEST_NAME_6) then id=6
end
end
return saveBotItemsForQuest(id,itemLink,bagId,slotId)
end
end
-- Event handlers -------------------------------------------------------------
local function OnInventorySingleSlotUpdate(_, bagId, slotId, isNewItem)
if not Dustman.GetSettings().automaticScan then
if not requestedScan then return end
end
local junked={}
if Dustman.savedVars.useGlobalSettings then
junked = globalMarkedAsJunk
else
junked = markedAsJunk
end
if IsUnderArrest() then return end -- Avoid check when a guard destroy stolen items
if IsItemJunk(bagId, slotId) then return end --we do not need to check junk again
if Roomba and Roomba.WorkInProgress and Roomba.WorkInProgress() then return end --support for Roomba
if BankManagerRevived_inProgress and BankManagerRevived_inProgress() then return end --support for BankManagerRevived
local _, stackCount, sellPrice, _, _, equipType, itemStyle, quality = GetItemInfo(bagId, slotId)
if stackCount < 1 then return end -- empty slot
local itemLink = GetItemLink(bagId, slotId)
local itemType, specializedItemType = GetItemLinkItemType(itemLink)
local itemId = select(4, ZO_LinkHandler_ParseLink(itemLink))
local level = GetItemLevel(bagId, slotId)
--priority 0: items from bursar of tributes cwc quest giver
if botItems(itemLink, bagId, slotId) then return end
local dontLaunder
-- Stolen item to do not launder, not in the main block because it must be re-evaluated.
if IsItemLinkStolen(itemLink) then
if itemType ~= ITEMTYPE_TREASURE then
if (Dustman.GetSettings().excludeLaunder[itemType] and quality <= ITEM_QUALITY_NORMAL and (itemType ~= ITEMTYPE_STYLE_MATERIAL or (itemType == ITEMTYPE_STYLE_MATERIAL and Dustman.GetSettings().styleMaterial[itemId] ~= nil))) or (itemType == ITEMTYPE_RECIPE and quality <= Dustman.GetSettings().stolenRecipeQuality) then
if Dustman.GetSettings().destroyNonLaundered then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "FENCE-TO-DESTROY") -- Will destroy the item directly
return
else
dontLaunder = true
end
end
else
if Dustman.GetSettings().lowStolen == 2 and quality < Dustman.GetSettings().stolenQuality then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "FENCE-TO-DESTROY") -- Will destroy the item directly
return
elseif Dustman.GetSettings().lowStolen ~= 3 then
dontLaunder = true
end
end
end
--ignored items
if Dustman.IsOnIgnoreList(itemId) then
return
--support for Item Saver and FCO ItemSaver
elseif IsItemProtected(bagId, slotId) then
return
--items marked by user (if it is set as a high priority filter)
elseif Dustman.GetSettings().useMemoryFirst and Dustman.GetSettings().memory then
local itemCode = zo_strjoin("_", itemId, quality, level)
if junked[itemCode] ~= nil then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "USER-BEFORE", itemCode)
return
end
end
--furninshing materials
if Dustman.GetSettings().furnishing.alchResin and specializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_MATERIAL_ALCHEMY then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "ALCHEMICAL RESIN")
return
end
if specializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_MATERIAL_CLOTHIER then
if Dustman.GetSettings().furnishing.bast and itemId == "114890" then HandleJunk(bagId, slotId, itemLink, sellPrice, false, "BAST") end
if Dustman.GetSettings().furnishing.cleanPelt and itemId == "114891" then HandleJunk(bagId, slotId, itemLink, sellPrice, false, "CLEAN PELT") end
return
end
if Dustman.GetSettings().furnishing.decWax and specializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_MATERIAL_PROVISIONING then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "DECORATIVE WAX")
return
end
if Dustman.GetSettings().furnishing.heartwood and specializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_MATERIAL_WOODWORKING then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "HEARTWOOD")
return
end
if Dustman.GetSettings().furnishing.mundRune and specializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_MATERIAL_ENCHANTING then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "MUNDUS RUNE")
return
end
if Dustman.GetSettings().furnishing.ochre and specializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_MATERIAL_JEWELRYCRAFTING then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "OCHRE")
return
end
if Dustman.GetSettings().furnishing.regulus and specializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_MATERIAL_BLACKSMITHING then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "REGULUS")
return
end
--daily login items
if not IsItemFromCrownCrate(bagId, slotId) and GetItemBindType(bagId, slotId) ~= BIND_TYPE_NONE then --the second check is to delete only bound potions (to introduce compatibility with Crafted potions addon)
if Dustman.GetSettings().dailyLoginFood and itemType==ITEMTYPE_FOOD and string.find(string.upper(GetItemLinkName(itemLink)), GetString(DUSTMAN_CROWN)) then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "DL FOOD")
return
end
--drinks
if Dustman.GetSettings().dailyLoginDrinks and itemType==ITEMTYPE_DRINK and string.find(string.upper(GetItemLinkName(itemLink)), GetString(DUSTMAN_CROWN)) then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "DL DRINK")
return
end
--potions
if Dustman.GetSettings().dailyLoginPotions and itemType==ITEMTYPE_POTION and quality>ITEM_QUALITY_NORMAL then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "DL POTION")
return
end
--potions
if Dustman.GetSettings().dailyLoginPoisons and itemType==ITEMTYPE_POISON and quality>ITEM_QUALITY_NORMAL then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "DL POISON")
return
end
--crown repair kits
if Dustman.GetSettings().dailyLoginRepairKits and itemType==ITEMTYPE_CROWN_REPAIR then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "DL REPAIR KIT")
return
end
--soul gems
if Dustman.GetSettings().dailyLoginSoulGems and itemType==ITEMTYPE_SOUL_GEM and quality>ITEM_QUALITY_MAGIC then
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "DL SOUL GEM")
return
end
end
--jewelry master writs
if itemType == ITEMTYPE_MASTER_WRIT and Dustman.GetSettings().jewelryMasterWrits and quality <= Dustman.GetSettings().jewelryMasterWritsQuality then
if SplitString(itemLink,':')[9]=='24' or SplitString(itemLink,':')[9]=='18' then --filtering jewelry writs -> 18: necklace 24: ring
HandleJunk(bagId, slotId, itemLink, sellPrice, true, "JEWELRY MASTER WRIT")
return
end
end
if quality == ITEM_QUALITY_LEGENDARY then return end
-- stolen clothes
if Dustman.GetSettings().excludeStolenClothes and itemType == ITEMTYPE_ARMOR and GetItemLinkArmorType(itemLink) == ARMORTYPE_NONE and
equipType ~= EQUIP_TYPE_NECK and equipType ~= EQUIP_TYPE_RING and equipType ~= EQUIP_TYPE_COSTUME and equipType ~= EQUIP_TYPE_INVALID then
return
--stolen items with no other use then selling to fence
elseif Dustman.GetSettings().stolen and itemType == ITEMTYPE_TREASURE and ((IsItemLinkStolen(itemLink) and quality >= Dustman.GetSettings().stolenQuality) or not IsItemLinkStolen(itemLink)) then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "FENCE")
return
--trash items
elseif itemType == ITEMTYPE_TRASH then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "TRASH")
return
--crafting low level materials (blacksmithing)
elseif Dustman.GetSettings().crafting.lowLevelBlacksmithingMaterials and itemType == ITEMTYPE_BLACKSMITHING_MATERIAL and itemId ~= "64489" then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "BLACKSMITHING LOW LEVEL MATERIAL")
return
elseif Dustman.GetSettings().crafting.lowLevelBlacksmithingRawMaterials and itemType == ITEMTYPE_BLACKSMITHING_RAW_MATERIAL and itemId ~= "71198" then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "BLACKSMITHING LOW LEVEL RAW MATERIAL")
return
--crafting low level materials (clothing)
elseif Dustman.GetSettings().crafting.lowLevelClothingMaterials and itemType == ITEMTYPE_CLOTHIER_MATERIAL and itemId ~= "64504" and itemId ~= "64506" then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "CLOTHING LOW LEVEL MATERIAL")
return
elseif Dustman.GetSettings().crafting.lowLevelClothingRawMaterials and itemType == ITEMTYPE_CLOTHIER_RAW_MATERIAL and itemId ~= "71200" and itemId ~= "71239" then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "CLOTHING LOW LEVEL RAW MATERIAL")
return
--crafting low level materials (woodworking)
elseif Dustman.GetSettings().crafting.lowLevelWoodworkingMaterials and itemType == ITEMTYPE_WOODWORKING_MATERIAL and itemId ~= "64502" then
HandleJunk(bagId, slotId, itemLink, sellPrice, false, "WOODWORKING LOW LEVEL MATERIAL")
return
elseif Dustman.GetSettings().crafting.lowLevelWoodworkingRawMaterials and itemType == ITEMTYPE_WOODWORKING_RAW_MATERIAL and itemId ~= "71199" then