mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 13:53:51 +00:00
Merge remote-tracking branch 'scrawl/book_skillgain' into next
This commit is contained in:
commit
bb6d9a329c
7 changed files with 28 additions and 11 deletions
|
@ -226,7 +226,7 @@ int main(int argc, char**argv)
|
|||
case REC_BOOK:
|
||||
{
|
||||
Book b;
|
||||
b.load(esm);
|
||||
b.load(esm, id);
|
||||
if(quiet) break;
|
||||
cout << " Name: " << b.name << endl;
|
||||
cout << " Mesh: " << b.model << endl;
|
||||
|
|
|
@ -227,3 +227,13 @@ int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
|
|||
else
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace MWMechanics
|
|||
|
||||
std::vector<int> mSkillIncreases; // number of skill increases for each attribute
|
||||
|
||||
std::set<std::string> mUsedIds;
|
||||
|
||||
public:
|
||||
|
||||
NpcStats();
|
||||
|
@ -86,6 +88,10 @@ namespace MWMechanics
|
|||
int getLevelupAttributeMultiplier(int attribute) const;
|
||||
|
||||
void levelUp();
|
||||
|
||||
void flagAsUsed (const std::string& id);
|
||||
|
||||
bool hasBeenUsed (const std::string& id) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -35,22 +35,21 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(getTarget());
|
||||
}
|
||||
|
||||
/*
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
|
||||
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)
|
||||
if (ref->base->data.skillID >= 0 && ref->base->data.skillID < ESM::Skill::Length
|
||||
&& !npcStats.hasBeenUsed (ref->base->id))
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
|
||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player);
|
||||
MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>();
|
||||
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find (
|
||||
playerRef->base->cls);
|
||||
|
||||
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
|
||||
/// and the skill will still increase.
|
||||
npcStats.flagAsUsed (ref->base->id);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace ESM
|
||||
{
|
||||
|
||||
void Book::load(ESMReader &esm)
|
||||
void Book::load(ESMReader &esm, const std::string& recordId)
|
||||
{
|
||||
model = esm.getHNString("MODL");
|
||||
name = esm.getHNOString("FNAM");
|
||||
|
@ -12,6 +12,7 @@ void Book::load(ESMReader &esm)
|
|||
icon = esm.getHNOString("ITEX");
|
||||
text = esm.getHNOString("TEXT");
|
||||
enchant = esm.getHNOString("ENAM");
|
||||
id = recordId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ struct Book
|
|||
|
||||
BKDTstruct data;
|
||||
std::string name, model, icon, script, enchant, text;
|
||||
std::string id;
|
||||
|
||||
void load(ESMReader &esm);
|
||||
void load(ESMReader &esm, const std::string& recordId);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace ESMS
|
|||
RecListT<Apparatus> appas;
|
||||
RecListT<Armor> armors;
|
||||
RecListT<BodyPart> bodyParts;
|
||||
RecListT<Book> books;
|
||||
RecListWithIDT<Book> books;
|
||||
RecListT<BirthSign> birthSigns;
|
||||
RecListT<Class> classes;
|
||||
RecListT<Clothing> clothes;
|
||||
|
|
Loading…
Reference in a new issue