Skip to content

Commit 01c396a

Browse files
author
justjuangui
committed
Add Ascendancy replacement feature
1 parent 86f6116 commit 01c396a

4 files changed

Lines changed: 132 additions & 10 deletions

File tree

src/Classes/PassiveSpec.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,12 @@ function PassiveSpecClass:BuildAllDependsAndPaths()
972972
-- ignore cluster jewel nodes that don't have an id in the tree
973973
if self.tree.nodes[id] then
974974
local nodeToReplace = self.tree.nodes[id]
975-
if self.tree.nodes[id].isSwitchable and self.tree.nodes[id].options[self.curClassName] then
976-
nodeToReplace = self.tree.nodes[id].options[self.curClassName]
975+
if self.tree.nodes[id].isSwitchable then
976+
if self.tree.nodes[id].options[self.curClassName] then
977+
nodeToReplace = self.tree.nodes[id].options[self.curClassName]
978+
elseif self.tree.nodes[id].options[self.curAscendClassName] then
979+
nodeToReplace = self.tree.nodes[id].options[self.curAscendClassName]
980+
end
977981
self.switchableNodes[nodeToReplace.id] = node
978982
end
979983
self:ReplaceNode(node, nodeToReplace)
@@ -1415,6 +1419,8 @@ function PassiveSpecClass:BuildAllDependsAndPaths()
14151419
end
14161420

14171421
function PassiveSpecClass:ReplaceNode(old, newNode)
1422+
old.overlay = newNode.overlay
1423+
old.icon = newNode.icon
14181424
-- Edited nodes can share a name
14191425
if old.sd == newNode.sd then
14201426
return 1
@@ -1426,8 +1432,6 @@ function PassiveSpecClass:ReplaceNode(old, newNode)
14261432
old.modList = new("ModList")
14271433
old.modList:AddList(newNode.modList)
14281434
old.keystoneMod = newNode.keystoneMod
1429-
old.icon = newNode.icon
1430-
old.spriteId = newNode.spriteId
14311435
old.activeEffectImage = newNode.activeEffectImage
14321436
old.reminderText = newNode.reminderText or { }
14331437
end

src/Classes/PassiveTree.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ local PassiveTreeClass = newClass("PassiveTree", function(self, treeVersion)
230230
node.type = "AscendClassStart"
231231
local ascendClass = self.ascendNameMap[node.ascendancyName].ascendClass
232232
ascendClass.startNodeId = node.id
233+
if node.isSwitchable then
234+
for ascName, _ in pairs(node.options) do
235+
local option = self.ascendNameMap[ascName].ascendClass
236+
option.startNodeId = node.id
237+
end
238+
end
233239
elseif node.isOnlyImage then
234240
node.type = "OnlyImage"
235241
elseif node.isJewelSocket then
@@ -550,6 +556,16 @@ function PassiveTreeClass:ProcessNode(node)
550556
switchNode.dn = switchNode.name
551557
switchNode.sd = switchNode.stats
552558

559+
if switchNode.jewelOverlay then
560+
ConPrintf("SwitchNode with jewelOverlay found: "..switchNode.name)
561+
switchNode.overlay = switchNode.jewelOverlay
562+
if switchNode.overlay then
563+
local size = node.targetSize["overlay"] and node.targetSize["overlay"].width or node.targetSize.width
564+
switchNode.rsq = size * size
565+
switchNode.size = size
566+
end
567+
end
568+
553569
self:ProcessStats(switchNode)
554570
end
555571
end

src/Classes/PassiveTreeView.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,14 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
421421
-- draw ascendancies
422422
for name, data in pairs(tree.ascendNameMap) do
423423
local ascendancy = data.ascendClass
424-
if ascendancy.background then
424+
local drawn = true
425+
if ascendancy.replaceBy and ascendancy.replaceBy == spec.curAscendClassBaseName then
426+
drawn = false
427+
elseif ascendancy.replace and name ~= spec.curAscendClassBaseName then
428+
drawn = false
429+
end
430+
431+
if ascendancy.background and drawn then
425432
local bg = tree:GetAssetByName(ascendancy.background.image)
426433
local scrX, scrY = treeToScreen(ascendancy.background.x * tree.scaleImage, ascendancy.background.y * tree.scaleImage)
427434
bg.width = ascendancy.background.width

src/Export/Scripts/passivetree.lua

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ local tree = {
615615
}
616616

617617
printf("Generating classes...")
618+
local ascedancyReplacements = {}
618619
for i, classId in ipairs(psg.passives) do
619620
local passiveRow = dat("passiveskills"):GetRow("PassiveSkillNodeId", classId)
620621
if passiveRow == nil then
@@ -669,10 +670,14 @@ for i, classId in ipairs(psg.passives) do
669670
printf("Ignoring ascendency " .. ascendency.Name .. " for class " .. character.Name)
670671
goto continue3
671672
end
673+
if ascendency.Replace then
674+
ascedancyReplacements[ascendency.Replace.Name] = ascendency.Name
675+
end
672676
table.insert(classDef.ascendancies, {
673677
["id"] = ascendency.Name,
674678
["name"] = ascendency.Name,
675679
["internalId"] = ascendency.Id,
680+
["replace"] = ascendency.Replace and ascendency.Replace.Name or nil,
676681
["background"] = {
677682
image = "Classes" .. ascendency.Name,
678683
section = "AscendancyBackground",
@@ -985,6 +990,63 @@ for i, group in ipairs(psg.groups) do
985990
}
986991
end
987992

993+
if passiveRow.Ascendancy and ascedancyReplacements[passiveRow.Ascendancy.Name] then
994+
node["isSwitchable"] = true
995+
local ascendancyRow = dat("ascendancy"):GetRow("Name", ascedancyReplacements[passiveRow.Ascendancy.Name])
996+
997+
local nodeInfo = {
998+
["ascendancyName"] = ascedancyReplacements[passiveRow.Ascendancy.Name]
999+
}
1000+
1001+
local switchNode = dat("ascendancypassiveskilloverrides"):GetRow("OriginalNode", passiveRow)
1002+
if switchNode then
1003+
nodeInfo.id = switchNode.SwitchedNode.PassiveSkillNodeId
1004+
nodeInfo.name = switchNode.SwitchedNode.Name
1005+
nodeInfo.icon = switchNode.SwitchedNode.Icon
1006+
nodeInfo.stats = {}
1007+
1008+
-- add to assets
1009+
addToSheet(getSheet("skills"), switchNode.SwitchedNode.Icon, "normalActive", commonMetadata(nil))
1010+
addToSheet(getSheet("skills-disabled"), switchNode.SwitchedNode.Icon, "normalInactive", commonMetadata(nil))
1011+
1012+
-- Stats
1013+
if switchNode.SwitchedNode.Stats ~= nil then
1014+
local parseStats = {}
1015+
for k, stat in ipairs(switchNode.SwitchedNode.Stats) do
1016+
parseStats[stat.Id] = { min = switchNode.SwitchedNode["Stat" .. k], max = switchNode.SwitchedNode["Stat" .. k] }
1017+
end
1018+
local out, orders = describeStats(parseStats)
1019+
for k, line in ipairs(out) do
1020+
table.insert(nodeInfo["stats"], line)
1021+
end
1022+
end
1023+
end
1024+
1025+
if passiveRow.JewelSocket and ascendancyRow.UIArt.JewelFrame then
1026+
-- override the jewel socket assets if any
1027+
local uioverride = ascendancyRow.UIArt.JewelFrame
1028+
1029+
local uiSocketNormal = uiImages[string.lower(uioverride.Normal)]
1030+
addToSheet(getSheet("group-background"), uiSocketNormal.path, "frame", commonMetadata(nil))
1031+
1032+
local uiSocketActive = uiImages[string.lower(uioverride.Active)]
1033+
addToSheet(getSheet("group-background"), uiSocketActive.path, "frame", commonMetadata(nil))
1034+
1035+
local uiSocketCanAllocate = uiImages[string.lower(uioverride.CanAllocate)]
1036+
addToSheet(getSheet("group-background"), uiSocketCanAllocate.path, "frame", commonMetadata(nil))
1037+
1038+
nodeInfo.jewelOverlay = {
1039+
alloc = uiSocketActive.path,
1040+
path = uiSocketCanAllocate.path,
1041+
unalloc = uiSocketNormal.path,
1042+
}
1043+
end
1044+
1045+
node["options"] = {
1046+
[ascedancyReplacements[passiveRow.Ascendancy.Name]] = nodeInfo
1047+
}
1048+
end
1049+
9881050
-- classStartName
9891051
if #passiveRow.ClassStart > 0 then
9901052
node["classesStart"] = {}
@@ -1113,11 +1175,6 @@ for i, classId in ipairs(psg.passives) do
11131175
local cX = hardCoded * math.cos(angle)
11141176
local cY = hardCoded * math.sin(angle)
11151177

1116-
ascendancy.background.x = cX
1117-
ascendancy.background.y = cY
1118-
1119-
j = j + 1
1120-
11211178
local info = ascendancyGroups[ascendancy.id]
11221179
if info == nil then
11231180
printf("Ascendancy group " .. ascendancy.id .. " not found")
@@ -1128,6 +1185,10 @@ for i, classId in ipairs(psg.passives) do
11281185
printf("Ascendancy node " .. ascendancy.id .. " not found")
11291186
goto continuepositioning
11301187
end
1188+
1189+
ascendancy.background.x = cX
1190+
ascendancy.background.y = cY
1191+
11311192
local groupAscendancy = tree.groups[ascendancyNode.group]
11321193

11331194
local innerRadious = dat("ascendancy"):GetRow("Id", ascendancy.internalId).distanceTree
@@ -1158,11 +1219,45 @@ for i, classId in ipairs(psg.passives) do
11581219
end
11591220
end
11601221

1222+
j = j + 1
11611223
:: continuepositioning ::
11621224
end
11631225
end
11641226
end
11651227

1228+
printf("Fixing replace ascendancies position...")
1229+
for from, to in pairs(ascedancyReplacements) do
1230+
local fromAscendancy
1231+
local toAscendancy
1232+
for _, class in ipairs(tree.classes) do
1233+
for _, ascendancy in ipairs(class.ascendancies) do
1234+
if ascendancy.name == from then
1235+
fromAscendancy = ascendancy
1236+
end
1237+
if ascendancy.name == to then
1238+
toAscendancy = ascendancy
1239+
end
1240+
end
1241+
end
1242+
1243+
if fromAscendancy == nil then
1244+
printf("From ascendancy " .. from .. " not found")
1245+
goto continuereplace
1246+
end
1247+
if toAscendancy == nil then
1248+
printf("To ascendancy " .. to .. " not found")
1249+
goto continuereplace
1250+
end
1251+
1252+
fromAscendancy.replaceBy = to
1253+
1254+
toAscendancy.background.x = fromAscendancy.background.x
1255+
toAscendancy.background.y = fromAscendancy.background.y
1256+
1257+
:: continuereplace ::
1258+
end
1259+
1260+
11661261
printf("Generating sprite info...")
11671262
for i, sheet in ipairs(sheets) do
11681263
printf("Calculating sprite dimensions for " .. sheet.name)

0 commit comments

Comments
 (0)