mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
125b21de20
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!
80 lines
2.8 KiB
C++
80 lines
2.8 KiB
C++
#ifndef MWMECHANICS_SPELLCASTING_H
|
|
#define MWMECHANICS_SPELLCASTING_H
|
|
|
|
#include <components/esm3/activespells.hpp>
|
|
#include <components/esm3/effectlist.hpp>
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
namespace ESM
|
|
{
|
|
struct Spell;
|
|
struct Ingredient;
|
|
struct Potion;
|
|
struct EffectList;
|
|
struct Enchantment;
|
|
struct MagicEffect;
|
|
}
|
|
|
|
namespace MWMechanics
|
|
{
|
|
struct EffectKey;
|
|
|
|
class CastSpell
|
|
{
|
|
private:
|
|
MWWorld::Ptr mCaster; // May be empty
|
|
MWWorld::Ptr mTarget; // May be empty
|
|
|
|
void playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects) const;
|
|
|
|
void explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const;
|
|
|
|
/// Launch a bolt with the given effects.
|
|
void launchMagicBolt() const;
|
|
|
|
public:
|
|
ESM::RefId mId; // ID of spell, potion, item etc
|
|
std::string mSourceName; // Display name for spell, potion, etc
|
|
osg::Vec3f mHitPosition{ 0, 0, 0 }; // Used for spawning area orb
|
|
bool mAlwaysSucceed{
|
|
false
|
|
}; // Always succeed spells casted by NPCs/creatures regardless of their chance (default: false)
|
|
bool mFromProjectile; // True if spell is cast by enchantment of some projectile (arrow, bolt or thrown weapon)
|
|
bool mManualSpell; // True if spell is casted from script and ignores some checks (mana level, success chance,
|
|
// etc.)
|
|
int mSlot{ 0 };
|
|
ESM::ActiveSpells::EffectType mType{ ESM::ActiveSpells::Type_Temporary };
|
|
|
|
CastSpell(const MWWorld::Ptr& caster, const MWWorld::Ptr& target, const bool fromProjectile = false,
|
|
const bool manualSpell = false);
|
|
|
|
bool cast(const ESM::Spell* spell);
|
|
|
|
/// @note mCaster must be an actor
|
|
/// @param launchProjectile If set to false, "on target" effects are directly applied instead of being launched
|
|
/// as projectile originating from the caster.
|
|
bool cast(const MWWorld::Ptr& item, int slot, bool launchProjectile = true);
|
|
|
|
/// @note mCaster must be an NPC
|
|
bool cast(const ESM::Ingredient* ingredient);
|
|
|
|
bool cast(const ESM::Potion* potion);
|
|
|
|
/// @note Auto detects if spell, ingredient or potion
|
|
bool cast(const ESM::RefId& id);
|
|
|
|
void playSpellCastingEffects(const ESM::Enchantment* enchantment) const;
|
|
|
|
void playSpellCastingEffects(const ESM::Spell* spell) const;
|
|
|
|
/// @note \a target can be any type of object, not just actors.
|
|
void inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range,
|
|
bool exploded = false) const;
|
|
};
|
|
|
|
void playEffects(const MWWorld::Ptr& target, const ESM::MagicEffect& magicEffect, bool playNonLooping = true);
|
|
}
|
|
|
|
#endif
|