mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 18:15:35 +00:00
Actors that start the game as dead do not float to the surface (Fixes #3177)
This has a minor bug (can you spot it?) that affects the vanilla engine as well, unfortunately not so simple to fix.
This commit is contained in:
parent
832eaae27b
commit
dda4273349
3 changed files with 9 additions and 3 deletions
|
@ -668,6 +668,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
, mHasMovedInXY(false)
|
, mHasMovedInXY(false)
|
||||||
, mMovementAnimationControlled(true)
|
, mMovementAnimationControlled(true)
|
||||||
, mDeathState(CharState_None)
|
, mDeathState(CharState_None)
|
||||||
|
, mFloatToSurface(true)
|
||||||
, mHitState(CharState_None)
|
, mHitState(CharState_None)
|
||||||
, mUpperBodyState(UpperCharState_Nothing)
|
, mUpperBodyState(UpperCharState_Nothing)
|
||||||
, mJumpState(JumpState_None)
|
, mJumpState(JumpState_None)
|
||||||
|
@ -716,6 +717,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
// Set the death state, but don't play it yet
|
// Set the death state, but don't play it yet
|
||||||
// We will play it in the first frame, but only if no script set the skipAnim flag
|
// We will play it in the first frame, but only if no script set the skipAnim flag
|
||||||
mDeathState = static_cast<CharacterState>(CharState_Death1 + mPtr.getClass().getCreatureStats(mPtr).getDeathAnimation());
|
mDeathState = static_cast<CharacterState>(CharState_Death1 + mPtr.getClass().getCreatureStats(mPtr).getDeathAnimation());
|
||||||
|
mFloatToSurface = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1864,7 +1866,7 @@ void CharacterController::update(float duration)
|
||||||
{
|
{
|
||||||
playDeath(1.f, mDeathState);
|
playDeath(1.f, mDeathState);
|
||||||
}
|
}
|
||||||
|
// We must always queue movement, even if there is none, to apply gravity.
|
||||||
world->queueMovement(mPtr, osg::Vec3f(0.f, 0.f, 0.f));
|
world->queueMovement(mPtr, osg::Vec3f(0.f, 0.f, 0.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1897,6 +1899,9 @@ void CharacterController::update(float duration)
|
||||||
if (mSkipAnim)
|
if (mSkipAnim)
|
||||||
mAnimation->updateEffects(duration);
|
mAnimation->updateEffects(duration);
|
||||||
|
|
||||||
|
if (mFloatToSurface && cls.isActor() && cls.getCreatureStats(mPtr).isDead())
|
||||||
|
moved.z() = 1.0;
|
||||||
|
|
||||||
// Update movement
|
// Update movement
|
||||||
if(mMovementAnimationControlled && mPtr.getClass().isActor())
|
if(mMovementAnimationControlled && mPtr.getClass().isActor())
|
||||||
world->queueMovement(mPtr, moved);
|
world->queueMovement(mPtr, moved);
|
||||||
|
|
|
@ -160,6 +160,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener
|
||||||
|
|
||||||
CharacterState mDeathState;
|
CharacterState mDeathState;
|
||||||
std::string mCurrentDeath;
|
std::string mCurrentDeath;
|
||||||
|
bool mFloatToSurface;
|
||||||
|
|
||||||
CharacterState mHitState;
|
CharacterState mHitState;
|
||||||
std::string mCurrentHit;
|
std::string mCurrentHit;
|
||||||
|
|
|
@ -289,8 +289,8 @@ namespace MWPhysics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dead actors underwater will float to the surface
|
// dead actors underwater will float to the surface, if the CharacterController tells us to do so
|
||||||
if (ptr.getClass().getCreatureStats(ptr).isDead() && position.z() < swimlevel)
|
if (movement.z() > 0 && ptr.getClass().getCreatureStats(ptr).isDead() && position.z() < swimlevel)
|
||||||
velocity = osg::Vec3f(0,0,1) * 25;
|
velocity = osg::Vec3f(0,0,1) * 25;
|
||||||
|
|
||||||
ptr.getClass().getMovementSettings(ptr).mPosition[2] = 0;
|
ptr.getClass().getMovementSettings(ptr).mPosition[2] = 0;
|
||||||
|
|
Loading…
Reference in a new issue