diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index fb9952ba7..6d36a9c42 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -156,7 +156,9 @@ namespace MWGui cls = &*it; } - setClassImage(mClassImage, cls->mId); + setClassImage(mClassImage, getLevelupClassImage(pcStats.getSkillIncreasesForSpecialization(0), + pcStats.getSkillIncreasesForSpecialization(1), + pcStats.getSkillIncreasesForSpecialization(2))); int level = creatureStats.getLevel ()+1; mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + MyGUI::utility::toString(level)); @@ -248,4 +250,103 @@ namespace MWGui } assignCoins(); } + + std::string LevelupDialog::getLevelupClassImage(const int combatIncreases, const int magicIncreases, const int stealthIncreases) + { + std::string ret = "acrobat"; + + int total = combatIncreases + magicIncreases + stealthIncreases; + if (total == 0) + return ret; + + int combatFraction = static_cast(static_cast(combatIncreases) / total * 10.f); + int magicFraction = static_cast(static_cast(magicIncreases) / total * 10.f); + int stealthFraction = static_cast(static_cast(stealthIncreases) / total * 10.f); + + if (combatFraction > 7) + ret = "warrior"; + else if (magicFraction > 7) + ret = "mage"; + else if (stealthFraction > 7) + ret = "thief"; + + switch (combatFraction) + { + case 7: + ret = "warrior"; + break; + case 6: + if (stealthFraction == 1) + ret = "barbarian"; + else if (stealthFraction == 3) + ret = "crusader"; + else + ret = "knight"; + break; + case 5: + if (stealthFraction == 3) + ret = "scout"; + else + ret = "archer"; + break; + case 4: + ret = "rogue"; + break; + default: + break; + } + + switch (magicFraction) + { + case 7: + ret = "mage"; + break; + case 6: + if (combatFraction == 2) + ret = "sorcerer"; + else if (combatIncreases == 3) + ret = "healer"; + else + ret = "battlemage"; + break; + case 5: + ret = "witchhunter"; + break; + case 4: + ret = "spellsword"; + // In vanilla there's also code for "nightblade", however it seems to be unreachable. + break; + default: + break; + } + + switch (stealthFraction) + { + case 7: + ret = "thief"; + break; + case 6: + if (magicFraction == 1) + ret = "agent"; + else if (magicIncreases == 3) + ret = "assassin"; + else + ret = "acrobat"; + break; + case 5: + if (magicIncreases == 3) + ret = "monk"; + else + ret = "pilgrim"; + break; + case 3: + if (magicFraction == 3 && stealthFraction == 3) + ret = "bard"; + break; + default: + break; + } + + return ret; + } } diff --git a/apps/openmw/mwgui/levelupdialog.hpp b/apps/openmw/mwgui/levelupdialog.hpp index e5edbd53c..d49f7536d 100644 --- a/apps/openmw/mwgui/levelupdialog.hpp +++ b/apps/openmw/mwgui/levelupdialog.hpp @@ -39,6 +39,8 @@ namespace MWGui void resetCoins(); void setAttributeValues(); + + std::string getLevelupClassImage(const int combatIncreases, const int magicIncreases, const int stealthIncreases); }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 10d603ff1..8bea109d0 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -34,6 +34,7 @@ MWMechanics::NpcStats::NpcStats() , mIsWerewolf(false) { mSkillIncreases.resize (ESM::Attribute::Length, 0); + mSpecIncreases.resize(3, 0); } int MWMechanics::NpcStats::getBaseDisposition() const @@ -255,6 +256,8 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas MWBase::Environment::get().getWorld ()->getStore ().get().find(skillIndex); mSkillIncreases[skill->mData.mAttribute] += increase; + mSpecIncreases[skill->mData.mSpecialization] += gmst.find("iLevelupSpecialization")->getInt(); + // Play sound & skill progress notification /// \todo check if character is the player, if levelling is ever implemented for NPCs MWBase::Environment::get().getSoundManager ()->playSound ("skillraise", 1, 1); @@ -326,6 +329,11 @@ int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const return MWBase::Environment::get().getWorld()->getStore().get().find(gmst.str())->getInt(); } +int MWMechanics::NpcStats::getSkillIncreasesForSpecialization(int spec) const +{ + return mSpecIncreases[spec]; +} + void MWMechanics::NpcStats::flagAsUsed (const std::string& id) { mUsedIds.insert (id); @@ -469,6 +477,9 @@ void MWMechanics::NpcStats::writeState (ESM::NpcStats& state) const for (int i=0; i::const_iterator iter (state.mUsedIds.begin()); iter!=state.mUsedIds.end(); ++iter) if (store.find (*iter)) diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 8a98b1d1d..9ded47c07 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -34,7 +34,8 @@ namespace MWMechanics std::set mExpelled; std::map mFactionReputation; int mLevelProgress; // 0-10 - std::vector mSkillIncreases; // number of skill increases for each attribute + std::vector mSkillIncreases; // number of skill increases for each attribute (resets after leveling up) + std::vector mSpecIncreases; // number of skill increases for each specialization (accumulates throughout the entire game) std::set mUsedIds; // --------------------------------------------------------------------------- @@ -86,6 +87,8 @@ namespace MWMechanics int getLevelupAttributeMultiplier(int attribute) const; + int getSkillIncreasesForSpecialization(int spec) const; + void levelUp(); void updateHealth(); diff --git a/components/esm/npcstats.cpp b/components/esm/npcstats.cpp index 10c0b6f16..c7804fd44 100644 --- a/components/esm/npcstats.cpp +++ b/components/esm/npcstats.cpp @@ -95,6 +95,8 @@ void ESM::NpcStats::load (ESMReader &esm) esm.getHNT (mSkillIncrease, "INCR"); + esm.getHNOT (mSpecIncreases, "SPEC"); + while (esm.isNextSub ("USED")) mUsedIds.push_back (esm.getHString()); @@ -156,6 +158,8 @@ void ESM::NpcStats::save (ESMWriter &esm) const esm.writeHNT ("INCR", mSkillIncrease); + esm.writeHNT ("SPEC", mSpecIncreases); + for (std::vector::const_iterator iter (mUsedIds.begin()); iter!=mUsedIds.end(); ++iter) esm.writeHNString ("USED", *iter); @@ -178,6 +182,8 @@ void ESM::NpcStats::blank() mLevelProgress = 0; for (int i=0; i<8; ++i) mSkillIncrease[i] = 0; + for (int i=0; i<3; ++i) + mSpecIncreases[i] = 0; mTimeToStartDrowning = 20; mCrimeId = -1; } diff --git a/components/esm/npcstats.hpp b/components/esm/npcstats.hpp index 9b27f587c..467a099ce 100644 --- a/components/esm/npcstats.hpp +++ b/components/esm/npcstats.hpp @@ -37,6 +37,7 @@ namespace ESM int mWerewolfKills; int mLevelProgress; int mSkillIncrease[8]; + int mSpecIncreases[3]; std::vector mUsedIds; // lower case IDs float mTimeToStartDrowning; int mCrimeId;