1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-07 01:45:34 +00:00

Redemption compatibility fix

This commit is contained in:
Marc Zinnschlag 2010-09-26 10:01:30 +02:00
parent 12a15e3fb7
commit 49f68e08bf
2 changed files with 79 additions and 60 deletions

View file

@ -27,85 +27,98 @@ namespace MWMechanics
npcStats.mSkill[i].setBase (player->npdt52.skills[i]); npcStats.mSkill[i].setBase (player->npdt52.skills[i]);
// race // race
const ESM::Race *race = if (mRaceSelected)
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayerPos().getRace());
bool male = mEnvironment.mWorld->getPlayerPos().isMale();
for (int i=0; i<8; ++i)
{ {
const ESM::Race::MaleFemale *attribute = 0; const ESM::Race *race =
switch (i) mEnvironment.mWorld->getStore().races.find (
mEnvironment.mWorld->getPlayerPos().getRace());
bool male = mEnvironment.mWorld->getPlayerPos().isMale();
for (int i=0; i<8; ++i)
{ {
case 0: attribute = &race->data.strength; break; const ESM::Race::MaleFemale *attribute = 0;
case 1: attribute = &race->data.intelligence; break; switch (i)
case 2: attribute = &race->data.willpower; break; {
case 3: attribute = &race->data.agility; break; case 0: attribute = &race->data.strength; break;
case 4: attribute = &race->data.speed; break; case 1: attribute = &race->data.intelligence; break;
case 5: attribute = &race->data.endurance; break; case 2: attribute = &race->data.willpower; break;
case 6: attribute = &race->data.personality; break; case 3: attribute = &race->data.agility; break;
case 7: attribute = &race->data.luck; break; case 4: attribute = &race->data.speed; break;
case 5: attribute = &race->data.endurance; break;
case 6: attribute = &race->data.personality; break;
case 7: attribute = &race->data.luck; break;
}
creatureStats.mAttributes[i].setBase (
static_cast<int> (male ? attribute->male : attribute->female));
} }
creatureStats.mAttributes[i].setBase ( for (int i=0; i<7; ++i)
static_cast<int> (male ? attribute->male : attribute->female));
}
for (int i=0; i<7; ++i)
{
int index = race->data.bonus[i].skill;
if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( int index = race->data.bonus[i].skill;
npcStats.mSkill[index].getBase() + race->data.bonus[i].bonus);
if (index>=0 && index<27)
{
npcStats.mSkill[index].setBase (
npcStats.mSkill[index].getBase() + race->data.bonus[i].bonus);
}
} }
// TODO handle magic effects
} }
// birthsign // birthsign
if (!mEnvironment.mWorld->getPlayerPos().getBirthsign().empty())
{
// TODO handle magic effects
}
// class // class
const ESM::Class& class_ = mEnvironment.mWorld->getPlayerPos().getClass(); if (mClassSelected)
for (int i=0; i<2; ++i)
{ {
int attribute = class_.data.attribute[i]; const ESM::Class& class_ = mEnvironment.mWorld->getPlayerPos().getClass();
if (attribute>=0 && attribute<8)
for (int i=0; i<2; ++i)
{ {
creatureStats.mAttributes[attribute].setBase ( int attribute = class_.data.attribute[i];
creatureStats.mAttributes[attribute].getBase() + 10); if (attribute>=0 && attribute<8)
}
}
for (int i=0; i<2; ++i)
{
int bonus = i==0 ? 10 : 25;
for (int i2=0; i2<5; ++i2)
{
int index = class_.data.skills[i2][i];
if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( creatureStats.mAttributes[attribute].setBase (
npcStats.mSkill[index].getBase() + bonus); creatureStats.mAttributes[attribute].getBase() + 10);
} }
} }
}
typedef ESMS::IndexListT<ESM::Skill>::MapType ContainerType; for (int i=0; i<2; ++i)
const ContainerType& skills = mEnvironment.mWorld->getStore().skills.list;
for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter)
{
if (iter->second.data.specialization==class_.data.specialization)
{ {
int index = iter->first; int bonus = i==0 ? 10 : 25;
if (index>=0 && index<27) for (int i2=0; i2<5; ++i2)
{ {
npcStats.mSkill[index].setBase ( int index = class_.data.skills[i2][i];
npcStats.mSkill[index].getBase() + 5);
if (index>=0 && index<27)
{
npcStats.mSkill[index].setBase (
npcStats.mSkill[index].getBase() + bonus);
}
}
}
typedef ESMS::IndexListT<ESM::Skill>::MapType ContainerType;
const ContainerType& skills = mEnvironment.mWorld->getStore().skills.list;
for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter)
{
if (iter->second.data.specialization==class_.data.specialization)
{
int index = iter->first;
if (index>=0 && index<27)
{
npcStats.mSkill[index].setBase (
npcStats.mSkill[index].getBase() + 5);
}
} }
} }
} }
@ -127,7 +140,8 @@ namespace MWMechanics
} }
MechanicsManager::MechanicsManager (MWWorld::Environment& environment) MechanicsManager::MechanicsManager (MWWorld::Environment& environment)
: mEnvironment (environment), mUpdatePlayer (true) : mEnvironment (environment), mUpdatePlayer (true), mClassSelected (false),
mRaceSelected (false)
{ {
buildPlayer(); buildPlayer();
} }
@ -267,6 +281,7 @@ namespace MWMechanics
{ {
mEnvironment.mWorld->getPlayerPos().setGender (male); mEnvironment.mWorld->getPlayerPos().setGender (male);
mEnvironment.mWorld->getPlayerPos().setRace (race); mEnvironment.mWorld->getPlayerPos().setRace (race);
mRaceSelected = true;
buildPlayer(); buildPlayer();
mUpdatePlayer = true; mUpdatePlayer = true;
} }
@ -280,6 +295,7 @@ namespace MWMechanics
void MechanicsManager::setPlayerClass (const std::string& id) void MechanicsManager::setPlayerClass (const std::string& id)
{ {
mEnvironment.mWorld->getPlayerPos().setClass (*mEnvironment.mWorld->getStore().classes.find (id)); mEnvironment.mWorld->getPlayerPos().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
mClassSelected = true;
buildPlayer(); buildPlayer();
mUpdatePlayer = true; mUpdatePlayer = true;
} }
@ -287,6 +303,7 @@ namespace MWMechanics
void MechanicsManager::setPlayerClass (const ESM::Class& class_) void MechanicsManager::setPlayerClass (const ESM::Class& class_)
{ {
mEnvironment.mWorld->getPlayerPos().setClass (class_); mEnvironment.mWorld->getPlayerPos().setClass (class_);
mClassSelected = true;
buildPlayer(); buildPlayer();
mUpdatePlayer = true; mUpdatePlayer = true;
} }

View file

@ -23,6 +23,8 @@ namespace MWMechanics
CreatureStats mWatchedCreature; CreatureStats mWatchedCreature;
NpcStats mWatchedNpc; NpcStats mWatchedNpc;
bool mUpdatePlayer; bool mUpdatePlayer;
bool mClassSelected;
bool mRaceSelected;
void buildPlayer(); void buildPlayer();
///< build player according to stored class/race/birthsign information. Will ///< build player according to stored class/race/birthsign information. Will