mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-02 06:06:41 +00:00
Use average speed for multiple spell projectiles
This commit is contained in:
parent
f1a18027f2
commit
f6c3a62b3e
1 changed files with 19 additions and 5 deletions
|
@ -286,9 +286,26 @@ namespace MWMechanics
|
||||||
/// If \a model is empty, the spell has no ranged effects and should not spawn a projectile.
|
/// If \a model is empty, the spell has no ranged effects and should not spawn a projectile.
|
||||||
void CastSpell::getProjectileInfoAndLaunch (const ESM::EffectList& effects)
|
void CastSpell::getProjectileInfoAndLaunch (const ESM::EffectList& effects)
|
||||||
{
|
{
|
||||||
|
// All projectiles should use the same speed. From observations in the
|
||||||
|
// original engine, this seems to be the average of the constituent effects.
|
||||||
|
// First we get this average speed.
|
||||||
|
float speed = 0;
|
||||||
|
int count = 0;
|
||||||
|
for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.mList.begin());
|
||||||
|
iter!=effects.mList.end(); ++iter)
|
||||||
|
{
|
||||||
|
const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
|
||||||
|
iter->mEffectID);
|
||||||
|
speed += magicEffect->mData.mSpeed;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count != 0)
|
||||||
|
speed /= count;
|
||||||
|
|
||||||
std::string model;
|
std::string model;
|
||||||
std::string sound;
|
std::string sound;
|
||||||
float speed = 0;
|
|
||||||
osg::Vec3f fallbackDirection (0,1,0);
|
osg::Vec3f fallbackDirection (0,1,0);
|
||||||
for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.mList.begin());
|
for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.mList.begin());
|
||||||
iter!=effects.mList.end(); ++iter)
|
iter!=effects.mList.end(); ++iter)
|
||||||
|
@ -311,8 +328,6 @@ namespace MWMechanics
|
||||||
else
|
else
|
||||||
sound = schools[magicEffect->mData.mSchool] + " bolt";
|
sound = schools[magicEffect->mData.mSchool] + " bolt";
|
||||||
|
|
||||||
speed = magicEffect->mData.mSpeed;
|
|
||||||
|
|
||||||
// Fall back to a "caster to target" direction if we have no other means of determining it
|
// Fall back to a "caster to target" direction if we have no other means of determining it
|
||||||
// (e.g. when cast by a non-actor)
|
// (e.g. when cast by a non-actor)
|
||||||
if (!mTarget.isEmpty())
|
if (!mTarget.isEmpty())
|
||||||
|
@ -320,7 +335,6 @@ namespace MWMechanics
|
||||||
osg::Vec3f(mTarget.getRefData().getPosition().asVec3())-
|
osg::Vec3f(mTarget.getRefData().getPosition().asVec3())-
|
||||||
osg::Vec3f(mCaster.getRefData().getPosition().asVec3());
|
osg::Vec3f(mCaster.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
MWBase::Environment::get().getWorld()->launchMagicBolt(model, sound, mId, speed,
|
MWBase::Environment::get().getWorld()->launchMagicBolt(model, sound, mId, speed,
|
||||||
false, effects, mCaster, mSourceName, fallbackDirection);
|
false, effects, mCaster, mSourceName, fallbackDirection);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue