|
|
|
@ -21,6 +21,7 @@
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
#include <components/misc/mathutil.hpp>
|
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
@ -51,15 +52,6 @@
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Wraps a value to (-PI, PI]
|
|
|
|
|
void wrap(float& rad)
|
|
|
|
|
{
|
|
|
|
|
if (rad>0)
|
|
|
|
|
rad = std::fmod(rad+osg::PI, 2.0f*osg::PI)-osg::PI;
|
|
|
|
|
else
|
|
|
|
|
rad = std::fmod(rad-osg::PI, 2.0f*osg::PI)+osg::PI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string getBestAttack (const ESM::Weapon* weapon)
|
|
|
|
|
{
|
|
|
|
|
int slash = (weapon->mData.mSlash[0] + weapon->mData.mSlash[1])/2;
|
|
|
|
@ -1958,23 +1950,19 @@ void CharacterController::update(float duration, bool animationOnly)
|
|
|
|
|
|
|
|
|
|
osg::Vec3f rot = cls.getRotationVector(mPtr);
|
|
|
|
|
osg::Vec3f vec(movementSettings.asVec3());
|
|
|
|
|
vec.normalize();
|
|
|
|
|
|
|
|
|
|
float analogueMult = 1.0f;
|
|
|
|
|
if (isPlayer)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Move this code to mwinput.
|
|
|
|
|
// Joystick analogue movement.
|
|
|
|
|
float xAxis = std::abs(movementSettings.mPosition[0]);
|
|
|
|
|
float yAxis = std::abs(movementSettings.mPosition[1]);
|
|
|
|
|
analogueMult = std::max(xAxis, yAxis);
|
|
|
|
|
movementSettings.mSpeedFactor = std::max(std::abs(vec.x()), std::abs(vec.y()));
|
|
|
|
|
|
|
|
|
|
// Due to the half way split between walking/running, we multiply speed by 2 while walking, unless a keyboard was used.
|
|
|
|
|
if(!isrunning && !sneak && !flying && analogueMult <= 0.5f)
|
|
|
|
|
analogueMult *= 2.f;
|
|
|
|
|
|
|
|
|
|
movementSettings.mSpeedFactor = analogueMult;
|
|
|
|
|
}
|
|
|
|
|
if(!isrunning && !sneak && !flying && movementSettings.mSpeedFactor <= 0.5f)
|
|
|
|
|
movementSettings.mSpeedFactor *= 2.f;
|
|
|
|
|
} else
|
|
|
|
|
movementSettings.mSpeedFactor = std::min(vec.length(), 1.f);
|
|
|
|
|
vec.normalize();
|
|
|
|
|
|
|
|
|
|
float effectiveRotation = rot.z();
|
|
|
|
|
static const bool turnToMovementDirection = Settings::Manager::getBool("turn to movement direction", "Game");
|
|
|
|
@ -2007,7 +1995,7 @@ void CharacterController::update(float duration, bool animationOnly)
|
|
|
|
|
else
|
|
|
|
|
mAnimation->setUpperBodyYawRadians(stats.getSideMovementAngle() / 4);
|
|
|
|
|
|
|
|
|
|
speed = cls.getSpeed(mPtr);
|
|
|
|
|
speed = cls.getCurrentSpeed(mPtr);
|
|
|
|
|
vec.x() *= speed;
|
|
|
|
|
vec.y() *= speed;
|
|
|
|
|
|
|
|
|
@ -2077,7 +2065,7 @@ void CharacterController::update(float duration, bool animationOnly)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fatigueLoss *= duration;
|
|
|
|
|
fatigueLoss *= analogueMult;
|
|
|
|
|
fatigueLoss *= movementSettings.mSpeedFactor;
|
|
|
|
|
DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue();
|
|
|
|
|
|
|
|
|
|
if (!godmode)
|
|
|
|
@ -2908,13 +2896,10 @@ void CharacterController::updateHeadTracking(float duration)
|
|
|
|
|
zAngleRadians = std::atan2(direction.x(), direction.y()) - std::atan2(actorDirection.x(), actorDirection.y());
|
|
|
|
|
xAngleRadians = -std::asin(direction.z());
|
|
|
|
|
|
|
|
|
|
wrap(zAngleRadians);
|
|
|
|
|
wrap(xAngleRadians);
|
|
|
|
|
|
|
|
|
|
xAngleRadians = std::min(xAngleRadians, osg::DegreesToRadians(40.f));
|
|
|
|
|
xAngleRadians = std::max(xAngleRadians, osg::DegreesToRadians(-40.f));
|
|
|
|
|
zAngleRadians = std::min(zAngleRadians, osg::DegreesToRadians(30.f));
|
|
|
|
|
zAngleRadians = std::max(zAngleRadians, osg::DegreesToRadians(-30.f));
|
|
|
|
|
const double xLimit = osg::DegreesToRadians(40.0);
|
|
|
|
|
const double zLimit = osg::DegreesToRadians(30.0);
|
|
|
|
|
zAngleRadians = osg::clampBetween(Misc::normalizeAngle(zAngleRadians), -xLimit, xLimit);
|
|
|
|
|
xAngleRadians = osg::clampBetween(Misc::normalizeAngle(xAngleRadians), -zLimit, zLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float factor = duration*5;
|
|
|
|
|