forked from mirror/openmw-tes3mp
Combine into one multi-effect magic projectile
This commit is contained in:
parent
10842462c7
commit
37f07f7435
7 changed files with 53 additions and 32 deletions
|
@ -486,7 +486,7 @@ namespace MWBase
|
||||||
|
|
||||||
virtual void castSpell (const MWWorld::Ptr& actor) = 0;
|
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,
|
float speed, bool stack, const ESM::EffectList& effects,
|
||||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection) = 0;
|
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection) = 0;
|
||||||
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
||||||
|
|
|
@ -303,8 +303,8 @@ namespace MWMechanics
|
||||||
if (count != 0)
|
if (count != 0)
|
||||||
speed /= count;
|
speed /= count;
|
||||||
|
|
||||||
std::string model;
|
std::string projectileID;
|
||||||
std::vector<std::string> models;
|
std::vector<std::string> projectileIDs;
|
||||||
std::string sound;
|
std::string sound;
|
||||||
std::vector<std::string> sounds;
|
std::vector<std::string> sounds;
|
||||||
ESM::EffectList projectileEffects;
|
ESM::EffectList projectileEffects;
|
||||||
|
@ -320,10 +320,10 @@ namespace MWMechanics
|
||||||
const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
|
const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
|
||||||
iter->mEffectID);
|
iter->mEffectID);
|
||||||
|
|
||||||
model = magicEffect->mBolt;
|
projectileID = magicEffect->mBolt;
|
||||||
if (model.empty())
|
if (projectileID.empty())
|
||||||
model = "VFX_DefaultBolt";
|
projectileID = "VFX_DefaultBolt";
|
||||||
models.push_back(model);
|
projectileIDs.push_back(projectileID);
|
||||||
|
|
||||||
static const std::string schools[] = {
|
static const std::string schools[] = {
|
||||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||||
|
@ -335,16 +335,28 @@ namespace MWMechanics
|
||||||
sounds.push_back(sound);
|
sounds.push_back(sound);
|
||||||
projectileEffects.mList.push_back(*iter);
|
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
|
// 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())
|
||||||
fallbackDirection =
|
fallbackDirection =
|
||||||
osg::Vec3f(mTarget.getRefData().getPosition().asVec3())-
|
osg::Vec3f(mTarget.getRefData().getPosition().asVec3())-
|
||||||
osg::Vec3f(mCaster.getRefData().getPosition().asVec3());
|
osg::Vec3f(mCaster.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->launchMagicBolt(models, sounds, mId, speed,
|
if (!projectileEffects.mList.empty())
|
||||||
false, projectileEffects, mCaster, mSourceName, fallbackDirection);
|
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,
|
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)
|
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, std::string texture)
|
||||||
{
|
{
|
||||||
if (!mObjectRoot.get())
|
if (!mObjectRoot.get())
|
||||||
|
{
|
||||||
|
std::cout << "no objectroot" << std::endl;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// Early out if we already have this effect
|
// Early out if we already have this effect
|
||||||
for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
||||||
if (it->mLoop && loop && it->mEffectId == effectId && it->mBoneName == bonename)
|
if (it->mLoop && loop && it->mEffectId == effectId && it->mBoneName == bonename)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EffectParams params;
|
EffectParams params;
|
||||||
params.mModelName = model;
|
params.mModelName = model;
|
||||||
osg::ref_ptr<osg::Group> parentNode;
|
osg::ref_ptr<osg::Group> parentNode;
|
||||||
|
|
|
@ -94,6 +94,17 @@ namespace MWWorld
|
||||||
|
|
||||||
mResourceSystem->getSceneManager()->getInstance(model, attachTo);
|
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;
|
SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
|
||||||
state.mNode->accept(disableFreezeOnCullVisitor);
|
state.mNode->accept(disableFreezeOnCullVisitor);
|
||||||
|
|
||||||
|
@ -112,7 +123,7 @@ namespace MWWorld
|
||||||
state.mEffectAnimationTime->addTime(duration);
|
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 std::string &spellId, float speed, bool stack,
|
||||||
const ESM::EffectList &effects, const Ptr &caster, const std::string &sourceName,
|
const ESM::EffectList &effects, const Ptr &caster, const std::string &sourceName,
|
||||||
const osg::Vec3f& fallbackDirection)
|
const osg::Vec3f& fallbackDirection)
|
||||||
|
@ -145,23 +156,20 @@ namespace MWWorld
|
||||||
state.mActorId = -1;
|
state.mActorId = -1;
|
||||||
state.mSpeed = speed;
|
state.mSpeed = speed;
|
||||||
state.mStack = stack;
|
state.mStack = stack;
|
||||||
state.mIdMagic = models;
|
state.mIdMagic = projectileIDs;
|
||||||
state.mSoundId = sounds;
|
state.mSoundId = sounds;
|
||||||
|
|
||||||
// Should have already had non-projectile effects removed
|
// Should have already had non-projectile effects removed
|
||||||
state.mEffects = effects;
|
state.mEffects = effects;
|
||||||
|
|
||||||
for (int iter = 0; iter != models.size(); ++iter)
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectileIDs.at(0));
|
||||||
{
|
MWWorld::Ptr ptr = ref.getPtr();
|
||||||
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);
|
createModel(state, ptr.getClass().getModel(ptr), pos, orient, true);
|
||||||
|
|
||||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||||
if (iter < sounds.size())
|
if (projectileIDs.size() == 1)
|
||||||
state.mSound = sndMgr->playSound3D(pos, sounds.at(iter), 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
|
state.mSound = sndMgr->playSound3D(pos, sounds.at(0), 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
|
||||||
}
|
|
||||||
|
|
||||||
mMagicBolts.push_back(state);
|
mMagicBolts.push_back(state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace MWWorld
|
||||||
MWRender::RenderingManager* rendering, MWPhysics::PhysicsSystem* physics);
|
MWRender::RenderingManager* rendering, MWPhysics::PhysicsSystem* physics);
|
||||||
|
|
||||||
/// If caster is an actor, the actor's facing orientation is used. Otherwise fallbackDirection is used.
|
/// 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,
|
float speed, bool stack, const ESM::EffectList& effects,
|
||||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection);
|
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);
|
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,
|
float speed, bool stack, const ESM::EffectList& effects,
|
||||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection)
|
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
|
const std::vector<std::string>& World::getContentFiles() const
|
||||||
|
|
|
@ -594,7 +594,7 @@ namespace MWWorld
|
||||||
*/
|
*/
|
||||||
virtual void castSpell (const MWWorld::Ptr& actor);
|
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,
|
float speed, bool stack, const ESM::EffectList& effects,
|
||||||
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection);
|
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection);
|
||||||
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
||||||
|
|
Loading…
Reference in a new issue