OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
spellcasting.hpp
Go to the documentation of this file.
1 #ifndef MWMECHANICS_SPELLSUCCESS_H
2 #define MWMECHANICS_SPELLSUCCESS_H
3 
5 
6 #include "../mwworld/ptr.hpp"
7 
8 namespace ESM
9 {
10  struct Spell;
11  struct Ingredient;
12  struct Potion;
13  struct EffectList;
14 }
15 
16 namespace MWMechanics
17 {
18  struct EffectKey;
19  class MagicEffects;
20  class CreatureStats;
21 
23 
24  bool isSummoningEffect(int effectId);
25 
34  float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool = NULL, bool cap=true);
35  float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = NULL, bool cap=true);
36 
37  int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor);
38  int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor);
39 
41  bool spellIncreasesSkill(const ESM::Spell* spell);
42  bool spellIncreasesSkill(const std::string& spellId);
43 
46  float getEffectResistanceAttribute (short effectId, const MagicEffects* actorEffects);
47 
52  float getEffectResistance (short effectId, const MWWorld::Ptr& actor, const MWWorld::Ptr& caster,
53  const ESM::Spell* spell = NULL, const MagicEffects* effects = NULL);
54 
59  float getEffectMultiplier(short effectId, const MWWorld::Ptr& actor, const MWWorld::Ptr& caster,
60  const ESM::Spell* spell = NULL, const MagicEffects* effects = NULL);
61 
62  bool checkEffectTarget (int effectId, const MWWorld::Ptr& target, const MWWorld::Ptr& caster, bool castByPlayer);
63 
64  int getEffectiveEnchantmentCastCost (float castCost, const MWWorld::Ptr& actor);
65 
68  bool effectTick(CreatureStats& creatureStats, const MWWorld::Ptr& actor, const MWMechanics::EffectKey& effectKey, float magnitude);
69 
70  class CastSpell
71  {
72  private:
73  MWWorld::Ptr mCaster; // May be empty
74  MWWorld::Ptr mTarget; // May be empty
75  public:
76  bool mStack;
77  std::string mId; // ID of spell, potion, item etc
78  std::string mSourceName; // Display name for spell, potion, etc
79  osg::Vec3f mHitPosition; // Used for spawning area orb
80  bool mAlwaysSucceed; // Always succeed spells casted by NPCs/creatures regardless of their chance (default: false)
81  bool mFromProjectile; // True if spell is cast by enchantment of some projectile (arrow, bolt or thrown weapon)
82 
83  public:
84  CastSpell(const MWWorld::Ptr& caster, const MWWorld::Ptr& target, const bool fromProjectile=false);
85 
86  bool cast (const ESM::Spell* spell);
87 
90  bool cast (const MWWorld::Ptr& item, bool launchProjectile=true);
91 
93  bool cast (const ESM::Ingredient* ingredient);
94 
95  bool cast (const ESM::Potion* potion);
96 
98  bool cast (const std::string& id);
99 
100  void playSpellCastingEffects(const std::string &spellid);
101 
103  void launchMagicBolt (const ESM::EffectList& effects);
104 
107  void inflict (const MWWorld::Ptr& target, const MWWorld::Ptr& caster,
108  const ESM::EffectList& effects, ESM::RangeType range, bool reflected=false, bool exploded=false);
109 
112  bool applyInstantEffect (const MWWorld::Ptr& target, const MWWorld::Ptr& caster, const MWMechanics::EffectKey& effect, float magnitude);
113  };
114 
115 }
116 
117 #endif
float getEffectMultiplier(short effectId, const MWWorld::Ptr &actor, const MWWorld::Ptr &caster, const ESM::Spell *spell, const MagicEffects *effects)
Definition: spellcasting.cpp:220
float getEffectResistance(short effectId, const MWWorld::Ptr &actor, const MWWorld::Ptr &caster, const ESM::Spell *spell, const MagicEffects *effects)
Definition: spellcasting.cpp:164
ESM::Skill::SkillEnum spellSchoolToSkill(int school)
Definition: spellcasting.cpp:34
Definition: loadingr.hpp:16
bool checkEffectTarget(int effectId, const MWWorld::Ptr &target, const MWWorld::Ptr &caster, bool castByPlayer)
Check if the given effect can be applied to the target. If castByPlayer, emits a message box on failu...
Definition: spellcasting.cpp:228
bool mFromProjectile
Definition: spellcasting.hpp:81
Definition: loadspel.hpp:14
CastSpell(const MWWorld::Ptr &caster, const MWWorld::Ptr &target, const bool fromProjectile=false)
Definition: spellcasting.cpp:277
MWWorld::Ptr mTarget
Definition: spellcasting.hpp:74
Definition: spellcasting.hpp:70
int getSpellSchool(const std::string &spellId, const MWWorld::Ptr &actor)
Definition: spellcasting.cpp:115
bool applyInstantEffect(const MWWorld::Ptr &target, const MWWorld::Ptr &caster, const MWMechanics::EffectKey &effect, float magnitude)
Definition: spellcasting.cpp:586
std::string mSourceName
Definition: spellcasting.hpp:78
RangeType
Definition: defs.hpp:27
bool mAlwaysSucceed
Definition: spellcasting.hpp:80
MWWorld::Ptr mCaster
Definition: spellcasting.hpp:73
Definition: magiceffects.hpp:17
bool mStack
Definition: spellcasting.hpp:76
int getEffectiveEnchantmentCastCost(float castCost, const MWWorld::Ptr &actor)
Definition: spellcasting.cpp:968
bool isSummoningEffect(int effectId)
Definition: spellcasting.cpp:980
float getSpellSuccessChance(const ESM::Spell *spell, const MWWorld::Ptr &actor, int *effectiveSchool, bool cap)
Definition: spellcasting.cpp:47
std::string mId
Definition: spellcasting.hpp:77
bool spellIncreasesSkill(const ESM::Spell *spell)
Get whether or not the given spell contributes to skill progress.
Definition: spellcasting.cpp:129
void playSpellCastingEffects(const std::string &spellid)
Definition: spellcasting.cpp:926
bool effectTick(CreatureStats &creatureStats, const MWWorld::Ptr &actor, const EffectKey &effectKey, float magnitude)
Definition: spellcasting.cpp:1037
float getEffectResistanceAttribute(short effectId, const MagicEffects *actorEffects)
Definition: spellcasting.cpp:143
osg::Vec3f mHitPosition
Definition: spellcasting.hpp:79
bool cast(const ESM::Spell *spell)
Definition: spellcasting.cpp:792
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
Definition: loadalch.hpp:18
SkillEnum
Definition: loadskil.hpp:45
void launchMagicBolt(const ESM::EffectList &effects)
Launch a bolt with the given effects.
Definition: spellcasting.cpp:287
EffectList, ENAM subrecord.
Definition: effectlist.hpp:33
void inflict(const MWWorld::Ptr &target, const MWWorld::Ptr &caster, const ESM::EffectList &effects, ESM::RangeType range, bool reflected=false, bool exploded=false)
Definition: spellcasting.cpp:302