@@ -332,10 +332,12 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
332
332
end
333
333
self .checkSection = false
334
334
self .sockets = { }
335
+ self .runes = { }
335
336
self .itemSocketCount = 0
336
337
self .classRequirementModLines = { }
337
338
self .buffModLines = { }
338
339
self .enchantModLines = { }
340
+ self .runeModLines = { }
339
341
self .implicitModLines = { }
340
342
self .explicitModLines = { }
341
343
local implicitLines = 0
@@ -417,6 +419,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
417
419
end
418
420
end
419
421
self .itemSocketCount = # self .sockets
422
+ elseif specName == " Rune" then
423
+ t_insert (self .runes , specVal )
420
424
elseif specName == " Radius" and self .type == " Jewel" then
421
425
self .jewelRadiusLabel = specVal :match (" ^[%a ]+" )
422
426
if specVal :match (" ^%a+" ) == " Variable" then
@@ -739,11 +743,13 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
739
743
end
740
744
741
745
local modLines
742
- if modLine .enchant then
746
+ if modLine .rune then
747
+ modLines = self .runeModLines
748
+ elseif modLine .enchant then
743
749
modLines = self .enchantModLines
744
750
elseif line :find (" Requires Class" ) then
745
751
modLines = self .classRequirementModLines
746
- elseif modLine .implicit or # self .enchantModLines + # self .implicitModLines < implicitLines then
752
+ elseif modLine .implicit or # self .runeModLines + # self . enchantModLines + # self .implicitModLines < implicitLines then
747
753
modLines = self .implicitModLines
748
754
else
749
755
modLines = self .explicitModLines
@@ -788,6 +794,37 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
788
794
if self .baseName and self .title then
789
795
self .name = self .title .. " , " .. self .baseName :gsub (" %(.+%)" ," " )
790
796
end
797
+ -- this will need more advanced logic for jewel sockets in items to work properly but could just be removed as items like this was only introduced during development.
798
+ if self .base then
799
+ if self .base .weapon or self .base .armour then
800
+ if # self .runes == 0 then
801
+ for i , modLine in ipairs (self .runeModLines ) do
802
+ local value
803
+ local strippedModeLine = modLine .line :gsub (" (%d%.?%d*)" , function (val )
804
+ value = val
805
+ return " #"
806
+ end )
807
+ for name , runeMods in pairs (data .itemMods .Runes ) do
808
+ local runeValue
809
+ local runeStrippedModeLine = (self .base .weapon and runeMods .weapon or runeMods .armour )[1 ]:gsub (" (%d%.?%d*)" , function (val )
810
+ runeValue = val
811
+ return " #"
812
+ end )
813
+ if strippedModeLine == runeStrippedModeLine then
814
+ for i = 1 , round (value / runeValue ) do
815
+ t_insert (self .runes , name )
816
+ end
817
+ end
818
+ end
819
+ end
820
+ end
821
+ else
822
+ self .sockets = { }
823
+ self .itemSocketCount = 0
824
+ self .runes = { }
825
+ end
826
+ end
827
+
791
828
if self .base and not self .requirements .level then
792
829
if importedLevelReq and # self .sockets == 0 then
793
830
-- Requirements on imported items can only be trusted for items with no sockets
@@ -838,14 +875,6 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
838
875
end
839
876
end
840
877
end
841
- if self .base and self .base .socketLimit and (self .base .weapon or self .base .armour ) then -- must be a martial weapon/armour
842
- if # self .sockets == 0 then
843
- for i = 1 , self .base .socketLimit do
844
- t_insert (self .sockets , { group = 0 })
845
- end
846
- self .itemSocketCount = # self .sockets
847
- end
848
- end
849
878
if self .variantList then
850
879
self .variant = m_min (# self .variantList , self .variant or # self .variantList )
851
880
if self .hasAltVariant then
@@ -975,6 +1004,9 @@ function ItemClass:BuildRaw()
975
1004
if modLine .corruptedRange then
976
1005
line = " {corruptedRange:" .. round (modLine .corruptedRange , 2 ) .. " }" .. line
977
1006
end
1007
+ if modLine .rune then
1008
+ line = " {rune}" .. line
1009
+ end
978
1010
if modLine .enchant then
979
1011
line = " {enchant}" .. line
980
1012
end
@@ -1028,13 +1060,16 @@ function ItemClass:BuildRaw()
1028
1060
if self .quality then
1029
1061
t_insert (rawLines , " Quality: " .. self .quality )
1030
1062
end
1031
- if self .itemSocketCount and self .itemSocketCount > 0 then
1063
+ if self .itemSocketCount and self .itemSocketCount > 0 and ( self . base . weapon or self . base . armour ) then
1032
1064
local socketString = " "
1033
1065
for _ = 1 , self .itemSocketCount do
1034
1066
socketString = socketString .. " S "
1035
1067
end
1036
1068
socketString = socketString :gsub (" $" , " " )
1037
1069
t_insert (rawLines , " Sockets: " .. socketString )
1070
+ for i = 1 , self .itemSocketCount do
1071
+ t_insert (rawLines , " Rune: " .. (self .runes [i ] or " None" ))
1072
+ end
1038
1073
end
1039
1074
if self .requirements and self .requirements .level then
1040
1075
t_insert (rawLines , " LevelReq: " .. self .requirements .level )
@@ -1048,7 +1083,10 @@ function ItemClass:BuildRaw()
1048
1083
if self .classRestriction then
1049
1084
t_insert (rawLines , " Requires Class " .. self .classRestriction )
1050
1085
end
1051
- t_insert (rawLines , " Implicits: " .. (# self .enchantModLines + # self .implicitModLines ))
1086
+ t_insert (rawLines , " Implicits: " .. (# self .runeModLines + # self .enchantModLines + # self .implicitModLines ))
1087
+ for _ , modLine in ipairs (self .runeModLines ) do
1088
+ writeModLine (modLine )
1089
+ end
1052
1090
for _ , modLine in ipairs (self .enchantModLines ) do
1053
1091
writeModLine (modLine )
1054
1092
end
@@ -1075,6 +1113,39 @@ function ItemClass:BuildAndParseRaw()
1075
1113
self :ParseRaw (raw )
1076
1114
end
1077
1115
1116
+ -- Rebuild rune modifiers using the item's runes
1117
+ function ItemClass :UpdateRunes ()
1118
+ wipeTable (self .runeModLines )
1119
+ local statOrder = {}
1120
+ for _ , name in ipairs (self .runes ) do
1121
+ if name ~= " None" then
1122
+ local mod = self .base .weapon and data .itemMods .Runes [name ].weapon or self .base .armour and data .itemMods .Runes [name ].armour or { }
1123
+ for i , line in ipairs (mod ) do
1124
+ local order = mod .statOrder [i ]
1125
+ if statOrder [order ] then
1126
+ -- Combine stats
1127
+ local start = 1
1128
+ statOrder [order ].line = statOrder [order ].line :gsub (" %d+" , function (num )
1129
+ local s , e , other = line :find (" (%d+)" , start )
1130
+ start = e + 1
1131
+ return tonumber (num ) + tonumber (other )
1132
+ end )
1133
+ else
1134
+ local modLine = { line = line , order = order , rune = true , enchant = true }
1135
+ for l = 1 , # self .runeModLines + 1 do
1136
+ if not self .runeModLines [l ] or self .runeModLines [l ].order > order then
1137
+ t_insert (self .runeModLines , l , modLine )
1138
+ break
1139
+ end
1140
+ end
1141
+ statOrder [order ] = modLine
1142
+ end
1143
+ end
1144
+ end
1145
+ end
1146
+
1147
+ end
1148
+
1078
1149
-- Rebuild explicit modifiers using the item's affixes
1079
1150
function ItemClass :Craft ()
1080
1151
-- Save off any custom mods so they can be re-added at the end
@@ -1503,6 +1574,9 @@ function ItemClass:BuildModList()
1503
1574
for _ , modLine in ipairs (self .enchantModLines ) do
1504
1575
processModLine (modLine )
1505
1576
end
1577
+ for _ , modLine in ipairs (self .runeModLines ) do
1578
+ processModLine (modLine )
1579
+ end
1506
1580
for _ , modLine in ipairs (self .classRequirementModLines ) do
1507
1581
processModLine (modLine )
1508
1582
end
0 commit comments