Implement slower movement against storms (Closes #41)

This commit is contained in:
scrawl 2014-06-26 20:26:46 +02:00
parent 07d0f4458d
commit 8b340ddd5e
2 changed files with 14 additions and 7 deletions

View file

@ -315,15 +315,22 @@ namespace MWWorld
wasOnGround = physicActor->getOnGround(); // store current state
tracer.doTrace(colobj, position, position - Ogre::Vector3(0,0,2), engine); // check if down 2 possible
if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope)
{
isOnGround = true;
// if we're on the ground, don't try to fall any more
velocity.z = std::max(0.0f, velocity.z);
}
}
}
// NOTE: isOnGround was initialised false, so should stay false if falling or sliding horizontally
if(isOnGround)
// Now that we have the effective movement vector, apply wind forces to it
if (MWBase::Environment::get().getWorld()->isInStorm())
{
// if we're on the ground, don't try to fall any more
velocity.z = std::max(0.0f, velocity.z); // NOTE: two different velocity assignments above
Ogre::Vector3 stormDirection = MWBase::Environment::get().getWorld()->getStormDirection();
Ogre::Degree angle = stormDirection.angleBetween(velocity);
static const float fStromWalkMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("fStromWalkMult")->getFloat();
velocity *= 1.f-(fStromWalkMult * (angle.valueDegrees()/180.f));
}
Ogre::Vector3 newPosition = position;

View file

@ -128,10 +128,10 @@ namespace MWWorld
// Rain sound effect
std::string mRainLoopSoundID;
// Is this an ash storm / blight storm? This controls two things:
// - The particle node will be oriented so that the particles appear to come from the Red Mountain. (not implemented yet)
// Is this an ash storm / blight storm? If so, the following will happen:
// - The particles and clouds will be oriented so they appear to come from the Red Mountain.
// - Characters will animate their hand to protect eyes from the storm when looking in its direction (idlestorm animation)
// Possible effect on movement speed?
// - Slower movement when walking against the storm (fStromWalkMult)
bool mIsStorm;
// How fast does rain travel down?