spellcasting.hpp 2.39 KB
Newer Older
1 2 3
#ifndef MWMECHANICS_SPELLSUCCESS_H
#define MWMECHANICS_SPELLSUCCESS_H

4
#include "../mwworld/ptr.hpp"
5

6 7
#include <OgreVector3.h>

8 9
namespace MWMechanics
{
10 11 12
    class EffectKey;

    ESM::Skill::SkillEnum spellSchoolToSkill(int school);
13 14

    /**
scrawl's avatar
scrawl committed
15
     * @param spell spell to cast
16
     * @param actor calculate spell success chance for this actor (depends on actor's skills)
17
     * @param effectiveSchool the spell's effective school (relevant for skill progress) will be written here
18 19 20
     * @attention actor has to be an NPC and not a creature!
     * @return success chance from 0 to 100 (in percent)
     */
21 22
    float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool = NULL);
    float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = NULL);
23

24 25
    int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor);
    int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor);
26

scrawl's avatar
scrawl committed
27
    /// @return >=100 for fully resisted. can also return negative value for damage amplification.
28
    float getEffectResistance (short effectId, const MWWorld::Ptr& actor, const MWWorld::Ptr& caster, const ESM::Spell* spell = NULL);
scrawl's avatar
scrawl committed
29

30
    float getEffectMultiplier(short effectId, const MWWorld::Ptr& actor, const MWWorld::Ptr& caster, const ESM::Spell* spell = NULL);
31 32 33 34 35 36

    class CastSpell
    {
    private:
        MWWorld::Ptr mCaster;
        MWWorld::Ptr mTarget;
scrawl's avatar
scrawl committed
37
    public:
38 39 40
        bool mStack;
        std::string mId; // ID of spell, potion, item etc
        std::string mSourceName; // Display name for spell, potion, etc
41
        Ogre::Vector3 mHitPosition; // Used for spawning area orb
42 43 44 45 46 47 48 49 50 51 52 53 54

    public:
        CastSpell(const MWWorld::Ptr& caster, const MWWorld::Ptr& target);

        bool cast (const ESM::Spell* spell);
        bool cast (const MWWorld::Ptr& item);
        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 inflict (const MWWorld::Ptr& target, const MWWorld::Ptr& caster,
55
                      const ESM::EffectList& effects, ESM::RangeType range, bool reflected=false, bool exploded=false);
56

57
        void applyInstantEffect (const MWWorld::Ptr& target, const MWWorld::Ptr& caster, const MWMechanics::EffectKey& effect, float magnitude);
58 59
    };

60 61 62
}

#endif