diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index 5937ce0f5..aff0390b5 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -63,7 +63,7 @@ void ScriptFunctions::SetRace(unsigned short pid, const char *race) noexcept if (player->Npc()->mRace == race) return; - LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Seting race for %s: %s -> %s", + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Setting race for %s: %s -> %s", player->Npc()->mName.c_str(), player->Npc()->mRace.c_str(), race); @@ -79,6 +79,30 @@ const char *ScriptFunctions::GetRace(unsigned short pid) noexcept return player->Npc()->mRace.c_str(); } +void ScriptFunctions::SetClass(unsigned short pid, const char *className) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + if (player->Npc()->mClass == className) + return; + + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Setting class for %s: %s -> %s", + player->Npc()->mName.c_str(), + player->Npc()->mClass.c_str(), + className); + + player->Npc()->mClass = className; +} + +const char *ScriptFunctions::GetClass(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->Npc()->mClass.c_str(); +} + void ScriptFunctions::SetHead(unsigned short pid, const char *race) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index da2e9eed2..033ef6738 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -63,6 +63,9 @@ public: static void SetRace(unsigned short pid, const char *race) noexcept; static const char *GetRace(unsigned short pid) noexcept; + static void SetClass(unsigned short pid, const char *name) noexcept; + static const char *GetClass(unsigned short pid) noexcept; + static void SetHead(unsigned short pid, const char *head) noexcept; static const char *GetHead(unsigned short pid) noexcept; @@ -197,6 +200,9 @@ public: {"GetRace", ScriptFunctions::GetRace}, {"SetRace", ScriptFunctions::SetRace}, + {"SetClass", ScriptFunctions::SetClass}, + {"GetClass", ScriptFunctions::GetClass}, + {"GetHead", ScriptFunctions::GetHead}, {"SetHead", ScriptFunctions::SetHead}, @@ -209,10 +215,10 @@ public: {"GetBirthsign", ScriptFunctions::GetBirthsign}, {"SetBirthsign", ScriptFunctions::SetBirthsign}, - {"GetAttributeId", ScriptFunctions::GetAttributeId}, - {"GetSkillId", ScriptFunctions::GetSkillId}, - {"GetAttributeName", ScriptFunctions::GetAttributeName}, - {"GetSkillName", ScriptFunctions::GetSkillName}, + {"GetAttributeId", ScriptFunctions::GetAttributeId}, + {"GetSkillId", ScriptFunctions::GetSkillId}, + {"GetAttributeName", ScriptFunctions::GetAttributeName}, + {"GetSkillName", ScriptFunctions::GetSkillName}, {"GetAttribute", ScriptFunctions::GetAttribute}, {"SetAttribute", ScriptFunctions::SetAttribute}, @@ -238,8 +244,6 @@ public: {"SetCurrentFatigue", ScriptFunctions::SetCurrentFatigue}, {"GetCurrentFatigue", ScriptFunctions::GetCurrentFatigue}, -// {"SetClass", ScriptFunctions::SetClass}, -// {"GetClass", ScriptFunctions::GetClass}, {"GetIncreaseSkill", ScriptFunctions::GetIncreaseSkill}, {"SetIncreaseSkill", ScriptFunctions::SetIncreaseSkill}, diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 37630e2cd..1365b01d9 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -54,6 +54,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id) dedic_pl.mRace = _player->Npc()->mRace; dedic_pl.mHead = _player->Npc()->mHead; dedic_pl.mHair = _player->Npc()->mHair; + dedic_pl.mClass = _player->Npc()->mClass; dedic_pl.mName = _player->Npc()->mName; dedic_pl.mFlags = _player->Npc()->mFlags; diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 89a123a99..32776f1ce 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -579,5 +579,8 @@ void LocalPlayer::updateChar() Npc()->mHead, Npc()->mHair ); + + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(Npc()->mClass); + MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar(); }