forked from teamnwah/openmw-tes3coop
Use GMSTs for levelup
This commit is contained in:
parent
cc40cec395
commit
82146e7f8d
4 changed files with 38 additions and 27 deletions
|
@ -234,9 +234,12 @@ namespace MWGui
|
|||
MyGUI::Widget* levelWidget;
|
||||
for (int i=0; i<2; ++i)
|
||||
{
|
||||
int max = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("iLevelUpTotal")->getInt();
|
||||
getWidget(levelWidget, i==0 ? "Level_str" : "LevelText");
|
||||
levelWidget->setUserString("RangePosition_LevelProgress", boost::lexical_cast<std::string>(PCstats.getLevelProgress()));
|
||||
levelWidget->setUserString("Caption_LevelProgressText", boost::lexical_cast<std::string>(PCstats.getLevelProgress()) + "/10");
|
||||
levelWidget->setUserString("Range_LevelProgress", boost::lexical_cast<std::string>(max));
|
||||
levelWidget->setUserString("Caption_LevelProgressText", boost::lexical_cast<std::string>(PCstats.getLevelProgress()) + "/"
|
||||
+ boost::lexical_cast<std::string>(max));
|
||||
}
|
||||
|
||||
setFactions(PCstats.getFactionRanks());
|
||||
|
|
|
@ -271,7 +271,9 @@ namespace MWGui
|
|||
const MWMechanics::NpcStats &pcstats = MWWorld::Class::get(player).getNpcStats(player);
|
||||
|
||||
// trigger levelup if possible
|
||||
if (mSleeping && pcstats.getLevelProgress () >= 10)
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
if (mSleeping && pcstats.getLevelProgress () >= gmst.find("iLevelUpTotal")->getInt())
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (GM_Levelup);
|
||||
}
|
||||
|
|
|
@ -190,22 +190,31 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas
|
|||
|
||||
base += 1;
|
||||
|
||||
// if this is a major or minor skill of the class, increase level progress
|
||||
bool levelProgress = false;
|
||||
for (int i=0; i<2; ++i)
|
||||
for (int j=0; j<5; ++j)
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
|
||||
// is this a minor or major skill?
|
||||
int increase = gmst.find("iLevelupMiscMultAttriubte")->getInt(); // Note: GMST has a typo
|
||||
for (int k=0; k<5; ++k)
|
||||
{
|
||||
if (class_.mData.mSkills[k][0] == skillIndex)
|
||||
{
|
||||
int skill = class_.mData.mSkills[j][i];
|
||||
if (skill == skillIndex)
|
||||
levelProgress = true;
|
||||
mLevelProgress += gmst.find("iLevelUpMinorMult")->getInt();
|
||||
increase = gmst.find("iLevelUpMajorMultAttribute")->getInt();
|
||||
}
|
||||
}
|
||||
for (int k=0; k<5; ++k)
|
||||
{
|
||||
if (class_.mData.mSkills[k][1] == skillIndex)
|
||||
{
|
||||
mLevelProgress += gmst.find("iLevelUpMajorMult")->getInt();
|
||||
increase = gmst.find("iLevelUpMinorMultAttribute")->getInt();
|
||||
}
|
||||
}
|
||||
|
||||
mLevelProgress += levelProgress;
|
||||
|
||||
// check the attribute this skill belongs to
|
||||
const ESM::Skill* skill =
|
||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::Skill>().find(skillIndex);
|
||||
++mSkillIncreases[skill->mData.mAttribute];
|
||||
mSkillIncreases[skill->mData.mAttribute] += increase;
|
||||
|
||||
// Play sound & skill progress notification
|
||||
/// \todo check if character is the player, if levelling is ever implemented for NPCs
|
||||
|
@ -217,7 +226,7 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas
|
|||
% static_cast<int> (base);
|
||||
MWBase::Environment::get().getWindowManager ()->messageBox(message.str());
|
||||
|
||||
if (mLevelProgress >= 10)
|
||||
if (mLevelProgress >= gmst.find("iLevelUpTotal")->getInt())
|
||||
{
|
||||
// levelup is possible now
|
||||
MWBase::Environment::get().getWindowManager ()->messageBox ("#{sLevelUpMsg}");
|
||||
|
@ -263,18 +272,18 @@ void MWMechanics::NpcStats::updateHealth()
|
|||
|
||||
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
|
||||
{
|
||||
// Source: http://www.uesp.net/wiki/Morrowind:Level#How_to_Level_Up
|
||||
int num = mSkillIncreases[attribute];
|
||||
if (num <= 1)
|
||||
|
||||
if (num == 0)
|
||||
return 1;
|
||||
else if (num <= 4)
|
||||
return 2;
|
||||
else if (num <= 7)
|
||||
return 3;
|
||||
else if (num <= 9)
|
||||
return 4;
|
||||
else
|
||||
return 5;
|
||||
|
||||
num = std::min(10, num);
|
||||
|
||||
// iLevelUp01Mult - iLevelUp10Mult
|
||||
std::stringstream gmst;
|
||||
gmst << "iLevelUp" << std::setfill('0') << std::setw(2) << num << "Mult";
|
||||
|
||||
return MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(gmst.str())->getInt();
|
||||
}
|
||||
|
||||
void MWMechanics::NpcStats::flagAsUsed (const std::string& id)
|
||||
|
|
|
@ -184,11 +184,8 @@
|
|||
</Widget>
|
||||
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Red" position="50 30 200 20" align="HCenter Bottom" name="LevelProgress">
|
||||
<Property key="Range" value="10"/>
|
||||
<Property key="RangePosition" value="0"/>
|
||||
<Widget type="TextBox" skin="ProgressText" position="0 0 200 20" align="Stretch" name="LevelProgressText">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Caption" value="0/10"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
|
Loading…
Reference in a new issue