2012-09-23 18:11:08 +00:00
|
|
|
#ifndef OPENMW_ESM_NPC_H
|
|
|
|
#define OPENMW_ESM_NPC_H
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2023-06-03 11:27:45 +00:00
|
|
|
#include <array>
|
2012-09-17 07:37:50 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2012-08-29 17:35:06 +00:00
|
|
|
#include "aipackage.hpp"
|
2023-12-17 14:16:32 +00:00
|
|
|
#include "components/esm/attr.hpp"
|
2022-01-22 14:58:41 +00:00
|
|
|
#include "components/esm/defs.hpp"
|
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 11:17:09 +00:00
|
|
|
#include "components/esm/refid.hpp"
|
2010-02-25 18:01:24 +00:00
|
|
|
#include "loadcont.hpp"
|
2013-12-08 20:47:43 +00:00
|
|
|
#include "loadskil.hpp"
|
2012-09-17 07:37:50 +00:00
|
|
|
#include "spelllist.hpp"
|
2015-03-08 19:44:41 +00:00
|
|
|
#include "transport.hpp"
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2022-04-11 22:18:39 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
2012-09-30 20:51:54 +00:00
|
|
|
|
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
|
|
|
|
2010-02-25 18:01:24 +00:00
|
|
|
/*
|
|
|
|
* NPC definition
|
|
|
|
*/
|
|
|
|
|
2012-09-30 19:34:53 +00:00
|
|
|
struct NPC
|
2010-02-25 18:01:24 +00:00
|
|
|
{
|
2022-06-04 14:34:23 +00:00
|
|
|
constexpr static RecNameInts sRecordId = REC_NPC_;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2015-06-14 00:31:00 +00:00
|
|
|
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
2021-10-11 22:18:23 +00:00
|
|
|
static std::string_view getRecordType() { return "NPC"; }
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2010-02-25 18:01:24 +00:00
|
|
|
// Services
|
|
|
|
enum Services
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2010-02-25 18:01:24 +00:00
|
|
|
// This merchant buys:
|
2011-01-05 21:18:21 +00:00
|
|
|
Weapon = 0x00001,
|
2012-08-29 17:35:06 +00:00
|
|
|
Armor = 0x00002,
|
2011-01-05 21:18:21 +00:00
|
|
|
Clothing = 0x00004,
|
2012-08-29 17:35:06 +00:00
|
|
|
Books = 0x00008,
|
2011-01-05 21:18:21 +00:00
|
|
|
Ingredients = 0x00010,
|
2012-08-29 17:35:06 +00:00
|
|
|
Picks = 0x00020,
|
2011-01-05 21:18:21 +00:00
|
|
|
Probes = 0x00040,
|
|
|
|
Lights = 0x00080,
|
|
|
|
Apparatus = 0x00100,
|
|
|
|
RepairItem = 0x00200,
|
2012-08-29 17:35:06 +00:00
|
|
|
Misc = 0x00400,
|
2013-04-07 19:38:53 +00:00
|
|
|
Potions = 0x02000,
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2017-09-25 17:52:20 +00:00
|
|
|
AllItems = Weapon | Armor | Clothing | Books | Ingredients | Picks | Probes | Lights | Apparatus
|
|
|
|
| RepairItem | Misc | Potions,
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2010-02-25 18:01:24 +00:00
|
|
|
// Other services
|
2011-01-05 21:18:21 +00:00
|
|
|
Spells = 0x00800,
|
|
|
|
MagicItems = 0x01000,
|
2017-09-25 15:47:30 +00:00
|
|
|
Training = 0x04000,
|
2011-01-05 21:18:21 +00:00
|
|
|
Spellmaking = 0x08000,
|
2022-09-22 18:26:05 +00:00
|
|
|
Enchanting = 0x10000,
|
2011-01-05 21:18:21 +00:00
|
|
|
Repair = 0x20000
|
2022-09-22 18:26:05 +00:00
|
|
|
};
|
|
|
|
|
2010-02-25 18:01:24 +00:00
|
|
|
enum Flags
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2018-12-31 14:55:46 +00:00
|
|
|
Female = 0x01,
|
2010-02-25 18:01:24 +00:00
|
|
|
Essential = 0x02,
|
2018-12-31 14:55:46 +00:00
|
|
|
Respawn = 0x04,
|
|
|
|
Base = 0x08,
|
|
|
|
Autocalc = 0x10
|
2022-09-22 18:26:05 +00:00
|
|
|
};
|
|
|
|
|
2013-12-08 20:47:43 +00:00
|
|
|
enum NpcType
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2013-12-08 20:47:43 +00:00
|
|
|
NPC_WITH_AUTOCALCULATED_STATS = 12,
|
|
|
|
NPC_DEFAULT = 52
|
2022-09-22 18:26:05 +00:00
|
|
|
};
|
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
struct NPDTstruct52
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2023-10-24 17:25:52 +00:00
|
|
|
int16_t mLevel;
|
2023-12-17 14:16:32 +00:00
|
|
|
std::array<unsigned char, Attribute::Length> mAttributes;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2014-09-06 15:04:50 +00:00
|
|
|
// mSkill can grow up to 200, it must be unsigned
|
2023-06-03 11:27:45 +00:00
|
|
|
std::array<unsigned char, Skill::Length> mSkills;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2023-10-24 17:25:52 +00:00
|
|
|
uint16_t mHealth, mMana, mFatigue;
|
2018-09-03 13:30:21 +00:00
|
|
|
unsigned char mDisposition, mReputation, mRank;
|
2023-10-24 17:25:52 +00:00
|
|
|
int32_t mGold;
|
2012-09-17 07:37:50 +00:00
|
|
|
}; // 52 bytes
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2014-09-03 12:40:32 +00:00
|
|
|
unsigned char mNpdtType;
|
2017-09-25 15:47:30 +00:00
|
|
|
// Worth noting when saving the struct:
|
2011-01-05 21:18:21 +00:00
|
|
|
// Although we might read a NPDTstruct12 in, we use NPDTstruct52 internally
|
2018-05-08 22:25:07 +00:00
|
|
|
NPDTstruct52 mNpdt;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
int getFactionRank() const; /// wrapper for mNpdt*, -1 = no rank
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2023-10-24 17:25:52 +00:00
|
|
|
int32_t mBloodType;
|
2011-01-05 21:18:21 +00:00
|
|
|
unsigned char mFlags;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
InventoryList mInventory;
|
2012-09-17 07:37:50 +00:00
|
|
|
SpellList mSpells;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2012-08-29 17:35:06 +00:00
|
|
|
AIData mAiData;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2015-03-08 19:44:41 +00:00
|
|
|
Transport mTransport;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2015-03-08 19:44:41 +00:00
|
|
|
const std::vector<Transport::Dest>& getTransport() const;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2012-08-29 17:35:06 +00:00
|
|
|
AIPackageList mAiPackage;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2023-10-24 17:25:52 +00:00
|
|
|
uint32_t mRecordFlags;
|
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 11:17:09 +00:00
|
|
|
RefId mId, mRace, mClass, mFaction, mScript;
|
|
|
|
std::string mModel, mName;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2012-08-29 17:35:06 +00:00
|
|
|
// body parts
|
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 11:17:09 +00:00
|
|
|
RefId mHair, mHead;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
void load(ESMReader& esm, bool& isDeleted);
|
|
|
|
void save(ESMWriter& esm, bool isDeleted = false) const;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-05-06 12:10:43 +00:00
|
|
|
bool isMale() const;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-05-06 12:10:43 +00:00
|
|
|
void setIsMale(bool value);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2013-05-06 12:10:43 +00:00
|
|
|
void blank();
|
|
|
|
///< Set record to default state (does not touch the ID).
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
/// Resets the mNpdt object
|
2018-05-08 22:25:07 +00:00
|
|
|
void blankNpdt();
|
2010-02-25 18:01:24 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|