Issue #219: added last missing function filters

actorid
Marc Zinnschlag 12 years ago
parent 5f7d349126
commit 9669eed083

@ -338,6 +338,58 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
return MWWorld::Class::get (player).getNpcStats (player).getReputation();
case SelectWrapper::Function_Weather:
return MWBase::Environment::get().getWorld()->getCurrentWeather();
case SelectWrapper::Function_Reputation:
return MWWorld::Class::get (mActor).getNpcStats (mActor).getReputation();
case SelectWrapper::Function_FactionRankDiff:
{
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
return 0;
std::pair<std::string, int> faction =
*MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin();
int rank = getFactionRank (player, faction.first);
return rank-faction.second;
}
case SelectWrapper::Function_WerewolfKills:
return MWWorld::Class::get (player).getNpcStats (player).getWerewolfKills();
case SelectWrapper::Function_RankLow:
case SelectWrapper::Function_RankHigh:
{
bool low = select.getFunction()==SelectWrapper::Function_RankLow;
if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty())
return 0;
std::string factionId =
MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first;
int value = 0;
const ESM::Faction& faction =
*MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId);
MWMechanics::NpcStats& playerStats = MWWorld::Class::get (player).getNpcStats (player);
for (std::vector<ESM::Faction::Reaction>::const_iterator iter (faction.mReactions.begin());
iter!=faction.mReactions.end(); ++iter)
if (playerStats.getFactionRanks().find (iter->mFaction)!=playerStats.getFactionRanks().end())
if (low ? iter->mReaction<value : iter->mReaction>value)
value = iter->mReaction;
return value;
}
default:
throw std::runtime_error ("unknown integer select function");
@ -423,6 +475,30 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
return mTalkedToPlayer;
case SelectWrapper::Function_Alarmed:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isAlarmed();
case SelectWrapper::Function_Detected:
return MWWorld::Class::get (mActor).hasDetected (mActor, player);
case SelectWrapper::Function_Attacked:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAttacked();
case SelectWrapper::Function_ShouldAttack:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).isHostile();
case SelectWrapper::Function_CreatureTargetted:
return MWWorld::Class::get (mActor).getCreatureStats (mActor).getCreatureTargetted();
case SelectWrapper::Function_PCWerewolf:
return MWWorld::Class::get (player).getNpcStats (player).isWerewolf();
default:
throw std::runtime_error ("unknown boolean select function");

@ -61,9 +61,10 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
switch (index)
{
// 0, 1
case 0: return Function_RankLow;
case 1: return Function_RankHigh;
case 2: return Function_RankRequirement;
// 3
case 3: return Function_Reputation;
case 4: return Function_HealthPercent;
case 5: return Function_PCReputation;
case 6: return Function_PcLevel;
@ -82,20 +83,24 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
case 44: return Function_SameGender;
case 45: return Function_SameRace;
case 46: return Function_SameFaction;
// 47-49
case 47: return Function_FactionRankDiff;
case 48: return Function_Detected;
case 49: return Function_Alarmed;
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
case 59: return Function_Weather;
case 60: return Function_PcVampire;
case 61: return Function_Level;
// 62
case 62: return Function_Attacked;
case 63: return Function_TalkedToPc;
case 64: return Function_PcDynamicStat;
// 65
case 65: return Function_CreatureTargetted;
case 66: return Function_FriendlyHit;
case 67: case 68: case 69: case 70: return Function_AiSetting;
// 71
case 71: return Function_ShouldAttack;
case 72: return Function_PCWerewolf;
case 73: return Function_WerewolfKills;
}
return Function_False;
@ -204,6 +209,10 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
Function_PcCrimeLevel,
Function_RankRequirement,
Function_Level, Function_PCReputation,
Function_Weather,
Function_Reputation, Function_FactionRankDiff,
Function_WerewolfKills,
Function_RankLow, Function_RankHigh,
Function_None // end marker
};
@ -223,6 +232,10 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus,
Function_PcExpelled,
Function_PcVampire, Function_TalkedToPc,
Function_Alarmed, Function_Detected,
Function_Attacked, Function_ShouldAttack,
Function_CreatureTargetted,
Function_PCWerewolf,
Function_None // end marker
};
@ -261,6 +274,9 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const
Function_PcVampire,
Function_PcCrimeLevel,
Function_RankRequirement,
Function_Reputation, Function_FactionRankDiff,
Function_PCWerewolf, Function_WerewolfKills,
Function_RankLow, Function_RankHigh,
Function_None // end marker
};

@ -36,7 +36,13 @@ namespace MWDialogue
Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat,
Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel,
Function_RankRequirement,
Function_HealthPercent, Function_Level, Function_PCReputation
Function_HealthPercent, Function_Level, Function_PCReputation,
Function_Weather,
Function_Reputation, Function_Alarmed, Function_FactionRankDiff, Function_Detected,
Function_Attacked, Function_ShouldAttack,
Function_CreatureTargetted,
Function_PCWerewolf, Function_WerewolfKills,
Function_RankLow, Function_RankHigh
};
enum Type

@ -10,7 +10,8 @@
namespace MWMechanics
{
CreatureStats::CreatureStats()
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false)
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false), mAlarmed (false),
mAttacked (false), mHostile (false)
{
for (int i=0; i<4; ++i)
mAiSettings[i] = 0;
@ -236,4 +237,39 @@ namespace MWMechanics
{
mTalkedTo = true;
}
bool CreatureStats::isAlarmed() const
{
return mAlarmed;
}
void CreatureStats::setAlarmed (bool alarmed)
{
mAlarmed = alarmed;
}
bool CreatureStats::getAttacked() const
{
return mAttacked;
}
void CreatureStats::setAttacked (bool attacked)
{
mAttacked = attacked;
}
bool CreatureStats::isHostile() const
{
return mHostile;
}
void CreatureStats::setHostile (bool hostile)
{
mHostile = hostile;
}
bool CreatureStats::getCreatureTargetted() const
{
return false;
}
}

@ -30,6 +30,9 @@ namespace MWMechanics
bool mDead;
int mFriendlyHits;
bool mTalkedTo;
bool mAlarmed;
bool mAttacked;
bool mHostile;
public:
CreatureStats();
@ -113,6 +116,20 @@ namespace MWMechanics
///< Has this creature talked with the player before?
void talkedToPlayer();
bool isAlarmed() const;
void setAlarmed (bool alarmed);
bool getAttacked() const;
void setAttacked (bool attacked);
bool isHostile() const;
void setHostile (bool hostile);
bool getCreatureTargetted() const;
};
}

@ -22,7 +22,7 @@
MWMechanics::NpcStats::NpcStats()
: mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0)
, mLevelProgress(0), mDisposition(0), mVampire (0), mReputation(0)
, mLevelProgress(0), mDisposition(0), mVampire (0), mReputation(0), mWerewolf (false), mWerewolfKills (0)
{
mSkillIncreases.resize (ESM::Attribute::Length);
for (int i=0; i<ESM::Attribute::Length; ++i)
@ -337,3 +337,17 @@ bool MWMechanics::NpcStats::hasSkillsForRank (const std::string& factionId, int
return *++iter>=rankData.mSkill2;
}
bool MWMechanics::NpcStats::isWerewolf() const
{
return mWerewolf;
}
void MWMechanics::NpcStats::setWerewolf (bool set)
{
mWerewolf = set;
}
int MWMechanics::NpcStats::getWerewolfKills() const
{
return mWerewolfKills;
}

@ -51,6 +51,8 @@ namespace MWMechanics
std::map<std::string, int> mFactionReputation;
bool mVampire;
int mReputation;
bool mWerewolf;
int mWerewolfKills;
int mLevelProgress; // 0-10
@ -125,6 +127,12 @@ namespace MWMechanics
void setVampire (bool set);
bool hasSkillsForRank (const std::string& factionId, int rank) const;
bool isWerewolf() const;
void setWerewolf (bool set);
int getWerewolfKills() const;
};
}

@ -162,6 +162,11 @@ namespace MWWorld
return false;
}
bool Class::hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const
{
return false;
}
const Class& Class::get (const std::string& key)
{
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);

@ -191,6 +191,11 @@ namespace MWWorld
///
/// (default implementation: return false)
virtual bool hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const;
///< Has \æ ptr detected \a ptr2?
///
/// (default implementation: return false)
static const Class& get (const std::string& key);
///< If there is no class for this \a key, an exception is thrown.

Loading…
Cancel
Save