1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 21:32:42 +00:00
OpenMW/apps/openmw/mwmechanics/npcstats.hpp
fteppe 125b21de20 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-12-27 19:15:54 +01:00

140 lines
4.5 KiB
C++

#ifndef GAME_MWMECHANICS_NPCSTATS_H
#define GAME_MWMECHANICS_NPCSTATS_H
#include <map>
#include <set>
#include <string>
#include <vector>
#include <components/esm/refid.hpp>
#include "creaturestats.hpp"
namespace ESM
{
struct Class;
struct NpcStats;
}
namespace MWMechanics
{
/// \brief Additional stats for NPCs
class NpcStats : public CreatureStats
{
int mDisposition;
SkillValue mSkill[ESM::Skill::Length]; // SkillValue.mProgress used by the player only
int mReputation;
int mCrimeId;
// ----- used by the player only, maybe should be moved at some point -------
int mBounty;
int mWerewolfKills;
/// Used only for the player and for NPC's with ranks, modified by scripts; other NPCs have maximum one faction
/// defined in their NPC record
std::map<ESM::RefId, int> mFactionRank;
std::set<ESM::RefId> mExpelled;
std::map<ESM::RefId, int> mFactionReputation;
int mLevelProgress; // 0-10
std::vector<int> mSkillIncreases; // number of skill increases for each attribute (resets after leveling up)
std::vector<int> mSpecIncreases; // number of skill increases for each specialization (accumulates throughout
// the entire game)
std::set<ESM::RefId> mUsedIds;
// ---------------------------------------------------------------------------
/// Countdown to getting damage while underwater
float mTimeToStartDrowning;
bool mIsWerewolf;
public:
NpcStats();
int getBaseDisposition() const;
void setBaseDisposition(int disposition);
int getReputation() const;
void setReputation(int reputation);
int getCrimeId() const;
void setCrimeId(int id);
const SkillValue& getSkill(int index) const;
SkillValue& getSkill(int index);
void setSkill(int index, const SkillValue& value);
int getFactionRank(const ESM::RefId& faction) const;
const std::map<ESM::RefId, int>& getFactionRanks() const;
/// Increase the rank in this faction by 1, if such a rank exists.
void raiseRank(const ESM::RefId& faction);
/// Lower the rank in this faction by 1, if such a rank exists.
void lowerRank(const ESM::RefId& faction);
/// Join this faction, setting the initial rank to 0.
void joinFaction(const ESM::RefId& faction);
const std::set<ESM::RefId>& getExpelled() const { return mExpelled; }
bool getExpelled(const ESM::RefId& factionID) const;
void expell(const ESM::RefId& factionID);
void clearExpelled(const ESM::RefId& factionID);
bool isInFaction(const ESM::RefId& faction) const;
float getSkillProgressRequirement(int skillIndex, const ESM::Class& class_) const;
void useSkill(int skillIndex, const ESM::Class& class_, int usageType = -1, float extraFactor = 1.f);
///< Increase skill by usage.
void increaseSkill(int skillIndex, const ESM::Class& class_, bool preserveProgress, bool readBook = false);
int getLevelProgress() const;
int getLevelupAttributeMultiplier(int attribute) const;
int getSkillIncreasesForSpecialization(int spec) const;
void levelUp();
void updateHealth();
///< Calculate health based on endurance and strength.
/// Called at character creation.
void flagAsUsed(const ESM::RefId& id);
///< @note Id must be lower-case
bool hasBeenUsed(const ESM::RefId& id) const;
///< @note Id must be lower-case
int getBounty() const;
void setBounty(int bounty);
int getFactionReputation(const ESM::RefId& faction) const;
void setFactionReputation(const ESM::RefId& faction, int value);
bool hasSkillsForRank(const ESM::RefId& factionId, int rank) const;
bool isWerewolf() const;
void setWerewolf(bool set);
int getWerewolfKills() const;
/// Increments mWerewolfKills by 1.
void addWerewolfKill();
float getTimeToStartDrowning() const;
/// Sets time left for the creature to drown if it stays underwater.
/// @param time value from [0,20]
void setTimeToStartDrowning(float time);
void writeState(ESM::CreatureStats& state) const;
void writeState(ESM::NpcStats& state) const;
void readState(const ESM::CreatureStats& state);
void readState(const ESM::NpcStats& state);
};
}
#endif