mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-12 19:06:44 +00:00
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;
|
MyGUI::Widget* levelWidget;
|
||||||
for (int i=0; i<2; ++i)
|
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");
|
getWidget(levelWidget, i==0 ? "Level_str" : "LevelText");
|
||||||
levelWidget->setUserString("RangePosition_LevelProgress", boost::lexical_cast<std::string>(PCstats.getLevelProgress()));
|
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());
|
setFactions(PCstats.getFactionRanks());
|
||||||
|
|
|
@ -271,7 +271,9 @@ namespace MWGui
|
||||||
const MWMechanics::NpcStats &pcstats = MWWorld::Class::get(player).getNpcStats(player);
|
const MWMechanics::NpcStats &pcstats = MWWorld::Class::get(player).getNpcStats(player);
|
||||||
|
|
||||||
// trigger levelup if possible
|
// 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);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode (GM_Levelup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,22 +190,31 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas
|
||||||
|
|
||||||
base += 1;
|
base += 1;
|
||||||
|
|
||||||
// if this is a major or minor skill of the class, increase level progress
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||||
bool levelProgress = false;
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
for (int i=0; i<2; ++i)
|
|
||||||
for (int j=0; j<5; ++j)
|
// 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];
|
mLevelProgress += gmst.find("iLevelUpMinorMult")->getInt();
|
||||||
if (skill == skillIndex)
|
increase = gmst.find("iLevelUpMajorMultAttribute")->getInt();
|
||||||
levelProgress = true;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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 =
|
const ESM::Skill* skill =
|
||||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::Skill>().find(skillIndex);
|
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::Skill>().find(skillIndex);
|
||||||
++mSkillIncreases[skill->mData.mAttribute];
|
mSkillIncreases[skill->mData.mAttribute] += increase;
|
||||||
|
|
||||||
// Play sound & skill progress notification
|
// Play sound & skill progress notification
|
||||||
/// \todo check if character is the player, if levelling is ever implemented for NPCs
|
/// \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);
|
% static_cast<int> (base);
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox(message.str());
|
MWBase::Environment::get().getWindowManager ()->messageBox(message.str());
|
||||||
|
|
||||||
if (mLevelProgress >= 10)
|
if (mLevelProgress >= gmst.find("iLevelUpTotal")->getInt())
|
||||||
{
|
{
|
||||||
// levelup is possible now
|
// levelup is possible now
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox ("#{sLevelUpMsg}");
|
MWBase::Environment::get().getWindowManager ()->messageBox ("#{sLevelUpMsg}");
|
||||||
|
@ -263,18 +272,18 @@ void MWMechanics::NpcStats::updateHealth()
|
||||||
|
|
||||||
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
|
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
|
||||||
{
|
{
|
||||||
// Source: http://www.uesp.net/wiki/Morrowind:Level#How_to_Level_Up
|
|
||||||
int num = mSkillIncreases[attribute];
|
int num = mSkillIncreases[attribute];
|
||||||
if (num <= 1)
|
|
||||||
|
if (num == 0)
|
||||||
return 1;
|
return 1;
|
||||||
else if (num <= 4)
|
|
||||||
return 2;
|
num = std::min(10, num);
|
||||||
else if (num <= 7)
|
|
||||||
return 3;
|
// iLevelUp01Mult - iLevelUp10Mult
|
||||||
else if (num <= 9)
|
std::stringstream gmst;
|
||||||
return 4;
|
gmst << "iLevelUp" << std::setfill('0') << std::setw(2) << num << "Mult";
|
||||||
else
|
|
||||||
return 5;
|
return MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(gmst.str())->getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWMechanics::NpcStats::flagAsUsed (const std::string& id)
|
void MWMechanics::NpcStats::flagAsUsed (const std::string& id)
|
||||||
|
|
|
@ -184,11 +184,8 @@
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="ProgressBar" skin="MW_Progress_Red" position="50 30 200 20" align="HCenter Bottom" name="LevelProgress">
|
<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">
|
<Widget type="TextBox" skin="ProgressText" position="0 0 200 20" align="Stretch" name="LevelProgressText">
|
||||||
<Property key="TextAlign" value="Center"/>
|
<Property key="TextAlign" value="Center"/>
|
||||||
<Property key="Caption" value="0/10"/>
|
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
Loading…
Reference in a new issue