mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 21:53:52 +00:00
Send lists of models and sounds to launchMagicBolt
This commit is contained in:
parent
96e1726e4d
commit
10842462c7
6 changed files with 44 additions and 48 deletions
|
@ -486,7 +486,7 @@ namespace MWBase
|
|||
|
||||
virtual void castSpell (const MWWorld::Ptr& actor) = 0;
|
||||
|
||||
virtual void launchMagicBolt (const std::string& model, const std::string& sound, const std::string& spellId,
|
||||
virtual void launchMagicBolt (const std::vector<std::string>& models, const std::vector<std::string>& sounds, const std::string& spellId,
|
||||
float speed, bool stack, const ESM::EffectList& effects,
|
||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection) = 0;
|
||||
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
||||
|
|
|
@ -304,11 +304,12 @@ namespace MWMechanics
|
|||
speed /= count;
|
||||
|
||||
std::string model;
|
||||
std::vector<std::string> models;
|
||||
std::string sound;
|
||||
std::vector<std::string> sounds;
|
||||
ESM::EffectList projectileEffects;
|
||||
|
||||
osg::Vec3f fallbackDirection (0,1,0);
|
||||
|
||||
bool isFirstProjectile = true;
|
||||
osg::Vec3f fallbackDirection (0,1,0);
|
||||
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.mList.begin());
|
||||
iter!=effects.mList.end(); ++iter)
|
||||
|
@ -322,6 +323,7 @@ namespace MWMechanics
|
|||
model = magicEffect->mBolt;
|
||||
if (model.empty())
|
||||
model = "VFX_DefaultBolt";
|
||||
models.push_back(model);
|
||||
|
||||
static const std::string schools[] = {
|
||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||
|
@ -330,6 +332,9 @@ namespace MWMechanics
|
|||
sound = magicEffect->mBoltSound;
|
||||
else
|
||||
sound = schools[magicEffect->mData.mSchool] + " bolt";
|
||||
sounds.push_back(sound);
|
||||
projectileEffects.mList.push_back(*iter);
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
@ -338,19 +343,8 @@ namespace MWMechanics
|
|||
osg::Vec3f(mTarget.getRefData().getPosition().asVec3())-
|
||||
osg::Vec3f(mCaster.getRefData().getPosition().asVec3());
|
||||
|
||||
// Only send the effects data with the first projectile, so we don't have the impact sounds
|
||||
// playing multiple times.
|
||||
if (isFirstProjectile)
|
||||
MWBase::Environment::get().getWorld()->launchMagicBolt(model, sound, mId, speed,
|
||||
false, effects, mCaster, mSourceName, fallbackDirection);
|
||||
else
|
||||
{
|
||||
ESM::EffectList empty;
|
||||
MWBase::Environment::get().getWorld()->launchMagicBolt(model, sound, mId, speed,
|
||||
false, empty, mCaster, mSourceName, fallbackDirection);
|
||||
}
|
||||
isFirstProjectile = false;
|
||||
}
|
||||
MWBase::Environment::get().getWorld()->launchMagicBolt(models, sounds, mId, speed,
|
||||
false, projectileEffects, mCaster, mSourceName, fallbackDirection);
|
||||
}
|
||||
|
||||
void CastSpell::inflict(const MWWorld::Ptr &target, const MWWorld::Ptr &caster,
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace MWWorld
|
|||
state.mEffectAnimationTime->addTime(duration);
|
||||
}
|
||||
|
||||
void ProjectileManager::launchMagicBolt(const std::string &model, const std::string &sound,
|
||||
void ProjectileManager::launchMagicBolt(const std::vector<std::string> &models, const std::vector<std::string> &sounds,
|
||||
const std::string &spellId, float speed, bool stack,
|
||||
const ESM::EffectList &effects, const Ptr &caster, const std::string &sourceName,
|
||||
const osg::Vec3f& fallbackDirection)
|
||||
|
@ -137,7 +137,6 @@ namespace MWWorld
|
|||
|
||||
MagicBoltState state;
|
||||
state.mSourceName = sourceName;
|
||||
state.mId = model;
|
||||
state.mSpellId = spellId;
|
||||
state.mCasterHandle = caster;
|
||||
if (caster.getClass().isActor())
|
||||
|
@ -146,24 +145,24 @@ namespace MWWorld
|
|||
state.mActorId = -1;
|
||||
state.mSpeed = speed;
|
||||
state.mStack = stack;
|
||||
state.mSoundId = sound;
|
||||
state.mIdMagic = models;
|
||||
state.mSoundId = sounds;
|
||||
|
||||
// Only interested in "on target" effects
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator iter (effects.mList.begin());
|
||||
iter!=effects.mList.end(); ++iter)
|
||||
// Should have already had non-projectile effects removed
|
||||
state.mEffects = effects;
|
||||
|
||||
for (int iter = 0; iter != models.size(); ++iter)
|
||||
{
|
||||
if (iter->mRange == ESM::RT_Target)
|
||||
state.mEffects.mList.push_back(*iter);
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), models.at(iter));
|
||||
MWWorld::Ptr ptr = ref.getPtr();
|
||||
|
||||
createModel(state, ptr.getClass().getModel(ptr), pos, orient, true);
|
||||
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
if (iter < sounds.size())
|
||||
state.mSound = sndMgr->playSound3D(pos, sounds.at(iter), 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
|
||||
}
|
||||
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), model);
|
||||
MWWorld::Ptr ptr = ref.getPtr();
|
||||
|
||||
createModel(state, ptr.getClass().getModel(ptr), pos, orient, true);
|
||||
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
state.mSound = sndMgr->playSound3D(pos, sound, 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
|
||||
|
||||
mMagicBolts.push_back(state);
|
||||
}
|
||||
|
||||
|
@ -173,7 +172,7 @@ namespace MWWorld
|
|||
state.mActorId = actor.getClass().getCreatureStats(actor).getActorId();
|
||||
state.mBowId = bow.getCellRef().getRefId();
|
||||
state.mVelocity = orient * osg::Vec3f(0,1,0) * speed;
|
||||
state.mId = projectile.getCellRef().getRefId();
|
||||
state.mIdArrow = projectile.getCellRef().getRefId();
|
||||
state.mCasterHandle = actor;
|
||||
state.mAttackStrength = attackStrength;
|
||||
|
||||
|
@ -286,7 +285,7 @@ namespace MWWorld
|
|||
{
|
||||
if (result.mHit)
|
||||
{
|
||||
MWWorld::ManualRef projectileRef(MWBase::Environment::get().getWorld()->getStore(), it->mId);
|
||||
MWWorld::ManualRef projectileRef(MWBase::Environment::get().getWorld()->getStore(), it->mIdArrow);
|
||||
|
||||
// Try to get a Ptr to the bow that was used. It might no longer exist.
|
||||
MWWorld::Ptr bow = projectileRef.getPtr();
|
||||
|
@ -338,7 +337,7 @@ namespace MWWorld
|
|||
writer.startRecord(ESM::REC_PROJ);
|
||||
|
||||
ESM::ProjectileState state;
|
||||
state.mId = it->mId;
|
||||
state.mId = it->mIdArrow;
|
||||
state.mPosition = ESM::Vector3(osg::Vec3f(it->mNode->getPosition()));
|
||||
state.mOrientation = ESM::Quaternion(osg::Quat(it->mNode->getAttitude()));
|
||||
state.mActorId = it->mActorId;
|
||||
|
@ -357,14 +356,14 @@ namespace MWWorld
|
|||
writer.startRecord(ESM::REC_MPRJ);
|
||||
|
||||
ESM::MagicBoltState state;
|
||||
state.mId = it->mId;
|
||||
state.mId = it->mIdMagic.at(0);
|
||||
state.mPosition = ESM::Vector3(osg::Vec3f(it->mNode->getPosition()));
|
||||
state.mOrientation = ESM::Quaternion(osg::Quat(it->mNode->getAttitude()));
|
||||
state.mActorId = it->mActorId;
|
||||
|
||||
state.mSpellId = it->mSpellId;
|
||||
state.mEffects = it->mEffects;
|
||||
state.mSound = it->mSoundId;
|
||||
state.mSound = it->mSoundId.at(0);
|
||||
state.mSourceName = it->mSourceName;
|
||||
state.mSpeed = it->mSpeed;
|
||||
state.mStack = it->mStack;
|
||||
|
@ -386,7 +385,7 @@ namespace MWWorld
|
|||
state.mActorId = esm.mActorId;
|
||||
state.mBowId = esm.mBowId;
|
||||
state.mVelocity = esm.mVelocity;
|
||||
state.mId = esm.mId;
|
||||
state.mIdArrow = esm.mId;
|
||||
state.mAttackStrength = esm.mAttackStrength;
|
||||
|
||||
std::string model;
|
||||
|
@ -413,7 +412,7 @@ namespace MWWorld
|
|||
|
||||
MagicBoltState state;
|
||||
state.mSourceName = esm.mSourceName;
|
||||
state.mId = esm.mId;
|
||||
state.mIdMagic.push_back(esm.mId);
|
||||
state.mSpellId = esm.mSpellId;
|
||||
state.mActorId = esm.mActorId;
|
||||
state.mSpeed = esm.mSpeed;
|
||||
|
@ -437,7 +436,7 @@ namespace MWWorld
|
|||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
state.mSound = sndMgr->playSound3D(esm.mPosition, esm.mSound, 1.0f, 1.0f,
|
||||
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
|
||||
state.mSoundId = esm.mSound;
|
||||
state.mSoundId.push_back(esm.mSound);
|
||||
|
||||
mMagicBolts.push_back(state);
|
||||
return true;
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace MWWorld
|
|||
MWRender::RenderingManager* rendering, MWPhysics::PhysicsSystem* physics);
|
||||
|
||||
/// If caster is an actor, the actor's facing orientation is used. Otherwise fallbackDirection is used.
|
||||
void launchMagicBolt (const std::string& model, const std::string &sound, const std::string &spellId,
|
||||
void launchMagicBolt (const std::vector<std::string>& models, const std::vector<std::string> &sounds, const std::string &spellId,
|
||||
float speed, bool stack, const ESM::EffectList& effects,
|
||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection);
|
||||
|
||||
|
@ -84,8 +84,11 @@ namespace MWWorld
|
|||
|
||||
MWWorld::Ptr getCaster();
|
||||
|
||||
// MW-id of this projectile
|
||||
std::string mId;
|
||||
// MW-ids of a magic projectile
|
||||
std::vector<std::string> mIdMagic;
|
||||
|
||||
// MW-id of an arrow projectile
|
||||
std::string mIdArrow;
|
||||
};
|
||||
|
||||
struct MagicBoltState : public State
|
||||
|
@ -102,7 +105,7 @@ namespace MWWorld
|
|||
bool mStack;
|
||||
|
||||
MWBase::SoundPtr mSound;
|
||||
std::string mSoundId;
|
||||
std::vector<std::string> mSoundId;
|
||||
};
|
||||
|
||||
struct ProjectileState : public State
|
||||
|
|
|
@ -2705,11 +2705,11 @@ namespace MWWorld
|
|||
mProjectileManager->launchProjectile(actor, projectile, worldPos, orient, bow, speed, attackStrength);
|
||||
}
|
||||
|
||||
void World::launchMagicBolt (const std::string& model, const std::string &sound, const std::string &spellId,
|
||||
void World::launchMagicBolt (const std::vector<std::string> &models, const std::vector<std::string> &sounds, const std::string &spellId,
|
||||
float speed, bool stack, const ESM::EffectList& effects,
|
||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection)
|
||||
{
|
||||
mProjectileManager->launchMagicBolt(model, sound, spellId, speed, stack, effects, caster, sourceName, fallbackDirection);
|
||||
mProjectileManager->launchMagicBolt(models, sounds, spellId, speed, stack, effects, caster, sourceName, fallbackDirection);
|
||||
}
|
||||
|
||||
const std::vector<std::string>& World::getContentFiles() const
|
||||
|
|
|
@ -594,7 +594,7 @@ namespace MWWorld
|
|||
*/
|
||||
virtual void castSpell (const MWWorld::Ptr& actor);
|
||||
|
||||
virtual void launchMagicBolt (const std::string& model, const std::string& sound, const std::string& spellId,
|
||||
virtual void launchMagicBolt (const std::vector<std::string>& models, const std::vector<std::string>& sounds, const std::string& spellId,
|
||||
float speed, bool stack, const ESM::EffectList& effects,
|
||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection);
|
||||
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
||||
|
|
Loading…
Reference in a new issue