mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 06:39:42 +00:00
Reuse CastSpell for explosions
This commit is contained in:
parent
8d66b2e75d
commit
325081dc07
2 changed files with 10 additions and 15 deletions
|
@ -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<ESM::Spell>().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<ESM::ENAMstruct>& effects)
|
||||
void CastSpell::playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects) const
|
||||
{
|
||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
std::vector<std::string> addedEffects;
|
||||
|
|
|
@ -25,12 +25,12 @@ namespace MWMechanics
|
|||
MWWorld::Ptr mCaster; // May be empty
|
||||
MWWorld::Ptr mTarget; // May be empty
|
||||
|
||||
void playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects);
|
||||
void playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& 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);
|
||||
|
|
Loading…
Reference in a new issue