diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index dc46acffe..5d570f227 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -246,6 +246,16 @@ void StatsFunctions::SetCurrentFatigue(unsigned short pid, float value) noexcept player->CreatureStats()->mDynamic[2].mCurrent = 0; } +int StatsFunctions::GetAttributeCount() noexcept +{ + return Attribute::Length; +} + +int StatsFunctions::GetSkillCount() noexcept +{ + return Skill::Length; +} + int StatsFunctions::GetAttributeId(const char *name) noexcept { for (int x = 0; x < Attribute::Length; x++) @@ -274,11 +284,17 @@ int StatsFunctions::GetSkillId(const char *name) noexcept const char *StatsFunctions::GetAttributeName(unsigned short attribute) noexcept { + if (attribute >= Attribute::Length) + return "invalid"; + return Attribute::sAttributeNames[attribute].c_str(); } const char *StatsFunctions::GetSkillName(unsigned short skill) noexcept { + if (skill >= Skill::Length) + return "invalid"; + return Skill::sSkillNames[skill].c_str(); } diff --git a/apps/openmw-mp/Script/Functions/Stats.hpp b/apps/openmw-mp/Script/Functions/Stats.hpp index 0c7e8a5c5..e757dfaad 100644 --- a/apps/openmw-mp/Script/Functions/Stats.hpp +++ b/apps/openmw-mp/Script/Functions/Stats.hpp @@ -27,6 +27,8 @@ {"GetBirthsign", StatsFunctions::GetBirthsign},\ {"SetBirthsign", StatsFunctions::SetBirthsign},\ \ + {"GetAttributeCount", StatsFunctions::GetAttributeCount},\ + {"GetSkillCount", StatsFunctions::GetSkillCount},\ {"GetAttributeId", StatsFunctions::GetAttributeId},\ {"GetSkillId", StatsFunctions::GetSkillId},\ {"GetAttributeName", StatsFunctions::GetAttributeName},\ @@ -108,6 +110,8 @@ public: static float GetCurrentFatigue(unsigned short pid) noexcept; static void SetCurrentFatigue(unsigned short pid, float value) noexcept; + static int GetAttributeCount() noexcept; + static int GetSkillCount() noexcept; static int GetAttributeId(const char *name) noexcept; static int GetSkillId(const char *name) noexcept; static const char *GetAttributeName(unsigned short attribute) noexcept;