mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-17 20:13:07 +00:00
Merge branch 'breakingcharacter' into 'master'
Make the character controller less miserable, round 5: landing animation See merge request OpenMW/openmw!2176
This commit is contained in:
commit
843728aadb
1 changed files with 44 additions and 41 deletions
|
|
@ -1792,6 +1792,7 @@ void CharacterController::updateAnimQueue()
|
||||||
void CharacterController::update(float duration)
|
void CharacterController::update(float duration)
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||||
const MWWorld::Class &cls = mPtr.getClass();
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
osg::Vec3f movement(0.f, 0.f, 0.f);
|
osg::Vec3f movement(0.f, 0.f, 0.f);
|
||||||
float speed = 0.f;
|
float speed = 0.f;
|
||||||
|
|
@ -2047,13 +2048,14 @@ void CharacterController::update(float duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(mJumpState == JumpState_InAir && !inwater && !flying && solid)
|
else
|
||||||
|
{
|
||||||
|
if (mJumpState == JumpState_InAir && !flying && solid)
|
||||||
{
|
{
|
||||||
jumpstate = JumpState_Landing;
|
|
||||||
vec.z() = 0.0f;
|
|
||||||
|
|
||||||
float height = cls.getCreatureStats(mPtr).land(isPlayer);
|
float height = cls.getCreatureStats(mPtr).land(isPlayer);
|
||||||
float healthLost = getFallDamage(mPtr, height);
|
float healthLost = 0.f;
|
||||||
|
if (!inwater)
|
||||||
|
healthLost = getFallDamage(mPtr, height);
|
||||||
|
|
||||||
if (healthLost > 0.0f)
|
if (healthLost > 0.0f)
|
||||||
{
|
{
|
||||||
|
|
@ -2062,8 +2064,13 @@ void CharacterController::update(float duration)
|
||||||
// inflict fall damages
|
// inflict fall damages
|
||||||
if (!godmode)
|
if (!godmode)
|
||||||
{
|
{
|
||||||
float realHealthLost = static_cast<float>(healthLost * (1.0f - 0.25f * fatigueTerm));
|
DynamicStat<float> health = cls.getCreatureStats(mPtr).getHealth();
|
||||||
cls.onHit(mPtr, realHealthLost, true, MWWorld::Ptr(), MWWorld::Ptr(), osg::Vec3f(), true);
|
float realHealthLost = healthLost * (1.0f - 0.25f * fatigueTerm);
|
||||||
|
health.setCurrent(health.getCurrent() - realHealthLost);
|
||||||
|
cls.getCreatureStats(mPtr).setHealth(health);
|
||||||
|
sndMgr->playSound3D(mPtr, "Health Damage", 1.0f, 1.0f);
|
||||||
|
if (isPlayer)
|
||||||
|
MWBase::Environment::get().getWindowManager()->activateHitOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
const float acrobaticsSkill = cls.getSkill(mPtr, ESM::Skill::Acrobatics);
|
const float acrobaticsSkill = cls.getSkill(mPtr, ESM::Skill::Acrobatics);
|
||||||
|
|
@ -2083,12 +2090,9 @@ void CharacterController::update(float duration)
|
||||||
if (mPtr.getClass().isNpc())
|
if (mPtr.getClass().isNpc())
|
||||||
playLandingSound = true;
|
playLandingSound = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if(mPtr.getClass().isNpc() && mJumpState == JumpState_InAir && !flying && solid)
|
|
||||||
playLandingSound = true;
|
|
||||||
|
|
||||||
jumpstate = mAnimation->isPlaying(mCurrentJump) ? JumpState_Landing : JumpState_None;
|
if (mAnimation->isPlaying(mCurrentJump))
|
||||||
|
jumpstate = JumpState_Landing;
|
||||||
|
|
||||||
vec.x() *= scale;
|
vec.x() *= scale;
|
||||||
vec.y() *= scale;
|
vec.y() *= scale;
|
||||||
|
|
@ -2126,7 +2130,7 @@ void CharacterController::update(float duration)
|
||||||
|
|
||||||
// It seems only bipedal actors use turning animations.
|
// It seems only bipedal actors use turning animations.
|
||||||
// Also do not use turning animations in the first-person view and when sneaking.
|
// Also do not use turning animations in the first-person view and when sneaking.
|
||||||
if (!sneak && jumpstate == JumpState_None && !isFirstPersonPlayer && mPtr.getClass().isBipedal(mPtr))
|
if (!sneak && !isFirstPersonPlayer && mPtr.getClass().isBipedal(mPtr))
|
||||||
{
|
{
|
||||||
if(effectiveRotation > rotationThreshold)
|
if(effectiveRotation > rotationThreshold)
|
||||||
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
|
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
|
||||||
|
|
@ -2138,7 +2142,6 @@ void CharacterController::update(float duration)
|
||||||
|
|
||||||
if (playLandingSound)
|
if (playLandingSound)
|
||||||
{
|
{
|
||||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
|
||||||
std::string sound;
|
std::string sound;
|
||||||
osg::Vec3f pos(mPtr.getRefData().getPosition().asVec3());
|
osg::Vec3f pos(mPtr.getRefData().getPosition().asVec3());
|
||||||
if (world->isUnderwater(mPtr.getCell(), pos) || world->isWalkingOnWater(mPtr))
|
if (world->isUnderwater(mPtr.getCell(), pos) || world->isWalkingOnWater(mPtr))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue