1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 13:23:55 +00:00

Issue #324: Finished turning NpcStats into a proper class

This commit is contained in:
Marc Zinnschlag 2012-07-06 18:23:48 +02:00
parent 771863e73b
commit d30ba14a17
10 changed files with 146 additions and 101 deletions

View file

@ -67,11 +67,11 @@ namespace MWClass
boost::algorithm::to_lower(faction); boost::algorithm::to_lower(faction);
if(ref->base->npdt52.gold != -10) if(ref->base->npdt52.gold != -10)
{ {
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt52.rank; data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt52.rank;
} }
else else
{ {
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt12.rank; data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt12.rank;
} }
} }
@ -79,7 +79,7 @@ namespace MWClass
if(ref->base->npdt52.gold != -10) if(ref->base->npdt52.gold != -10)
{ {
for (int i=0; i<27; ++i) for (int i=0; i<27; ++i)
data->mNpcStats.mSkill[i].setBase (ref->base->npdt52.skills[i]); data->mNpcStats.getSkill (i).setBase (ref->base->npdt52.skills[i]);
data->mCreatureStats.mAttributes[0].set (ref->base->npdt52.strength); data->mCreatureStats.mAttributes[0].set (ref->base->npdt52.strength);
data->mCreatureStats.mAttributes[1].set (ref->base->npdt52.intelligence); data->mCreatureStats.mAttributes[1].set (ref->base->npdt52.intelligence);
@ -201,12 +201,12 @@ namespace MWClass
{ {
case Run: case Run:
stats.mForceRun = force; stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceRun, force);
break; break;
case Sneak: case Sneak:
stats.mForceSneak = force; stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak, force);
break; break;
case Combat: case Combat:
@ -223,12 +223,12 @@ namespace MWClass
{ {
case Run: case Run:
stats.mRun = set; stats.setMovementFlag (MWMechanics::NpcStats::Flag_Run, set);
break; break;
case Sneak: case Sneak:
stats.mSneak = set; stats.setMovementFlag (MWMechanics::NpcStats::Flag_Sneak, set);
break; break;
case Combat: case Combat:
@ -247,17 +247,17 @@ namespace MWClass
{ {
case Run: case Run:
if (!ignoreForce && stats.mForceRun) if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun))
return true; return true;
return stats.mRun; return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Run);
case Sneak: case Sneak:
if (!ignoreForce && stats.mForceSneak) if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak))
return true; return true;
return stats.mSneak; return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Sneak);
case Combat: case Combat:

View file

@ -203,10 +203,10 @@ namespace MWDialogue
MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor); MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor);
int sameFaction = 0; int sameFaction = 0;
if(!NPCstats.mFactionRank.empty()) if(!NPCstats.getFactionRanks().empty())
{ {
std::string NPCFaction = NPCstats.mFactionRank.begin()->first; std::string NPCFaction = NPCstats.getFactionRanks().begin()->first;
if(PCstats.mFactionRank.find(toLower(NPCFaction)) != PCstats.mFactionRank.end()) sameFaction = 1; if(PCstats.getFactionRanks().find(toLower(NPCFaction)) != PCstats.getFactionRanks().end()) sameFaction = 1;
} }
if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false; if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false;
} }
@ -525,8 +525,8 @@ namespace MWDialogue
//MWWorld::Class npcClass = MWWorld::Class::get(actor); //MWWorld::Class npcClass = MWWorld::Class::get(actor);
MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor); MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor);
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.npcFaction)); std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.npcFaction));
if(it!=stats.mFactionRank.end()) if(it!=stats.getFactionRanks().end())
{ {
//check rank //check rank
if(it->second < (int)info.data.rank) return false; if(it->second < (int)info.data.rank) return false;
@ -542,8 +542,8 @@ namespace MWDialogue
if(!info.pcFaction.empty()) if(!info.pcFaction.empty())
{ {
MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.pcFaction)); std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.pcFaction));
if(it!=stats.mFactionRank.end()) if(it!=stats.getFactionRanks().end())
{ {
//check rank //check rank
if(it->second < (int)info.data.PCrank) return false; if(it->second < (int)info.data.PCrank) return false;
@ -903,13 +903,13 @@ namespace MWDialogue
std::string factionID(""); std::string factionID("");
MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor); MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
if(stats.mFactionRank.empty()) if(stats.getFactionRanks().empty())
{ {
std::cout << "No faction for this actor!"; std::cout << "No faction for this actor!";
} }
else else
{ {
factionID = stats.mFactionRank.begin()->first; factionID = stats.getFactionRanks().begin()->first;
} }
return factionID; return factionID;
} }

View file

@ -270,7 +270,7 @@ void StatsWindow::onFrame ()
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::NpcStats PCstats = MWWorld::Class::get(player).getNpcStats(player); MWMechanics::NpcStats PCstats = MWWorld::Class::get(player).getNpcStats(player);
setFactions(PCstats.mFactionRank); setFactions(PCstats.getFactionRanks());
setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign());

View file

@ -28,7 +28,7 @@ namespace MWMechanics
creatureStats.mMagicEffects = MagicEffects(); creatureStats.mMagicEffects = MagicEffects();
for (int i=0; i<27; ++i) for (int i=0; i<27; ++i)
npcStats.mSkill[i].setBase (player->npdt52.skills[i]); npcStats.getSkill (i).setBase (player->npdt52.skills[i]);
creatureStats.mAttributes[0].setBase (player->npdt52.strength); creatureStats.mAttributes[0].setBase (player->npdt52.strength);
creatureStats.mAttributes[1].setBase (player->npdt52.intelligence); creatureStats.mAttributes[1].setBase (player->npdt52.intelligence);
@ -73,8 +73,8 @@ namespace MWMechanics
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( npcStats.getSkill (index).setBase (
npcStats.mSkill[index].getBase() + race->data.bonus[i].bonus); npcStats.getSkill (index).getBase() + race->data.bonus[i].bonus);
} }
} }
@ -124,8 +124,8 @@ namespace MWMechanics
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( npcStats.getSkill (index).setBase (
npcStats.mSkill[index].getBase() + bonus); npcStats.getSkill (index).getBase() + bonus);
} }
} }
} }
@ -141,8 +141,8 @@ namespace MWMechanics
if (index>=0 && index<27) if (index>=0 && index<27)
{ {
npcStats.mSkill[index].setBase ( npcStats.getSkill (index).setBase (
npcStats.mSkill[index].getBase() + 5); npcStats.getSkill (index).getBase() + 5);
} }
} }
} }
@ -236,11 +236,11 @@ namespace MWMechanics
//Loop over ESM::Skill::SkillEnum //Loop over ESM::Skill::SkillEnum
for(int i = 0; i < 27; ++i) for(int i = 0; i < 27; ++i)
{ {
if(npcStats.mSkill[i] != mWatchedNpc.mSkill[i]) if(npcStats.getSkill (i) != mWatchedNpc.getSkill (i))
{ {
update = true; update = true;
mWatchedNpc.mSkill[i] = npcStats.mSkill[i]; mWatchedNpc.getSkill (i) = npcStats.getSkill (i);
MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]); MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.getSkill (i));
} }
} }

View file

@ -1,9 +1,10 @@
#include "npcstats.hpp" #include "npcstats.hpp"
#include <stdexcept>
MWMechanics::NpcStats::NpcStats() MWMechanics::NpcStats::NpcStats()
: mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), : mMovementFlags (0), mDrawState (DrawState_Nothing)
mDrawState (DrawState_Nothing)
{} {}
MWMechanics::DrawState MWMechanics::NpcStats::getDrawState() const MWMechanics::DrawState MWMechanics::NpcStats::getDrawState() const
@ -15,3 +16,42 @@ void MWMechanics::NpcStats::setDrawState (DrawState state)
{ {
mDrawState = state; mDrawState = state;
} }
bool MWMechanics::NpcStats::getMovementFlag (Flag flag) const
{
return mMovementFlags & flag;
}
void MWMechanics::NpcStats::setMovementFlag (Flag flag, bool state)
{
if (state)
mMovementFlags |= flag;
else
mMovementFlags &= ~flag;
}
const MWMechanics::Stat<float>& MWMechanics::NpcStats::getSkill (int index) const
{
if (index<0 || index>=27)
throw std::runtime_error ("skill index out of range");
return mSkill[index];
}
MWMechanics::Stat<float>& MWMechanics::NpcStats::getSkill (int index)
{
if (index<0 || index>=27)
throw std::runtime_error ("skill index out of range");
return mSkill[index];
}
std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks()
{
return mFactionRank;
}
const std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks() const
{
return mFactionRank;
}

View file

@ -19,27 +19,46 @@ namespace MWMechanics
class NpcStats class NpcStats
{ {
DrawState mDrawState;
public: public:
/// NPCs other than the player can only have one faction. But for the sake of consistency enum Flag
/// we use the same data structure for the PC and the NPCs. {
/// \note the faction key must be in lowercase Flag_ForceRun = 1,
std::map<std::string, int> mFactionRank; Flag_ForceSneak = 2,
Flag_Run = 4,
Flag_Sneak = 8
};
Stat<float> mSkill[27]; private:
bool mForceRun; /// NPCs other than the player can only have one faction. But for the sake of consistency
bool mForceSneak; /// we use the same data structure for the PC and the NPCs.
bool mRun; /// \note the faction key must be in lowercase
bool mSneak; std::map<std::string, int> mFactionRank;
DrawState mDrawState;
unsigned int mMovementFlags;
Stat<float> mSkill[27];
public:
NpcStats(); NpcStats();
DrawState getDrawState() const; DrawState getDrawState() const;
void setDrawState (DrawState state); void setDrawState (DrawState state);
bool getMovementFlag (Flag flag) const;
void setMovementFlag (Flag flag, bool state);
const Stat<float>& getSkill (int index) const;
Stat<float>& getSkill (int index);
std::map<std::string, int>& getFactionRanks();
const std::map<std::string, int>& getFactionRanks() const;
}; };
} }

View file

@ -41,7 +41,7 @@ namespace MWMechanics
{ {
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->effectID); const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->effectID);
int _school = effect->data.school; int _school = effect->data.school;
int _skillLevel = stats.mSkill[spellSchoolToSkill(_school)].getModified(); int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified();
if (school == -1) if (school == -1)
{ {
@ -78,7 +78,7 @@ namespace MWMechanics
NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor); NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor);
CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor); CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor);
int skillLevel = stats.mSkill[getSpellSchool(spellId, actor)].getModified(); int skillLevel = stats.getSkill (getSpellSchool(spellId, actor)).getModified();
// Sound magic effect (reduces spell casting chance) // Sound magic effect (reduces spell casting chance)
int soundMagnitude = creatureStats.mMagicEffects.get (MWMechanics::EffectKey (48)).mMagnitude; int soundMagnitude = creatureStats.mMagicEffects.get (MWMechanics::EffectKey (48)).mMagnitude;

View file

@ -59,54 +59,36 @@ namespace MWScript
}; };
template<class R> template<class R>
class OpClearForceRun : public Interpreter::Opcode0 class OpClearMovementFlag : public Interpreter::Opcode0
{ {
MWMechanics::NpcStats::Flag mFlag;
public: public:
OpClearMovementFlag (MWMechanics::NpcStats::Flag flag) : mFlag (flag) {}
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
MWWorld::Class::get (ptr).getNpcStats (ptr).mForceRun = false; MWWorld::Class::get (ptr).getNpcStats (ptr).setMovementFlag (mFlag, false);
} }
}; };
template<class R> template<class R>
class OpForceRun : public Interpreter::Opcode0 class OpSetMovementFlag : public Interpreter::Opcode0
{ {
MWMechanics::NpcStats::Flag mFlag;
public: public:
OpSetMovementFlag (MWMechanics::NpcStats::Flag flag) : mFlag (flag) {}
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
MWWorld::Class::get (ptr).getNpcStats (ptr).mForceRun = true; MWWorld::Class::get (ptr).getNpcStats (ptr).setMovementFlag (mFlag, true);
}
};
template<class R>
class OpClearForceSneak : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::Ptr ptr = R()(runtime);
MWWorld::Class::get (ptr).getNpcStats (ptr).mForceSneak = false;
}
};
template<class R>
class OpForceSneak : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::Ptr ptr = R()(runtime);
MWWorld::Class::get (ptr).getNpcStats (ptr).mForceSneak = true;
} }
}; };
@ -165,19 +147,23 @@ namespace MWScript
interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision); interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision);
interpreter.installSegment5 (opcodeClearForceRun, new OpClearForceRun<ImplicitRef>); interpreter.installSegment5 (opcodeClearForceRun,
interpreter.installSegment5 (opcodeForceRun, new OpForceRun<ImplicitRef>); new OpClearMovementFlag<ImplicitRef> (MWMechanics::NpcStats::Flag_ForceRun));
interpreter.installSegment5 (opcodeClearForceSneak, new OpClearForceSneak<ImplicitRef>); interpreter.installSegment5 (opcodeForceRun,
interpreter.installSegment5 (opcodeForceSneak, new OpForceSneak<ImplicitRef>); new OpSetMovementFlag<ImplicitRef> (MWMechanics::NpcStats::Flag_ForceRun));
interpreter.installSegment5 (opcodeClearForceSneak,
new OpClearMovementFlag<ImplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
interpreter.installSegment5 (opcodeForceSneak,
new OpSetMovementFlag<ImplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
interpreter.installSegment5 (opcodeClearForceRunExplicit, interpreter.installSegment5 (opcodeClearForceRunExplicit,
new OpClearForceRun<ExplicitRef>); new OpClearMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceRun));
interpreter.installSegment5 (opcodeForceRunExplicit, interpreter.installSegment5 (opcodeForceRunExplicit,
new OpForceRun<ExplicitRef>); new OpSetMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceRun));
interpreter.installSegment5 (opcodeClearForceSneakExplicit, interpreter.installSegment5 (opcodeClearForceSneakExplicit,
new OpClearForceSneak<ExplicitRef>); new OpClearMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
interpreter.installSegment5 (opcodeForceSneakExplicit, interpreter.installSegment5 (opcodeForceSneakExplicit,
new OpForceSneak<ExplicitRef>); new OpSetMovementFlag<ExplicitRef> (MWMechanics::NpcStats::Flag_ForceSneak));
} }
} }
} }

View file

@ -237,7 +237,7 @@ namespace MWScript
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = Interpreter::Type_Integer value =
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex).
getModified(); getModified();
runtime.push (value); runtime.push (value);
@ -260,7 +260,7 @@ namespace MWScript
Interpreter::Type_Integer value = runtime[0].mInteger; Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop(); runtime.pop();
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex).
setModified (value, 0); setModified (value, 0);
} }
}; };
@ -281,10 +281,10 @@ namespace MWScript
Interpreter::Type_Integer value = runtime[0].mInteger; Interpreter::Type_Integer value = runtime[0].mInteger;
runtime.pop(); runtime.pop();
value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. value += MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex).
getModified(); getModified();
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex).
setModified (value, 0, 100); setModified (value, 0, 100);
} }
}; };
@ -373,9 +373,9 @@ namespace MWScript
if(factionID != "") if(factionID != "")
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) == MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end())
{ {
MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = 0;
} }
} }
} }
@ -402,13 +402,13 @@ namespace MWScript
if(factionID != "") if(factionID != "")
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) == MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end())
{ {
MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = 0;
} }
else else
{ {
MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] +1; MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] +1;
} }
} }
} }
@ -435,9 +435,9 @@ namespace MWScript
if(factionID != "") if(factionID != "")
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) != MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end())
{ {
MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] -1; MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] -1;
} }
} }
} }
@ -460,22 +460,22 @@ namespace MWScript
} }
else else
{ {
if(MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.empty()) if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty())
{ {
//throw exception? //throw exception?
} }
else else
{ {
factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.begin()->first; factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().begin()->first;
} }
} }
boost::algorithm::to_lower(factionID); boost::algorithm::to_lower(factionID);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
if(factionID!="") if(factionID!="")
{ {
if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) != MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end())
{ {
runtime.push(MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID]); runtime.push(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID]);
} }
else else
{ {

View file

@ -161,10 +161,10 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats)
if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill) if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill)
{ {
if (stats.mSkill[oldSkill].getModified()>stats.mSkill[testSkill].getModified()) if (stats.getSkill (oldSkill).getModified()>stats.getSkill (testSkill).getModified())
continue; // rejected, because old item better matched the NPC's skills. continue; // rejected, because old item better matched the NPC's skills.
if (stats.mSkill[oldSkill].getModified()<stats.mSkill[testSkill].getModified()) if (stats.getSkill (oldSkill).getModified()<stats.getSkill (testSkill).getModified())
use = true; use = true;
} }
} }