forked from mirror/openmw-tes3mp
Add script functions for getting attributes and skills by their IDs
This commit is contained in:
parent
e5cb58e7c4
commit
41868cc9cc
2 changed files with 35 additions and 0 deletions
|
@ -5,10 +5,13 @@
|
|||
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <apps/openmw-mp/Networking.hpp>
|
||||
#include <components/esm/attr.hpp>
|
||||
#include <components/esm/loadskil.hpp>
|
||||
#include <components/misc/stringops.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace ESM;
|
||||
|
||||
void ScriptFunctions::SetName(unsigned short pid, const char *name) noexcept
|
||||
{
|
||||
|
@ -230,6 +233,32 @@ void ScriptFunctions::SetCurrentFatigue(unsigned short pid, float value) noexcep
|
|||
player->CreatureStats()->mDynamic[2].mCurrent = 0;
|
||||
}
|
||||
|
||||
int ScriptFunctions::GetAttributeIdByName(const char *name) noexcept
|
||||
{
|
||||
for (int x = 0; x < 8; x++)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(name, Attribute::sAttributeNames[x]))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ScriptFunctions::GetSkillIdByName(const char *name) noexcept
|
||||
{
|
||||
for (int x = 0; x < 27; x++)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(name, Skill::sSkillNames[x]))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ScriptFunctions::GetAttribute(unsigned short pid, unsigned short attribute) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
|
|
@ -87,6 +87,9 @@ public:
|
|||
static float GetCurrentFatigue(unsigned short pid) noexcept;
|
||||
static void SetCurrentFatigue(unsigned short pid, float fatigue) noexcept;
|
||||
|
||||
static int GetAttributeIdByName(const char *name) noexcept;
|
||||
static int GetSkillIdByName(const char *name) noexcept;
|
||||
|
||||
static int GetAttribute(unsigned short pid, unsigned short attribute) noexcept;
|
||||
static void SetAttribute(unsigned short pid, unsigned short attribute, int value) noexcept;
|
||||
static int GetCurrentAttribute(unsigned short pid, unsigned short attribute) noexcept;
|
||||
|
@ -194,6 +197,9 @@ public:
|
|||
{"GetBirthsign", ScriptFunctions::GetBirthsign},
|
||||
{"SetBirthsign", ScriptFunctions::SetBirthsign},
|
||||
|
||||
{"GetAttributeIdByName", ScriptFunctions::GetAttributeIdByName},
|
||||
{"GetSkillIdByName", ScriptFunctions::GetSkillIdByName},
|
||||
|
||||
{"GetAttribute", ScriptFunctions::GetAttribute},
|
||||
{"SetAttribute", ScriptFunctions::SetAttribute},
|
||||
{"GetCurrentAttribute", ScriptFunctions::GetCurrentAttribute},
|
||||
|
|
Loading…
Reference in a new issue