mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
fixes to slow-down at jump startup and infinite air intertia growth
This commit is contained in:
parent
9e79fb5b87
commit
f596b698d9
@ -1006,7 +1006,16 @@ void CharacterController::update(float duration)
|
||||
bool flying = world->isFlying(mPtr);
|
||||
//Ogre::Vector3 vec = cls.getMovementVector(mPtr);
|
||||
Ogre::Vector3 vec(cls.getMovementSettings(mPtr).mPosition);
|
||||
vec.normalise();
|
||||
if(vec.z > 0.0f) // to avoid slow-down when jumping
|
||||
{
|
||||
Ogre::Vector2 vecXY = Ogre::Vector2(vec.x, vec.y);
|
||||
vecXY.normalise();
|
||||
vec.x = vecXY.x;
|
||||
vec.y = vecXY.y;
|
||||
}
|
||||
else
|
||||
vec.normalise();
|
||||
|
||||
if(mHitState != CharState_None && mJumpState == JumpState_None)
|
||||
vec = Ogre::Vector3(0.0f);
|
||||
Ogre::Vector3 rot = cls.getRotationVector(mPtr);
|
||||
@ -1107,9 +1116,12 @@ void CharacterController::update(float duration)
|
||||
if(cls.isNpc())
|
||||
{
|
||||
const NpcStats &stats = cls.getNpcStats(mPtr);
|
||||
mult = gmst.find("fJumpMoveBase")->getFloat() +
|
||||
static const float fJumpMoveBase = gmst.find("fJumpMoveBase")->getFloat();
|
||||
static const float fJumpMoveMult = gmst.find("fJumpMoveMult")->getFloat();
|
||||
|
||||
mult = fJumpMoveBase +
|
||||
(stats.getSkill(ESM::Skill::Acrobatics).getModified()/100.0f *
|
||||
gmst.find("fJumpMoveMult")->getFloat());
|
||||
fJumpMoveMult);
|
||||
}
|
||||
|
||||
vec.x *= mult;
|
||||
@ -1119,14 +1131,7 @@ void CharacterController::update(float duration)
|
||||
else if(vec.z > 0.0f && mJumpState == JumpState_None)
|
||||
{
|
||||
// Started a jump.
|
||||
float z = cls.getJump(mPtr);
|
||||
if(vec.x == 0 && vec.y == 0)
|
||||
vec = Ogre::Vector3(0.0f, 0.0f, z);
|
||||
else
|
||||
{
|
||||
Ogre::Vector3 lat = Ogre::Vector3(vec.x, vec.y, 0.0f).normalisedCopy();
|
||||
vec = Ogre::Vector3(lat.x, lat.y, 1.0f) * z * 0.707f;
|
||||
}
|
||||
vec.z = cls.getJump(mPtr);
|
||||
|
||||
// advance acrobatics
|
||||
if (mPtr.getRefData().getHandle() == "player")
|
||||
@ -1438,14 +1443,14 @@ void CharacterController::updateVisibility()
|
||||
|
||||
void CharacterController::determineAttackType()
|
||||
{
|
||||
float * move = mPtr.getClass().getMovementSettings(mPtr).mPosition;
|
||||
float *move = mPtr.getClass().getMovementSettings(mPtr).mPosition;
|
||||
|
||||
if(mPtr.getClass().hasInventoryStore(mPtr))
|
||||
{
|
||||
if (move[0] && !move[1]) //sideway
|
||||
mAttackType = "slash";
|
||||
else if (move[1]) //forward
|
||||
if (move[1]) // forward-backward
|
||||
mAttackType = "thrust";
|
||||
else if (move[0]) //sideway
|
||||
mAttackType = "slash";
|
||||
else
|
||||
mAttackType = "chop";
|
||||
}
|
||||
|
@ -246,6 +246,15 @@ namespace MWWorld
|
||||
// If falling, add part of the incoming velocity with the current inertia
|
||||
// TODO: but we could be jumping up?
|
||||
velocity = velocity * time + physicActor->getInertialForce();
|
||||
|
||||
// avoid getting infinite inertia in air
|
||||
float actorSpeed = ptr.getClass().getSpeed(ptr);
|
||||
float speedXY = Ogre::Vector2(velocity.x, velocity.y).length();
|
||||
if (speedXY > actorSpeed)
|
||||
{
|
||||
velocity.x *= actorSpeed / speedXY;
|
||||
velocity.y *= actorSpeed / speedXY;
|
||||
}
|
||||
}
|
||||
inertia = velocity; // NOTE: velocity is for z axis only in this code block
|
||||
|
||||
@ -314,7 +323,7 @@ namespace MWWorld
|
||||
if(stepMove(colobj, newPosition, velocity, remainingTime, engine))
|
||||
{
|
||||
// don't let pure water creatures move out of water after stepMove
|
||||
if((ptr.getClass().canSwim(ptr) && !ptr.getClass().canWalk(ptr))
|
||||
if((ptr.getClass().canSwim(ptr) && !canWalk)
|
||||
&& newPosition.z > (waterlevel - halfExtents.z * 0.5))
|
||||
newPosition = oldPosition;
|
||||
else // Only on the ground if there's gravity
|
||||
|
Loading…
x
Reference in New Issue
Block a user