From 264a8c06690e2039a6d8afee6a81e9e17c708527 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Mon, 15 Jan 2024 21:48:46 +0100 Subject: [PATCH] Remove the now unused npcstats methods useSkill and increaseSkill --- apps/openmw/mwmechanics/npcstats.cpp | 84 ---------------------------- apps/openmw/mwmechanics/npcstats.hpp | 5 -- 2 files changed, 89 deletions(-) diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 2c7a710355..eceaf8b482 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -209,90 +209,6 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(ESM::RefId id, const ES return progressRequirement; } -void MWMechanics::NpcStats::useSkill(ESM::RefId id, const ESM::Class& class_, int usageType, float extraFactor) -{ - const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(id); - float skillGain = 1; - if (usageType >= 4) - throw std::runtime_error("skill usage type out of range"); - if (usageType >= 0) - { - skillGain = skill->mData.mUseValue[usageType]; - if (skillGain < 0) - throw std::runtime_error("invalid skill gain factor"); - } - skillGain *= extraFactor; - - MWMechanics::SkillValue& value = getSkill(skill->mId); - - value.setProgress(value.getProgress() + skillGain); - - if (int(value.getProgress()) >= int(getSkillProgressRequirement(skill->mId, class_))) - { - // skill levelled up - increaseSkill(skill->mId, class_, false); - } -} - -void MWMechanics::NpcStats::increaseSkill(ESM::RefId id, const ESM::Class& class_, bool preserveProgress, bool readBook) -{ - const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(id); - float base = getSkill(skill->mId).getBase(); - - if (base >= 100.f) - return; - - base += 1; - - const MWWorld::Store& gmst = MWBase::Environment::get().getESMStore()->get(); - - // is this a minor or major skill? - int increase = gmst.find("iLevelupMiscMultAttriubte")->mValue.getInteger(); // Note: GMST has a typo - int index = ESM::Skill::refIdToIndex(skill->mId); - for (const auto& skills : class_.mData.mSkills) - { - if (skills[0] == index) - { - mLevelProgress += gmst.find("iLevelUpMinorMult")->mValue.getInteger(); - increase = gmst.find("iLevelUpMinorMultAttribute")->mValue.getInteger(); - break; - } - else if (skills[1] == index) - { - mLevelProgress += gmst.find("iLevelUpMajorMult")->mValue.getInteger(); - increase = gmst.find("iLevelUpMajorMultAttribute")->mValue.getInteger(); - break; - } - } - - mSkillIncreases[ESM::Attribute::indexToRefId(skill->mData.mAttribute)] += increase; - - mSpecIncreases[skill->mData.mSpecialization] += gmst.find("iLevelupSpecialization")->mValue.getInteger(); - - // Play sound & skill progress notification - /// \todo check if character is the player, if levelling is ever implemented for NPCs - MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("skillraise")); - - std::string message{ MWBase::Environment::get().getWindowManager()->getGameSettingString("sNotifyMessage39", {}) }; - message = Misc::StringUtils::format( - message, MyGUI::TextIterator::toTagsString(skill->mName).asUTF8(), static_cast(base)); - - if (readBook) - message = "#{sBookSkillMessage}\n" + message; - - MWBase::Environment::get().getWindowManager()->messageBox(message, MWGui::ShowInDialogueMode_Never); - - if (mLevelProgress >= gmst.find("iLevelUpTotal")->mValue.getInteger()) - { - // levelup is possible now - MWBase::Environment::get().getWindowManager()->messageBox("#{sLevelUpMsg}", MWGui::ShowInDialogueMode_Never); - } - - getSkill(skill->mId).setBase(base); - if (!preserveProgress) - getSkill(skill->mId).setProgress(0); -} - int MWMechanics::NpcStats::getLevelProgress() const { return mLevelProgress; diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 0104153a38..f94744cb71 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -87,11 +87,6 @@ namespace MWMechanics float getSkillProgressRequirement(ESM::RefId id, const ESM::Class& class_) const; - void useSkill(ESM::RefId id, const ESM::Class& class_, int usageType = -1, float extraFactor = 1.f); - ///< Increase skill by usage. - - void increaseSkill(ESM::RefId id, const ESM::Class& class_, bool preserveProgress, bool readBook = false); - int getLevelProgress() const; void setLevelProgress(int progress);