2020-04-04 15:28:53 +00:00
# ifndef MWMECHANICS_SPELLCASTING_H
# define MWMECHANICS_SPELLCASTING_H
2012-05-29 13:13:44 +00:00
2017-06-30 12:27:18 +00:00
# include <components/esm/effectlist.hpp>
2018-08-27 09:38:53 +00:00
# include <components/esm/loadmgef.hpp>
2014-02-23 19:11:05 +00:00
2016-06-17 14:07:16 +00:00
# include "../mwworld/ptr.hpp"
2014-02-23 19:11:05 +00:00
namespace ESM
{
struct Spell ;
struct Ingredient ;
struct Potion ;
struct EffectList ;
}
2012-05-29 13:13:44 +00:00
namespace MWMechanics
{
2015-03-06 08:36:42 +00:00
struct EffectKey ;
2014-01-18 09:52:16 +00:00
2013-11-17 22:15:57 +00:00
class CastSpell
{
private :
2014-06-17 23:41:07 +00:00
MWWorld : : Ptr mCaster ; // May be empty
MWWorld : : Ptr mTarget ; // May be empty
2019-04-08 08:07:44 +00:00
void playSpellCastingEffects ( const std : : vector < ESM : : ENAMstruct > & effects ) ;
2013-11-28 16:31:17 +00:00
public :
2020-04-25 20:56:05 +00:00
bool mStack { false } ;
2013-11-17 22:15:57 +00:00
std : : string mId ; // ID of spell, potion, item etc
std : : string mSourceName ; // Display name for spell, potion, etc
2020-04-25 20:56:05 +00: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 09:15:19 +00:00
bool mFromProjectile ; // True if spell is cast by enchantment of some projectile (arrow, bolt or thrown weapon)
2018-08-03 08:01:31 +00:00
bool mManualSpell ; // True if spell is casted from script and ignores some checks (mana level, success chance, etc.)
2013-11-17 22:15:57 +00:00
public :
2018-08-03 08:01:31 +00:00
CastSpell ( const MWWorld : : Ptr & caster , const MWWorld : : Ptr & target , const bool fromProjectile = false , const bool manualSpell = false ) ;
2013-11-17 22:15:57 +00:00
bool cast ( const ESM : : Spell * spell ) ;
2014-06-17 23:41:07 +00:00
/// @note mCaster must be an actor
2016-02-22 18:37:19 +00:00
/// @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 , bool launchProjectile = true ) ;
2014-06-17 23:41:07 +00:00
/// @note mCaster must be an NPC
2013-11-17 22:15:57 +00:00
bool cast ( const ESM : : Ingredient * ingredient ) ;
2014-06-17 23:41:07 +00:00
2013-11-17 22:15:57 +00:00
bool cast ( const ESM : : Potion * potion ) ;
/// @note Auto detects if spell, ingredient or potion
bool cast ( const std : : string & id ) ;
2019-04-08 08:07:44 +00:00
void playSpellCastingEffects ( const std : : string & spellid , bool enchantment ) ;
2016-07-16 13:47:33 +00:00
2016-09-04 19:22:57 +00:00
/// Launch a bolt with the given effects.
2017-09-20 16:56:32 +00:00
void launchMagicBolt ( ) ;
2016-08-31 10:03:28 +00:00
2014-05-14 03:33:18 +00:00
/// @note \a target can be any type of object, not just actors.
2014-05-15 00:37:20 +00:00
/// @note \a caster can be any type of object, or even an empty object.
2013-11-17 22:15:57 +00:00
void inflict ( const MWWorld : : Ptr & target , const MWWorld : : Ptr & caster ,
2014-01-20 14:48:06 +00:00
const ESM : : EffectList & effects , ESM : : RangeType range , bool reflected = false , bool exploded = false ) ;
2013-11-17 22:15:57 +00:00
2014-05-15 00:37:20 +00:00
/// @note \a caster can be any type of object, or even an empty object.
2015-08-04 15:55:38 +00:00
/// @return was the target suitable for the effect?
bool applyInstantEffect ( const MWWorld : : Ptr & target , const MWWorld : : Ptr & caster , const MWMechanics : : EffectKey & effect , float magnitude ) ;
2013-11-17 22:15:57 +00:00
} ;
2012-05-29 13:13:44 +00:00
}
# endif