mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Closes #1123: Implement SlowFall magic effect
This commit is contained in:
parent
27d0d9c592
commit
c76a0448a3
1 changed files with 12 additions and 5 deletions
|
@ -108,7 +108,7 @@ namespace MWWorld
|
|||
}
|
||||
|
||||
static Ogre::Vector3 move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time,
|
||||
bool isFlying, float waterlevel, OEngine::Physic::PhysicEngine *engine)
|
||||
bool isFlying, float waterlevel, float slowFall, OEngine::Physic::PhysicEngine *engine)
|
||||
{
|
||||
const ESM::Position &refpos = ptr.getRefData().getPosition();
|
||||
Ogre::Vector3 position(refpos.pos);
|
||||
|
@ -229,7 +229,10 @@ namespace MWWorld
|
|||
physicActor->setInertialForce(Ogre::Vector3(0.0f));
|
||||
else
|
||||
{
|
||||
inertia.z += time*-627.2f;
|
||||
float diff = time*-627.2f;
|
||||
if (inertia.z < 0)
|
||||
diff *= slowFall;
|
||||
inertia.z += diff;
|
||||
physicActor->setInertialForce(inertia);
|
||||
}
|
||||
physicActor->setOnGround(isOnGround);
|
||||
|
@ -577,9 +580,10 @@ namespace MWWorld
|
|||
|
||||
float oldHeight = iter->first.getRefData().getPosition().pos[2];
|
||||
|
||||
const MWMechanics::MagicEffects& effects = iter->first.getClass().getCreatureStats(iter->first).getMagicEffects();
|
||||
|
||||
bool waterCollision = false;
|
||||
if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects()
|
||||
.get(ESM::MagicEffect::WaterWalking).mMagnitude
|
||||
if (effects.get(ESM::MagicEffect::WaterWalking).mMagnitude
|
||||
&& cell->hasWater()
|
||||
&& !world->isUnderwater(iter->first.getCell(),
|
||||
Ogre::Vector3(iter->first.getRefData().getPosition().pos)))
|
||||
|
@ -592,9 +596,12 @@ namespace MWWorld
|
|||
if (waterCollision)
|
||||
mEngine->dynamicsWorld->addCollisionObject(&object);
|
||||
|
||||
// 100 points of slowfall reduce gravity by 90% (this is just a guess)
|
||||
float slowFall = 1-std::min(std::max(0.f, (effects.get(ESM::MagicEffect::SlowFall).mMagnitude / 100.f) * 0.9f), 0.9f);
|
||||
|
||||
Ogre::Vector3 newpos = MovementSolver::move(iter->first, iter->second, mTimeAccum,
|
||||
world->isFlying(iter->first),
|
||||
waterlevel, mEngine);
|
||||
waterlevel, slowFall, mEngine);
|
||||
|
||||
if (waterCollision)
|
||||
mEngine->dynamicsWorld->removeCollisionObject(&object);
|
||||
|
|
Loading…
Reference in a new issue