1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 09:36:37 +00:00
OpenMW/apps/openmw/mwmechanics/spellcasting.hpp

72 lines
2.7 KiB
C++
Raw Normal View History

2020-04-04 15:28:53 +00:00
#ifndef MWMECHANICS_SPELLCASTING_H
#define MWMECHANICS_SPELLCASTING_H
#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;
}
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);
2013-11-28 16:31:17 +00:00
public:
2020-04-25 20:56:05 +00:00
bool mStack{false};
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)
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.)
public:
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, 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 std::string& id);
void playSpellCastingEffects(const std::string &spellid, bool enchantment);
/// Launch a bolt with the given effects.
void launchMagicBolt ();
/// @note \a target can be any type of object, not just actors.
/// @note \a caster can be any type of object, or even an empty object.
void inflict (const MWWorld::Ptr& target, const MWWorld::Ptr& caster,
const ESM::EffectList& effects, ESM::RangeType range, bool reflected=false, bool exploded=false);
/// @note \a caster can be any type of object, or even an empty object.
/// @return was the target suitable for the effect?
bool applyInstantEffect (const MWWorld::Ptr& target, const MWWorld::Ptr& caster, const MWMechanics::EffectKey& effect, float magnitude);
};
}
#endif