From be8f8526633a9568f3c033e84b5074800f880c46 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 16 Sep 2010 10:45:08 +0200 Subject: [PATCH] implemented skill value handling during character creation (untested) --- apps/openmw/mwclass/npc.cpp | 3 +++ apps/openmw/mwmechanics/mechanicsmanager.cpp | 16 +++++++++++++++- apps/openmw/mwmechanics/npcstats.hpp | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 699d518b8..f9f99e58d 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -119,6 +119,9 @@ namespace MWClass stats->mFactionRank[ref->base->faction] = 0; } + for (int i=0; i<27; ++i) + stats->mSkill[i].setBase (ref->base->npdt52.skills[i]); + ptr.getRefData().getNpcStats() = stats; } diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index c41ec9cba..75418ffbd 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -16,13 +16,16 @@ namespace MWMechanics MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayerPos().getPlayer(); MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); -// MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); + MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); const ESM::NPC *player = ptr.get()->base; // reset creatureStats.mLevel = player->npdt52.level; + for (int i=0; i<27; ++i) + npcStats.mSkill[i].setBase (player->npdt52.skills[i]); + // race const ESM::Race *race = mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayerPos().getRace()); @@ -48,6 +51,16 @@ namespace MWMechanics static_cast (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[i].setBase ( + npcStats.mSkill[i].getBase() + race->data.bonus[i].bonus); + } + } // birthsign @@ -66,6 +79,7 @@ namespace MWMechanics } + // calculate dynamic stats int strength = creatureStats.mAttributes[0].getBase(); int intelligence = creatureStats.mAttributes[1].getBase(); diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 25f698bca..b5ca93749 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -3,6 +3,8 @@ #include +#include "stat.hpp" + namespace MWMechanics { /// \brief Additional stats for NPCs @@ -14,6 +16,8 @@ namespace MWMechanics // NPCs other than the player can only have one faction. But for the sake of consistency // we use the same data structure for the PC and the NPCs. std::map mFactionRank; + + Stat mSkill[27]; }; }