mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Merge branch 'clickbait' into 'master'
Move more arrays to the ESM::Attribute struct See merge request OpenMW/openmw!3074
This commit is contained in:
commit
4399748889
@ -48,22 +48,18 @@ namespace MWGui
|
||||
}
|
||||
|
||||
int w = 2;
|
||||
|
||||
const auto& store = MWBase::Environment::get().getESMStore();
|
||||
for (const auto& [effectId, effectInfos] : effects)
|
||||
{
|
||||
const ESM::MagicEffect* effect
|
||||
= MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effectId);
|
||||
const ESM::MagicEffect* effect = store->get<ESM::MagicEffect>().find(effectId);
|
||||
|
||||
float remainingDuration = 0;
|
||||
float totalDuration = 0;
|
||||
|
||||
std::string sourcesDescription;
|
||||
|
||||
static const float fadeTime = MWBase::Environment::get()
|
||||
.getESMStore()
|
||||
->get<ESM::GameSetting>()
|
||||
.find("fMagicStartIconBlink")
|
||||
->mValue.getFloat();
|
||||
static const float fadeTime
|
||||
= store->get<ESM::GameSetting>().find("fMagicStartIconBlink")->mValue.getFloat();
|
||||
|
||||
bool addNewLine = false;
|
||||
for (const MagicEffectInfo& effectInfo : effectInfos)
|
||||
@ -94,9 +90,10 @@ namespace MWGui
|
||||
}
|
||||
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
{
|
||||
const ESM::Attribute* attribute = store->get<ESM::Attribute>().find(effectInfo.mKey.mArg);
|
||||
sourcesDescription += " (";
|
||||
sourcesDescription += MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
||||
ESM::Attribute::sGmstAttributeIds[effectInfo.mKey.mArg], {});
|
||||
sourcesDescription
|
||||
+= MWBase::Environment::get().getWindowManager()->getGameSettingString(attribute->mName, {});
|
||||
sourcesDescription += ')';
|
||||
}
|
||||
ESM::MagicEffect::MagnitudeDisplayType displayType = effect->getMagnitudeDisplayType();
|
||||
|
@ -54,9 +54,9 @@ namespace MWGui
|
||||
if (effectId != -1)
|
||||
{
|
||||
const ESM::MagicEffect* magicEffect = store.get<ESM::MagicEffect>().find(effectId);
|
||||
const ESM::Attribute* attribute = store.get<ESM::Attribute>().search(effect.mAttribute);
|
||||
|
||||
std::string fullEffectName
|
||||
= MWMechanics::getMagicEffectString(*magicEffect, effect.mAttribute, effect.mSkill);
|
||||
std::string fullEffectName = MWMechanics::getMagicEffectString(*magicEffect, attribute, effect.mSkill);
|
||||
std::string convert = Utf8Stream::lowerCaseUtf8(fullEffectName);
|
||||
if (convert.find(filter) != std::string::npos)
|
||||
{
|
||||
|
@ -340,20 +340,21 @@ namespace MWGui
|
||||
|
||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||
const MWMechanics::NpcStats& PCstats = player.getClass().getNpcStats(player);
|
||||
const auto& store = MWBase::Environment::get().getESMStore();
|
||||
|
||||
std::string detailText;
|
||||
std::stringstream detail;
|
||||
bool first = true;
|
||||
for (int attribute = 0; attribute < ESM::Attribute::Length; ++attribute)
|
||||
for (const auto& attribute : store->get<ESM::Attribute>())
|
||||
{
|
||||
float mult = PCstats.getLevelupAttributeMultiplier(attribute);
|
||||
mult = std::min(mult, 100 - PCstats.getAttribute(attribute).getBase());
|
||||
float mult = PCstats.getLevelupAttributeMultiplier(attribute.mId);
|
||||
mult = std::min(mult, 100 - PCstats.getAttribute(attribute.mId).getBase());
|
||||
if (mult > 1)
|
||||
{
|
||||
if (!first)
|
||||
detail << '\n';
|
||||
detail << "#{" << MyGUI::TextIterator::toTagsString(ESM::Attribute::sGmstAttributeIds[attribute])
|
||||
<< "} x" << MyGUI::utility::toString(mult);
|
||||
detail << "#{" << MyGUI::TextIterator::toTagsString(attribute.mName) << "} x"
|
||||
<< MyGUI::utility::toString(mult);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
@ -363,11 +364,7 @@ namespace MWGui
|
||||
MyGUI::Widget* levelWidget;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
int max = MWBase::Environment::get()
|
||||
.getESMStore()
|
||||
->get<ESM::GameSetting>()
|
||||
.find("iLevelUpTotal")
|
||||
->mValue.getInteger();
|
||||
int max = store->get<ESM::GameSetting>().find("iLevelUpTotal")->mValue.getInteger();
|
||||
getWidget(levelWidget, i == 0 ? "Level_str" : "LevelText");
|
||||
|
||||
levelWidget->setUserString(
|
||||
|
@ -829,12 +829,14 @@ namespace MWGui
|
||||
|
||||
void ToolTips::createAttributeToolTip(MyGUI::Widget* widget, int attributeId)
|
||||
{
|
||||
if (attributeId == -1)
|
||||
const ESM::Attribute* attribute
|
||||
= MWBase::Environment::get().getESMStore()->get<ESM::Attribute>().search(attributeId);
|
||||
if (!attribute)
|
||||
return;
|
||||
|
||||
const std::string& icon = ESM::Attribute::sAttributeIcons[attributeId];
|
||||
const std::string& name = ESM::Attribute::sGmstAttributeIds[attributeId];
|
||||
const std::string& desc = ESM::Attribute::sGmstAttributeDescIds[attributeId];
|
||||
const std::string& icon = attribute->mIcon;
|
||||
const std::string& name = attribute->mName;
|
||||
const std::string& desc = attribute->mDescription;
|
||||
|
||||
widget->setUserString("ToolTipType", "Layout");
|
||||
widget->setUserString("ToolTipLayout", "AttributeToolTip");
|
||||
|
@ -378,6 +378,7 @@ namespace MWGui::Widgets
|
||||
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
|
||||
|
||||
const ESM::MagicEffect* magicEffect = store.get<ESM::MagicEffect>().search(mEffectParams.mEffectID);
|
||||
const ESM::Attribute* attribute = store.get<ESM::Attribute>().search(mEffectParams.mAttribute);
|
||||
|
||||
assert(magicEffect);
|
||||
|
||||
@ -393,8 +394,7 @@ namespace MWGui::Widgets
|
||||
std::string sec = " " + std::string{ windowManager->getGameSettingString("ssecond", {}) };
|
||||
std::string secs = " " + std::string{ windowManager->getGameSettingString("sseconds", {}) };
|
||||
|
||||
std::string spellLine
|
||||
= MWMechanics::getMagicEffectString(*magicEffect, mEffectParams.mAttribute, mEffectParams.mSkill);
|
||||
std::string spellLine = MWMechanics::getMagicEffectString(*magicEffect, attribute, mEffectParams.mSkill);
|
||||
|
||||
if (mEffectParams.mMagnMin || mEffectParams.mMagnMax)
|
||||
{
|
||||
|
@ -561,23 +561,23 @@ std::vector<std::string> MWMechanics::Alchemy::effectsDescription(const MWWorld:
|
||||
std::vector<std::string> effects;
|
||||
|
||||
const auto& item = ptr.get<ESM::Ingredient>()->mBase;
|
||||
const auto& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
|
||||
const auto& mgef = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>();
|
||||
const static auto fWortChanceValue = gmst.find("fWortChanceValue")->mValue.getFloat();
|
||||
const auto& store = MWBase::Environment::get().getESMStore();
|
||||
const auto& mgef = store->get<ESM::MagicEffect>();
|
||||
const static auto fWortChanceValue = store->get<ESM::GameSetting>().find("fWortChanceValue")->mValue.getFloat();
|
||||
const auto& data = item->mData;
|
||||
|
||||
for (auto i = 0; i < 4; ++i)
|
||||
{
|
||||
const auto effectID = data.mEffectID[i];
|
||||
const auto skillID = data.mSkills[i];
|
||||
const auto attributeID = data.mAttributes[i];
|
||||
|
||||
if (alchemySkill < fWortChanceValue * (i + 1))
|
||||
break;
|
||||
|
||||
if (effectID != -1)
|
||||
{
|
||||
std::string effect = getMagicEffectString(*mgef.find(effectID), attributeID, skillID);
|
||||
const ESM::Attribute* attribute = store->get<ESM::Attribute>().search(data.mAttributes[i]);
|
||||
std::string effect = getMagicEffectString(*mgef.find(effectID), attribute, skillID);
|
||||
|
||||
effects.push_back(effect);
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ namespace MWMechanics
|
||||
|
||||
std::string EffectKey::toString() const
|
||||
{
|
||||
const ESM::MagicEffect* magicEffect
|
||||
= MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().search(mId);
|
||||
return getMagicEffectString(*magicEffect, mArg, mArg);
|
||||
const auto& store = MWBase::Environment::get().getESMStore();
|
||||
const ESM::MagicEffect* magicEffect = store->get<ESM::MagicEffect>().search(mId);
|
||||
return getMagicEffectString(*magicEffect, store->get<ESM::Attribute>().find(mArg), mArg);
|
||||
}
|
||||
|
||||
bool operator<(const EffectKey& left, const EffectKey& right)
|
||||
@ -227,10 +227,10 @@ namespace MWMechanics
|
||||
}
|
||||
}
|
||||
|
||||
std::string getMagicEffectString(const ESM::MagicEffect& effect, int attributeArg, int skillArg)
|
||||
std::string getMagicEffectString(const ESM::MagicEffect& effect, const ESM::Attribute* attribute, int skillArg)
|
||||
{
|
||||
const bool targetsSkill = effect.mData.mFlags & ESM::MagicEffect::TargetSkill && skillArg != -1;
|
||||
const bool targetsAttribute = effect.mData.mFlags & ESM::MagicEffect::TargetAttribute && attributeArg != -1;
|
||||
const bool targetsAttribute = effect.mData.mFlags & ESM::MagicEffect::TargetAttribute && attribute;
|
||||
|
||||
std::string spellLine;
|
||||
|
||||
@ -277,7 +277,7 @@ namespace MWMechanics
|
||||
else if (targetsAttribute)
|
||||
{
|
||||
spellLine += ' ';
|
||||
spellLine += windowManager->getGameSettingString(ESM::Attribute::sGmstAttributeIds[attributeArg], {});
|
||||
spellLine += windowManager->getGameSettingString(attribute->mName, {});
|
||||
}
|
||||
return spellLine;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct Attribute;
|
||||
struct ENAMstruct;
|
||||
struct EffectList;
|
||||
struct MagicEffect;
|
||||
@ -113,7 +114,7 @@ namespace MWMechanics
|
||||
///< Return changes from \a prev to \a now.
|
||||
};
|
||||
|
||||
std::string getMagicEffectString(const ESM::MagicEffect& effect, int attributeArg, int skillArg);
|
||||
std::string getMagicEffectString(const ESM::MagicEffect& effect, const ESM::Attribute* attribute, int skillArg);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -90,22 +90,17 @@ namespace MWWorld
|
||||
|
||||
void Player::setWerewolfStats()
|
||||
{
|
||||
const MWWorld::Store<ESM::GameSetting>& gmst
|
||||
= MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
|
||||
const auto& store = MWBase::Environment::get().getESMStore();
|
||||
const MWWorld::Store<ESM::GameSetting>& gmst = store->get<ESM::GameSetting>();
|
||||
MWMechanics::CreatureStats& creatureStats = getPlayer().getClass().getCreatureStats(getPlayer());
|
||||
MWMechanics::NpcStats& npcStats = getPlayer().getClass().getNpcStats(getPlayer());
|
||||
MWMechanics::DynamicStat<float> health = creatureStats.getDynamic(0);
|
||||
creatureStats.setHealth(health.getBase() * gmst.find("fWereWolfHealth")->mValue.getFloat());
|
||||
for (size_t i = 0; i < ESM::Attribute::Length; ++i)
|
||||
for (const auto& attribute : store->get<ESM::Attribute>())
|
||||
{
|
||||
// Oh, Bethesda. It's "Intelligence".
|
||||
std::string name = "fWerewolf"
|
||||
+ ((i == ESM::Attribute::Intelligence) ? std::string("Intellegence")
|
||||
: ESM::Attribute::sAttributeNames[i]);
|
||||
|
||||
MWMechanics::AttributeValue value = npcStats.getAttribute(i);
|
||||
value.setModifier(gmst.find(name)->mValue.getFloat() - value.getModified());
|
||||
npcStats.setAttribute(i, value);
|
||||
MWMechanics::AttributeValue value = npcStats.getAttribute(attribute.mId);
|
||||
value.setModifier(gmst.find(attribute.mWerewolfGMST)->mValue.getFloat() - value.getModified());
|
||||
npcStats.setAttribute(attribute.mId, value);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ESM::Skill::Length; i++)
|
||||
|
@ -948,14 +948,47 @@ namespace MWWorld
|
||||
}
|
||||
void Store<ESM::Attribute>::setUp()
|
||||
{
|
||||
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
||||
{
|
||||
ESM::Attribute newAttribute;
|
||||
newAttribute.mId = ESM::Attribute::AttributeID(i);
|
||||
newAttribute.mName = ESM::Attribute::sGmstAttributeIds[i];
|
||||
newAttribute.mDescription = ESM::Attribute::sGmstAttributeDescIds[i];
|
||||
mStatic.push_back(newAttribute);
|
||||
}
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Strength,
|
||||
.mName = "sAttributeStrength",
|
||||
.mDescription = "sStrDesc",
|
||||
.mIcon = "icons\\k\\attribute_strength.dds",
|
||||
.mWerewolfGMST = "fWerewolfStrength" });
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Intelligence,
|
||||
.mName = "sAttributeIntelligence",
|
||||
.mDescription = "sIntDesc",
|
||||
.mIcon = "icons\\k\\attribute_int.dds",
|
||||
// Oh, Bethesda. It's "Intelligence".
|
||||
.mWerewolfGMST = "fWerewolfIntellegence" });
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Willpower,
|
||||
.mName = "sAttributeWillpower",
|
||||
.mDescription = "sWilDesc",
|
||||
.mIcon = "icons\\k\\attribute_wilpower.dds",
|
||||
.mWerewolfGMST = "fWerewolfWillpower" });
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Agility,
|
||||
.mName = "sAttributeAgility",
|
||||
.mDescription = "sAgiDesc",
|
||||
.mIcon = "icons\\k\\attribute_agility.dds",
|
||||
.mWerewolfGMST = "fWerewolfAgility" });
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Speed,
|
||||
.mName = "sAttributeSpeed",
|
||||
.mDescription = "sSpdDesc",
|
||||
.mIcon = "icons\\k\\attribute_speed.dds",
|
||||
.mWerewolfGMST = "fWerewolfSpeed" });
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Endurance,
|
||||
.mName = "sAttributeEndurance",
|
||||
.mDescription = "sEndDesc",
|
||||
.mIcon = "icons\\k\\attribute_endurance.dds",
|
||||
.mWerewolfGMST = "fWerewolfEndurance" });
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Personality,
|
||||
.mName = "sAttributePersonality",
|
||||
.mDescription = "sPerDesc",
|
||||
.mIcon = "icons\\k\\attribute_personality.dds",
|
||||
.mWerewolfGMST = "fWerewolfPersonality" });
|
||||
mStatic.push_back({ .mId = ESM::Attribute::Luck,
|
||||
.mName = "sAttributeLuck",
|
||||
.mDescription = "sLucDesc",
|
||||
.mIcon = "icons\\k\\attribute_luck.dds",
|
||||
.mWerewolfGMST = "fWerewolfLuck" });
|
||||
}
|
||||
size_t Store<ESM::Attribute>::getSize() const
|
||||
{
|
||||
|
@ -15,39 +15,6 @@ const std::string Attribute::sAttributeNames[Attribute::Length] = {
|
||||
"Luck",
|
||||
};
|
||||
|
||||
const std::string Attribute::sGmstAttributeIds[Attribute::Length] = {
|
||||
"sAttributeStrength",
|
||||
"sAttributeIntelligence",
|
||||
"sAttributeWillpower",
|
||||
"sAttributeAgility",
|
||||
"sAttributeSpeed",
|
||||
"sAttributeEndurance",
|
||||
"sAttributePersonality",
|
||||
"sAttributeLuck",
|
||||
};
|
||||
|
||||
const std::string Attribute::sGmstAttributeDescIds[Attribute::Length] = {
|
||||
"sStrDesc",
|
||||
"sIntDesc",
|
||||
"sWilDesc",
|
||||
"sAgiDesc",
|
||||
"sSpdDesc",
|
||||
"sEndDesc",
|
||||
"sPerDesc",
|
||||
"sLucDesc",
|
||||
};
|
||||
|
||||
const std::string Attribute::sAttributeIcons[Attribute::Length] = {
|
||||
"icons\\k\\attribute_strength.dds",
|
||||
"icons\\k\\attribute_int.dds",
|
||||
"icons\\k\\attribute_wilpower.dds",
|
||||
"icons\\k\\attribute_agility.dds",
|
||||
"icons\\k\\attribute_speed.dds",
|
||||
"icons\\k\\attribute_endurance.dds",
|
||||
"icons\\k\\attribute_personality.dds",
|
||||
"icons\\k\\attribute_luck.dds",
|
||||
};
|
||||
|
||||
Attribute::AttributeID Attribute::stringToAttributeId(std::string_view attribute)
|
||||
{
|
||||
for (int id = 0; id < Attribute::Length; ++id)
|
||||
|
@ -26,12 +26,9 @@ namespace ESM
|
||||
};
|
||||
|
||||
AttributeID mId;
|
||||
std::string mName, mDescription;
|
||||
std::string mName, mDescription, mIcon, mWerewolfGMST;
|
||||
|
||||
static const std::string sAttributeNames[Length];
|
||||
static const std::string sGmstAttributeIds[Length];
|
||||
static const std::string sGmstAttributeDescIds[Length];
|
||||
static const std::string sAttributeIcons[Length];
|
||||
|
||||
static AttributeID stringToAttributeId(std::string_view attribute);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user