Combine into one multi-effect magic projectile

coverity_scan^2
Allofich 8 years ago
parent 10842462c7
commit 37f07f7435

@ -486,7 +486,7 @@ namespace MWBase
virtual void castSpell (const MWWorld::Ptr& actor) = 0;
virtual void launchMagicBolt (const std::vector<std::string>& models, const std::vector<std::string>& sounds, const std::string& spellId,
virtual void launchMagicBolt (const std::vector<std::string>& projectileIDs, 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,

@ -303,8 +303,8 @@ namespace MWMechanics
if (count != 0)
speed /= count;
std::string model;
std::vector<std::string> models;
std::string projectileID;
std::vector<std::string> projectileIDs;
std::string sound;
std::vector<std::string> sounds;
ESM::EffectList projectileEffects;
@ -320,10 +320,10 @@ namespace MWMechanics
const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
iter->mEffectID);
model = magicEffect->mBolt;
if (model.empty())
model = "VFX_DefaultBolt";
models.push_back(model);
projectileID = magicEffect->mBolt;
if (projectileID.empty())
projectileID = "VFX_DefaultBolt";
projectileIDs.push_back(projectileID);
static const std::string schools[] = {
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
@ -335,16 +335,28 @@ namespace MWMechanics
sounds.push_back(sound);
projectileEffects.mList.push_back(*iter);
}
if (projectileEffects.mList.size() > 1) // add a VFX_Multiple projectile if there are multiple projectile effects
{
std::vector<std::string>::iterator it;
it = projectileIDs.begin();
char numstr[8];
sprintf(numstr, "%zd", (effects.mList.size()));
std::string ID = "VFX_Multiple";
ID = ID + numstr;
it = projectileIDs.insert(it, ID);
}
// 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)
if (!mTarget.isEmpty())
fallbackDirection =
osg::Vec3f(mTarget.getRefData().getPosition().asVec3())-
osg::Vec3f(mCaster.getRefData().getPosition().asVec3());
// 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)
if (!mTarget.isEmpty())
fallbackDirection =
osg::Vec3f(mTarget.getRefData().getPosition().asVec3())-
osg::Vec3f(mCaster.getRefData().getPosition().asVec3());
MWBase::Environment::get().getWorld()->launchMagicBolt(models, sounds, mId, speed,
false, projectileEffects, mCaster, mSourceName, fallbackDirection);
if (!projectileEffects.mList.empty())
MWBase::Environment::get().getWorld()->launchMagicBolt(projectileIDs, sounds, mId, speed,
false, projectileEffects, mCaster, mSourceName, fallbackDirection);
}
void CastSpell::inflict(const MWWorld::Ptr &target, const MWWorld::Ptr &caster,

@ -1296,13 +1296,14 @@ namespace MWRender
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, std::string texture)
{
if (!mObjectRoot.get())
{
std::cout << "no objectroot" << std::endl;
return;
}
// Early out if we already have this effect
for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it)
if (it->mLoop && loop && it->mEffectId == effectId && it->mBoneName == bonename)
return;
EffectParams params;
params.mModelName = model;
osg::ref_ptr<osg::Group> parentNode;

@ -94,6 +94,17 @@ namespace MWWorld
mResourceSystem->getSceneManager()->getInstance(model, attachTo);
if (state.mIdMagic.size() > 1)
for (size_t iter = 1; iter != state.mIdMagic.size(); ++iter)
{
char numstr[8];
sprintf(numstr, "%zd", iter);
std::string node = "Dummy0";
node = node + numstr;
const ESM::Weapon* weapon = MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>().find (state.mIdMagic.at(iter));
mResourceSystem->getSceneManager()->getInstance("meshes\\" + weapon->mModel, attachTo);
}
SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
state.mNode->accept(disableFreezeOnCullVisitor);
@ -112,7 +123,7 @@ namespace MWWorld
state.mEffectAnimationTime->addTime(duration);
}
void ProjectileManager::launchMagicBolt(const std::vector<std::string> &models, const std::vector<std::string> &sounds,
void ProjectileManager::launchMagicBolt(const std::vector<std::string> &projectileIDs, 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)
@ -145,23 +156,20 @@ namespace MWWorld
state.mActorId = -1;
state.mSpeed = speed;
state.mStack = stack;
state.mIdMagic = models;
state.mIdMagic = projectileIDs;
state.mSoundId = sounds;
// Should have already had non-projectile effects removed
state.mEffects = effects;
for (int iter = 0; iter != models.size(); ++iter)
{
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), models.at(iter));
MWWorld::Ptr ptr = ref.getPtr();
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectileIDs.at(0));
MWWorld::Ptr ptr = ref.getPtr();
createModel(state, ptr.getClass().getModel(ptr), pos, orient, true);
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);
}
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
if (projectileIDs.size() == 1)
state.mSound = sndMgr->playSound3D(pos, sounds.at(0), 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
mMagicBolts.push_back(state);
}

@ -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::vector<std::string>& models, const std::vector<std::string> &sounds, const std::string &spellId,
void launchMagicBolt (const std::vector<std::string>& projectileIDs, 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);

@ -2705,11 +2705,11 @@ namespace MWWorld
mProjectileManager->launchProjectile(actor, projectile, worldPos, orient, bow, speed, attackStrength);
}
void World::launchMagicBolt (const std::vector<std::string> &models, const std::vector<std::string> &sounds, const std::string &spellId,
void World::launchMagicBolt (const std::vector<std::string> &projectileIDs, 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(models, sounds, spellId, speed, stack, effects, caster, sourceName, fallbackDirection);
mProjectileManager->launchMagicBolt(projectileIDs, 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::vector<std::string>& models, const std::vector<std::string>& sounds, const std::string& spellId,
virtual void launchMagicBolt (const std::vector<std::string>& projectileIDs, 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…
Cancel
Save