forked from teamnwah/openmw-tes3coop
Add script functions for saving and loading non-custom player classes
This commit is contained in:
parent
7bb6020e51
commit
00e7810428
4 changed files with 39 additions and 7 deletions
|
@ -63,7 +63,7 @@ void ScriptFunctions::SetRace(unsigned short pid, const char *race) noexcept
|
||||||
if (player->Npc()->mRace == race)
|
if (player->Npc()->mRace == race)
|
||||||
return;
|
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()->mName.c_str(),
|
||||||
player->Npc()->mRace.c_str(),
|
player->Npc()->mRace.c_str(),
|
||||||
race);
|
race);
|
||||||
|
@ -79,6 +79,30 @@ const char *ScriptFunctions::GetRace(unsigned short pid) noexcept
|
||||||
return player->Npc()->mRace.c_str();
|
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
|
void ScriptFunctions::SetHead(unsigned short pid, const char *race) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
static void SetRace(unsigned short pid, const char *race) noexcept;
|
static void SetRace(unsigned short pid, const char *race) noexcept;
|
||||||
static const char *GetRace(unsigned short pid) 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 void SetHead(unsigned short pid, const char *head) noexcept;
|
||||||
static const char *GetHead(unsigned short pid) noexcept;
|
static const char *GetHead(unsigned short pid) noexcept;
|
||||||
|
|
||||||
|
@ -197,6 +200,9 @@ public:
|
||||||
{"GetRace", ScriptFunctions::GetRace},
|
{"GetRace", ScriptFunctions::GetRace},
|
||||||
{"SetRace", ScriptFunctions::SetRace},
|
{"SetRace", ScriptFunctions::SetRace},
|
||||||
|
|
||||||
|
{"SetClass", ScriptFunctions::SetClass},
|
||||||
|
{"GetClass", ScriptFunctions::GetClass},
|
||||||
|
|
||||||
{"GetHead", ScriptFunctions::GetHead},
|
{"GetHead", ScriptFunctions::GetHead},
|
||||||
{"SetHead", ScriptFunctions::SetHead},
|
{"SetHead", ScriptFunctions::SetHead},
|
||||||
|
|
||||||
|
@ -209,10 +215,10 @@ public:
|
||||||
{"GetBirthsign", ScriptFunctions::GetBirthsign},
|
{"GetBirthsign", ScriptFunctions::GetBirthsign},
|
||||||
{"SetBirthsign", ScriptFunctions::SetBirthsign},
|
{"SetBirthsign", ScriptFunctions::SetBirthsign},
|
||||||
|
|
||||||
{"GetAttributeId", ScriptFunctions::GetAttributeId},
|
{"GetAttributeId", ScriptFunctions::GetAttributeId},
|
||||||
{"GetSkillId", ScriptFunctions::GetSkillId},
|
{"GetSkillId", ScriptFunctions::GetSkillId},
|
||||||
{"GetAttributeName", ScriptFunctions::GetAttributeName},
|
{"GetAttributeName", ScriptFunctions::GetAttributeName},
|
||||||
{"GetSkillName", ScriptFunctions::GetSkillName},
|
{"GetSkillName", ScriptFunctions::GetSkillName},
|
||||||
|
|
||||||
{"GetAttribute", ScriptFunctions::GetAttribute},
|
{"GetAttribute", ScriptFunctions::GetAttribute},
|
||||||
{"SetAttribute", ScriptFunctions::SetAttribute},
|
{"SetAttribute", ScriptFunctions::SetAttribute},
|
||||||
|
@ -238,8 +244,6 @@ public:
|
||||||
{"SetCurrentFatigue", ScriptFunctions::SetCurrentFatigue},
|
{"SetCurrentFatigue", ScriptFunctions::SetCurrentFatigue},
|
||||||
{"GetCurrentFatigue", ScriptFunctions::GetCurrentFatigue},
|
{"GetCurrentFatigue", ScriptFunctions::GetCurrentFatigue},
|
||||||
|
|
||||||
// {"SetClass", ScriptFunctions::SetClass},
|
|
||||||
// {"GetClass", ScriptFunctions::GetClass},
|
|
||||||
{"GetIncreaseSkill", ScriptFunctions::GetIncreaseSkill},
|
{"GetIncreaseSkill", ScriptFunctions::GetIncreaseSkill},
|
||||||
{"SetIncreaseSkill", ScriptFunctions::SetIncreaseSkill},
|
{"SetIncreaseSkill", ScriptFunctions::SetIncreaseSkill},
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id)
|
||||||
dedic_pl.mRace = _player->Npc()->mRace;
|
dedic_pl.mRace = _player->Npc()->mRace;
|
||||||
dedic_pl.mHead = _player->Npc()->mHead;
|
dedic_pl.mHead = _player->Npc()->mHead;
|
||||||
dedic_pl.mHair = _player->Npc()->mHair;
|
dedic_pl.mHair = _player->Npc()->mHair;
|
||||||
|
dedic_pl.mClass = _player->Npc()->mClass;
|
||||||
dedic_pl.mName = _player->Npc()->mName;
|
dedic_pl.mName = _player->Npc()->mName;
|
||||||
dedic_pl.mFlags = _player->Npc()->mFlags;
|
dedic_pl.mFlags = _player->Npc()->mFlags;
|
||||||
|
|
||||||
|
|
|
@ -579,5 +579,8 @@ void LocalPlayer::updateChar()
|
||||||
Npc()->mHead,
|
Npc()->mHead,
|
||||||
Npc()->mHair
|
Npc()->mHair
|
||||||
);
|
);
|
||||||
|
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(Npc()->mClass);
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
|
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue