styyx-util 1.0
Utility Header for SKSE Plugin development
Loading...
Searching...
No Matches
st-perks.h
Go to the documentation of this file.
1//
2// Created by styyx on 08/03/2026.
3//
4
5#pragma once
6#include <unordered_set>
7
8namespace StyyxUtil
9{
10 struct PerkUtil
11 {
12
16 static constexpr std::array<RE::ActorValue, 18> kPlayableSkills = {
17 RE::ActorValue::kOneHanded, RE::ActorValue::kTwoHanded,
18 RE::ActorValue::kArchery, RE::ActorValue::kBlock,
19 RE::ActorValue::kSmithing, RE::ActorValue::kHeavyArmor,
20 RE::ActorValue::kLightArmor, RE::ActorValue::kPickpocket,
21 RE::ActorValue::kLockpicking, RE::ActorValue::kSneak,
22 RE::ActorValue::kAlchemy, RE::ActorValue::kSpeech,
23 RE::ActorValue::kAlteration, RE::ActorValue::kConjuration,
24 RE::ActorValue::kDestruction, RE::ActorValue::kIllusion,
25 RE::ActorValue::kRestoration, RE::ActorValue::kEnchanting
26 };
27
32 static void TraversePerkNode(RE::BGSSkillPerkTreeNode* node,
33 std::unordered_set<RE::BGSPerk*>& set_out,
34 std::unordered_set<RE::BGSSkillPerkTreeNode*>& visited)
35 {
36 if (!node || !visited.insert(node).second)
37 return;
38
39 if (node->perk) {
40 set_out.insert(node->perk);
41 }
42
43 for (auto* child : node->children) {
44 TraversePerkNode(child, set_out, visited);
45 }
46 };
47
51 static std::unordered_set<RE::BGSPerk*> GetPerksForSkill(RE::ActorValue av)
52 {
53 std::unordered_set<RE::BGSPerk*> out;
54 if (!std::ranges::contains(kPlayableSkills.begin(), kPlayableSkills.end(), av))
55 return out;
56
57 std::unordered_set<RE::BGSSkillPerkTreeNode*> visited;
58 if (const auto avif = RE::ActorValueList::GetActorValueInfo(av); avif && avif->perkTree)
59 TraversePerkNode(avif->perkTree, out, visited);
60 return out;
61 }
62
65 static std::unordered_set<RE::BGSPerk*> GetAllPlayablePerks()
66 {
68 }
69
72 static std::unordered_set<RE::BGSPerk*> GetAllMagicPerks()
73 {
75
76 }
77
80 static std::unordered_set<RE::BGSPerk*> GetAllThiefPerks()
81 {
83 }
84
87 static std::unordered_set<RE::BGSPerk*> GetAllWarriorPerks()
88 {
90 }
91 private:
92
93 static constexpr std::array<RE::ActorValue, 6> kWarriorSkills = {
94 RE::ActorValue::kOneHanded, RE::ActorValue::kTwoHanded,
95 RE::ActorValue::kHeavyArmor, RE::ActorValue::kArchery,
96 RE::ActorValue::kSmithing, RE::ActorValue::kBlock
97 };
98 static constexpr std::array<RE::ActorValue, 6> kThiefSkills = {
99 RE::ActorValue::kSpeech, RE::ActorValue::kAlchemy,
100 RE::ActorValue::kLockpicking, RE::ActorValue::kSneak,
101 RE::ActorValue::kPickpocket, RE::ActorValue::kLightArmor
102 };
103 static constexpr std::array<RE::ActorValue, 6> kMageSkills = {
104 RE::ActorValue::kAlteration, RE::ActorValue::kConjuration,
105 RE::ActorValue::kDestruction, RE::ActorValue::kIllusion,
106 RE::ActorValue::kEnchanting, RE::ActorValue::kRestoration
107 };
108
109 static std::unordered_set<RE::BGSPerk*> GetPerksForSkills(std::span<const RE::ActorValue> skills)
110 {
111 std::unordered_set<RE::BGSPerk*> out;
112 std::unordered_set<RE::BGSSkillPerkTreeNode*> visited;
113
114 for (const auto av : skills)
115 {
116 if (const auto avif = RE::ActorValueList::GetActorValueInfo(av); avif && avif->perkTree)
117 TraversePerkNode(avif->perkTree, out, visited);
118 }
119 return out;
120 }
121
122 };
123}
Definition st-actor.h:7
Definition st-perks.h:11
static std::unordered_set< RE::BGSPerk * > GetPerksForSkill(RE::ActorValue av)
Gets an unordered_set of all the perks from a given skill early return if skill is not part of Styy...
Definition st-perks.h:51
static std::unordered_set< RE::BGSPerk * > GetPerksForSkills(std::span< const RE::ActorValue > skills)
Definition st-perks.h:109
static std::unordered_set< RE::BGSPerk * > GetAllWarriorPerks()
Gets all perks belonging to warrior skills (One-Handed, Two-Handed, Archery, Block,...
Definition st-perks.h:87
static constexpr std::array< RE::ActorValue, 6 > kWarriorSkills
Definition st-perks.h:93
static constexpr std::array< RE::ActorValue, 6 > kMageSkills
Definition st-perks.h:103
static std::unordered_set< RE::BGSPerk * > GetAllPlayablePerks()
Definition st-perks.h:65
static void TraversePerkNode(RE::BGSSkillPerkTreeNode *node, std::unordered_set< RE::BGSPerk * > &set_out, std::unordered_set< RE::BGSSkillPerkTreeNode * > &visited)
recursively look through the perk tree nodes in an AVIF
Definition st-perks.h:32
static constexpr std::array< RE::ActorValue, 18 > kPlayableSkills
array of all skill relevant for the stats menu. Does not take any custom skill or the likes into acco...
Definition st-perks.h:16
static constexpr std::array< RE::ActorValue, 6 > kThiefSkills
Definition st-perks.h:98
static std::unordered_set< RE::BGSPerk * > GetAllThiefPerks()
Gets all perks belonging to thief skills (Pickpocket, Lockpicking, Light Armor, Alchemy,...
Definition st-perks.h:80
static std::unordered_set< RE::BGSPerk * > GetAllMagicPerks()
Gets all perks belonging to magic skills (Alteration, Conjuration, Destruction, Illusion,...
Definition st-perks.h:72