mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Issue #219: added filters for various player stats
This commit is contained in:
parent
f8fcca64b6
commit
d24e3eec9f
@ -114,10 +114,6 @@ namespace MWDialogue
|
|||||||
iss >> ifunction;
|
iss >> ifunction;
|
||||||
switch(ifunction)
|
switch(ifunction)
|
||||||
{
|
{
|
||||||
case 43://PC Crime level
|
|
||||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 48://Detected
|
case 48://Detected
|
||||||
if(!selectCompare<int,int>(comp,1,select.mI)) return false;
|
if(!selectCompare<int,int>(comp,1,select.mI)) return false;
|
||||||
break;
|
break;
|
||||||
@ -134,10 +130,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 64://PC Health
|
|
||||||
if(!selectCompare<int,int>(comp,50,select.mI)) return false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 65://Creature target
|
case 65://Creature target
|
||||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||||
break;
|
break;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
@ -188,6 +189,26 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
|
|||||||
return select.selectCompare (locals.mFloats.at (i));
|
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:
|
default:
|
||||||
|
|
||||||
throw std::runtime_error ("unknown numeric select function");
|
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;
|
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:
|
default:
|
||||||
|
|
||||||
throw std::runtime_error ("unknown integer select function");
|
throw std::runtime_error ("unknown integer select function");
|
||||||
@ -322,7 +375,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
|
|||||||
case SelectWrapper::Function_TalkedToPc:
|
case SelectWrapper::Function_TalkedToPc:
|
||||||
|
|
||||||
return mTalkedToPlayer;
|
return mTalkedToPlayer;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
throw std::runtime_error ("unknown boolean select function");
|
throw std::runtime_error ("unknown boolean select function");
|
||||||
|
@ -61,16 +61,21 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
|
|||||||
|
|
||||||
switch (index)
|
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 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 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 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;
|
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 39: return Function_PcExpelled;
|
||||||
case 40: return Function_PcCommonDisease;
|
case 40: return Function_PcCommonDisease;
|
||||||
case 41: return Function_PcBlightDisease;
|
case 41: return Function_PcBlightDisease;
|
||||||
// 42-45
|
// 42
|
||||||
|
case 42: return Function_PcClothingModifier;
|
||||||
|
case 43: return Function_PcCrimeLevel;
|
||||||
case 46: return Function_SameFaction;
|
case 46: return Function_SameFaction;
|
||||||
// 47-49
|
// 47-49
|
||||||
case 50: return Function_Choice;
|
case 50: return Function_Choice;
|
||||||
@ -80,7 +85,8 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
|
|||||||
case 60: return Function_PcVampire;
|
case 60: return Function_PcVampire;
|
||||||
// 61, 62
|
// 61, 62
|
||||||
case 63: return Function_TalkedToPc;
|
case 63: return Function_TalkedToPc;
|
||||||
// 64, 65
|
case 64: return Function_PcDynamicStat;
|
||||||
|
// 65
|
||||||
case 66: return Function_FriendlyHit;
|
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
|
||||||
@ -169,6 +175,11 @@ int MWDialogue::SelectWrapper::getArgument() const
|
|||||||
case 35: return 24;
|
case 35: return 24;
|
||||||
case 36: return 25;
|
case 36: return 25;
|
||||||
case 37: return 26;
|
case 37: return 26;
|
||||||
|
|
||||||
|
// dynamic stats
|
||||||
|
case 8: return 1;
|
||||||
|
case 9: return 2;
|
||||||
|
case 64: return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -183,12 +194,15 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
|||||||
Function_AiSetting,
|
Function_AiSetting,
|
||||||
Function_PcAttribute, Function_PcSkill,
|
Function_PcAttribute, Function_PcSkill,
|
||||||
Function_FriendlyHit,
|
Function_FriendlyHit,
|
||||||
|
Function_PcLevel, Function_PcGender, Function_PcClothingModifier,
|
||||||
|
Function_PcCrimeLevel,
|
||||||
Function_None // end marker
|
Function_None // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Function numericFunctions[] =
|
static const Function numericFunctions[] =
|
||||||
{
|
{
|
||||||
Function_Global, Function_Local,
|
Function_Global, Function_Local,
|
||||||
|
Function_PcDynamicStat, Function_PcHealthPercent,
|
||||||
Function_None // end marker
|
Function_None // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -233,6 +247,10 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const
|
|||||||
{
|
{
|
||||||
Function_Faction, SelectWrapper::Function_Class, SelectWrapper::Function_Race,
|
Function_Faction, SelectWrapper::Function_Class, SelectWrapper::Function_Race,
|
||||||
Function_SameFaction,
|
Function_SameFaction,
|
||||||
|
Function_PcSkill,
|
||||||
|
Function_PcExpelled,
|
||||||
|
Function_PcVampire,
|
||||||
|
Function_PcCrimeLevel,
|
||||||
Function_None // end marker
|
Function_None // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,9 @@ namespace MWDialogue
|
|||||||
Function_PcExpelled,
|
Function_PcExpelled,
|
||||||
Function_PcVampire,
|
Function_PcVampire,
|
||||||
Function_FriendlyHit,
|
Function_FriendlyHit,
|
||||||
Function_TalkedToPc
|
Function_TalkedToPc,
|
||||||
|
Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat,
|
||||||
|
Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user