Issue #219: added various creature and NPC stats; implemented respective filters

This commit is contained in:
Marc Zinnschlag 2012-11-10 13:20:41 +01:00
parent e97f3003ab
commit 7e8d4bb3c9
8 changed files with 100 additions and 18 deletions

View file

@ -125,10 +125,6 @@ namespace MWDialogue
if(!selectCompare<int,int>(comp,0,select.mI)) return false; if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break; break;
case 60://PC Vampire
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;
case 61://Level case 61://Level
if(!selectCompare<int,int>(comp,1,select.mI)) return false; if(!selectCompare<int,int>(comp,1,select.mI)) return false;
break; break;
@ -137,10 +133,6 @@ namespace MWDialogue
if(!selectCompare<int,int>(comp,0,select.mI)) return false; if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break; break;
case 63://Talked to PC
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;
case 64://PC Health case 64://PC Health
if(!selectCompare<int,int>(comp,50,select.mI)) return false; if(!selectCompare<int,int>(comp,50,select.mI)) return false;
break; break;
@ -149,10 +141,6 @@ namespace MWDialogue
if(!selectCompare<int,int>(comp,0,select.mI)) return false; if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break; break;
case 66://Friend hit
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;
case 71://Should Attack case 71://Should Attack
if(!selectCompare<int,int>(comp,0,select.mI)) return false; if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break; break;

View file

@ -241,6 +241,13 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
return static_cast<int> (MWWorld::Class::get (player). return static_cast<int> (MWWorld::Class::get (player).
getNpcStats (player).getSkill (select.getArgument()).getModified()); getNpcStats (player).getSkill (select.getArgument()).getModified());
case SelectWrapper::Function_FriendlyHit:
{
int hits = MWWorld::Class::get (mActor).getCreatureStats (mActor).getFriendlyHits();
return hits>4 ? 4 : hits;
}
default: default:
throw std::runtime_error ("unknown integer select function"); throw std::runtime_error ("unknown integer select function");
@ -307,6 +314,14 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
return expelled.find (faction)!=expelled.end(); return expelled.find (faction)!=expelled.end();
} }
case SelectWrapper::Function_PcVampire:
return MWWorld::Class::get (player).getNpcStats (player).isVampire();
case SelectWrapper::Function_TalkedToPc:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).hasTalkedToPlayer();
default: default:

View file

@ -76,7 +76,12 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
case 50: return Function_Choice; case 50: return Function_Choice;
case 51: case 52: case 53: case 54: case 55: case 56: case 57: return Function_PcAttribute; case 51: case 52: case 53: case 54: case 55: case 56: case 57: return Function_PcAttribute;
case 58: return Function_PcCorprus; case 58: return Function_PcCorprus;
// 59-66 // 59
case 60: return Function_PcVampire;
// 61, 62
case 63: return Function_TalkedToPc;
// 64, 65
case 66: return Function_FriendlyHit;
case 67: case 68: case 69: case 70: return Function_AiSetting; case 67: case 68: case 69: case 70: return Function_AiSetting;
// 71-77 // 71-77
} }
@ -177,6 +182,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
Function_Choice, Function_Choice,
Function_AiSetting, Function_AiSetting,
Function_PcAttribute, Function_PcSkill, Function_PcAttribute, Function_PcSkill,
Function_FriendlyHit,
Function_None // end marker Function_None // end marker
}; };
@ -193,6 +199,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
Function_SameFaction, Function_SameFaction,
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus,
Function_PcExpelled, Function_PcExpelled,
Function_PcVampire, Function_TalkedToPc,
Function_None // end marker Function_None // end marker
}; };

View file

@ -29,7 +29,10 @@ namespace MWDialogue
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus,
Function_AiSetting, Function_AiSetting,
Function_PcAttribute, Function_PcSkill, Function_PcAttribute, Function_PcSkill,
Function_PcExpelled Function_PcExpelled,
Function_PcVampire,
Function_FriendlyHit,
Function_TalkedToPc
}; };
enum Type enum Type

View file

@ -10,7 +10,7 @@
namespace MWMechanics namespace MWMechanics
{ {
CreatureStats::CreatureStats() CreatureStats::CreatureStats()
: mLevel (0), mLevelHealthBonus(0.f), mDead (false) : mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false)
{ {
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
mAiSettings[i] = 0; mAiSettings[i] = 0;
@ -216,4 +216,24 @@ namespace MWMechanics
{ {
return mSpells.hasBlightDisease(); return mSpells.hasBlightDisease();
} }
int CreatureStats::getFriendlyHits() const
{
return mFriendlyHits;
}
void CreatureStats::friendlyHit()
{
++mFriendlyHits;
}
bool CreatureStats::hasTalkedToPlayer() const
{
return mTalkedTo;
}
void CreatureStats::talkedToPlayer()
{
mTalkedTo = true;
}
} }

View file

@ -27,7 +27,9 @@ namespace MWMechanics
int mAiSettings[4]; int mAiSettings[4];
AiSequence mAiSequence; AiSequence mAiSequence;
float mLevelHealthBonus; float mLevelHealthBonus;
bool mDead; bool mDead;
int mFriendlyHits;
bool mTalkedTo;
public: public:
CreatureStats(); CreatureStats();
@ -99,7 +101,18 @@ namespace MWMechanics
bool hasCommonDisease() const; bool hasCommonDisease() const;
bool hasBlightDisease() const; bool hasBlightDisease() const;
int getFriendlyHits() const;
///< Number of friendly hits received.
void friendlyHit();
///< Increase number of friendly hits by one.
bool hasTalkedToPlayer() const;
///< Has this creature talked with the player before?
void talkedToPlayer();
}; };
} }

View file

@ -19,7 +19,7 @@
MWMechanics::NpcStats::NpcStats() MWMechanics::NpcStats::NpcStats()
: mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0) : mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0)
, mLevelProgress(0), mDisposition(0) , mLevelProgress(0), mDisposition(0), mVampire (0)
{ {
mSkillIncreases.resize (ESM::Attribute::Length); mSkillIncreases.resize (ESM::Attribute::Length);
@ -274,3 +274,29 @@ void MWMechanics::NpcStats::setBounty (int bounty)
{ {
mBounty = bounty; mBounty = bounty;
} }
int MWMechanics::NpcStats::getFactionReputation (const std::string& faction) const
{
std::map<std::string, int>::const_iterator iter = mFactionReputation.find (faction);
if (iter==mFactionReputation.end())
return 0;
return iter->second;
}
void MWMechanics::NpcStats::setFactionReputation (const std::string& faction, int value)
{
mFactionReputation[faction] = value;
}
bool MWMechanics::NpcStats::isVampire() const
{
return mVampire;
}
void MWMechanics::NpcStats::setVampire (bool set)
{
mVampire = set;
}

View file

@ -48,6 +48,8 @@ namespace MWMechanics
Stat<float> mSkill[27]; Stat<float> mSkill[27];
int mBounty; int mBounty;
std::set<std::string> mExpelled; std::set<std::string> mExpelled;
std::map<std::string, int> mFactionReputation;
bool mVampire;
int mLevelProgress; // 0-10 int mLevelProgress; // 0-10
@ -108,6 +110,14 @@ namespace MWMechanics
int getBounty() const; int getBounty() const;
void setBounty (int bounty); void setBounty (int bounty);
int getFactionReputation (const std::string& faction) const;
void setFactionReputation (const std::string& faction, int value);
bool isVampire() const;
void setVampire (bool set);
}; };
} }