MCPcopy Create free account
hub / github.com/Norbyte/ositools / CharacterGetCustomStat

Function CharacterGetCustomStat

OsiInterface/Functions/CustomStatFunctions.cpp:77–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 }
76
77 bool CharacterGetCustomStat(OsiArgumentDesc & args)
78 {
79 auto character = FindCharacterByNameGuid(args[0].String);
80 auto statId = args[1].String;
81 auto & statValue = args[2].Int32;
82
83 auto statDefn = FindCustomStatDefinitionById(statId);
84 if (statDefn == nullptr) return false;
85
86 auto entityWorld = GetEntityWorld();
87 auto statsComponent = entityWorld->GetCustomStatsComponentByEntityHandle(character->Base.EntityObjectHandle);
88 if (statsComponent == nullptr) {
89 OsiError("Character has no CustomStatsComponent");
90 return false;
91 }
92
93 auto value = statsComponent->StatValues.Find(statDefn->Id.Str);
94 if (value == nullptr) {
95 OsiWarn("Character has no custom stat named '" << statId << "'");
96 return false;
97 }
98
99 statValue = *value;
100 return true;
101 }
102
103 void CharacterSyncCustomStats(esv::Character * character, eoc::CustomStatsComponent * stats,
104 FixedString statKey, int statValue)

Callers

nothing calls this directly

Calls 5

FindCharacterByNameGuidFunction · 0.85
GetEntityWorldFunction · 0.85
FindMethod · 0.45

Tested by

no test coverage detected