Merge remote-tracking branch 'scrawl/book_skillgain' into next

This commit is contained in:
Marc Zinnschlag 2012-09-26 20:35:48 +02:00
commit bb6d9a329c
7 changed files with 28 additions and 11 deletions

View file

@ -226,7 +226,7 @@ int main(int argc, char**argv)
case REC_BOOK: case REC_BOOK:
{ {
Book b; Book b;
b.load(esm); b.load(esm, id);
if(quiet) break; if(quiet) break;
cout << " Name: " << b.name << endl; cout << " Name: " << b.name << endl;
cout << " Mesh: " << b.model << endl; cout << " Mesh: " << b.model << endl;

View file

@ -227,3 +227,13 @@ int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
else else
return 5; return 5;
} }
void MWMechanics::NpcStats::flagAsUsed (const std::string& id)
{
mUsedIds.insert (id);
}
bool MWMechanics::NpcStats::hasBeenUsed (const std::string& id) const
{
return mUsedIds.find (id)!=mUsedIds.end();
}

View file

@ -50,6 +50,8 @@ namespace MWMechanics
std::vector<int> mSkillIncreases; // number of skill increases for each attribute std::vector<int> mSkillIncreases; // number of skill increases for each attribute
std::set<std::string> mUsedIds;
public: public:
NpcStats(); NpcStats();
@ -86,6 +88,10 @@ namespace MWMechanics
int getLevelupAttributeMultiplier(int attribute) const; int getLevelupAttributeMultiplier(int attribute) const;
void levelUp(); void levelUp();
void flagAsUsed (const std::string& id);
bool hasBeenUsed (const std::string& id) const;
}; };
} }

View file

@ -35,22 +35,21 @@ namespace MWWorld
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(getTarget()); MWBase::Environment::get().getWindowManager()->getBookWindow()->open(getTarget());
} }
/*
// Skill gain from books
if (ref->base->data.skillID >= 0 && ref->base->data.skillID < ESM::Skill::Length)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player); MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
// Skill gain from books
if (ref->base->data.skillID >= 0 && ref->base->data.skillID < ESM::Skill::Length
&& !npcStats.hasBeenUsed (ref->base->id))
{
MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>();
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find (
playerRef->base->cls); playerRef->base->cls);
npcStats.increaseSkill (ref->base->data.skillID, *class_, true); npcStats.increaseSkill (ref->base->data.skillID, *class_, true);
/// \todo Remove skill from the book. Right now you can read as many times as you want npcStats.flagAsUsed (ref->base->id);
/// and the skill will still increase.
} }
*/
} }
} }

View file

@ -3,7 +3,7 @@
namespace ESM namespace ESM
{ {
void Book::load(ESMReader &esm) void Book::load(ESMReader &esm, const std::string& recordId)
{ {
model = esm.getHNString("MODL"); model = esm.getHNString("MODL");
name = esm.getHNOString("FNAM"); name = esm.getHNOString("FNAM");
@ -12,6 +12,7 @@ void Book::load(ESMReader &esm)
icon = esm.getHNOString("ITEX"); icon = esm.getHNOString("ITEX");
text = esm.getHNOString("TEXT"); text = esm.getHNOString("TEXT");
enchant = esm.getHNOString("ENAM"); enchant = esm.getHNOString("ENAM");
id = recordId;
} }
} }

View file

@ -20,8 +20,9 @@ struct Book
BKDTstruct data; BKDTstruct data;
std::string name, model, icon, script, enchant, text; std::string name, model, icon, script, enchant, text;
std::string id;
void load(ESMReader &esm); void load(ESMReader &esm, const std::string& recordId);
}; };
} }
#endif #endif

View file

@ -34,7 +34,7 @@ namespace ESMS
RecListT<Apparatus> appas; RecListT<Apparatus> appas;
RecListT<Armor> armors; RecListT<Armor> armors;
RecListT<BodyPart> bodyParts; RecListT<BodyPart> bodyParts;
RecListT<Book> books; RecListWithIDT<Book> books;
RecListT<BirthSign> birthSigns; RecListT<BirthSign> birthSigns;
RecListT<Class> classes; RecListT<Class> classes;
RecListT<Clothing> clothes; RecListT<Clothing> clothes;