Skip to content

Commit a5fa50f

Browse files
justjuanguijustjuangui
andauthored
Fix ascendancy nodes position (#1016)
Co-authored-by: justjuangui <servicios@juacarvajal.com>
1 parent 383bebf commit a5fa50f

File tree

5 files changed

+1256
-431
lines changed

5 files changed

+1256
-431
lines changed

src/Classes/PassiveTree.lua

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ local m_sqrt = math.sqrt
1919
local m_rad = math.rad
2020
local m_atan2 = math.atan2
2121

22-
-- These values are from the 3.6 tree; older trees are missing values for these constants
23-
local legacySkillsPerOrbit = { 1, 6, 12, 12, 40 }
24-
local legacyOrbitRadii = { 0, 82, 162, 335, 493 }
25-
2622
-- Retrieve the file at the given URL
2723
-- This is currently disabled as it does not work due to issues
2824
-- its possible to fix this but its never used due to us performing preprocessing on tree
@@ -116,12 +112,9 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
116112
end
117113
end
118114

119-
self.skillsPerOrbit = self.constants.skillsPerOrbit or legacySkillsPerOrbit
120-
self.orbitRadii = self.constants.orbitRadii or legacyOrbitRadii
121-
self.orbitAnglesByOrbit = {}
122-
for orbit, skillsInOrbit in ipairs(self.skillsPerOrbit) do
123-
self.orbitAnglesByOrbit[orbit] = self:CalcOrbitAngles(skillsInOrbit)
124-
end
115+
self.skillsPerOrbit = self.constants.skillsPerOrbit
116+
self.orbitRadii = self.constants.orbitRadii
117+
self.orbitAnglesByOrbit = self.constants.orbitAnglesByOrbit
125118

126119
ConPrintf("Loading passive tree assets...")
127120
for name, data in pairs(self.assets) do
@@ -285,31 +278,6 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
285278
group.ascendancyName = node.ascendancyName
286279
if node.isAscendancyStart then
287280
group.isAscendancyStart = true
288-
self.ascendNameMap[node.ascendancyName].ascendClass.background = {
289-
image = "Classes" .. self.ascendNameMap[node.ascendancyName].ascendClass.name,
290-
section = "AscendancyBackground",
291-
x = group.x,
292-
y = group.y,
293-
width = 1500 * self.scaleImage,
294-
height = 1500 * self.scaleImage
295-
}
296-
end
297-
if node.classesStart then
298-
for _, className in ipairs(node.classesStart) do
299-
local class = self.classes[self.classNameMap[className]]
300-
if class ~= nil then
301-
class.background = {
302-
["active"] = { width = 2000 * self.scaleImage, height = 2000 * self.scaleImage },
303-
["bg"] = { width = 2000 * self.scaleImage, height = 2000 * self.scaleImage },
304-
image = "Classes" .. className,
305-
section = "AscendancyBackground",
306-
x = 0,
307-
y = 0,
308-
width = 1500 * self.scaleImage,
309-
height = 1500 * self.scaleImage
310-
}
311-
end
312-
end
313281
end
314282
elseif node.type == "Notable" or node.type == "Keystone" then
315283
self.clusterNodeMap[node.dn] = node

src/Export/Scripts/passivetree.lua

Lines changed: 86 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ if not loadStatFile then
1212
end
1313
loadStatFile("passive_skill_stat_descriptions.csd")
1414

15+
local function CalcOrbitAngles(nodesInOrbit)
16+
local orbitAngles = {}
17+
18+
if nodesInOrbit == 16 then
19+
-- Every 30 and 45 degrees, per https://github.com/grindinggear/skilltree-export/blob/3.17.0/README.md
20+
orbitAngles = { 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330 }
21+
elseif nodesInOrbit == 40 then
22+
-- Every 10 and 45 degrees
23+
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 }
24+
else
25+
-- Uniformly spaced
26+
for i = 0, nodesInOrbit do
27+
orbitAngles[i + 1] = 360 * i / nodesInOrbit
28+
end
29+
end
30+
31+
for i, degrees in ipairs(orbitAngles) do
32+
orbitAngles[i] = math.rad(degrees)
33+
end
34+
35+
return orbitAngles
36+
end
37+
1538
local function extractFromGgpk(listToExtract, useRegex)
1639
useRegex = useRegex or false
1740
local sweetSpotCharacter = 6000
@@ -542,36 +565,37 @@ end
542565
local tree = {
543566
["tree"] = idPassiveTree,
544567
["min_x"]= 0,
545-
["min_y"]= 0,
546-
["max_x"]= 0,
547-
["max_y"]= 0,
568+
["min_y"]= 0,
569+
["max_x"]= 0,
570+
["max_y"]= 0,
548571
["classes"] = {},
549572
["groups"] = { },
550573
["nodes"]= { },
551574
["assets"]={},
552575
["ddsCoords"] = {},
553576
["jewelSlots"] = {},
554577
["constants"]= { -- calculate this
555-
["classes"]= {
556-
["StrDexIntClass"]= 0,
557-
["StrClass"]= 1,
558-
["DexClass"]= 2,
559-
["IntClass"]= 3,
560-
["StrDexClass"]= 4,
561-
["StrIntClass"]= 5,
562-
["DexIntClass"]= 6
563-
},
564-
["characterAttributes"]= {
565-
["Strength"]= 0,
566-
["Dexterity"]= 1,
567-
["Intelligence"]= 2
568-
},
569-
["PSSCentreInnerRadius"]= 130,
570-
["skillsPerOrbit"]= {},
571-
["orbitRadii"]= {
578+
["classes"]= {
579+
["StrDexIntClass"]= 0,
580+
["StrClass"]= 1,
581+
["DexClass"]= 2,
582+
["IntClass"]= 3,
583+
["StrDexClass"]= 4,
584+
["StrIntClass"]= 5,
585+
["DexIntClass"]= 6
586+
},
587+
["characterAttributes"]= {
588+
["Strength"]= 0,
589+
["Dexterity"]= 1,
590+
["Intelligence"]= 2
591+
},
592+
["PSSCentreInnerRadius"]= 130,
593+
["skillsPerOrbit"]= {},
594+
["orbitAnglesByOrbit"] = {},
595+
["orbitRadii"]= {
572596
0, 82, 162, 335, 493, 662, 846, 251, 1080, 1322
573-
}
574-
},
597+
},
598+
},
575599
}
576600

577601
printf("Generating classes...")
@@ -605,6 +629,16 @@ for i, classId in ipairs(psg.passives) do
605629
["base_dex"] = character.BaseDexterity,
606630
["base_int"] = character.BaseIntelligence,
607631
["ascendancies"] = {},
632+
["background"] = {
633+
["active"] = { width = 2000, height = 2000 },
634+
["bg"] = { width = 2000, height = 2000 },
635+
image = "Classes" .. character.Name,
636+
section = "AscendancyBackground",
637+
x = 0,
638+
y = 0,
639+
width = 1500,
640+
height = 1500
641+
}
608642
}
609643

610644
-- add assets
@@ -622,7 +656,15 @@ for i, classId in ipairs(psg.passives) do
622656
table.insert(classDef.ascendancies, {
623657
["id"] = ascendency.Name,
624658
["name"] = ascendency.Name,
625-
["internalId"] = ascendency.Id
659+
["internalId"] = ascendency.Id,
660+
["background"] = {
661+
image = "Classes" .. ascendency.Name,
662+
section = "AscendancyBackground",
663+
x = 0,
664+
y = 0,
665+
width = 1500,
666+
height = 1500
667+
}
626668
})
627669

628670
-- add assets
@@ -985,6 +1027,11 @@ for i, orbit in ipairs(orbitsConstants) do
9851027
tree.constants.skillsPerOrbit[i] = orbit
9861028
end
9871029

1030+
-- calculate the orbit radius
1031+
for orbit, skillsInOrbit in ipairs(tree.constants.skillsPerOrbit) do
1032+
tree.constants.orbitAnglesByOrbit[orbit] = CalcOrbitAngles(skillsInOrbit)
1033+
end
1034+
9881035
-- Update position of ascendancy base on min / max
9891036
-- get the orbit radius + hard-coded value, calculate the angle of the class start
9901037
-- translate the ascendancy to the new position in arc position
@@ -1025,12 +1072,25 @@ for i, classId in ipairs(psg.passives) do
10251072
local groupAscendancy = tree.groups[ascendancyNode.group]
10261073

10271074
local angle = startAngle + (j - 1) * angleStep
1028-
local newX = hardCoded * math.cos(angle)
1029-
local newY = hardCoded * math.sin(angle)
1075+
local cX = hardCoded * math.cos(angle)
1076+
local cY = hardCoded * math.sin(angle)
1077+
1078+
ascendancy.background.x = cX
1079+
ascendancy.background.y = cY
1080+
1081+
local innerRadious = dat("ascendancy"):GetRow("Id", ascendancy.internalId).distanceTree
1082+
1083+
local newInnerX = cX + math.cos(angleToCenter) * innerRadious
1084+
local newInnerY = cY + math.sin(angleToCenter) * innerRadious
1085+
1086+
local nodeAngle = tree.constants.orbitAnglesByOrbit[ascendancyNode.orbit + 1][ascendancyNode.orbitIndex + 1]
1087+
local orbitRadius = tree.constants.orbitRadii[ascendancyNode.orbit + 1]
1088+
local newX = newInnerX - math.sin(nodeAngle) * orbitRadius
1089+
local newY = newInnerY + math.cos(nodeAngle) * orbitRadius
10301090

10311091
local offsetX = newX - groupAscendancy.x
10321092
local offsetY = newY - groupAscendancy.y
1033-
1093+
10341094
-- now update the whole groups with the offset
10351095
for groupId, value in pairs(info) do
10361096
if type(value) == "boolean" then

src/Export/spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ return {
14781478
},
14791479
[10]={
14801480
list=false,
1481-
name="",
1481+
name="distanceTree",
14821482
refTo="",
14831483
type="Int",
14841484
width=180

src/TreeData/0_2/tree.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)