Skip to content

Commit 1969b7a

Browse files
committed
feat: include more talent/perk info
1 parent 5cb6cb7 commit 1969b7a

6 files changed

Lines changed: 132 additions & 19 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#nullable enable
2+
using TankLib;
3+
4+
namespace DataTool.DataModels;
5+
6+
public record GenericGUIDValue(teResourceGUID GUID, string? Value = null);

DataTool/DataModels/Hero/Hero.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Dank hack to make it easier to reference this class elsewhere
2+
global using HeroVM = DataTool.DataModels.Hero.Hero;
3+
14
#nullable enable
25
using System.Collections.Generic;
36
using System.Diagnostics;

DataTool/DataModels/Hero/Loadout.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#nullable enable
1+
// Dank hack to make it easier to reference this class elsewhere
2+
global using LoadoutVM = DataTool.DataModels.Hero.Loadout;
3+
4+
#nullable enable
25
using System.Linq;
36
using DataTool.Helper;
47
using TankLib;
@@ -57,16 +60,24 @@ public LoadoutLite ToLite() {
5760

5861
return new Loadout(stu, guid);
5962
}
63+
64+
public static string? GetName(ulong guid) {
65+
var stu = STUHelper.GetInstance<STULoadout>(guid);
66+
if (stu == null) return null;
67+
return GetString(stu.m_name);
68+
}
6069
}
6170

6271
public class LoadoutLite {
72+
public teResourceGUID GUID { get; set; }
6373
public string? Name { get; set; }
6474
public string? Description { get; set; }
6575
public LoadoutCategory Category { get; set; }
6676
public teResourceGUID MovieGUID { get; set; }
6777
public teResourceGUID TextureGUID { get; set; }
6878

6979
public LoadoutLite(Loadout loadout) {
80+
GUID = loadout.GUID;
7081
Name = loadout.Name;
7182
Description = loadout.Description;
7283
Category = loadout.Category;

DataTool/DataModels/Hero/Talent.cs

Lines changed: 90 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,112 @@
11
#nullable enable
2+
using System.Linq;
23
using DataTool.Helper;
34
using TankLib;
4-
using TankLib.STU.Types;
5+
6+
using STUTalentBase = TankLib.STU.Types.STU_DF0481B0;
7+
using STUTalent = TankLib.STU.Types.STU_BDDF370E;
8+
using STUPerk = TankLib.STU.Types.STU_42B75C40;
59

610
namespace DataTool.DataModels.Hero;
711

812
public class Talent {
913
public teResourceGUID GUID { get; set; }
14+
public ETalentType TalentType = ETalentType.Unknown;
1015
public string? Name { get; set; }
1116
public string? Description { get; set; }
1217
public teResourceGUID TextureGUID { get; set; }
18+
public HeroLoadout? Loadout;
19+
public int MaxCount;
20+
public int Cost;
21+
public GenericGUIDValue? Hero;
22+
public GenericGUIDValue? Rarity;
23+
public GenericGUIDValue? Category;
24+
25+
public int Level;
26+
public bool Major;
1327

14-
public Talent(STU_BDDF370E stu, ulong key = default) {
28+
public Talent(STUTalentBase stu, ulong key = default) {
1529
Init(stu, key);
1630
}
1731

18-
public void Init(STU_BDDF370E talent, ulong key = default) {
19-
GUID = (teResourceGUID) key;
20-
TextureGUID = talent.m_544A6A4F;
32+
public void Init(STUTalentBase stu, ulong key = default) {
33+
if (stu is STUTalent talent) {
34+
TalentType = ETalentType.Talent;
35+
Name = IO.GetString(talent.m_name);
36+
Description = IO.GetString(talent.m_description);
37+
TextureGUID = talent.m_544A6A4F;
38+
MaxCount = talent.m_BBD71D14;
39+
Cost = talent.m_925E7392;
40+
41+
if (talent.m_hero != null) {
42+
Hero = new GenericGUIDValue(talent.m_hero, HeroVM.GetName(talent.m_hero));
43+
}
44+
45+
if (talent.m_672DA932 != null) {
46+
Rarity = new GenericGUIDValue(talent.m_672DA932, IO.GetNullableGUIDName(talent.m_672DA932));
47+
}
48+
49+
if (talent.m_category?.m_id != null) {
50+
Category = new GenericGUIDValue(talent.m_category.m_id, IO.GetNullableGUIDName(talent.m_category.m_id));
51+
}
52+
53+
if (talent.m_loadout != null) {
54+
var hero = FindHeroForLoadout(talent.m_loadout);
55+
56+
Loadout = new HeroLoadout {
57+
GUID = talent.m_loadout,
58+
Name = LoadoutVM.GetName(talent.m_loadout),
59+
HeroGUID = hero?.GUID ?? null,
60+
HeroName = hero?.Name,
61+
};
62+
}
63+
} else if (stu is STUPerk perk) {
64+
TalentType = ETalentType.Perk;
65+
if (perk.m_loadout != null) {
66+
var hero = FindHeroForLoadout(perk.m_loadout);
67+
68+
Loadout = new HeroLoadout {
69+
GUID = perk.m_loadout,
70+
Name = LoadoutVM.GetName(perk.m_loadout),
71+
HeroGUID = hero?.GUID ?? null,
72+
HeroName = hero?.Name,
73+
};
74+
}
2175

22-
Name = IO.GetString(talent.m_name)?.TrimEnd();
23-
// todo: why do the names end in spaces.. it causes a double-space with the chat box in-game
24-
Description = IO.GetString(talent.m_description);
76+
Name = LoadoutVM.GetName(perk.m_loadout);
77+
Level = (int) perk.m_4DDE5023;
78+
Major = perk.m_D60C9EA2 != 0;
79+
}
2580
}
2681

2782
public static Talent? Load(ulong guid) {
28-
var baseType = STUHelper.GetInstance<STU_DF0481B0>(guid);
29-
if (baseType is not STU_BDDF370E talent) {
30-
// is a perk (or null)
31-
return null;
83+
var stu = STUHelper.GetInstance<STUTalentBase>(guid);
84+
if (stu == null) return null;
85+
return new Talent(stu, guid);
86+
}
87+
88+
private static HeroVM? FindHeroForLoadout(teResourceGUID loadoutGuid) {
89+
foreach (var (heroGuid, hero) in Helpers.GetHeroes()) {
90+
if (!hero.IsHero || hero.Loadouts == null) continue;
91+
if (hero.Loadouts.Any(loadout => loadout.GUID == loadoutGuid)) {
92+
return hero;
93+
}
3294
}
3395

34-
return new Talent(talent, guid);
96+
return null;
97+
}
98+
99+
public record HeroLoadout {
100+
public teResourceGUID GUID;
101+
public string? Name;
102+
public teResourceGUID? HeroGUID;
103+
public string? HeroName;
104+
}
105+
106+
public enum ETalentType {
107+
Unknown = 0,
108+
Talent = 1,
109+
Perk = 2,
35110
}
36-
}
111+
}
112+

DataTool/Static/GUIDNames.csv

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,4 +899,17 @@ F4A,09F,Menu/Ilios (Junker Queen),1
899899
01E,17B,Legendary Loot Box (S15),1
900900
021,17B,Epic Loot Box (S16),1
901901
026,17B,Loot Box (S16),1
902-
027,17B,Legendary Loot Box (S16),1
902+
027,17B,Legendary Loot Box (S16),1
903+
; Rarities,,,
904+
297,01C,Common,1
905+
61ED,01C,Epic,1
906+
3DA0,01C,Rare,1
907+
644A,01C,Legendary,1
908+
64F0,01C,Mythic,1
909+
; Stadium Categories,,,
910+
68D3,01C,Weapon,1
911+
5FDC,01C,Ability,1
912+
ECD2,01C,Survival,1
913+
ECC7,01C,HeroPower,1
914+
2BB,01C,Gadget,1
915+

DataTool/ToolLogic/List/ListTalents.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ public void Parse(ICLIFlags toolFlags) {
1919
}
2020

2121
IndentHelper indentLevel = new IndentHelper();
22-
foreach (var loadout in data) {
23-
Log($"{indentLevel}{loadout.Value.Name}:");
22+
foreach (var (key, talent) in data) {
23+
Log($"{indentLevel}{talent.Name}:");
2424
if (!flags.Simplify) {
25-
Log($"{indentLevel + 1}Description: {loadout.Value.Description}");
25+
Log($"{indentLevel + 1}Type: {talent.TalentType}");
26+
Log($"{indentLevel + 1}Description: {talent.Description}");
27+
Log($"{indentLevel + 1}Rarity: {talent.Rarity?.Value}");
28+
Log($"{indentLevel + 1}Category: {talent.Category?.Value}");
29+
2630
Log();
2731
}
2832
}

0 commit comments

Comments
 (0)