Remove SkillEnum

revert-6246b479
Evil Eye 2 years ago
parent 72f8f9d1ad
commit 65b22975c9

@ -43,20 +43,13 @@ namespace MWClass
return;
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
switch (shield->getClass().getEquipmentSkill(*shield))
{
case ESM::Skill::LightArmor:
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Light Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::MediumArmor:
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Medium Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::HeavyArmor:
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Heavy Armor Hit"), 1.0f, 1.0f);
break;
default:
return;
}
ESM::RefId skill = shield->getClass().getEquipmentSkill(*shield);
if (skill == ESM::Skill::LightArmor)
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Light Armor Hit"), 1.0f, 1.0f);
else if (skill == ESM::Skill::MediumArmor)
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Medium Armor Hit"), 1.0f, 1.0f);
else if (skill == ESM::Skill::HeavyArmor)
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Heavy Armor Hit"), 1.0f, 1.0f);
}
osg::Vec3f Actor::getRotationVector(const MWWorld::Ptr& ptr) const

@ -112,7 +112,7 @@ namespace MWClass
return std::make_pair(slots_, false);
}
int Armor::getEquipmentSkill(const MWWorld::ConstPtr& ptr) const
ESM::RefId Armor::getEquipmentSkill(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
@ -150,7 +150,7 @@ namespace MWClass
}
if (typeGmst.empty())
return -1;
return {};
const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
@ -178,7 +178,7 @@ namespace MWClass
const ESM::RefId& Armor::getUpSoundId(const MWWorld::ConstPtr& ptr) const
{
int es = getEquipmentSkill(ptr);
ESM::RefId es = getEquipmentSkill(ptr);
static const ESM::RefId lightUp = ESM::RefId::stringRefId("Item Armor Light Up");
static const ESM::RefId mediumUp = ESM::RefId::stringRefId("Item Armor Medium Up");
static const ESM::RefId heavyUp = ESM::RefId::stringRefId("Item Armor Heavy Up");
@ -193,7 +193,7 @@ namespace MWClass
const ESM::RefId& Armor::getDownSoundId(const MWWorld::ConstPtr& ptr) const
{
int es = getEquipmentSkill(ptr);
ESM::RefId es = getEquipmentSkill(ptr);
static const ESM::RefId lightDown = ESM::RefId::stringRefId("Item Armor Light Down");
static const ESM::RefId mediumDown = ESM::RefId::stringRefId("Item Armor Medium Down");
static const ESM::RefId heavyDown = ESM::RefId::stringRefId("Item Armor Heavy Down");
@ -232,7 +232,7 @@ namespace MWClass
}
else
{
int armorType = getEquipmentSkill(ptr);
ESM::RefId armorType = getEquipmentSkill(ptr);
if (armorType == ESM::Skill::LightArmor)
typeText = "#{sLight}";
else if (armorType == ESM::Skill::MediumArmor)
@ -297,8 +297,8 @@ namespace MWClass
{
const MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
int armorSkillType = getEquipmentSkill(ptr);
float armorSkill = actor.getClass().getSkill(actor, ESM::Skill::indexToRefId(armorSkillType));
ESM::RefId armorSkillType = getEquipmentSkill(ptr);
float armorSkill = actor.getClass().getSkill(actor, armorSkillType);
int iBaseArmorSkill = MWBase::Environment::get()
.getESMStore()

@ -41,9 +41,7 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
int getEquipmentSkill(const MWWorld::ConstPtr& ptr) const override;
/// Return the index of the skill this item corresponds to when equipped or -1, if there is
/// no such skill.
ESM::RefId getEquipmentSkill(const MWWorld::ConstPtr& ptr) const override;
MWGui::ToolTipInfo getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

@ -101,14 +101,14 @@ namespace MWClass
return std::make_pair(slots_, false);
}
int Clothing::getEquipmentSkill(const MWWorld::ConstPtr& ptr) const
ESM::RefId Clothing::getEquipmentSkill(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
if (ref->mBase->mData.mType == ESM::Clothing::Shoes)
return ESM::Skill::Unarmored;
return -1;
return {};
}
int Clothing::getValue(const MWWorld::ConstPtr& ptr) const

@ -33,9 +33,7 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
int getEquipmentSkill(const MWWorld::ConstPtr& ptr) const override;
/// Return the index of the skill this item corresponds to when equipped or -1, if there is
/// no such skill.
ESM::RefId getEquipmentSkill(const MWWorld::ConstPtr& ptr) const override;
MWGui::ToolTipInfo getToolTipInfo(const MWWorld::ConstPtr& ptr, int count) const override;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

@ -582,11 +582,11 @@ namespace MWClass
victim = result.first;
hitPosition = result.second;
int weapskill = ESM::Skill::HandToHand;
ESM::RefId weapskill = ESM::Skill::HandToHand;
if (!weapon.isEmpty())
weapskill = weapon.getClass().getEquipmentSkill(weapon);
float hitchance = MWMechanics::getHitChance(ptr, victim, getSkill(ptr, ESM::Skill::indexToRefId(weapskill)));
float hitchance = MWMechanics::getHitChance(ptr, victim, getSkill(ptr, weapskill));
return Misc::Rng::roll0to99(world->getPrng()) < hitchance;
}
@ -651,10 +651,10 @@ namespace MWClass
if (ptr == MWMechanics::getPlayer())
{
int weapskill = ESM::Skill::HandToHand;
ESM::RefId weapskill = ESM::Skill::HandToHand;
if (!weapon.isEmpty())
weapskill = weapon.getClass().getEquipmentSkill(weapon);
skillUsageSucceeded(ptr, ESM::Skill::indexToRefId(weapskill), 0);
skillUsageSucceeded(ptr, weapskill, 0);
const MWMechanics::AiSequence& seq = victim.getClass().getCreatureStats(victim).getAiSequence();
@ -842,25 +842,19 @@ namespace MWClass
armor = *inv.unequipItem(armor);
}
ESM::RefId skill = armor.getClass().getEquipmentSkill(armor);
if (ptr == MWMechanics::getPlayer())
skillUsageSucceeded(
ptr, ESM::Skill::indexToRefId(armor.getClass().getEquipmentSkill(armor)), 0);
switch (armor.getClass().getEquipmentSkill(armor))
{
case ESM::Skill::LightArmor:
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Light Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::MediumArmor:
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Medium Armor Hit"), 1.0f, 1.0f);
break;
case ESM::Skill::HeavyArmor:
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Heavy Armor Hit"), 1.0f, 1.0f);
break;
}
skillUsageSucceeded(ptr, skill, 0);
if (skill == ESM::Skill::LightArmor)
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Light Armor Hit"), 1.0f, 1.0f);
else if (skill == ESM::Skill::MediumArmor)
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Medium Armor Hit"), 1.0f, 1.0f);
else if (skill == ESM::Skill::HeavyArmor)
sndMgr->playSound3D(ptr, ESM::RefId::stringRefId("Heavy Armor Hit"), 1.0f, 1.0f);
}
else if (ptr == MWMechanics::getPlayer())
Class::skillUsageSucceeded(ptr, ESM::Skill::Unarmored, 0);
skillUsageSucceeded(ptr, ESM::Skill::Unarmored, 0);
}
}
@ -1046,7 +1040,7 @@ namespace MWClass
const float encumbranceTerm = gmst.fJumpEncumbranceBase->mValue.getFloat()
+ gmst.fJumpEncumbranceMultiplier->mValue.getFloat() * (1.0f - Npc::getNormalizedEncumbrance(ptr));
float a = Class::getSkill(ptr, ESM::Skill::Acrobatics);
float a = getSkill(ptr, ESM::Skill::Acrobatics);
float b = 0.0f;
if (a > 50.0f)
{
@ -1179,7 +1173,7 @@ namespace MWClass
float fUnarmoredBase1 = store.find("fUnarmoredBase1")->mValue.getFloat();
float fUnarmoredBase2 = store.find("fUnarmoredBase2")->mValue.getFloat();
float unarmoredSkill = Class::getSkill(ptr, ESM::Skill::Unarmored);
float unarmoredSkill = getSkill(ptr, ESM::Skill::Unarmored);
float ratings[MWWorld::InventoryStore::Slots];
for (int i = 0; i < MWWorld::InventoryStore::Slots; i++)
@ -1305,18 +1299,13 @@ namespace MWClass
if (boots == inv.end() || boots->getType() != ESM::Armor::sRecordId)
return (name == "left") ? footBareLeft : footBareRight;
switch (boots->getClass().getEquipmentSkill(*boots))
{
case ESM::Skill::LightArmor:
return (name == "left") ? footLightLeft : footLightRight;
break;
case ESM::Skill::MediumArmor:
return (name == "left") ? footMediumLeft : footMediumRight;
break;
case ESM::Skill::HeavyArmor:
return (name == "left") ? footHeavyLeft : footHeavyRight;
break;
}
ESM::RefId skill = boots->getClass().getEquipmentSkill(*boots);
if (skill == ESM::Skill::LightArmor)
return (name == "left") ? footLightLeft : footLightRight;
else if (skill == ESM::Skill::MediumArmor)
return (name == "left") ? footMediumLeft : footMediumRight;
else if (skill == ESM::Skill::HeavyArmor)
return (name == "left") ? footHeavyLeft : footHeavyRight;
}
return ESM::RefId();
}
@ -1544,7 +1533,7 @@ namespace MWClass
{
const GMST& gmst = getGmst();
return getWalkSpeed(ptr)
* (0.01f * Class::getSkill(ptr, ESM::Skill::Athletics) * gmst.fAthleticsRunBonus->mValue.getFloat()
* (0.01f * getSkill(ptr, ESM::Skill::Athletics) * gmst.fAthleticsRunBonus->mValue.getFloat()
+ gmst.fBaseRunMultiplier->mValue.getFloat());
}

@ -108,7 +108,7 @@ namespace MWClass
return std::make_pair(slots_, stack);
}
int Weapon::getEquipmentSkill(const MWWorld::ConstPtr& ptr) const
ESM::RefId Weapon::getEquipmentSkill(const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
int type = ref->mBase->mData.mType;

@ -42,9 +42,7 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
int getEquipmentSkill(const MWWorld::ConstPtr& ptr) const override;
/// Return the index of the skill this item corresponds to when equipped or -1, if there is
/// no such skill.
ESM::RefId getEquipmentSkill(const MWWorld::ConstPtr& ptr) const override;
int getValue(const MWWorld::ConstPtr& ptr) const override;
///< Return trade value of the object. Throws an exception, if the object can't be traded.

@ -475,14 +475,14 @@ namespace MWGui
assert(attributes.size() == klass.mData.mAttribute.size());
std::copy(attributes.begin(), attributes.end(), klass.mData.mAttribute.begin());
std::vector<ESM::Skill::SkillEnum> majorSkills = mCreateClassDialog->getMajorSkills();
std::vector<ESM::Skill::SkillEnum> minorSkills = mCreateClassDialog->getMinorSkills();
std::vector<ESM::RefId> majorSkills = mCreateClassDialog->getMajorSkills();
std::vector<ESM::RefId> minorSkills = mCreateClassDialog->getMinorSkills();
assert(majorSkills.size() >= klass.mData.mSkills.size());
assert(minorSkills.size() >= klass.mData.mSkills.size());
for (size_t i = 0; i < klass.mData.mSkills.size(); ++i)
{
klass.mData.mSkills[i][1] = majorSkills[i];
klass.mData.mSkills[i][0] = minorSkills[i];
klass.mData.mSkills[i][1] = majorSkills[i].getIf<ESM::IndexRefId>()->getValue();
klass.mData.mSkills[i][0] = minorSkills[i].getIf<ESM::IndexRefId>()->getValue();
}
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass);

@ -266,10 +266,12 @@ namespace MWGui
for (size_t i = 0; i < klass->mData.mSkills.size(); ++i)
{
mMinorSkill[i]->setSkillNumber(klass->mData.mSkills[i][0]);
mMajorSkill[i]->setSkillNumber(klass->mData.mSkills[i][1]);
ToolTips::createSkillToolTip(mMinorSkill[i], klass->mData.mSkills[i][0]);
ToolTips::createSkillToolTip(mMajorSkill[i], klass->mData.mSkills[i][1]);
ESM::RefId minor = ESM::Skill::indexToRefId(klass->mData.mSkills[i][0]);
ESM::RefId major = ESM::Skill::indexToRefId(klass->mData.mSkills[i][1]);
mMinorSkill[i]->setSkillId(minor);
mMajorSkill[i]->setSkillId(major);
ToolTips::createSkillToolTip(mMinorSkill[i], minor);
ToolTips::createSkillToolTip(mMajorSkill[i], major);
}
setClassImage(mClassImage, mCurrentClassId);
@ -514,24 +516,24 @@ namespace MWGui
return v;
}
std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMajorSkills() const
std::vector<ESM::RefId> CreateClassDialog::getMajorSkills() const
{
std::vector<ESM::Skill::SkillEnum> v;
v.reserve(5);
for (int i = 0; i < 5; i++)
std::vector<ESM::RefId> v;
v.reserve(mMajorSkill.size());
for (const auto& widget : mMajorSkill)
{
v.push_back(mMajorSkill[i]->getSkillId());
v.push_back(widget->getSkillId());
}
return v;
}
std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMinorSkills() const
std::vector<ESM::RefId> CreateClassDialog::getMinorSkills() const
{
std::vector<ESM::Skill::SkillEnum> v;
v.reserve(5);
for (int i = 0; i < 5; i++)
std::vector<ESM::RefId> v;
v.reserve(mMinorSkill.size());
for (const auto& widget : mMinorSkill)
{
v.push_back(mMinorSkill[i]->getSkillId());
v.push_back(widget->getSkillId());
}
return v;
}
@ -624,7 +626,7 @@ namespace MWGui
void CreateClassDialog::onSkillSelected()
{
ESM::Skill::SkillEnum id = mSkillDialog->getSkillId();
ESM::RefId id = mSkillDialog->getSkillId();
// Avoid duplicate skills by swapping any skill field that matches the selected one
for (Widgets::MWSkillPtr& skill : mSkills)
@ -804,7 +806,7 @@ namespace MWGui
struct
{
Widgets::MWSkillPtr widget;
ESM::Skill::SkillEnum skillId;
ESM::RefId skillId;
} mSkills[3][9]
= { { { mCombatSkill[0], ESM::Skill::Block }, { mCombatSkill[1], ESM::Skill::Armorer },
{ mCombatSkill[2], ESM::Skill::MediumArmor }, { mCombatSkill[3], ESM::Skill::HeavyArmor },

@ -1,6 +1,7 @@
#ifndef MWGUI_CLASS_H
#define MWGUI_CLASS_H
#include <array>
#include <memory>
#include <MyGUI_EditBox.h>
@ -218,7 +219,7 @@ namespace MWGui
bool exit() override;
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
ESM::RefId getSkillId() const { return mSkillId; }
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
@ -242,7 +243,7 @@ namespace MWGui
Widgets::MWSkillPtr mMagicSkill[9];
Widgets::MWSkillPtr mStealthSkill[9];
ESM::Skill::SkillEnum mSkillId;
ESM::RefId mSkillId;
};
class DescriptionDialog : public WindowModal
@ -278,8 +279,8 @@ namespace MWGui
std::string getDescription() const;
ESM::Class::Specialization getSpecializationId() const;
std::vector<int> getFavoriteAttributes() const;
std::vector<ESM::Skill::SkillEnum> getMajorSkills() const;
std::vector<ESM::Skill::SkillEnum> getMinorSkills() const;
std::vector<ESM::RefId> getMajorSkills() const;
std::vector<ESM::RefId> getMinorSkills() const;
void setNextButtonShow(bool shown);
@ -318,8 +319,8 @@ namespace MWGui
MyGUI::EditBox* mEditName;
MyGUI::TextBox* mSpecializationName;
Widgets::MWAttributePtr mFavoriteAttribute0, mFavoriteAttribute1;
Widgets::MWSkillPtr mMajorSkill[5];
Widgets::MWSkillPtr mMinorSkill[5];
std::array<Widgets::MWSkillPtr, 5> mMajorSkill;
std::array<Widgets::MWSkillPtr, 5> mMinorSkill;
std::vector<Widgets::MWSkillPtr> mSkills;
std::string mDescription;

@ -97,7 +97,7 @@ namespace MWGui
skills.insert(skill);
MWMechanics::SkillValue& value = player.getClass().getNpcStats(player).getSkill(skill->mId);
if (skill->mIndex == ESM::Skill::Security || skill->mIndex == ESM::Skill::Sneak)
if (skill->mId == ESM::Skill::Security || skill->mId == ESM::Skill::Sneak)
value.setBase(std::min(100.f, value.getBase() + 1));
else
value.setBase(std::max(0.f, value.getBase() - 1));
@ -118,7 +118,7 @@ namespace MWGui
{
int skillValue = player.getClass().getNpcStats(player).getSkill(skill->mId).getBase();
std::string skillMsg = gmst.find("sNotifyMessage44")->mValue.getString();
if (skill->mIndex == ESM::Skill::Sneak || skill->mIndex == ESM::Skill::Security)
if (skill->mId == ESM::Skill::Sneak || skill->mId == ESM::Skill::Security)
skillMsg = gmst.find("sNotifyMessage39")->mValue.getString();
skillMsg = Misc::StringUtils::format(skillMsg, skill->mName, skillValue);

@ -414,13 +414,14 @@ namespace MWGui
const ESM::Race* race = store.get<ESM::Race>().find(mCurrentRaceId);
for (const auto& bonus : race->mData.mBonus)
{
if (bonus.mSkill < 0 || bonus.mSkill >= ESM::Skill::Length) // Skip unknown skill indexes
ESM::RefId skill = ESM::Skill::indexToRefId(bonus.mSkill);
if (skill.empty()) // Skip unknown skill indexes
continue;
skillWidget = mSkillList->createWidget<Widgets::MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default);
skillWidget->setSkillId(ESM::Skill::SkillEnum(bonus.mSkill));
skillWidget->setSkillId(skill);
skillWidget->setSkillValue(Widgets::MWSkill::SkillValue(static_cast<float>(bonus.mBonus), 0.f));
ToolTips::createSkillToolTip(skillWidget, bonus.mSkill);
ToolTips::createSkillToolTip(skillWidget, skill);
mSkillItems.push_back(skillWidget);

@ -360,7 +360,7 @@ namespace MWGui
for (int i = 0; i < 2; ++i)
{
ToolTips::createSkillToolTip(mSkillWidgets[mSkillWidgets.size() - 1 - i], skill->mIndex);
ToolTips::createSkillToolTip(mSkillWidgets[mSkillWidgets.size() - 1 - i], skill->mId);
}
mSkillWidgetMap[skill->mId] = widget;

@ -286,9 +286,9 @@ namespace MWGui
exit();
}
void EditEffectDialog::setSkill(int skill)
void EditEffectDialog::setSkill(ESM::RefId skill)
{
mEffect.mSkill = skill;
mEffect.mSkill = skill.getIf<ESM::IndexRefId>()->getValue();
eventEffectModified(mEffect);
}

@ -30,7 +30,7 @@ namespace MWGui
void setConstantEffect(bool constant);
void setSkill(int skill);
void setSkill(ESM::RefId skill);
void setAttribute(int attribute);
void newEffect(const ESM::MagicEffect* effect);

@ -83,7 +83,8 @@ namespace MWGui
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
{
const ESM::Skill* skill = store->get<ESM::Skill>().find(effectInfo.mKey.mArg);
const ESM::Skill* skill
= store->get<ESM::Skill>().find(ESM::Skill::indexToRefId(effectInfo.mKey.mArg));
sourcesDescription += " (" + skill->mName + ')';
}
if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)

@ -805,9 +805,9 @@ namespace MWGui
mFocusToolTipY = min_y;
}
void ToolTips::createSkillToolTip(MyGUI::Widget* widget, int skillId)
void ToolTips::createSkillToolTip(MyGUI::Widget* widget, ESM::RefId skillId)
{
if (skillId == -1)
if (skillId.empty())
return;
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();

@ -93,7 +93,7 @@ namespace MWGui
// these do not create an actual tooltip, but they fill in the data that is required so the tooltip
// system knows what to show in case this widget is hovered
static void createSkillToolTip(MyGUI::Widget* widget, int skillId);
static void createSkillToolTip(MyGUI::Widget* widget, ESM::RefId skillId);
static void createAttributeToolTip(MyGUI::Widget* widget, int attributeId);
static void createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId);
static void createBirthsignToolTip(MyGUI::Widget* widget, const ESM::RefId& birthsignId);

@ -110,7 +110,7 @@ namespace MWGui
button->setSize(button->getTextSize().width + 12, button->getSize().height);
ToolTips::createSkillToolTip(button, skill->mIndex);
ToolTips::createSkillToolTip(button, skill->mId);
}
center();

@ -28,28 +28,17 @@ namespace MWGui::Widgets
/* MWSkill */
MWSkill::MWSkill()
: mSkillId(ESM::Skill::Length)
, mSkillNameWidget(nullptr)
: mSkillNameWidget(nullptr)
, mSkillValueWidget(nullptr)
{
}
void MWSkill::setSkillId(ESM::Skill::SkillEnum skill)
void MWSkill::setSkillId(ESM::RefId skill)
{
mSkillId = skill;
updateWidgets();
}
void MWSkill::setSkillNumber(int skill)
{
if (skill < 0)
setSkillId(ESM::Skill::Length);
else if (skill < ESM::Skill::Length)
setSkillId(static_cast<ESM::Skill::SkillEnum>(skill));
else
throw std::runtime_error("Skill number out of range");
}
void MWSkill::setSkillValue(const SkillValue& value)
{
mValue = value;
@ -60,8 +49,7 @@ namespace MWGui::Widgets
{
if (mSkillNameWidget)
{
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().search(
ESM::Skill::indexToRefId(mSkillId));
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().search(mSkillId);
if (skill == nullptr)
mSkillNameWidget->setCaption({});
else

@ -100,11 +100,10 @@ namespace MWGui
typedef MWMechanics::Stat<float> SkillValue;
void setSkillId(ESM::Skill::SkillEnum skillId);
void setSkillNumber(int skillId);
void setSkillId(ESM::RefId skillId);
void setSkillValue(const SkillValue& value);
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
ESM::RefId getSkillId() const { return mSkillId; }
const SkillValue& getSkillValue() const { return mValue; }
// Events
@ -125,7 +124,7 @@ namespace MWGui
private:
void updateWidgets();
ESM::Skill::SkillEnum mSkillId;
ESM::RefId mSkillId;
SkillValue mValue;
MyGUI::TextBox* mSkillNameWidget;
MyGUI::TextBox* mSkillValueWidget;

@ -67,7 +67,7 @@ namespace MWLua
sol::table skill(context.mLua->sol(), sol::create);
book["SKILL"] = LuaUtil::makeStrictReadOnly(skill);
book["createRecordDraft"] = tableToBook;
for (int id = ESM::Skill::Block; id < ESM::Skill::Length; ++id)
for (int id = 0; id < ESM::Skill::Length; ++id)
{
std::string skillName = Misc::StringUtils::lowerCase(ESM::Skill::sSkillNames[id]);
skill[skillName] = skillName;

@ -299,7 +299,7 @@ namespace MWMechanics
x *= 1.5f;
float s = 0.f;
ESM::RefId skill = ESM::Skill::indexToRefId(spellSchoolToSkill(magicEffect->mData.mSchool));
ESM::RefId skill = spellSchoolToSkill(magicEffect->mData.mSchool);
auto found = actorSkills.find(skill);
if (found != actorSkills.end())
s = 2.f * found->second.getBase();
@ -322,10 +322,13 @@ namespace MWMechanics
return 100.f;
float skillTerm = 0;
ESM::RefId skill = ESM::Skill::indexToRefId(spellSchoolToSkill(effectiveSchool));
auto found = actorSkills.find(skill);
if (found != actorSkills.end())
skillTerm = 2.f * found->second.getBase();
if (effectiveSchool != -1)
{
ESM::RefId skill = spellSchoolToSkill(effectiveSchool);
auto found = actorSkills.find(skill);
if (found != actorSkills.end())
skillTerm = 2.f * found->second.getBase();
}
else
calcWeakestSchool(
spell, actorSkills, effectiveSchool, skillTerm); // Note effectiveSchool is unused after this

@ -122,8 +122,7 @@ namespace MWMechanics
if (weapon.isEmpty())
attackerSkill = attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand);
else
attackerSkill = attacker.getClass().getSkill(
attacker, ESM::Skill::indexToRefId(weapon.getClass().getEquipmentSkill(weapon)));
attackerSkill = attacker.getClass().getSkill(attacker, weapon.getClass().getEquipmentSkill(weapon));
float attackerTerm = attackerSkill + 0.2f * attackerStats.getAttribute(ESM::Attribute::Agility).getModified()
+ 0.1f * attackerStats.getAttribute(ESM::Attribute::Luck).getModified();
attackerTerm *= attackerStats.getFatigueTerm();
@ -218,7 +217,7 @@ namespace MWMechanics
bool validVictim = !victim.isEmpty() && victim.getClass().isActor();
int weaponSkill = ESM::Skill::Marksman;
ESM::RefId weaponSkill = ESM::Skill::Marksman;
if (!weapon.isEmpty())
weaponSkill = weapon.getClass().getEquipmentSkill(weapon);
@ -228,7 +227,7 @@ namespace MWMechanics
if (attacker == getPlayer())
MWBase::Environment::get().getWindowManager()->setEnemy(victim);
int skillValue = attacker.getClass().getSkill(attacker, ESM::Skill::indexToRefId(weaponSkill));
int skillValue = attacker.getClass().getSkill(attacker, weaponSkill);
if (Misc::Rng::roll0to99(world->getPrng()) >= getHitChance(attacker, victim, skillValue))
{
@ -259,7 +258,7 @@ namespace MWMechanics
applyWerewolfDamageMult(victim, projectile, damage);
if (attacker == getPlayer())
attacker.getClass().skillUsageSucceeded(attacker, ESM::Skill::indexToRefId(weaponSkill), 0);
attacker.getClass().skillUsageSucceeded(attacker, weaponSkill, 0);
const MWMechanics::AiSequence& sequence = victim.getClass().getCreatureStats(victim).getAiSequence();
bool unaware = attacker == getPlayer() && !sequence.isInCombat()

@ -60,10 +60,6 @@ namespace MWMechanics
void setCrimeId(int id);
const SkillValue& getSkill(ESM::RefId id) const;
const SkillValue& getSkill(ESM::Skill::SkillEnum index) const
{
return getSkill(ESM::Skill::indexToRefId(index));
}
SkillValue& getSkill(ESM::RefId id);
void setSkill(ESM::RefId id, const SkillValue& value);

@ -600,7 +600,7 @@ namespace MWMechanics
&& (e != ESM::MagicEffect::BoundLongbow || effect.mEffectID == e
|| rateAmmo(actor, enemy, getWeaponType(ESM::Weapon::MarksmanBow)->mAmmoType) <= 0.f))
return 0.f;
ESM::Skill::SkillEnum skill = ESM::Skill::ShortBlade;
ESM::RefId skill = ESM::Skill::ShortBlade;
if (effect.mEffectID == ESM::MagicEffect::BoundLongsword)
skill = ESM::Skill::LongBlade;
else if (effect.mEffectID == ESM::MagicEffect::BoundMace)

@ -15,9 +15,9 @@
namespace MWMechanics
{
ESM::Skill::SkillEnum spellSchoolToSkill(int school)
ESM::RefId spellSchoolToSkill(int school)
{
static const std::array<ESM::Skill::SkillEnum, 6> schoolSkillArray{
static const std::array<ESM::RefId, 6> schoolSkillArray{
ESM::Skill::Alteration,
ESM::Skill::Conjuration,
ESM::Skill::Destruction,

@ -17,7 +17,7 @@ namespace MWWorld
namespace MWMechanics
{
ESM::Skill::SkillEnum spellSchoolToSkill(int school);
ESM::RefId spellSchoolToSkill(int school);
enum class EffectCostMethod
{

@ -120,7 +120,7 @@ namespace MWMechanics
int value = 50.f;
if (actor.getClass().isNpc())
{
ESM::RefId skill = ESM::Skill::indexToRefId(item.getClass().getEquipmentSkill(item));
ESM::RefId skill = item.getClass().getEquipmentSkill(item);
if (!skill.empty())
value = actor.getClass().getSkill(actor, skill);
}
@ -179,9 +179,7 @@ namespace MWMechanics
if (weapon.isEmpty())
return 0.f;
float skillMult
= actor.getClass().getSkill(actor, ESM::Skill::indexToRefId(weapon.getClass().getEquipmentSkill(weapon)))
* 0.01f;
float skillMult = actor.getClass().getSkill(actor, weapon.getClass().getEquipmentSkill(weapon)) * 0.01f;
float chopMult = fAIMeleeWeaponMult;
float bonusDamage = 0.f;

@ -392,7 +392,7 @@ namespace MWScript
return;
}
int skill = it->getClass().getEquipmentSkill(*it);
ESM::RefId skill = it->getClass().getEquipmentSkill(*it);
if (skill == ESM::Skill::HeavyArmor)
runtime.push(2);
else if (skill == ESM::Skill::MediumArmor)

@ -209,9 +209,9 @@ namespace MWWorld
return std::make_pair(std::vector<int>(), false);
}
int Class::getEquipmentSkill(const ConstPtr& ptr) const
ESM::RefId Class::getEquipmentSkill(const ConstPtr& ptr) const
{
return -1;
return {};
}
int Class::getValue(const ConstPtr& ptr) const

@ -209,10 +209,9 @@ namespace MWWorld
///
/// Default implementation: return (empty vector, false).
virtual int getEquipmentSkill(const ConstPtr& ptr) const;
/// Return the index of the skill this item corresponds to when equipped or -1, if there is
/// no such skill.
/// (default implementation: return -1)
virtual ESM::RefId getEquipmentSkill(const ConstPtr& ptr) const;
/// Return the index of the skill this item corresponds to when equipped.
/// (default implementation: return empty ref id)
virtual int getValue(const ConstPtr& ptr) const;
///< Return trade value of the object. Throws an exception, if the object can't be traded.
@ -239,11 +238,6 @@ namespace MWWorld
///< Inform actor \a ptr that a skill use has succeeded.
///
/// (default implementations: throws an exception)
void skillUsageSucceeded(
const MWWorld::Ptr& ptr, ESM::Skill::SkillEnum index, int usageType, float extraFactor = 1.f) const
{
return skillUsageSucceeded(ptr, ESM::Skill::indexToRefId(index), usageType, extraFactor);
};
virtual bool isEssential(const MWWorld::ConstPtr& ptr) const;
///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable)
@ -347,10 +341,6 @@ namespace MWWorld
bool isMobile(const MWWorld::Ptr& ptr) const;
virtual float getSkill(const MWWorld::Ptr& ptr, ESM::RefId id) const;
float getSkill(const MWWorld::Ptr& ptr, ESM::Skill::SkillEnum index) const
{
return getSkill(ptr, ESM::Skill::indexToRefId(index));
};
virtual void readAdditionalState(const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const;
///< Read additional state from \a state into \a ptr.

@ -236,7 +236,7 @@ void MWWorld::InventoryStore::autoEquipWeapon(TSlots& slots_)
return;
}
static const ESM::Skill::SkillEnum weaponSkills[] = {
static const ESM::RefId weaponSkills[] = {
ESM::Skill::LongBlade,
ESM::Skill::Axe,
ESM::Skill::Spear,

@ -106,7 +106,7 @@ namespace MWWorld
for (const auto& skill : store->get<ESM::Skill>())
{
// Acrobatics is set separately for some reason.
if (skill.mIndex == ESM::Skill::Acrobatics)
if (skill.mId == ESM::Skill::Acrobatics)
continue;
MWMechanics::SkillValue& value = npcStats.getSkill(skill.mId);

@ -481,10 +481,6 @@ namespace MWWorld
public:
Store() = default;
using TypedDynamicStore<ESM::Skill>::find;
// TODO delete
const ESM::Skill* find(int index) const { return find(ESM::Skill::indexToRefId(index)); }
void setUp(const MWWorld::Store<ESM::GameSetting>& settings);
};

@ -496,7 +496,7 @@ namespace
const RecordType* result = nullptr;
if constexpr (std::is_same_v<RecordType, ESM::LandTexture>)
result = esmStore.get<RecordType>().search(index, 0);
else if constexpr (ESM::hasIndex<RecordType>)
else if constexpr (ESM::hasIndex<RecordType> && !std::is_same_v<RecordType, ESM::Skill>)
result = esmStore.get<RecordType>().search(index);
else
result = esmStore.get<RecordType>().search(refId);

@ -7,6 +7,34 @@
namespace ESM
{
const RefId Skill::Block = Skill::indexToRefId(0);
const RefId Skill::Armorer = Skill::indexToRefId(1);
const RefId Skill::MediumArmor = Skill::indexToRefId(2);
const RefId Skill::HeavyArmor = Skill::indexToRefId(3);
const RefId Skill::BluntWeapon = Skill::indexToRefId(4);
const RefId Skill::LongBlade = Skill::indexToRefId(5);
const RefId Skill::Axe = Skill::indexToRefId(6);
const RefId Skill::Spear = Skill::indexToRefId(7);
const RefId Skill::Athletics = Skill::indexToRefId(8);
const RefId Skill::Enchant = Skill::indexToRefId(9);
const RefId Skill::Destruction = Skill::indexToRefId(10);
const RefId Skill::Alteration = Skill::indexToRefId(11);
const RefId Skill::Illusion = Skill::indexToRefId(12);
const RefId Skill::Conjuration = Skill::indexToRefId(13);
const RefId Skill::Mysticism = Skill::indexToRefId(14);
const RefId Skill::Restoration = Skill::indexToRefId(15);
const RefId Skill::Alchemy = Skill::indexToRefId(16);
const RefId Skill::Unarmored = Skill::indexToRefId(17);
const RefId Skill::Security = Skill::indexToRefId(18);
const RefId Skill::Sneak = Skill::indexToRefId(19);
const RefId Skill::Acrobatics = Skill::indexToRefId(20);
const RefId Skill::LightArmor = Skill::indexToRefId(21);
const RefId Skill::ShortBlade = Skill::indexToRefId(22);
const RefId Skill::Marksman = Skill::indexToRefId(23);
const RefId Skill::Mercantile = Skill::indexToRefId(24);
const RefId Skill::Speechcraft = Skill::indexToRefId(25);
const RefId Skill::HandToHand = Skill::indexToRefId(26);
const std::string Skill::sSkillNames[Length] = {
"Block",
"Armorer",
@ -37,11 +65,11 @@ namespace ESM
"Handtohand",
};
Skill::SkillEnum Skill::stringToSkillId(std::string_view skill)
int Skill::stringToSkillId(std::string_view skill)
{
for (int id = 0; id < Skill::Length; ++id)
if (Misc::StringUtils::ciEqual(sSkillNames[id], skill))
return Skill::SkillEnum(id);
return id;
throw std::logic_error("No such skill: " + std::string(skill));
}

@ -48,40 +48,37 @@ namespace ESM
std::string mIcon;
float mWerewolfValue{};
enum SkillEnum
{
Block = 0,
Armorer = 1,
MediumArmor = 2,
HeavyArmor = 3,
BluntWeapon = 4,
LongBlade = 5,
Axe = 6,
Spear = 7,
Athletics = 8,
Enchant = 9,
Destruction = 10,
Alteration = 11,
Illusion = 12,
Conjuration = 13,
Mysticism = 14,
Restoration = 15,
Alchemy = 16,
Unarmored = 17,
Security = 18,
Sneak = 19,
Acrobatics = 20,
LightArmor = 21,
ShortBlade = 22,
Marksman = 23,
Mercantile = 24,
Speechcraft = 25,
HandToHand = 26,
Length
};
static const RefId Block;
static const RefId Armorer;
static const RefId MediumArmor;
static const RefId HeavyArmor;
static const RefId BluntWeapon;
static const RefId LongBlade;
static const RefId Axe;
static const RefId Spear;
static const RefId Athletics;
static const RefId Enchant;
static const RefId Destruction;
static const RefId Alteration;
static const RefId Illusion;
static const RefId Conjuration;
static const RefId Mysticism;
static const RefId Restoration;
static const RefId Alchemy;
static const RefId Unarmored;
static const RefId Security;
static const RefId Sneak;
static const RefId Acrobatics;
static const RefId LightArmor;
static const RefId ShortBlade;
static const RefId Marksman;
static const RefId Mercantile;
static const RefId Speechcraft;
static const RefId HandToHand;
static constexpr int Length = 27;
static const std::string sSkillNames[Length];
static SkillEnum stringToSkillId(std::string_view skill);
static int stringToSkillId(std::string_view skill);
void load(ESMReader& esm, bool& isDeleted);
void save(ESMWriter& esm, bool isDeleted = false) const;

@ -109,13 +109,13 @@ namespace ESM
ESM::RefId mSoundIdUp;
std::string mAttachBone;
std::string mSheathingBone;
Skill::SkillEnum mSkill;
ESM::RefId mSkill;
Class mWeaponClass;
int mAmmoType;
int mFlags;
WeaponType(std::string shortGroup, std::string longGroup, const std::string& soundId, std::string attachBone,
std::string sheathingBone, Skill::SkillEnum skill, Class weaponClass, int ammoType, int flags)
std::string sheathingBone, ESM::RefId skill, Class weaponClass, int ammoType, int flags)
: mShortGroup(std::move(shortGroup))
, mLongGroup(std::move(longGroup))
, mSoundIdDown(ESM::RefId::stringRefId(soundId + " Down"))

@ -73,7 +73,8 @@ namespace ESM
mSaveSkills[i] = skill.mBase + skill.mMod - skill.mDamage;
if (mObject.mNpcStats.mIsWerewolf)
{
if (i == Skill::Acrobatics)
constexpr int Acrobatics = 20;
if (i == Acrobatics)
mSetWerewolfAcrobatics = mObject.mNpcStats.mSkills[i].mBase != skill.mBase;
mObject.mNpcStats.mSkills[i] = skill;
}

Loading…
Cancel
Save