|
|
|
@ -37,16 +37,17 @@ namespace MWMechanics
|
|
|
|
|
creatureStats.getAttribute(5).setBase (player->mNpdt52.mEndurance);
|
|
|
|
|
creatureStats.getAttribute(6).setBase (player->mNpdt52.mPersonality);
|
|
|
|
|
creatureStats.getAttribute(7).setBase (player->mNpdt52.mLuck);
|
|
|
|
|
|
|
|
|
|
const MWWorld::ESMStore &esmStore =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
|
|
|
|
|
|
// race
|
|
|
|
|
if (mRaceSelected)
|
|
|
|
|
{
|
|
|
|
|
const ESM::Race *race =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find (
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().getRace()
|
|
|
|
|
);
|
|
|
|
|
esmStore.get<ESM::Race>().find(player->mRace);
|
|
|
|
|
|
|
|
|
|
bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale();
|
|
|
|
|
bool male = (player->mFlags & ESM::NPC::Female) == 0;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<8; ++i)
|
|
|
|
|
{
|
|
|
|
@ -89,11 +90,13 @@ namespace MWMechanics
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// birthsign
|
|
|
|
|
if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty())
|
|
|
|
|
const std::string &signId =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
|
|
|
|
|
|
|
|
|
|
if (!signId.empty())
|
|
|
|
|
{
|
|
|
|
|
const ESM::BirthSign *sign =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find (
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().getBirthsign());
|
|
|
|
|
esmStore.get<ESM::BirthSign>().find(signId);
|
|
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin());
|
|
|
|
|
iter!=sign->mPowers.mList.end(); ++iter)
|
|
|
|
@ -105,11 +108,12 @@ namespace MWMechanics
|
|
|
|
|
// class
|
|
|
|
|
if (mClassSelected)
|
|
|
|
|
{
|
|
|
|
|
const ESM::Class& class_ = MWBase::Environment::get().getWorld()->getPlayer().getClass();
|
|
|
|
|
const ESM::Class *class_ =
|
|
|
|
|
esmStore.get<ESM::Class>().find(player->mClass);
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<2; ++i)
|
|
|
|
|
{
|
|
|
|
|
int attribute = class_.mData.mAttribute[i];
|
|
|
|
|
int attribute = class_->mData.mAttribute[i];
|
|
|
|
|
if (attribute>=0 && attribute<8)
|
|
|
|
|
{
|
|
|
|
|
creatureStats.getAttribute(attribute).setBase (
|
|
|
|
@ -123,7 +127,7 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
for (int i2=0; i2<5; ++i2)
|
|
|
|
|
{
|
|
|
|
|
int index = class_.mData.mSkills[i2][i];
|
|
|
|
|
int index = class_->mData.mSkills[i2][i];
|
|
|
|
|
|
|
|
|
|
if (index>=0 && index<27)
|
|
|
|
|
{
|
|
|
|
@ -134,12 +138,12 @@ namespace MWMechanics
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MWWorld::Store<ESM::Skill> &skills =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
|
|
|
|
|
esmStore.get<ESM::Skill>();
|
|
|
|
|
|
|
|
|
|
MWWorld::Store<ESM::Skill>::iterator iter = skills.begin();
|
|
|
|
|
for (; iter != skills.end(); ++iter)
|
|
|
|
|
{
|
|
|
|
|
if (iter->mData.mSpecialization==class_.mData.mSpecialization)
|
|
|
|
|
if (iter->mData.mSpecialization==class_->mData.mSpecialization)
|
|
|
|
|
{
|
|
|
|
|
int index = iter->mIndex;
|
|
|
|
|
|
|
|
|
@ -265,13 +269,19 @@ namespace MWMechanics
|
|
|
|
|
// basic player profile; should not change anymore after the creation phase is finished.
|
|
|
|
|
MWBase::WindowManager *winMgr =
|
|
|
|
|
MWBase::Environment::get().getWindowManager();
|
|
|
|
|
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
MWWorld::Player &player = world->getPlayer();
|
|
|
|
|
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
const ESM::NPC *player =
|
|
|
|
|
world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
|
|
|
|
|
|
|
|
|
const ESM::Race *race =
|
|
|
|
|
world->getStore().get<ESM::Race>().find(player->mRace);
|
|
|
|
|
const ESM::Class *cls =
|
|
|
|
|
world->getStore().get<ESM::Class>().find(player->mClass);
|
|
|
|
|
|
|
|
|
|
winMgr->setValue ("name", player.getName());
|
|
|
|
|
winMgr->setValue ("race", world->getStore().get<ESM::Race>().find (player.getRace())->mName);
|
|
|
|
|
winMgr->setValue ("class", player.getClass().mName);
|
|
|
|
|
winMgr->setValue ("name", player->mName);
|
|
|
|
|
winMgr->setValue ("race", race->mName);
|
|
|
|
|
winMgr->setValue ("class", cls->mName);
|
|
|
|
|
|
|
|
|
|
mUpdatePlayer = false;
|
|
|
|
|
|
|
|
|
@ -280,8 +290,8 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<5; ++i)
|
|
|
|
|
{
|
|
|
|
|
minorSkills[i] = player.getClass().mData.mSkills[i][0];
|
|
|
|
|
majorSkills[i] = player.getClass().mData.mSkills[i][1];
|
|
|
|
|
minorSkills[i] = cls->mData.mSkills[i][0];
|
|
|
|
|
majorSkills[i] = cls->mData.mSkills[i][1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
winMgr->configureSkills (majorSkills, minorSkills);
|
|
|
|
@ -297,14 +307,33 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::setPlayerName (const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setName (name);
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
ESM::NPC player =
|
|
|
|
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
|
|
|
|
player.mName = name;
|
|
|
|
|
|
|
|
|
|
world->createRecord(player);
|
|
|
|
|
|
|
|
|
|
mUpdatePlayer = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setGender (male);
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setRace (race);
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
ESM::NPC player =
|
|
|
|
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
|
|
|
|
|
|
|
|
|
player.mRace = race;
|
|
|
|
|
|
|
|
|
|
player.mFlags |= ESM::NPC::Female;
|
|
|
|
|
if (male) {
|
|
|
|
|
player.mFlags ^= ESM::NPC::Female;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
world->createRecord(player);
|
|
|
|
|
|
|
|
|
|
mRaceSelected = true;
|
|
|
|
|
buildPlayer();
|
|
|
|
|
mUpdatePlayer = true;
|
|
|
|
@ -312,29 +341,43 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::setPlayerBirthsign (const std::string& id)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setBirthsign (id);
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setBirthSign(id);
|
|
|
|
|
buildPlayer();
|
|
|
|
|
mUpdatePlayer = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::setPlayerClass (const std::string& id)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setClass (
|
|
|
|
|
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find (id)
|
|
|
|
|
);
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
ESM::NPC player =
|
|
|
|
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
|
|
|
|
player.mClass = id;
|
|
|
|
|
|
|
|
|
|
world->createRecord(player);
|
|
|
|
|
|
|
|
|
|
mClassSelected = true;
|
|
|
|
|
buildPlayer();
|
|
|
|
|
mUpdatePlayer = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
|
|
|
|
|
void MechanicsManager::setPlayerClass (const ESM::Class &cls)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWorld()->getPlayer().setClass (class_);
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
const ESM::Class *ptr = world->createRecord(cls);
|
|
|
|
|
|
|
|
|
|
ESM::NPC player =
|
|
|
|
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
|
|
|
|
player.mClass = ptr->mId;
|
|
|
|
|
|
|
|
|
|
world->createRecord(player);
|
|
|
|
|
|
|
|
|
|
mClassSelected = true;
|
|
|
|
|
buildPlayer();
|
|
|
|
|
mUpdatePlayer = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int MechanicsManager::countDeaths (const std::string& id) const
|
|
|
|
|
{
|
|
|
|
|
return mActors.countDeaths (id);
|
|
|
|
|