2012-07-06 15:50:26 +02:00
|
|
|
#include "npcstats.hpp"
|
|
|
|
|
2023-08-18 12:46:45 +04:00
|
|
|
#include <cassert>
|
2014-02-19 18:40:29 +01:00
|
|
|
#include <iomanip>
|
2022-06-27 21:32:46 +02:00
|
|
|
#include <sstream>
|
2014-02-19 18:40:29 +01:00
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/loadclas.hpp>
|
|
|
|
#include <components/esm3/loadfact.hpp>
|
|
|
|
#include <components/esm3/loadgmst.hpp>
|
|
|
|
#include <components/esm3/npcstats.hpp>
|
2012-07-06 21:07:04 +02:00
|
|
|
|
2022-08-03 00:00:54 +02:00
|
|
|
#include <components/misc/strings/format.hpp>
|
|
|
|
|
2023-05-29 17:56:14 +02:00
|
|
|
#include <MyGUI_TextIterator.h>
|
|
|
|
|
2012-10-01 19:17:04 +04:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-07-06 21:07:04 +02:00
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
2012-09-15 17:12:42 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2012-07-06 21:07:04 +02:00
|
|
|
|
2012-07-06 15:50:26 +02:00
|
|
|
MWMechanics::NpcStats::NpcStats()
|
2015-04-30 19:24:27 -05:00
|
|
|
: mDisposition(0)
|
2023-09-24 21:58:10 +04:00
|
|
|
, mCrimeDispositionModifier(0)
|
2013-03-31 13:13:46 +02:00
|
|
|
, mReputation(0)
|
2014-04-05 10:26:14 -04:00
|
|
|
, mCrimeId(-1)
|
2015-04-30 19:24:27 -05:00
|
|
|
, mBounty(0)
|
2013-03-31 13:13:46 +02:00
|
|
|
, mWerewolfKills(0)
|
2015-04-30 19:24:27 -05:00
|
|
|
, mLevelProgress(0)
|
2017-04-16 22:15:25 +04:00
|
|
|
, mTimeToStartDrowning(-1.0) // set breath to special value, it will be replaced during actor update
|
2015-06-21 17:27:52 +02:00
|
|
|
, mIsWerewolf(false)
|
2012-09-15 17:12:42 +02:00
|
|
|
{
|
2016-06-26 03:22:58 +02:00
|
|
|
mSpecIncreases.resize(3, 0);
|
2023-06-05 21:21:30 +02:00
|
|
|
for (const ESM::Skill& skill : MWBase::Environment::get().getESMStore()->get<ESM::Skill>())
|
|
|
|
mSkills.emplace(skill.mId, SkillValue{});
|
2012-09-15 17:12:42 +02:00
|
|
|
}
|
2012-07-06 15:50:26 +02:00
|
|
|
|
2012-11-09 20:18:38 +01:00
|
|
|
int MWMechanics::NpcStats::getBaseDisposition() const
|
2012-11-05 11:07:43 +01:00
|
|
|
{
|
|
|
|
return mDisposition;
|
|
|
|
}
|
|
|
|
|
2012-11-09 20:18:38 +01:00
|
|
|
void MWMechanics::NpcStats::setBaseDisposition(int disposition)
|
2012-11-05 11:07:43 +01:00
|
|
|
{
|
|
|
|
mDisposition = disposition;
|
|
|
|
}
|
|
|
|
|
2023-09-24 21:58:10 +04:00
|
|
|
int MWMechanics::NpcStats::getCrimeDispositionModifier() const
|
|
|
|
{
|
|
|
|
return mCrimeDispositionModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::setCrimeDispositionModifier(int value)
|
|
|
|
{
|
|
|
|
mCrimeDispositionModifier = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::modCrimeDispositionModifier(int value)
|
|
|
|
{
|
|
|
|
mCrimeDispositionModifier += value;
|
|
|
|
}
|
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
const MWMechanics::SkillValue& MWMechanics::NpcStats::getSkill(ESM::RefId id) const
|
2012-07-06 18:23:48 +02:00
|
|
|
{
|
2023-06-05 21:21:30 +02:00
|
|
|
auto it = mSkills.find(id);
|
|
|
|
if (it == mSkills.end())
|
|
|
|
throw std::runtime_error("skill not found");
|
|
|
|
return it->second;
|
2012-07-06 18:23:48 +02:00
|
|
|
}
|
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
MWMechanics::SkillValue& MWMechanics::NpcStats::getSkill(ESM::RefId id)
|
2012-07-06 18:23:48 +02:00
|
|
|
{
|
2023-06-05 21:21:30 +02:00
|
|
|
auto it = mSkills.find(id);
|
|
|
|
if (it == mSkills.end())
|
|
|
|
throw std::runtime_error("skill not found");
|
|
|
|
return it->second;
|
2015-06-21 17:27:52 +02:00
|
|
|
}
|
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
void MWMechanics::NpcStats::setSkill(ESM::RefId id, const MWMechanics::SkillValue& value)
|
2015-06-21 17:27:52 +02:00
|
|
|
{
|
2023-06-05 21:21:30 +02:00
|
|
|
auto it = mSkills.find(id);
|
|
|
|
if (it == mSkills.end())
|
|
|
|
throw std::runtime_error("skill not found");
|
|
|
|
it->second = value;
|
2012-07-06 18:23:48 +02:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const std::map<ESM::RefId, int>& MWMechanics::NpcStats::getFactionRanks() const
|
2013-08-09 01:14:08 -07:00
|
|
|
{
|
|
|
|
return mFactionRank;
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
int MWMechanics::NpcStats::getFactionRank(const ESM::RefId& faction) const
|
2019-05-14 10:12:40 +04:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
auto it = mFactionRank.find(faction);
|
2019-05-14 10:12:40 +04:00
|
|
|
if (it != mFactionRank.end())
|
|
|
|
return it->second;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2023-06-14 03:38:22 +08:00
|
|
|
void MWMechanics::NpcStats::joinFaction(const ESM::RefId& faction)
|
2012-07-06 18:23:48 +02:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
auto it = mFactionRank.find(faction);
|
2023-06-14 03:38:22 +08:00
|
|
|
if (it == mFactionRank.end())
|
|
|
|
mFactionRank[faction] = 0;
|
2014-10-05 16:47:55 +02:00
|
|
|
}
|
|
|
|
|
2023-06-14 03:38:22 +08:00
|
|
|
void MWMechanics::NpcStats::setFactionRank(const ESM::RefId& faction, int newRank)
|
2014-10-05 16:47:55 +02:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
auto it = mFactionRank.find(faction);
|
2014-10-05 16:47:55 +02:00
|
|
|
if (it != mFactionRank.end())
|
|
|
|
{
|
2023-06-14 03:38:22 +08:00
|
|
|
const ESM::Faction* factionPtr = MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction);
|
|
|
|
if (newRank < 0)
|
2019-05-13 10:22:03 +03:00
|
|
|
{
|
2019-05-12 20:57:54 +03:00
|
|
|
mFactionRank.erase(it);
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
mExpelled.erase(faction);
|
2019-05-13 10:22:03 +03:00
|
|
|
}
|
2023-06-14 03:38:22 +08:00
|
|
|
else if (newRank < static_cast<int>(factionPtr->mData.mRankData.size()))
|
|
|
|
do
|
|
|
|
it->second = newRank;
|
|
|
|
// Does the new rank exist?
|
|
|
|
while (newRank > 0 && factionPtr->mRanks[newRank--].empty());
|
2014-10-05 16:47:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
bool MWMechanics::NpcStats::getExpelled(const ESM::RefId& factionID) const
|
2012-11-10 12:28:40 +01:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
return mExpelled.find(factionID) != mExpelled.end();
|
2012-11-10 12:28:40 +01:00
|
|
|
}
|
|
|
|
|
2023-09-06 20:28:35 +04:00
|
|
|
void MWMechanics::NpcStats::expell(const ESM::RefId& factionID, bool printMessage)
|
2012-07-06 18:23:48 +02:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
if (mExpelled.find(factionID) == mExpelled.end())
|
2014-01-08 18:59:00 +01:00
|
|
|
{
|
2023-09-06 20:28:35 +04:00
|
|
|
mExpelled.insert(factionID);
|
|
|
|
if (!printMessage)
|
|
|
|
return;
|
|
|
|
|
2014-01-08 18:59:00 +01:00
|
|
|
std::string message = "#{sExpelledMessage}";
|
2023-04-20 21:07:53 +02:00
|
|
|
message += MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionID)->mName;
|
2014-01-08 18:59:00 +01:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void MWMechanics::NpcStats::clearExpelled(const ESM::RefId& factionID)
|
2014-01-08 18:59:00 +01:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
mExpelled.erase(factionID);
|
2012-07-06 18:23:48 +02:00
|
|
|
}
|
2012-07-06 21:07:04 +02:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
bool MWMechanics::NpcStats::isInFaction(const ESM::RefId& faction) const
|
2012-11-10 09:35:50 +01:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
return (mFactionRank.find(faction) != mFactionRank.end());
|
2012-11-10 09:35:50 +01:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
int MWMechanics::NpcStats::getFactionReputation(const ESM::RefId& faction) const
|
2015-02-08 21:04:01 +01:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
auto iter = mFactionReputation.find(faction);
|
2015-02-08 21:04:01 +01:00
|
|
|
|
|
|
|
if (iter == mFactionReputation.end())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return iter->second;
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void MWMechanics::NpcStats::setFactionReputation(const ESM::RefId& faction, int value)
|
2015-02-08 21:04:01 +01:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
mFactionReputation[faction] = value;
|
2015-02-08 21:04:01 +01:00
|
|
|
}
|
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
float MWMechanics::NpcStats::getSkillProgressRequirement(ESM::RefId id, const ESM::Class& class_) const
|
2012-07-06 21:07:04 +02:00
|
|
|
{
|
2023-06-05 21:21:30 +02:00
|
|
|
float progressRequirement = 1.f + getSkill(id).getBase();
|
2014-09-25 12:25:57 +02:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
|
2023-06-05 21:21:30 +02:00
|
|
|
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(id);
|
2012-11-05 21:19:22 +04:00
|
|
|
|
2018-08-29 18:38:12 +03:00
|
|
|
float typeFactor = gmst.find("fMiscSkillBonus")->mValue.getFloat();
|
2023-06-15 20:49:14 +02:00
|
|
|
int index = ESM::Skill::refIdToIndex(skill->mId);
|
2023-06-03 11:58:09 +02:00
|
|
|
for (const auto& skills : class_.mData.mSkills)
|
2019-01-24 13:33:18 +00:00
|
|
|
{
|
2023-06-15 20:49:14 +02:00
|
|
|
if (skills[0] == index)
|
2012-07-06 21:07:04 +02:00
|
|
|
{
|
2018-08-29 18:38:12 +03:00
|
|
|
typeFactor = gmst.find("fMinorSkillBonus")->mValue.getFloat();
|
2012-07-06 21:07:04 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-06-15 20:49:14 +02:00
|
|
|
else if (skills[1] == index)
|
2012-07-06 21:07:04 +02:00
|
|
|
{
|
2018-08-29 18:38:12 +03:00
|
|
|
typeFactor = gmst.find("fMajorSkillBonus")->mValue.getFloat();
|
2012-07-06 21:07:04 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-01-24 13:33:18 +00:00
|
|
|
}
|
2012-07-06 21:07:04 +02:00
|
|
|
|
2015-02-04 23:15:12 +01:00
|
|
|
progressRequirement *= typeFactor;
|
|
|
|
|
2012-07-06 21:07:04 +02:00
|
|
|
if (typeFactor <= 0)
|
|
|
|
throw std::runtime_error("invalid skill type factor");
|
|
|
|
|
|
|
|
float specialisationFactor = 1;
|
|
|
|
|
2012-09-17 11:37:50 +04:00
|
|
|
if (skill->mData.mSpecialization == class_.mData.mSpecialization)
|
2012-07-06 21:07:04 +02:00
|
|
|
{
|
2018-08-29 18:38:12 +03:00
|
|
|
specialisationFactor = gmst.find("fSpecialSkillBonus")->mValue.getFloat();
|
2012-07-06 21:07:04 +02:00
|
|
|
|
|
|
|
if (specialisationFactor <= 0)
|
|
|
|
throw std::runtime_error("invalid skill specialisation factor");
|
|
|
|
}
|
2015-02-04 23:15:12 +01:00
|
|
|
progressRequirement *= specialisationFactor;
|
|
|
|
|
|
|
|
return progressRequirement;
|
2012-07-06 21:07:04 +02:00
|
|
|
}
|
2012-07-09 21:15:52 +02:00
|
|
|
|
2023-06-06 17:02:10 +02:00
|
|
|
void MWMechanics::NpcStats::useSkill(ESM::RefId id, const ESM::Class& class_, int usageType, float extraFactor)
|
2012-07-09 21:15:52 +02:00
|
|
|
{
|
2023-06-06 17:02:10 +02:00
|
|
|
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(id);
|
2015-02-04 23:15:12 +01:00
|
|
|
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;
|
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
MWMechanics::SkillValue& value = getSkill(skill->mId);
|
2012-07-09 21:15:52 +02:00
|
|
|
|
2015-02-04 23:15:12 +01:00
|
|
|
value.setProgress(value.getProgress() + skillGain);
|
2012-07-09 21:15:52 +02:00
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
if (int(value.getProgress()) >= int(getSkillProgressRequirement(skill->mId, class_)))
|
2012-09-15 17:12:42 +02:00
|
|
|
{
|
2015-02-01 00:26:06 +01:00
|
|
|
// skill levelled up
|
2023-06-06 17:02:10 +02:00
|
|
|
increaseSkill(skill->mId, class_, false);
|
2012-09-15 19:06:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-06 17:02:10 +02:00
|
|
|
void MWMechanics::NpcStats::increaseSkill(ESM::RefId id, const ESM::Class& class_, bool preserveProgress, bool readBook)
|
2012-09-15 19:06:56 +02:00
|
|
|
{
|
2023-06-06 17:02:10 +02:00
|
|
|
const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(id);
|
2023-06-05 21:21:30 +02:00
|
|
|
float base = getSkill(skill->mId).getBase();
|
2012-09-15 19:06:56 +02:00
|
|
|
|
2018-12-23 15:18:33 +04:00
|
|
|
if (base >= 100.f)
|
2012-09-15 19:10:48 +02:00
|
|
|
return;
|
|
|
|
|
2014-01-03 03:46:30 +01:00
|
|
|
base += 1;
|
2012-07-09 21:15:52 +02:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
|
2014-01-26 21:50:40 +01:00
|
|
|
|
|
|
|
// is this a minor or major skill?
|
2018-08-29 18:38:12 +03:00
|
|
|
int increase = gmst.find("iLevelupMiscMultAttriubte")->mValue.getInteger(); // Note: GMST has a typo
|
2023-06-15 20:49:14 +02:00
|
|
|
int index = ESM::Skill::refIdToIndex(skill->mId);
|
2023-06-03 11:58:09 +02:00
|
|
|
for (const auto& skills : class_.mData.mSkills)
|
2014-01-26 21:50:40 +01:00
|
|
|
{
|
2023-06-15 20:49:14 +02:00
|
|
|
if (skills[0] == index)
|
2012-09-15 17:12:42 +02:00
|
|
|
{
|
2018-08-29 18:38:12 +03:00
|
|
|
mLevelProgress += gmst.find("iLevelUpMinorMult")->mValue.getInteger();
|
2019-01-24 13:33:18 +00:00
|
|
|
increase = gmst.find("iLevelUpMinorMultAttribute")->mValue.getInteger();
|
|
|
|
break;
|
2012-09-15 17:12:42 +02:00
|
|
|
}
|
2023-06-15 20:49:14 +02:00
|
|
|
else if (skills[1] == index)
|
2014-01-26 21:50:40 +01:00
|
|
|
{
|
2018-08-29 18:38:12 +03:00
|
|
|
mLevelProgress += gmst.find("iLevelUpMajorMult")->mValue.getInteger();
|
2019-01-24 13:33:18 +00:00
|
|
|
increase = gmst.find("iLevelUpMajorMultAttribute")->mValue.getInteger();
|
|
|
|
break;
|
2014-01-26 21:50:40 +01:00
|
|
|
}
|
|
|
|
}
|
2012-09-15 19:06:56 +02:00
|
|
|
|
2023-08-03 20:21:44 +02:00
|
|
|
mSkillIncreases[ESM::Attribute::indexToRefId(skill->mData.mAttribute)] += increase;
|
2012-09-15 19:06:56 +02:00
|
|
|
|
2018-08-29 18:38:12 +03:00
|
|
|
mSpecIncreases[skill->mData.mSpecialization] += gmst.find("iLevelupSpecialization")->mValue.getInteger();
|
2016-06-26 03:22:58 +02:00
|
|
|
|
2012-09-15 19:06:56 +02:00
|
|
|
// Play sound & skill progress notification
|
|
|
|
/// \todo check if character is the player, if levelling is ever implemented for NPCs
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("skillraise"));
|
2012-09-15 19:06:56 +02:00
|
|
|
|
2022-08-24 23:10:05 +02:00
|
|
|
std::string message{ MWBase::Environment::get().getWindowManager()->getGameSettingString("sNotifyMessage39", {}) };
|
2023-05-30 17:35:26 +02:00
|
|
|
message = Misc::StringUtils::format(
|
|
|
|
message, MyGUI::TextIterator::toTagsString(skill->mName).asUTF8(), static_cast<int>(base));
|
2018-03-24 13:43:18 +03:00
|
|
|
|
|
|
|
if (readBook)
|
2019-02-23 00:14:07 +03:00
|
|
|
message = "#{sBookSkillMessage}\n" + message;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2019-02-23 00:14:07 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox(message, MWGui::ShowInDialogueMode_Never);
|
2012-09-15 19:06:56 +02:00
|
|
|
|
2018-08-29 18:38:12 +03:00
|
|
|
if (mLevelProgress >= gmst.find("iLevelUpTotal")->mValue.getInteger())
|
2012-09-15 19:06:56 +02:00
|
|
|
{
|
|
|
|
// levelup is possible now
|
2015-01-10 23:21:39 +01:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sLevelUpMsg}", MWGui::ShowInDialogueMode_Never);
|
2012-09-15 19:06:56 +02:00
|
|
|
}
|
2012-09-15 17:12:42 +02:00
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
getSkill(skill->mId).setBase(base);
|
2014-01-03 03:46:30 +01:00
|
|
|
if (!preserveProgress)
|
2023-06-05 21:21:30 +02:00
|
|
|
getSkill(skill->mId).setProgress(0);
|
2012-07-09 21:15:52 +02:00
|
|
|
}
|
2012-09-15 17:12:42 +02:00
|
|
|
|
|
|
|
int MWMechanics::NpcStats::getLevelProgress() const
|
|
|
|
{
|
|
|
|
return mLevelProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::levelUp()
|
|
|
|
{
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
|
2014-01-26 21:08:11 +01:00
|
|
|
|
2018-08-29 18:38:12 +03:00
|
|
|
mLevelProgress -= gmst.find("iLevelUpTotal")->mValue.getInteger();
|
2015-02-05 01:08:26 +01:00
|
|
|
mLevelProgress = std::max(0, mLevelProgress); // might be necessary when levelup was invoked via console
|
2015-02-05 01:03:10 +01:00
|
|
|
|
2023-06-19 20:41:54 +02:00
|
|
|
mSkillIncreases.clear();
|
2015-02-05 01:03:10 +01:00
|
|
|
|
2018-12-23 15:18:33 +04:00
|
|
|
const float endurance = getAttribute(ESM::Attribute::Endurance).getBase();
|
2014-01-26 21:08:11 +01:00
|
|
|
|
|
|
|
// "When you gain a level, in addition to increasing three primary attributes, your Health
|
|
|
|
// will automatically increase by 10% of your Endurance attribute. If you increased Endurance this level,
|
|
|
|
// the Health increase is calculated from the increased Endurance"
|
2018-09-22 07:46:47 +04:00
|
|
|
// Note: we should add bonus Health points to current level too.
|
|
|
|
float healthGain = endurance * gmst.find("fLevelUpHealthEndMult")->mValue.getFloat();
|
|
|
|
MWMechanics::DynamicStat<float> health(getHealth());
|
|
|
|
health.setBase(getHealth().getBase() + healthGain);
|
|
|
|
health.setCurrent(std::max(1.f, getHealth().getCurrent() + healthGain));
|
|
|
|
setHealth(health);
|
2014-01-26 21:08:11 +01:00
|
|
|
|
|
|
|
setLevel(getLevel() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::updateHealth()
|
|
|
|
{
|
2018-12-23 15:18:33 +04:00
|
|
|
const float endurance = getAttribute(ESM::Attribute::Endurance).getBase();
|
|
|
|
const float strength = getAttribute(ESM::Attribute::Strength).getBase();
|
2014-01-26 21:08:11 +01:00
|
|
|
|
2015-03-08 17:42:07 +13:00
|
|
|
setHealth(floor(0.5f * (strength + endurance)));
|
2012-09-15 17:12:42 +02:00
|
|
|
}
|
|
|
|
|
2023-06-19 20:41:54 +02:00
|
|
|
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(ESM::Attribute::AttributeID attribute) const
|
2012-09-15 17:12:42 +02:00
|
|
|
{
|
2023-06-19 20:41:54 +02:00
|
|
|
auto it = mSkillIncreases.find(attribute);
|
|
|
|
if (it == mSkillIncreases.end() || it->second == 0)
|
2012-09-15 17:12:42 +02:00
|
|
|
return 1;
|
2023-06-19 20:41:54 +02:00
|
|
|
int num = std::min(10, it->second);
|
2014-01-26 21:50:40 +01:00
|
|
|
|
|
|
|
// iLevelUp01Mult - iLevelUp10Mult
|
|
|
|
std::stringstream gmst;
|
|
|
|
gmst << "iLevelUp" << std::setfill('0') << std::setw(2) << num << "Mult";
|
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
return MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find(gmst.str())->mValue.getInteger();
|
2012-09-15 17:12:42 +02:00
|
|
|
}
|
2012-09-25 10:48:57 +02:00
|
|
|
|
2016-06-26 03:22:58 +02:00
|
|
|
int MWMechanics::NpcStats::getSkillIncreasesForSpecialization(int spec) const
|
|
|
|
{
|
|
|
|
return mSpecIncreases[spec];
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void MWMechanics::NpcStats::flagAsUsed(const ESM::RefId& id)
|
2012-09-25 10:48:57 +02:00
|
|
|
{
|
|
|
|
mUsedIds.insert(id);
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
bool MWMechanics::NpcStats::hasBeenUsed(const ESM::RefId& id) const
|
2012-09-25 10:48:57 +02:00
|
|
|
{
|
|
|
|
return mUsedIds.find(id) != mUsedIds.end();
|
|
|
|
}
|
2012-11-09 14:31:38 +01:00
|
|
|
|
|
|
|
int MWMechanics::NpcStats::getBounty() const
|
|
|
|
{
|
2014-12-18 18:08:51 +01:00
|
|
|
return mBounty;
|
2012-11-09 14:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::setBounty(int bounty)
|
|
|
|
{
|
2014-12-18 18:08:51 +01:00
|
|
|
mBounty = bounty;
|
2012-11-09 14:31:38 +01:00
|
|
|
}
|
2012-11-10 13:20:41 +01:00
|
|
|
|
2012-11-10 00:29:36 +01:00
|
|
|
int MWMechanics::NpcStats::getReputation() const
|
|
|
|
{
|
|
|
|
return mReputation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::setReputation(int reputation)
|
|
|
|
{
|
2019-12-11 08:47:46 +04:00
|
|
|
// Reputation is capped in original engine
|
2021-11-06 07:30:28 +03:00
|
|
|
mReputation = std::clamp(reputation, 0, 255);
|
2012-11-10 00:29:36 +01:00
|
|
|
}
|
2012-11-10 15:44:44 +01:00
|
|
|
|
2014-04-05 10:26:14 -04:00
|
|
|
int MWMechanics::NpcStats::getCrimeId() const
|
|
|
|
{
|
|
|
|
return mCrimeId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::setCrimeId(int id)
|
|
|
|
{
|
|
|
|
mCrimeId = id;
|
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
bool MWMechanics::NpcStats::hasSkillsForRank(const ESM::RefId& factionId, int rank) const
|
2012-11-12 13:23:25 +01:00
|
|
|
{
|
2023-04-20 21:07:53 +02:00
|
|
|
const ESM::Faction& faction = *MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionId);
|
2012-11-12 13:23:25 +01:00
|
|
|
|
2023-06-03 13:11:49 +02:00
|
|
|
const ESM::RankData& rankData = faction.mData.mRankData.at(rank);
|
|
|
|
|
2012-11-12 13:23:25 +01:00
|
|
|
std::vector<int> skills;
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
for (int index : faction.mData.mSkills)
|
2014-06-15 23:05:38 +02:00
|
|
|
{
|
2023-06-05 21:21:30 +02:00
|
|
|
ESM::RefId id = ESM::Skill::indexToRefId(index);
|
|
|
|
if (!id.empty())
|
2023-06-03 13:11:49 +02:00
|
|
|
skills.push_back(static_cast<int>(getSkill(id).getBase()));
|
2014-06-15 23:05:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (skills.empty())
|
|
|
|
return true;
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-11-12 13:23:25 +01:00
|
|
|
std::sort(skills.begin(), skills.end());
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2012-11-12 13:23:25 +01:00
|
|
|
std::vector<int>::const_reverse_iterator iter = skills.rbegin();
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2020-06-26 11:47:59 +04:00
|
|
|
if (*iter < rankData.mPrimarySkill)
|
2012-11-12 13:23:25 +01:00
|
|
|
return false;
|
2012-11-15 20:00:27 +01:00
|
|
|
|
2014-06-15 23:05:38 +02:00
|
|
|
if (skills.size() < 2)
|
|
|
|
return true;
|
|
|
|
|
2020-06-26 11:14:38 +04:00
|
|
|
iter++;
|
2020-06-26 11:47:59 +04:00
|
|
|
if (*iter < rankData.mFavouredSkill)
|
2020-06-26 11:14:38 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (skills.size() < 3)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
iter++;
|
2020-06-26 11:47:59 +04:00
|
|
|
if (*iter < rankData.mFavouredSkill)
|
2020-06-26 11:14:38 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2012-11-12 13:23:25 +01:00
|
|
|
}
|
|
|
|
|
2012-11-15 20:00:27 +01:00
|
|
|
bool MWMechanics::NpcStats::isWerewolf() const
|
|
|
|
{
|
2013-08-09 05:14:58 -07:00
|
|
|
return mIsWerewolf;
|
2012-11-15 20:00:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MWMechanics::NpcStats::setWerewolf(bool set)
|
|
|
|
{
|
2015-06-21 17:27:52 +02:00
|
|
|
if (mIsWerewolf == set)
|
|
|
|
return;
|
|
|
|
|
2013-08-09 05:14:58 -07:00
|
|
|
if (set != false)
|
|
|
|
{
|
2014-06-17 16:51:59 +02:00
|
|
|
mWerewolfKills = 0;
|
2013-08-09 05:14:58 -07:00
|
|
|
}
|
|
|
|
mIsWerewolf = set;
|
2012-11-15 20:00:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int MWMechanics::NpcStats::getWerewolfKills() const
|
|
|
|
{
|
|
|
|
return mWerewolfKills;
|
2012-11-28 02:15:34 +01:00
|
|
|
}
|
2013-03-31 13:13:46 +02:00
|
|
|
|
2014-06-17 16:51:59 +02:00
|
|
|
void MWMechanics::NpcStats::addWerewolfKill()
|
|
|
|
{
|
|
|
|
++mWerewolfKills;
|
|
|
|
}
|
|
|
|
|
2013-08-27 17:13:49 -07:00
|
|
|
float MWMechanics::NpcStats::getTimeToStartDrowning() const
|
2013-08-07 15:34:11 +02:00
|
|
|
{
|
|
|
|
return mTimeToStartDrowning;
|
|
|
|
}
|
2014-05-11 21:03:27 +02:00
|
|
|
|
2013-08-07 15:34:11 +02:00
|
|
|
void MWMechanics::NpcStats::setTimeToStartDrowning(float time)
|
|
|
|
{
|
|
|
|
mTimeToStartDrowning = time;
|
|
|
|
}
|
2014-02-16 15:06:34 +01:00
|
|
|
|
2020-03-17 14:15:19 +04:00
|
|
|
void MWMechanics::NpcStats::writeState(ESM::CreatureStats& state) const
|
|
|
|
{
|
|
|
|
CreatureStats::writeState(state);
|
|
|
|
}
|
|
|
|
|
2014-02-16 15:06:34 +01:00
|
|
|
void MWMechanics::NpcStats::writeState(ESM::NpcStats& state) const
|
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
for (std::map<ESM::RefId, int>::const_iterator iter(mFactionRank.begin()); iter != mFactionRank.end(); ++iter)
|
2014-02-16 15:06:34 +01:00
|
|
|
state.mFactions[iter->first].mRank = iter->second;
|
|
|
|
|
|
|
|
state.mDisposition = mDisposition;
|
2023-09-24 21:58:10 +04:00
|
|
|
state.mCrimeDispositionModifier = mCrimeDispositionModifier;
|
2014-02-16 15:06:34 +01:00
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
for (const auto& [id, value] : mSkills)
|
|
|
|
{
|
|
|
|
// TODO extend format
|
2023-06-15 20:49:14 +02:00
|
|
|
auto index = ESM::Skill::refIdToIndex(id);
|
2023-08-18 12:46:45 +04:00
|
|
|
assert(index >= 0);
|
2023-08-20 16:25:58 +02:00
|
|
|
value.writeState(state.mSkills[static_cast<size_t>(index)]);
|
2023-06-05 21:21:30 +02:00
|
|
|
}
|
2015-06-21 18:18:24 +02:00
|
|
|
|
2014-05-12 21:04:02 +02:00
|
|
|
state.mIsWerewolf = mIsWerewolf;
|
2014-02-16 15:06:34 +01:00
|
|
|
|
2014-04-14 18:11:04 -04:00
|
|
|
state.mCrimeId = mCrimeId;
|
|
|
|
|
2014-02-16 15:06:34 +01:00
|
|
|
state.mBounty = mBounty;
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
for (auto iter(mExpelled.begin()); iter != mExpelled.end(); ++iter)
|
2014-02-16 15:06:34 +01:00
|
|
|
state.mFactions[*iter].mExpelled = true;
|
|
|
|
|
2022-10-18 09:26:55 +02:00
|
|
|
for (auto iter(mFactionReputation.begin()); iter != mFactionReputation.end(); ++iter)
|
2014-02-16 15:06:34 +01:00
|
|
|
state.mFactions[iter->first].mReputation = iter->second;
|
|
|
|
|
|
|
|
state.mReputation = mReputation;
|
|
|
|
state.mWerewolfKills = mWerewolfKills;
|
|
|
|
state.mLevelProgress = mLevelProgress;
|
|
|
|
|
2023-06-20 20:26:08 +02:00
|
|
|
state.mSkillIncrease.fill(0);
|
|
|
|
for (const auto& [key, value] : mSkillIncreases)
|
2023-08-31 10:30:37 +04:00
|
|
|
{
|
|
|
|
// TODO extend format
|
|
|
|
auto index = ESM::Attribute::refIdToIndex(key);
|
|
|
|
assert(index >= 0);
|
|
|
|
state.mSkillIncrease[static_cast<size_t>(index)] = value;
|
|
|
|
}
|
2014-02-16 15:56:36 +01:00
|
|
|
|
2023-06-03 14:26:37 +02:00
|
|
|
for (size_t i = 0; i < state.mSpecIncreases.size(); ++i)
|
2016-06-26 03:22:58 +02:00
|
|
|
state.mSpecIncreases[i] = mSpecIncreases[i];
|
|
|
|
|
2014-02-16 15:06:34 +01:00
|
|
|
std::copy(mUsedIds.begin(), mUsedIds.end(), std::back_inserter(state.mUsedIds));
|
|
|
|
|
|
|
|
state.mTimeToStartDrowning = mTimeToStartDrowning;
|
|
|
|
}
|
2020-03-17 14:15:19 +04:00
|
|
|
void MWMechanics::NpcStats::readState(const ESM::CreatureStats& state)
|
|
|
|
{
|
|
|
|
CreatureStats::readState(state);
|
|
|
|
}
|
2014-02-16 15:06:34 +01:00
|
|
|
|
|
|
|
void MWMechanics::NpcStats::readState(const ESM::NpcStats& state)
|
|
|
|
{
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
|
2014-02-16 16:22:09 +01:00
|
|
|
|
2022-10-18 09:26:55 +02:00
|
|
|
for (auto iter(state.mFactions.begin()); iter != state.mFactions.end(); ++iter)
|
2014-02-16 16:22:09 +01:00
|
|
|
if (store.get<ESM::Faction>().search(iter->first))
|
|
|
|
{
|
|
|
|
if (iter->second.mExpelled)
|
|
|
|
mExpelled.insert(iter->first);
|
2014-02-16 15:06:34 +01:00
|
|
|
|
2014-04-26 11:41:44 +02:00
|
|
|
if (iter->second.mRank >= 0)
|
2014-05-26 12:31:08 +02:00
|
|
|
mFactionRank[iter->first] = iter->second.mRank;
|
2014-02-16 15:06:34 +01:00
|
|
|
|
2014-02-16 16:22:09 +01:00
|
|
|
if (iter->second.mReputation)
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
mFactionReputation[iter->first] = iter->second.mReputation;
|
2014-02-16 16:22:09 +01:00
|
|
|
}
|
2014-02-16 15:06:34 +01:00
|
|
|
|
|
|
|
mDisposition = state.mDisposition;
|
2023-09-24 21:58:10 +04:00
|
|
|
mCrimeDispositionModifier = state.mCrimeDispositionModifier;
|
2014-02-16 15:06:34 +01:00
|
|
|
|
2023-06-03 14:26:37 +02:00
|
|
|
for (size_t i = 0; i < state.mSkills.size(); ++i)
|
2023-06-05 21:21:30 +02:00
|
|
|
{
|
|
|
|
// TODO extend format
|
|
|
|
ESM::RefId id = ESM::Skill::indexToRefId(i);
|
2023-08-18 12:46:45 +04:00
|
|
|
assert(!id.empty());
|
2023-06-05 21:21:30 +02:00
|
|
|
mSkills[id].readState(state.mSkills[i]);
|
|
|
|
}
|
2014-05-12 21:04:02 +02:00
|
|
|
|
|
|
|
mIsWerewolf = state.mIsWerewolf;
|
2014-02-16 15:06:34 +01:00
|
|
|
|
2014-04-14 18:11:04 -04:00
|
|
|
mCrimeId = state.mCrimeId;
|
2014-02-16 15:06:34 +01:00
|
|
|
mBounty = state.mBounty;
|
|
|
|
mReputation = state.mReputation;
|
|
|
|
mWerewolfKills = state.mWerewolfKills;
|
|
|
|
mLevelProgress = state.mLevelProgress;
|
|
|
|
|
2023-06-03 14:26:37 +02:00
|
|
|
for (size_t i = 0; i < state.mSkillIncrease.size(); ++i)
|
2023-08-03 20:21:44 +02:00
|
|
|
mSkillIncreases[ESM::Attribute::indexToRefId(i)] = state.mSkillIncrease[i];
|
2014-02-16 15:56:36 +01:00
|
|
|
|
2023-06-03 14:26:37 +02:00
|
|
|
for (size_t i = 0; i < state.mSpecIncreases.size(); ++i)
|
2016-06-26 03:22:58 +02:00
|
|
|
mSpecIncreases[i] = state.mSpecIncreases[i];
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
for (auto iter(state.mUsedIds.begin()); iter != state.mUsedIds.end(); ++iter)
|
2014-02-16 16:22:09 +01:00
|
|
|
if (store.find(*iter))
|
|
|
|
mUsedIds.insert(*iter);
|
2014-02-16 15:06:34 +01:00
|
|
|
|
|
|
|
mTimeToStartDrowning = state.mTimeToStartDrowning;
|
2014-02-19 18:40:29 +01:00
|
|
|
}
|