mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-09 12:07:51 +03: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)
|
if (applyPair.first == ignore)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MWMechanics::CastSpell cast(mCaster, applyPair.first);
|
|
||||||
cast.mHitPosition = mHitPosition;
|
|
||||||
cast.mId = mId;
|
|
||||||
cast.mSourceName = mSourceName;
|
|
||||||
cast.mSlot = mSlot;
|
|
||||||
ESM::EffectList effectsToApply;
|
ESM::EffectList effectsToApply;
|
||||||
effectsToApply.mList = applyPair.second;
|
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 fallbackDirection(0, 1, 0);
|
||||||
osg::Vec3f offset(0, 0, 0);
|
osg::Vec3f offset(0, 0, 0);
|
||||||
|
@ -150,7 +145,7 @@ namespace MWMechanics
|
||||||
MWBase::Environment::get().getWorld()->launchMagicBolt(mId, mCaster, fallbackDirection, mSlot);
|
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();
|
const bool targetIsActor = !target.isEmpty() && target.getClass().isActor();
|
||||||
if (targetIsActor)
|
if (targetIsActor)
|
||||||
|
@ -527,7 +522,7 @@ namespace MWMechanics
|
||||||
return true;
|
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();
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
if (enchantment)
|
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();
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
std::vector<std::string> addedEffects;
|
std::vector<std::string> addedEffects;
|
||||||
|
|
|
@ -25,12 +25,12 @@ namespace MWMechanics
|
||||||
MWWorld::Ptr mCaster; // May be empty
|
MWWorld::Ptr mCaster; // May be empty
|
||||||
MWWorld::Ptr mTarget; // 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;
|
void explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const;
|
||||||
|
|
||||||
/// Launch a bolt with the given effects.
|
/// Launch a bolt with the given effects.
|
||||||
void launchMagicBolt();
|
void launchMagicBolt() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string mId; // ID of spell, potion, item etc
|
std::string mId; // ID of spell, potion, item etc
|
||||||
|
@ -58,10 +58,10 @@ namespace MWMechanics
|
||||||
/// @note Auto detects if spell, ingredient or potion
|
/// @note Auto detects if spell, ingredient or potion
|
||||||
bool cast (const std::string& id);
|
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.
|
/// @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);
|
void playEffects(const MWWorld::Ptr& target, const ESM::MagicEffect& magicEffect, bool playNonLooping = true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue