2020-04-04 18:28:53 +03:00
|
|
|
#ifndef MWMECHANICS_SPELLCASTING_H
|
|
|
|
#define MWMECHANICS_SPELLCASTING_H
|
2012-05-29 15:13:44 +02:00
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/activespells.hpp>
|
|
|
|
#include <components/esm3/effectlist.hpp>
|
2014-02-23 20:11:05 +01:00
|
|
|
|
2016-06-17 23:07:16 +09:00
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
|
2014-02-23 20:11:05 +01:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct Spell;
|
|
|
|
struct Ingredient;
|
|
|
|
struct Potion;
|
|
|
|
struct EffectList;
|
2022-09-04 15:42:40 +02:00
|
|
|
struct Enchantment;
|
2021-08-27 20:07:50 +02:00
|
|
|
struct MagicEffect;
|
2014-02-23 20:11:05 +01:00
|
|
|
}
|
|
|
|
|
2012-05-29 15:13:44 +02:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
2015-03-06 21:36:42 +13:00
|
|
|
struct EffectKey;
|
2014-01-18 10:52:16 +01:00
|
|
|
|
2013-11-17 23:15:57 +01:00
|
|
|
class CastSpell
|
|
|
|
{
|
|
|
|
private:
|
2014-06-18 01:41:07 +02:00
|
|
|
MWWorld::Ptr mCaster; // May be empty
|
|
|
|
MWWorld::Ptr mTarget; // May be empty
|
2019-04-08 12:07:44 +04:00
|
|
|
|
2022-09-04 15:09:31 +02:00
|
|
|
void playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects) const;
|
2019-04-08 12:07:44 +04:00
|
|
|
|
2022-09-04 14:51:19 +02:00
|
|
|
void explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const;
|
|
|
|
|
|
|
|
/// Launch a bolt with the given effects.
|
2022-09-04 15:09:31 +02:00
|
|
|
void launchMagicBolt() const;
|
2022-09-04 14:01:36 +02:00
|
|
|
|
2013-11-28 17:31:17 +01:00
|
|
|
public:
|
2013-11-17 23:15:57 +01:00
|
|
|
std::string mId; // ID of spell, potion, item etc
|
|
|
|
std::string mSourceName; // Display name for spell, potion, etc
|
2020-04-25 23:56:05 +03:00
|
|
|
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)
|
2016-12-19 10:15:19 +01:00
|
|
|
bool mFromProjectile; // True if spell is cast by enchantment of some projectile (arrow, bolt or thrown weapon)
|
2018-08-03 12:01:31 +04:00
|
|
|
bool mManualSpell; // True if spell is casted from script and ignores some checks (mana level, success chance,
|
|
|
|
// etc.)
|
2021-08-27 20:07:50 +02:00
|
|
|
int mSlot{ 0 };
|
|
|
|
ESM::ActiveSpells::EffectType mType{ ESM::ActiveSpells::Type_Temporary };
|
2013-11-17 23:15:57 +01:00
|
|
|
|
2018-08-03 12:01:31 +04:00
|
|
|
CastSpell(const MWWorld::Ptr& caster, const MWWorld::Ptr& target, const bool fromProjectile = false,
|
|
|
|
const bool manualSpell = false);
|
2013-11-17 23:15:57 +01:00
|
|
|
|
|
|
|
bool cast(const ESM::Spell* spell);
|
2014-06-18 01:41:07 +02:00
|
|
|
|
|
|
|
/// @note mCaster must be an actor
|
2016-02-22 19:37:19 +01:00
|
|
|
/// @param launchProjectile If set to false, "on target" effects are directly applied instead of being launched
|
|
|
|
/// as projectile originating from the caster.
|
2021-08-27 20:07:50 +02:00
|
|
|
bool cast(const MWWorld::Ptr& item, int slot, bool launchProjectile = true);
|
2014-06-18 01:41:07 +02:00
|
|
|
|
|
|
|
/// @note mCaster must be an NPC
|
2013-11-17 23:15:57 +01:00
|
|
|
bool cast(const ESM::Ingredient* ingredient);
|
2014-06-18 01:41:07 +02:00
|
|
|
|
2013-11-17 23:15:57 +01:00
|
|
|
bool cast(const ESM::Potion* potion);
|
|
|
|
|
|
|
|
/// @note Auto detects if spell, ingredient or potion
|
|
|
|
bool cast(const std::string& id);
|
|
|
|
|
2022-09-04 15:42:40 +02:00
|
|
|
void playSpellCastingEffects(const ESM::Enchantment* enchantment) const;
|
|
|
|
|
|
|
|
void playSpellCastingEffects(const ESM::Spell* spell) const;
|
2016-07-16 22:47:33 +09:00
|
|
|
|
2014-05-14 05:33:18 +02:00
|
|
|
/// @note \a target can be any type of object, not just actors.
|
2022-09-04 15:09:31 +02:00
|
|
|
void inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range,
|
|
|
|
bool exploded = false) const;
|
2013-11-17 23:15:57 +01:00
|
|
|
};
|
2021-08-27 20:07:50 +02:00
|
|
|
|
|
|
|
void playEffects(const MWWorld::Ptr& target, const ESM::MagicEffect& magicEffect, bool playNonLooping = true);
|
2012-05-29 15:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|