diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 8c8f932467..9fbf601463 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -122,18 +122,13 @@ namespace MWMechanics if (applyPair.first == ignore) continue; - MWMechanics::CastSpell cast(mCaster, applyPair.first); - cast.mHitPosition = mHitPosition; - cast.mId = mId; - cast.mSourceName = mSourceName; - cast.mSlot = mSlot; ESM::EffectList effectsToApply; effectsToApply.mList = applyPair.second; - cast.inflict(applyPair.first, effectsToApply, rangeType, true); + inflict(applyPair.first, effectsToApply, rangeType, true); } } - void CastSpell::launchMagicBolt () + void CastSpell::launchMagicBolt() const { osg::Vec3f fallbackDirection(0, 1, 0); osg::Vec3f offset(0, 0, 0); @@ -150,7 +145,7 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->launchMagicBolt(mId, mCaster, fallbackDirection, mSlot); } - void CastSpell::inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range, bool exploded) + void CastSpell::inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range, bool exploded) const { const bool targetIsActor = !target.isEmpty() && target.getClass().isActor(); if (targetIsActor) @@ -285,7 +280,7 @@ namespace MWMechanics } } - bool CastSpell::cast(const std::string &id) + bool CastSpell::cast(const std::string& id) { const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (const auto spell = store.get().search(id)) @@ -527,7 +522,7 @@ namespace MWMechanics return true; } - void CastSpell::playSpellCastingEffects(std::string_view spellid, bool enchantment) + void CastSpell::playSpellCastingEffects(std::string_view spellid, bool enchantment) const { const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (enchantment) @@ -542,7 +537,7 @@ namespace MWMechanics } } - void CastSpell::playSpellCastingEffects(const std::vector& effects) + void CastSpell::playSpellCastingEffects(const std::vector& effects) const { const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); std::vector addedEffects; diff --git a/apps/openmw/mwmechanics/spellcasting.hpp b/apps/openmw/mwmechanics/spellcasting.hpp index c4ba8631b4..e92902b175 100644 --- a/apps/openmw/mwmechanics/spellcasting.hpp +++ b/apps/openmw/mwmechanics/spellcasting.hpp @@ -25,12 +25,12 @@ namespace MWMechanics MWWorld::Ptr mCaster; // May be empty MWWorld::Ptr mTarget; // May be empty - void playSpellCastingEffects(const std::vector& effects); + void playSpellCastingEffects(const std::vector& effects) const; void explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const; /// Launch a bolt with the given effects. - void launchMagicBolt(); + void launchMagicBolt() const; public: std::string mId; // ID of spell, potion, item etc @@ -58,10 +58,10 @@ namespace MWMechanics /// @note Auto detects if spell, ingredient or potion bool cast (const std::string& id); - void playSpellCastingEffects(std::string_view spellid, bool enchantment); + void playSpellCastingEffects(std::string_view spellid, bool enchantment) const; /// @note \a target can be any type of object, not just actors. - void inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range, bool exploded = false); + void inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range, bool exploded = false) const; }; void playEffects(const MWWorld::Ptr& target, const ESM::MagicEffect& magicEffect, bool playNonLooping = true);