You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/components/esm3/activespells.hpp

106 lines
3.3 KiB
C++

#ifndef OPENMW_ESM_ACTIVESPELLS_H
#define OPENMW_ESM_ACTIVESPELLS_H
#include "cellref.hpp"
#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!
2 years ago
#include "components/esm/refid.hpp"
#include "timestamp.hpp"
#include <string>
#include <variant>
#include <vector>
namespace ESM
{
class ESMReader;
class ESMWriter;
// Parameters of an effect concerning lasting effects.
// Note we are not using ENAMstruct since the magnitude may be modified by magic resistance, etc.
struct ActiveEffect
{
enum Flags
{
Flag_None = 0,
Flag_Applied = 1 << 0,
Flag_Remove = 1 << 1,
Flag_Ignore_Resistances = 1 << 2,
Flag_Ignore_Reflect = 1 << 3,
Flag_Ignore_SpellAbsorption = 1 << 4
};
int32_t mEffectId;
float mMagnitude;
float mMinMagnitude;
float mMaxMagnitude;
std::variant<RefId, int> mArg; // skill, attribute, or summon
float mDuration;
float mTimeLeft;
int32_t mEffectIndex;
int32_t mFlags;
RefId getSkillOrAttribute() const;
int getActorId() const;
};
// format 0, saved games only
struct ActiveSpells
{
enum Flags : uint32_t
{
Flag_Temporary = 1 << 0, //!< Effect will end automatically once its duration ends.
Flag_Equipment = 1 << 1, //!< Effect will end automatically if item is unequipped.
Flag_SpellStore = 1 << 2, //!< Effect will end automatically if removed from the actor's spell store.
Flag_AffectsBaseValues = 1 << 3, //!< Effects will affect base values instead of current values.
Flag_Stackable
= 1 << 4, //!< Effect can stack. If this flag is not set, spells from the same caster and item cannot stack.
Flag_Lua
= 1 << 5, //!< Effect was added via Lua. Should not do any vfx/sound as this is handled by Lua scripts.
};
struct ActiveSpellParams
{
RefId mActiveSpellId;
RefId mSourceSpellId;
std::vector<ActiveEffect> mEffects;
std::string mDisplayName;
int32_t mCasterActorId;
RefNum mItem;
Flags mFlags;
int32_t mWorsenings;
TimeStamp mNextWorsening;
};
std::vector<ActiveSpellParams> mSpells;
std::vector<ActiveSpellParams> mQueue;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
namespace Compatibility
{
namespace ActiveSpells
{
enum EffectType
{
Type_Temporary,
Type_Ability,
Type_Enchantment,
Type_Permanent,
Type_Consumable,
};
using Flags = ESM::ActiveSpells::Flags;
constexpr Flags Type_Temporary_Flags = Flags::Flag_Temporary;
constexpr Flags Type_Consumable_Flags = static_cast<Flags>(Flags::Flag_Temporary | Flags::Flag_Stackable);
constexpr Flags Type_Permanent_Flags = Flags::Flag_SpellStore;
constexpr Flags Type_Ability_Flags
= static_cast<Flags>(Flags::Flag_SpellStore | Flags::Flag_AffectsBaseValues);
constexpr Flags Type_Enchantment_Flags = Flags::Flag_Equipment;
}
}
}
#endif