Issue #219: added filters for various player stats

actorid
Marc Zinnschlag 12 years ago
parent f8fcca64b6
commit d24e3eec9f

@ -114,10 +114,6 @@ namespace MWDialogue
iss >> ifunction;
switch(ifunction)
{
case 43://PC Crime level
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;
case 48://Detected
if(!selectCompare<int,int>(comp,1,select.mI)) return false;
break;
@ -134,10 +130,6 @@ namespace MWDialogue
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;
case 64://PC Health
if(!selectCompare<int,int>(comp,50,select.mI)) return false;
break;
case 65://Creature target
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
break;

@ -9,6 +9,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/creaturestats.hpp"
@ -188,6 +189,26 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
return select.selectCompare (locals.mFloats.at (i));
}
case SelectWrapper::Function_PcHealthPercent:
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
float ratio = MWWorld::Class::get (player).getCreatureStats (player).getHealth().getCurrent() /
MWWorld::Class::get (player).getCreatureStats (player).getHealth().getModified();
return select.selectCompare (ratio);
}
case SelectWrapper::Function_PcDynamicStat:
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
float value = MWWorld::Class::get (player).getCreatureStats (player).
getDynamic (select.getArgument()).getCurrent();
return select.selectCompare (value);
}
default:
throw std::runtime_error ("unknown numeric select function");
@ -247,7 +268,39 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
return hits>4 ? 4 : hits;
}
case SelectWrapper::Function_PcLevel:
return MWWorld::Class::get (player).getCreatureStats (player).getLevel();
case SelectWrapper::Function_PcGender:
{
MWWorld::LiveCellRef<ESM::NPC> *cellRef = player.get<ESM::NPC>();
return cellRef->mBase->Female ? 0 : 1;
}
case SelectWrapper::Function_PcClothingModifier:
{
MWWorld::InventoryStore& store = MWWorld::Class::get (player).getInventoryStore (player);
int value = 0;
for (int i=0; i<=15; ++i) // everything except thigns held in hands and amunition
{
MWWorld::ContainerStoreIterator slot = store.getSlot (i);
if (slot!=store.end())
value += MWWorld::Class::get (*slot).getValue (*slot);
}
return value;
}
case SelectWrapper::Function_PcCrimeLevel:
return MWWorld::Class::get (player).getNpcStats (player).getBounty();
default:
throw std::runtime_error ("unknown integer select function");
@ -322,7 +375,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_TalkedToPc:
return mTalkedToPlayer;
default:
throw std::runtime_error ("unknown boolean select function");

@ -61,16 +61,21 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
switch (index)
{
// 0-9
// 0-5
case 6: return Function_PcLevel;
case 7: return Function_PcHealthPercent;
case 8: case 9: return Function_PcDynamicStat;
case 10: return Function_PcAttribute;
case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20:
case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30:
case 31: case 32: case 33: case 34: case 35: case 36: case 37: return Function_PcSkill;
// 38
case 38: return Function_PcGender;
case 39: return Function_PcExpelled;
case 40: return Function_PcCommonDisease;
case 41: return Function_PcBlightDisease;
// 42-45
// 42
case 42: return Function_PcClothingModifier;
case 43: return Function_PcCrimeLevel;
case 46: return Function_SameFaction;
// 47-49
case 50: return Function_Choice;
@ -80,7 +85,8 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
case 60: return Function_PcVampire;
// 61, 62
case 63: return Function_TalkedToPc;
// 64, 65
case 64: return Function_PcDynamicStat;
// 65
case 66: return Function_FriendlyHit;
case 67: case 68: case 69: case 70: return Function_AiSetting;
// 71-77
@ -169,6 +175,11 @@ int MWDialogue::SelectWrapper::getArgument() const
case 35: return 24;
case 36: return 25;
case 37: return 26;
// dynamic stats
case 8: return 1;
case 9: return 2;
case 64: return 0;
}
return 0;
@ -183,12 +194,15 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
Function_AiSetting,
Function_PcAttribute, Function_PcSkill,
Function_FriendlyHit,
Function_PcLevel, Function_PcGender, Function_PcClothingModifier,
Function_PcCrimeLevel,
Function_None // end marker
};
static const Function numericFunctions[] =
{
Function_Global, Function_Local,
Function_PcDynamicStat, Function_PcHealthPercent,
Function_None // end marker
};
@ -233,6 +247,10 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const
{
Function_Faction, SelectWrapper::Function_Class, SelectWrapper::Function_Race,
Function_SameFaction,
Function_PcSkill,
Function_PcExpelled,
Function_PcVampire,
Function_PcCrimeLevel,
Function_None // end marker
};

@ -32,7 +32,9 @@ namespace MWDialogue
Function_PcExpelled,
Function_PcVampire,
Function_FriendlyHit,
Function_TalkedToPc
Function_TalkedToPc,
Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat,
Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel
};
enum Type

Loading…
Cancel
Save