From 7e8d4bb3c928fd2c1047e9111b894ebe83ef7d1f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 10 Nov 2012 13:20:41 +0100 Subject: [PATCH] Issue #219: added various creature and NPC stats; implemented respective filters --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 12 -------- apps/openmw/mwdialogue/filter.cpp | 15 ++++++++++ apps/openmw/mwdialogue/selectwrapper.cpp | 9 +++++- apps/openmw/mwdialogue/selectwrapper.hpp | 5 +++- apps/openmw/mwmechanics/creaturestats.cpp | 22 ++++++++++++++- apps/openmw/mwmechanics/creaturestats.hpp | 17 +++++++++-- apps/openmw/mwmechanics/npcstats.cpp | 28 ++++++++++++++++++- apps/openmw/mwmechanics/npcstats.hpp | 10 +++++++ 8 files changed, 100 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index b5ce4c5361..ff5ad40c28 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -125,10 +125,6 @@ namespace MWDialogue if(!selectCompare(comp,0,select.mI)) return false; break; - case 60://PC Vampire - if(!selectCompare(comp,0,select.mI)) return false; - break; - case 61://Level if(!selectCompare(comp,1,select.mI)) return false; break; @@ -137,10 +133,6 @@ namespace MWDialogue if(!selectCompare(comp,0,select.mI)) return false; break; - case 63://Talked to PC - if(!selectCompare(comp,0,select.mI)) return false; - break; - case 64://PC Health if(!selectCompare(comp,50,select.mI)) return false; break; @@ -149,10 +141,6 @@ namespace MWDialogue if(!selectCompare(comp,0,select.mI)) return false; break; - case 66://Friend hit - if(!selectCompare(comp,0,select.mI)) return false; - break; - case 71://Should Attack if(!selectCompare(comp,0,select.mI)) return false; break; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index a901fc8e06..3dac9a07a0 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -241,6 +241,13 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return static_cast (MWWorld::Class::get (player). 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: 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(); } + + 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: diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 96bf932a1a..5211edba59 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -76,7 +76,12 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 50: return Function_Choice; case 51: case 52: case 53: case 54: case 55: case 56: case 57: return Function_PcAttribute; 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; // 71-77 } @@ -177,6 +182,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_Choice, Function_AiSetting, Function_PcAttribute, Function_PcSkill, + Function_FriendlyHit, Function_None // end marker }; @@ -193,6 +199,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_SameFaction, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_PcExpelled, + Function_PcVampire, Function_TalkedToPc, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 2c8c9f24e1..14f2926329 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -29,7 +29,10 @@ namespace MWDialogue Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_AiSetting, Function_PcAttribute, Function_PcSkill, - Function_PcExpelled + Function_PcExpelled, + Function_PcVampire, + Function_FriendlyHit, + Function_TalkedToPc }; enum Type diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 10b9b2f7e4..9ee7ca7c27 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -10,7 +10,7 @@ namespace MWMechanics { 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) mAiSettings[i] = 0; @@ -216,4 +216,24 @@ namespace MWMechanics { return mSpells.hasBlightDisease(); } + + int CreatureStats::getFriendlyHits() const + { + return mFriendlyHits; + } + + void CreatureStats::friendlyHit() + { + ++mFriendlyHits; + } + + bool CreatureStats::hasTalkedToPlayer() const + { + return mTalkedTo; + } + + void CreatureStats::talkedToPlayer() + { + mTalkedTo = true; + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index bbb8b8b300..937cb61cc7 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -27,7 +27,9 @@ namespace MWMechanics int mAiSettings[4]; AiSequence mAiSequence; float mLevelHealthBonus; - bool mDead; + bool mDead; + int mFriendlyHits; + bool mTalkedTo; public: CreatureStats(); @@ -99,7 +101,18 @@ namespace MWMechanics 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(); }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 0116b6a964..3402779d4b 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -19,7 +19,7 @@ MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0) -, mLevelProgress(0), mDisposition(0) +, mLevelProgress(0), mDisposition(0), mVampire (0) { mSkillIncreases.resize (ESM::Attribute::Length); @@ -274,3 +274,29 @@ void MWMechanics::NpcStats::setBounty (int bounty) { mBounty = bounty; } + +int MWMechanics::NpcStats::getFactionReputation (const std::string& faction) const +{ + std::map::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; +} + diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index ca0ed07df5..1ffc06cdf2 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -48,6 +48,8 @@ namespace MWMechanics Stat mSkill[27]; int mBounty; std::set mExpelled; + std::map mFactionReputation; + bool mVampire; int mLevelProgress; // 0-10 @@ -108,6 +110,14 @@ namespace MWMechanics int getBounty() const; 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); }; }