-
Notifications
You must be signed in to change notification settings - Fork 303
Expand file tree
/
Copy pathpassivetree.lua
More file actions
1467 lines (1263 loc) · 47.5 KB
/
passivetree.lua
File metadata and controls
1467 lines (1263 loc) · 47.5 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
local gimpBatch = require("Tree/GimpBatch/gimp_batch")
local nvtt = LoadModule("Tree/nvtt")
local json = require("dkjson")
-- by session we would like to don't extract the same file multiple times
main.treeCacheExtract = main.treeCacheExtract or { }
local cacheExtract = main.treeCacheExtract
local ignoreFilter = "^%[DNT"
if not loadStatFile then
dofile("statdesc.lua")
end
loadStatFile("passive_skill_stat_descriptions.csd")
local function CalcOrbitAngles(nodesInOrbit)
local orbitAngles = {}
if nodesInOrbit == 16 then
-- Every 30 and 45 degrees, per https://github.com/grindinggear/skilltree-export/blob/3.17.0/README.md
orbitAngles = { 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330 }
elseif nodesInOrbit == 40 then
-- Every 10 and 45 degrees
orbitAngles = { 0, 10, 20, 30, 40, 45, 50, 60, 70, 80, 90, 100, 110, 120, 130, 135, 140, 150, 160, 170, 180, 190, 200, 210, 220, 225, 230, 240, 250, 260, 270, 280, 290, 300, 310, 315, 320, 330, 340, 350 }
else
-- Uniformly spaced
for i = 0, nodesInOrbit do
orbitAngles[i + 1] = 360 * i / nodesInOrbit
end
end
for i, degrees in ipairs(orbitAngles) do
orbitAngles[i] = math.rad(degrees)
end
return orbitAngles
end
local function bits(int, s, e)
return bit.band(bit.rshift(int, s), 2 ^ (e - s + 1) - 1)
end
local function toFloat(int)
local s = (-1) ^ bits(int, 31, 31)
local e = bits(int, 23, 30) - 127
if e == -127 then
return 0 * s
end
local m = 1
for i = 0, 22 do
m = m + bits(int, i, i) * 2 ^ (i - 23)
end
return s * m * 2 ^ e
end
local function getInt(f)
local int = f:read(4)
return bytesToInt(int)
end
local function getLong(f)
local bytes = f:read(8)
local a, b, c, d, e, f, g, h = bytes:byte(1, 8)
return a + b * 256 + c * 65536 + d * 16777216 + e * 4294967296 + f * 1099511627776 + g * 281474976710656 + h * 72057594037927936
end
local function getFloat(f)
return toFloat(getInt(f))
end
local function getUint16(f)
-- Read 2 bytes
local bytes = f:read(2)
-- Convert the 2 bytes to an unsigned integer (little-endian)
local b1, b2 = bytes:byte(1, 2)
local uint16 = b1 + b2 * 256
return uint16
end
local function round_to(num, decimal_places)
local multiplier = 10 ^ decimal_places
return math.floor(num * multiplier + 0.5) / multiplier
end
local function extractSheetFiles(allSheets, is4kEnabled, extraFiles)
local filesToExtract = {}
local seen = {}
for _, sheet in ipairs(allSheets) do
for icon in pairs(sheet.files) do
if not seen[icon] then
seen[icon] = true
table.insert(filesToExtract, icon)
end
if is4kEnabled then
local icon4k = icon:gsub("(.*/)([^/]+)$", "%14k/%2")
if not seen[icon4k] then
seen[icon4k] = true
table.insert(filesToExtract, icon4k)
end
end
end
end
if extraFiles then
for _, file in ipairs(extraFiles) do
if not seen[file] then
seen[file] = true
table.insert(filesToExtract, file)
end
end
end
if #filesToExtract > 0 then
main.ggpk:ExtractList(filesToExtract, cacheExtract)
end
end
local function print_table(t, indent)
indent = indent or 0
local prefix = string.rep(" ", indent)
if type(t) ~= "table" then
print(prefix .. tostring(t))
return
end
for key, value in pairs(t) do
if type(value) == "table" then
print(prefix .. tostring(key) .. ": {")
print_table(value, indent + 1)
print(prefix .. "}")
else
print(prefix .. tostring(key) .. ": " .. tostring(value))
end
end
end
local function newSheet(name, startWidth, saturation)
return {
name = name,
startWidth = startWidth,
saturation = saturation,
sprite = { },
files = {}
}
end
local function addToSheet(sheet, icon, section, metadata)
sheet.files[icon] = sheet.files[icon] or {}
if sheet.files[icon][section] then
-- check if metadata alias already exists
if metadata.alias then
for _, meta in pairs(sheet.files[icon][section]) do
if meta.alias == metadata.alias then
return
end
end
else
for _, meta in pairs(sheet.files[icon][section]) do
if meta.alias == nil then
return
end
end
end
end
sheet.files[icon][section] = sheet.files[icon][section] or {}
table.insert(sheet.files[icon][section], metadata)
end
local function calculateDDSPack(sheet, from_base, to_base, is4kEnabled)
local stackTextures = {}
local ddsCoords = {}
for icon, sections in pairsSortByKey(sheet.files) do
local tex = Texture.new()
local rc
if is4kEnabled then
local icon4k = icon:gsub("(.*/)([^/]+)$", "%14k/%2")
rc = tex:Load(from_base .. string.lower(icon4k))
end
if not rc then
rc = tex:Load(from_base .. string.lower(icon))
end
local info = tex:Info()
local ident = string.format("%d_%d_%s", info.width, info.height, info.formatStr)
if not stackTextures[ident] then
stackTextures[ident] = {}
end
table.insert(stackTextures[ident], {
tex = tex,
icon = icon,
sections = sections
})
end
for iden, stackInfo in pairsSortByKey(stackTextures) do
local stacks = {}
local file = sheet.name .. "_" .. iden .. ".dds.zst"
ddsCoords[file] = {}
for position, stack in ipairs(stackInfo) do
for _, metadata in pairs(stack.sections) do
for _, meta in ipairs(metadata) do
local icon = meta.alias or stack.icon
ddsCoords[file][icon] = position
end
end
table.insert(stacks, stack.tex)
end
local stackTex = Texture.new()
local rc = stackTex:StackTextures(stacks)
rc = stackTex:Save(to_base .. file)
end
sheet.ddsCoords = ddsCoords
end
local function parseUIImages(file)
local text
if main.ggpk.txt[file] then
text = main.ggpk.txt[file]
else
text = convertUTF16to8(getFile(file))
main.ggpk.txt[file] = text
end
local images = {}
for line in text:gmatch("[^\r\n]+") do
local index = 0
local name = ""
for field in line:gmatch('"?([^%s"]+)"?') do
if index == 0 then
name = string.lower(field)
images[name] = {}
elseif index ==1 then
images[name]["path"] = string.lower(field)
elseif index == 2 then
images[name]["x"] = tonumber(field)
elseif index == 3 then
images[name]["y"] = tonumber(field)
elseif index == 4 then
images[name]["width"] = tonumber(field)
elseif index == 5 then
images[name]["height"] = tonumber(field)
end
index = index + 1
end
end
printf("UI Images parsed")
return images
end
--[[
===== Extraction =====
Extraction of passives tree from psg file
workflow:
- read data file
- get psg file
- parse psg file
- check version (only support version 3 for now)
--]]
-- Set to true if you want to generate assets
local generateAssets = false
local use4kIfPossible = false
-- Find a way to get the default passive tree
local idPassiveTree = 'Default'
-- Find a way to get version
local basePath = GetWorkDir() .. "/../TreeData/"
local version = "0_4"
local path = basePath .. version .. "/"
local fileTree = path .. "tree.lua"
printf("Getting passives tree...")
local rowPassiveTree = dat("passiveskilltrees"):GetRow("Id", idPassiveTree)
if rowPassiveTree == nil then
printf("Passive tree not found")
return
end
local psgFile = rowPassiveTree.PassiveSkillGraph .. ".psg"
local uiImagesFile = "art/uiimages1.txt"
printf("Extracting required assets (psg + ui images)...")
main.ggpk:ExtractList({psgFile, uiImagesFile}, cacheExtract)
-- parse UI Images
--printf("Getting UIImages ...")
local uiImages = parseUIImages(uiImagesFile)
-- uncomment next line if wanna print what we found
-- print_table(uiImages, 0)
--printf("Parsing passives tree " .. idPassiveTree .. " from " .. main.ggpk.oozPath .. psgFile)
local f = io.open(main.ggpk.oozPath .. psgFile, "rb")
-- validate version
local pgb_version = getUint16(f)
if pgb_version ~= 3 then
printf("Version " .. version .. " not supported")
return
end
f:read(11)
local psg = {
passives = { },
groups = { },
}
--printf("Parsing passives...")
local passivesCount = getInt(f)
--printf("Passive count: " .. passivesCount)
for i = 1 , passivesCount do
table.insert(psg.passives, getLong(f))
end
--printf("Parsing groups...")
local groupCount = getInt(f)
--printf("Group count: " .. groupCount)
for i = 1 , groupCount do
local group = {
x = getFloat(f),
y = getFloat(f),
flags = getInt(f),
unk1 = getInt(f),
unk2 = f:read(1):byte(),
passives = { },
}
local passiveCount = getInt(f)
for j = 1, passiveCount do
local passive = {
id = getInt(f),
radius = getInt(f),
position = getInt(f),
connections = { },
}
local connectionCount = getInt(f)
for k = 1, connectionCount do
table.insert(passive.connections, {
id = getInt(f),
radius = getInt(f),
})
end
table.insert(group.passives, passive)
end
table.insert(psg.groups, group)
end
f:close()
--printf("Passives tree " .. idPassiveTree .. " parsed")
-- uncomment next line if wanna print what we found
-- print_table(psg, 0)
--[[
===== Generation =====
Generation of passives tree from psg file
workflow:
- generate classes
- generate groups
- generate nodes
- generate sprites (with sprite sheet)
- generate zoom levels
- generate constants
--]]
-- we use functions to generate a new table and not shared table
local function commonMetadata(alias)
local metadata = {
alias = alias,
}
return metadata
end
local defaultMaxWidth = 1500
local sheets = {
newSheet("skills", defaultMaxWidth, 100),
newSheet("skills-disabled", defaultMaxWidth, 60),
newSheet("background", defaultMaxWidth, 100),
newSheet("group-background", defaultMaxWidth, 100),
newSheet("mastery-active-effect", defaultMaxWidth, 100),
newSheet("ascendancy-background", defaultMaxWidth, 100),
newSheet("oils", defaultMaxWidth, 100),
newSheet("lines", defaultMaxWidth, 100),
newSheet("jewel-sockets", defaultMaxWidth, 100),
newSheet("legion", defaultMaxWidth, 100),
newSheet("monster-categories", defaultMaxWidth, 100),
}
local sheetLocations = {
["skills"] = 1,
["skills-disabled"] = 2,
["background"] = 3,
["group-background"] = 4,
["mastery-active-effect"] = 5,
["ascendancy-background"] = 6,
["oils"] = 7,
["lines"] = 8,
["jewel-sockets"] = 9,
["legion"] = 10,
["monster-categories"] = 11,
}
local connectionArtToDecompose = {
Character = true,
CharacterAscendancy = true,
--AbyssLichAscendancy = true, Currently breaks the GIMP mask script so can't include it atm
CharacterPlanned = true,
}
local linesFiles = {}
local linesDds = {}
do
local typeOfConnections = {
"Normal", "Intermediate", "IntermediateActive"
}
for connectionArtId in pairs(connectionArtToDecompose) do
local connectionArt = dat("PassiveSkillTreeConnectionArt"):GetRow("Id", connectionArtId)
if connectionArt == nil then
printf("Connection art " .. connectionArtId .. " not found")
else
for _, typeName in ipairs(typeOfConnections) do
local linesFile = {
file = connectionArt[typeName],
mask = connectionArt.Mask,
extension = ".png",
basename = connectionArtId .. "_orbit_" .. string.lower(typeName),
first = connectionArtId .. "LineConnector",
prefix = connectionArtId .. "Orbit",
postfix = typeName == "IntermediateActive" and "Active" or typeName,
total = 10
}
table.insert(linesFiles, linesFile)
end
end
end
for _, lines in ipairs(linesFiles) do
table.insert(linesDds, lines.file)
table.insert(linesDds, lines.mask)
end
end
local function getSheet(sheetLocation)
return sheets[sheetLocations[sheetLocation]]
end
-- Looking for Background2
--printf("Extracting Background2...")
local bg2 = uiImages["art/2dart/uiimages/common/background2"]
if not bg2 then
printf("Background2 not found")
goto final
end
-- for support we needs to _out.dds when .dds
addToSheet(getSheet("background"), bg2.path, "background", commonMetadata("Background2"))
-- add Group Background base ond UIArt from PassiveTree\
--printf("Getting Background Group...")
local uIArt = rowPassiveTree.UIArt
local gBgSmall = uiImages[string.lower(uIArt.GroupBackgroundSmall)].path
addToSheet(getSheet("group-background"), gBgSmall, "groupBackground", commonMetadata("PSGroupBackground1"))
local gBgMedium = uiImages[string.lower(uIArt.GroupBackgroundMedium)].path
addToSheet(getSheet("group-background"), gBgMedium, "groupBackground", commonMetadata("PSGroupBackground2"))
local gBgLarge = uiImages[string.lower(uIArt.GroupBackgroundLarge)].path
addToSheet(getSheet("group-background"), gBgLarge, "groupBackground", commonMetadata("PSGroupBackground3"))
--printf("Getting PassiveFrame")
local pFrameNormal = uiImages[string.lower(uIArt.PassiveFrame.Normal)].path
addToSheet(getSheet("group-background"), pFrameNormal, "frame", commonMetadata("PSSkillFrame"))
local pFrameActive = uiImages[string.lower(uIArt.PassiveFrame.Active)].path
addToSheet(getSheet("group-background"), pFrameActive, "frame", commonMetadata("PSSkillFrameActive"))
local pFrameCanAllocate = uiImages[string.lower(uIArt.PassiveFrame.CanAllocate)].path
addToSheet(getSheet("group-background"), pFrameCanAllocate, "frame", commonMetadata("PSSkillFrameHighlighted"))
--printf("Getting KeystoneFrame")
local kFrameNormal = uiImages[string.lower(uIArt.KeystoneFrame.Normal)].path
addToSheet(getSheet("group-background"), kFrameNormal, "frame", commonMetadata("KeystoneFrameUnallocated"))
local kFrameActive = uiImages[string.lower(uIArt.KeystoneFrame.Active)].path
addToSheet(getSheet("group-background"), kFrameActive, "frame", commonMetadata("KeystoneFrameAllocated"))
local kFrameCanAllocate = uiImages[string.lower(uIArt.KeystoneFrame.CanAllocate)].path
addToSheet(getSheet("group-background"), kFrameCanAllocate, "frame", commonMetadata("KeystoneFrameCanAllocate"))
--printf("Getting NotableFrame")
local nFrameNormal = uiImages[string.lower(uIArt.NotableFrame.Normal)].path
addToSheet(getSheet("group-background"), nFrameNormal, "frame", commonMetadata("NotableFrameUnallocated"))
local nFrameActive = uiImages[string.lower(uIArt.NotableFrame.Active)].path
addToSheet(getSheet("group-background"), nFrameActive, "frame", commonMetadata("NotableFrameAllocated"))
local nFrameCanAllocate = uiImages[string.lower(uIArt.NotableFrame.CanAllocate)].path
addToSheet(getSheet("group-background"), nFrameCanAllocate, "frame", commonMetadata("NotableFrameCanAllocate"))
--printf("Getting GroupBackgroundBlank")
local gBgSmallBlank = uiImages[string.lower(uIArt.GroupBackgroundSmall)].path
addToSheet(getSheet("group-background"), gBgSmallBlank, "groupBackground", commonMetadata("PSGroupBackgroundSmallBlank"))
local gBgMediumBlank = uiImages[string.lower(uIArt.GroupBackgroundMedium)].path
addToSheet(getSheet("group-background"), gBgMediumBlank, "groupBackground", commonMetadata("PSGroupBackgroundMediumBlank"))
local gBgLargeBlank = uiImages[string.lower(uIArt.GroupBackgroundLarge)].path
addToSheet(getSheet("group-background"), gBgLargeBlank, "groupBackground", commonMetadata("PSGroupBackgroundLargeBlank"))
--printf("Getting JewelSocketFrame")
local jFrameNormal = uiImages[string.lower(uIArt.JewelFrame.CanAllocate)].path
addToSheet(getSheet("group-background"), jFrameNormal, "frame", commonMetadata("JewelFrameCanAllocate"))
local jFrameActive = uiImages[string.lower(uIArt.JewelFrame.Active)].path
addToSheet(getSheet("group-background"), jFrameActive, "frame", commonMetadata("JewelFrameAllocated"))
local jFrameCanAllocate = uiImages[string.lower(uIArt.JewelFrame.Normal)].path
addToSheet(getSheet("group-background"), jFrameCanAllocate, "frame", commonMetadata("JewelFrameUnallocated"))
--print("Getting Orbits art")
connectionArtToDecompose[uIArt.ConnectionsArt.Id] = true
--printf("Getting Ascendancy frames")
local ascMiddle = uiImages[string.lower("Art/2DArt/UIImages/InGame/PassiveSkillScreenAscendancyMiddle")].path
addToSheet(getSheet("group-background"), ascMiddle, "frame", commonMetadata("AscendancyMiddle"))
local ascStart = uiImages[string.lower("Art/2DArt/UIImages/InGame/PassiveSkillScreenStartNodeBackgroundInactive")].path
addToSheet(getSheet("group-background"), ascStart, "startNode", commonMetadata("PSStartNodeBackgroundInactive"))
-- adding passive tree assets
addToSheet(getSheet("ascendancy-background"), "art/textures/interface/2d/2dart/uiimages/ingame/passivetree/passivetreemaincircle.dds", "AscendancyBackground", commonMetadata("BGTree"))
addToSheet(getSheet("ascendancy-background"), "art/textures/interface/2d/2dart/uiimages/ingame/passivetree/passivetreemaincircleactive2.dds", "AscendancyBackground", commonMetadata("BGTreeActive"))
-- adding jewel sockets
local jewelArt = dat("PassiveJewelArt")
for jewel in jewelArt:Rows() do
if jewel.Item.Name:find(ignoreFilter) ~= nil then
printf("Ignoring jewel socket " .. jewel.Item.Name)
goto nexttogo
end
local asset = uiImages[string.lower(jewel.JewelArt)]
local name = jewel.Item.Name
--printf("Adding jewel socket " .. name .. " " .. asset.path .. " to sprite")
addToSheet(getSheet("jewel-sockets"), asset.path, "jewelpassive", commonMetadata(name))
:: nexttogo ::
end
-- adding unique jewel sockets
local uniqueJewelArt = dat("PassiveJewelUniqueArt")
for jewel in uniqueJewelArt:Rows() do
if jewel.WordsKey.Text:find(ignoreFilter) ~= nil then
printf("Ignoring unique jewel socket " .. jewel.Item.Name)
goto nexttogo
end
local asset = uiImages[string.lower(jewel.JewelArt)]
local name = jewel.WordsKey.Text
--printf("Adding unique jewel socket " .. name .. " " .. asset.path .. " to sprite")
addToSheet(getSheet("jewel-sockets"), asset.path, "jewelpassive", commonMetadata(name))
:: nexttogo ::
end
-- adding monster types
local monsterCategories = dat("MonsterCategories")
for category in monsterCategories:Rows() do
if category.Type:find(ignoreFilter) ~= nil then
printf("Ignoring category" .. category.Type)
goto nexttogo
end
local asset = uiImages[string.lower(category.HudImage)]
--printf("Adding category " .. category.Type .. " " .. asset.path .. " to sprite")
local name = category.Type
addToSheet(getSheet("monster-categories"), asset.path, "monster-categories", commonMetadata(name))
:: nexttogo ::
end
-- adding legion assets
for legion in dat("AlternatePassiveSkills"):Rows() do
addToSheet(getSheet("legion"), legion.DDSIcon, "legion", commonMetadata(legion.DDSIcon))
end
local artsToLegion = {
"Art/2DArt/UIImages/InGame/Abyss/AbyssPassiveSkillScreenJewelCircle1",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenEternalEmpireJewelCircle1",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenEternalEmpireJewelCircle2",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenKalguuranJewelCircle1",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenKalguuranJewelCircle2",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenKaruiJewelCircle1",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenKaruiJewelCircle2",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenMarakethJewelCircle1",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenMarakethJewelCircle2",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenTemplarJewelCircle1",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenTemplarJewelCircle2",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenVaalJewelCircle1",
"Art/2DArt/UIImages/InGame/PassiveSkillScreenVaalJewelCircle2",
}
for _, art in ipairs(artsToLegion) do
local asset = uiImages[string.lower(art)]
addToSheet(getSheet("legion"), asset.path, "legion", commonMetadata(asset.path))
end
local tree = {
["tree"] = idPassiveTree,
["min_x"]= 0,
["min_y"]= 0,
["max_x"]= 0,
["max_y"]= 0,
["classes"] = {},
["groups"] = { },
["nodes"]= { },
["assets"]={},
["ddsCoords"] = {},
["jewelSlots"] = {},
["constants"]= { -- calculate this
["classes"]= {
["StrDexIntClass"]= 0,
["StrClass"]= 1,
["DexClass"]= 2,
["IntClass"]= 3,
["StrDexClass"]= 4,
["StrIntClass"]= 5,
["DexIntClass"]= 6
},
["characterAttributes"]= {
["Strength"]= 0,
["Dexterity"]= 1,
["Intelligence"]= 2
},
["PSSCentreInnerRadius"]= 130,
["skillsPerOrbit"]= {},
["orbitAnglesByOrbit"] = {},
["orbitRadii"]= {
0, 82, 162, 335, 493, 662, 846, 251, 1080, 1322
},
},
["nodeOverlay"] = {
Normal = {
alloc = "PSSkillFrameActive",
path = "PSSkillFrameHighlighted",
unalloc = "PSSkillFrame",
},
Notable = {
alloc = "NotableFrameAllocated",
path = "NotableFrameCanAllocate",
unalloc = "NotableFrameUnallocated",
},
Keystone = {
alloc = "KeystoneFrameAllocated",
path = "KeystoneFrameCanAllocate",
unalloc = "KeystoneFrameUnallocated",
},
Socket = {
alloc = "JewelFrameAllocated",
path = "JewelFrameCanAllocate",
unalloc = "JewelFrameUnallocated",
},
},
["connectionArt"] = {
default = "Character",
ascendancy = "CharacterAscendancy",
},
}
printf("Generating classes...")
local ascedancyReplacements = {}
for i, classId in ipairs(psg.passives) do
local passiveRow = dat("passiveskills"):GetRow("PassiveSkillNodeId", classId)
if passiveRow == nil then
printf("Class " .. passiveRow.id .. " not found")
goto continue
end
if passiveRow.Name:find(ignoreFilter) ~= nil then
--printf("Ignoring class " .. passiveRow.Name)
goto continue
end
local listCharacters = passiveRow.ClassStart
if listCharacters == nil then
printf("Characters not found")
goto continue
end
for j, character in ipairs(listCharacters) do
if character.Name:find(ignoreFilter) ~= nil then
--printf("Ignoring character " .. character.Name)
goto continue2
end
local classDef = {
["name"] = character.Name,
["integerId"] = character.IntegerId,
["base_str"] = character.BaseStrength,
["base_dex"] = character.BaseDexterity,
["base_int"] = character.BaseIntelligence,
["ascendancies"] = {},
["background"] = {
["active"] = { width = 2000, height = 2000 },
["bg"] = { width = 2000, height = 2000 },
image = "Classes" .. character.Name,
section = "AscendancyBackground",
x = 0,
y = 0,
width = 1500,
height = 1500
}
}
-- add assets
addToSheet(getSheet("ascendancy-background"), character.PassiveTreeImage, "AscendancyBackground", commonMetadata( "Classes" .. character.Name))
-- We are going to ignore for now, because current tree doesn't use that
--addToSheet(getSheet("group-background"), uiImages[string.lower(character.SkillTreeBackground)].path, "startNode", commonMetadata( "center" .. string.lower(character.Name)))
local ascendancies = dat("ascendancy"):GetRowList("Class", character)
for k, ascendency in ipairs(ascendancies) do
if ascendency.Name:find(ignoreFilter) ~= nil or ascendency.isDisabled then
--printf("Ignoring ascendency " .. ascendency.Name .. " for class " .. character.Name)
goto continue3
end
if ascendency.Replace then
ascedancyReplacements[ascendency.Replace.Name] = ascendency.Name
end
table.insert(classDef.ascendancies, {
["id"] = ascendency.Name,
["name"] = ascendency.Name,
["internalId"] = ascendency.Id,
["replace"] = ascendency.Replace and ascendency.Replace.Name or nil,
["background"] = {
image = "Classes" .. ascendency.Name,
section = "AscendancyBackground",
x = 0,
y = 0,
width = 1500,
height = 1500
}
})
-- add assets
addToSheet(getSheet("ascendancy-background"), ascendency.PassiveTreeImage, "AscendancyBackground", commonMetadata( "Classes" .. ascendency.Name))
--printf("Getting Ascendancy frames " .. ascendency.Name)
local ascFrameNormal = uiImages[string.lower(ascendency.UIArt.PassiveFrame.CanAllocate)].path
addToSheet(getSheet("group-background"), ascFrameNormal, "frame", commonMetadata(ascendency.Name .. "FrameSmallCanAllocate"))
local ascFrameActive = uiImages[string.lower(ascendency.UIArt.PassiveFrame.Normal)].path
addToSheet(getSheet("group-background"), ascFrameActive, "frame", commonMetadata(ascendency.Name .. "FrameSmallNormal"))
local ascFrameCanAllocate = uiImages[string.lower(ascendency.UIArt.PassiveFrame.Active)].path
addToSheet(getSheet("group-background"), ascFrameCanAllocate, "frame", commonMetadata(ascendency.Name .. "FrameSmallAllocated"))
local ascFrameLargeNormal = uiImages[string.lower(ascendency.UIArt.NotableFrame.Normal)].path
addToSheet(getSheet("group-background"), ascFrameLargeNormal, "frame", commonMetadata(ascendency.Name .. "FrameLargeNormal"))
local ascFrameLargeCanAllocate = uiImages[string.lower(ascendency.UIArt.NotableFrame.CanAllocate)].path
addToSheet(getSheet("group-background"), ascFrameLargeCanAllocate, "frame", commonMetadata(ascendency.Name .. "FrameLargeCanAllocate"))
local ascFrameLargeAllocated = uiImages[string.lower(ascendency.UIArt.NotableFrame.Active)].path
addToSheet(getSheet("group-background"), ascFrameLargeAllocated, "frame", commonMetadata(ascendency.Name .. "FrameLargeAllocated"))
:: continue3 ::
end
if #classDef.ascendancies == 0 then
--printf("No ascendancies found for class " .. character.Name)
goto continue2
end
table.insert(tree.classes,classDef)
:: continue2 ::
end
:: continue ::
end
-- for now we are hardcoding attributes id
local base_attributes = {
{id=26297}, -- str
{id=14927}, -- dex
{id=57022}, --int
{id=46793, unlockedBy = {46454}}, -- Damage
{id=44242, unlockedBy = {46454}}, -- Defences
{id=5375, unlockedBy = {46454}}, -- Cost efficiency
}
for _, attrInfo in ipairs(base_attributes) do
local base = dat("passiveskills"):GetRow("PassiveSkillNodeId", attrInfo.id)
if base == nil then
printf("Base attribute " .. attrInfo.id .. " not found")
goto continue
end
if base.Name:find(ignoreFilter) ~= nil then
printf("Ignoring base attribute " .. base.Name)
goto continue
end
local attribute = attrInfo
attribute["name"] = base.Name
attribute["icon"] = base.Icon
attribute["stats"] = {}
-- Stats
if base.Stats ~= nil then
local parseStats = {}
for k, stat in ipairs(base.Stats) do
parseStats[stat.Id] = { min = base["Stat" .. k], max = base["Stat" .. k] }
end
local out, orders = describeStats(parseStats)
for k, line in ipairs(out) do
table.insert(attribute["stats"], line)
end
end
addToSheet(getSheet("skills"), base.Icon, "normalActive", commonMetadata(nil))
:: continue ::
end
printf("Generating tree groups...")
local orbitsConstants = { }
local ascendancyGroups = {}
local missingStatInfo = {}
for i, group in ipairs(psg.groups) do
local groupIsAscendancy = false
local treeGroup = {
["x"] = round_to(group.x, 2),
["y"] = round_to(group.y, 2),
["orbits"] ={},
["nodes"] = {}
}
local orbits = { }
for j, passive in ipairs(group.passives) do
local node = {
["skill"] = passive.id,
["group"] = i,
["orbit"] = passive.radius,
["orbitIndex"] = passive.position,
["connections"] = {},
}
-- Get Information from passive Skill
local passiveRow = dat("passiveskills"):GetRow("PassiveSkillNodeId", passive.id)
if passiveRow == nil then
--printf("Passive skill " .. passive.id .. " not found")
else
if passiveRow.Name == "" then
--printf("Ignoring passive skill " .. passive.id .. " No name")
goto exitNode
end
if passiveRow.Name:find(ignoreFilter) ~= nil and passiveRow.Name ~= "[DNT] Kite Fisher" and passiveRow.Name ~= "[DNT] Troller" and passiveRow.Name ~= "[DNT] Spearfisher" and passiveRow.Name ~= "[DNT] Angler" and passiveRow.Name ~= "[DNT] Whaler" then
--printf("Ignoring passive skill " .. passiveRow.Name)
goto exitNode
end
--printf("Passive skill " .. passiveRow.Name .. "(id: " .. passiveRow.Id .. ") found")
node["name"] = escapeGGGString(passiveRow.Name)
node["icon"] = passiveRow.Icon
if passiveRow.FlavourText ~= "" then
node["flavourText"] = passiveRow.FlavourText:gsub('\r',''):gsub('\n','\\n')
end
if passiveRow.Keystone then
node["isKeystone"] = true
addToSheet(getSheet("skills"), passiveRow.Icon, "keystoneActive", commonMetadata(nil))
addToSheet(getSheet("skills-disabled"), passiveRow.Icon, "keystoneInactive", commonMetadata(nil))
elseif passiveRow.Notable then
node["isNotable"] = true
addToSheet(getSheet("skills"), passiveRow.Icon, "notableActive", commonMetadata(nil))
addToSheet(getSheet("skills-disabled"), passiveRow.Icon, "notableInactive", commonMetadata(nil))
elseif passiveRow.IsOnlyImage then
node["isOnlyImage"] = true
elseif passiveRow.JewelSocket then
node["isJewelSocket"] = true
addToSheet(getSheet("skills"), passiveRow.Icon, "socketActive", commonMetadata(nil))
addToSheet(getSheet("skills-disabled"), passiveRow.Icon, "socketInactive", commonMetadata(nil))
else
addToSheet(getSheet("skills"), passiveRow.Icon, "normalActive", commonMetadata(nil))
addToSheet(getSheet("skills-disabled"), passiveRow.Icon, "normalInactive", commonMetadata(nil))
end
-- Ascendancy
if passiveRow.Ascendancy ~= nil then
groupIsAscendancy = true
if passiveRow.Ascendancy.Name:find(ignoreFilter) ~= nil or passiveRow.Ascendancy.isDisabled then
--printf("Ignoring node ascendancy " .. passiveRow.Ascendancy.Name)
goto exitNode
end
node["ascendancyName"] = passiveRow.Ascendancy.Name
node["isAscendancyStart"] = passiveRow.AscendancyStart or nil
-- support for jewel sockets in ascendancy
if passiveRow.JewelSocket then
node["containJewelSocket"] = true
local uioverride = passiveRow.Ascendancy.UIArt.JewelFrame
if uioverride then
local uiSocketNormal = uiImages[string.lower(uioverride.Normal)]
addToSheet(getSheet("group-background"), uiSocketNormal.path, "frame", commonMetadata(nil))
local uiSocketActive = uiImages[string.lower(uioverride.Active)]
addToSheet(getSheet("group-background"), uiSocketActive.path, "frame", commonMetadata(nil))
local uiSocketCanAllocate = uiImages[string.lower(uioverride.CanAllocate)]
addToSheet(getSheet("group-background"), uiSocketCanAllocate.path, "frame", commonMetadata(nil))
node.nodeOverlay = {
alloc = uiSocketActive.path,
path = uiSocketCanAllocate.path,
unalloc = uiSocketNormal.path,
}
else
--printf("Jewel socket not found for ascendancy " .. passiveRow.Ascendancy.Name)
end
elseif node["isOnlyImage"] == nil then
local typeFrame = node["isNotable"] and "Large" or "Small"
node.nodeOverlay = {
alloc = passiveRow.Ascendancy.Name .. "Frame" .. typeFrame .. "Allocated",
path = passiveRow.Ascendancy.Name .. "Frame" .. typeFrame .. "CanAllocate",
unalloc = passiveRow.Ascendancy.Name .. "Frame" .. typeFrame .. "Normal",
}
end
ascendancyGroups = ascendancyGroups or {}
ascendancyGroups[passiveRow.Ascendancy.Name] = ascendancyGroups[passiveRow.Ascendancy.Name] or { }
ascendancyGroups[passiveRow.Ascendancy.Name].startId = passiveRow.AscendancyStart and passive.id or ascendancyGroups[passiveRow.Ascendancy.Name].startId
ascendancyGroups[passiveRow.Ascendancy.Name][i] = true
end
-- enable custom frameArt by node
if passiveRow.FrameArt ~= nil and node["isOnlyImage"] == nil then
local frameArt = passiveRow.FrameArt
if frameArt ~= nil then
local uiNormal = uiImages[string.lower(frameArt.Normal)]
addToSheet(getSheet("group-background"), uiNormal.path, "frame", commonMetadata(nil))
local uiActive = uiImages[string.lower(frameArt.Active)]
addToSheet(getSheet("group-background"), uiActive.path, "frame", commonMetadata(nil))
local uiCanAllocate = uiImages[string.lower(frameArt.CanAllocate)]
addToSheet(getSheet("group-background"), uiCanAllocate.path, "frame", commonMetadata(nil))
node.nodeOverlay = {
alloc = uiActive.path,
path = uiCanAllocate.path,
unalloc = uiNormal.path,
}
end
end
-- Enable Ascendancy Unlock
if passiveRow.AscendancyUnlock ~= nil then
node.unlockConstraint = {
ascendancy = passiveRow.AscendancyUnlock.Name,
nodes = {}
}
for id, refNode in ipairs(passiveRow.ConstraintNode) do
--printf(" - adding node " .. refNode.Name .. " to unlock constraint")
node.unlockConstraint.nodes[id] = refNode.PassiveSkillNodeId
end
-- enable the alternative connectionArt for this node
node.connectionArt = "CharacterPlanned"
end
-- Stats
if passiveRow.Stats ~= nil then
node["stats"] = node["stats"] or {}
local parseStats = {}
local totalStats = 0
local namesStats = ""
for k, stat in ipairs(passiveRow.Stats) do
parseStats[stat.Id] = { min = passiveRow["Stat" .. k], max = passiveRow["Stat" .. k] }
totalStats = totalStats + 1
namesStats = namesStats .. stat.Id .. " | "
end
local out, orders, missing = describeStats(parseStats)
if #out < totalStats then
table.insert(missingStatInfo, "====================================")
table.insert(missingStatInfo,"Stats not found for passive " .. passiveRow.Name .. " " .. passive.id)
table.insert(missingStatInfo,"Stats found: " .. totalStats)
table.insert(missingStatInfo,namesStats)
table.insert(missingStatInfo,"Stats out: " .. #out)
for k, line in ipairs(out) do
table.insert(missingStatInfo,line)
end
table.insert(missingStatInfo,"Missing: ")
for k, _ in pairs(missing) do
if k ~= 1 then
table.insert(missingStatInfo,k)
end
end
table.insert(missingStatInfo,"====================================")