1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 16:15:31 +00:00

Fix paralyze for swimming actors

This commit is contained in:
Alexei Dobrohotov 2020-12-22 06:19:18 +03:00
parent 218597b13d
commit 22476281da
7 changed files with 18 additions and 9 deletions

View file

@ -519,7 +519,7 @@ namespace MWBase
/// Returns true if levitation spell effect is allowed.
virtual bool isLevitationEnabled() const = 0;
virtual bool getGodModeState() = 0;
virtual bool getGodModeState() const = 0;
virtual bool toggleGodMode() = 0;

View file

@ -2439,8 +2439,14 @@ void CharacterController::update(float duration, bool animationOnly)
}
}
if (mFloatToSurface && cls.isActor() && cls.getCreatureStats(mPtr).isDead() && cls.canSwim(mPtr))
moved.z() = 1.0;
if (mFloatToSurface && cls.isActor() && cls.canSwim(mPtr))
{
if (cls.getCreatureStats(mPtr).isDead()
|| (!godmode && cls.getCreatureStats(mPtr).isParalyzed()))
{
moved.z() = 1.0;
}
}
// Update movement
if(!animationOnly && mMovementAnimationControlled && mPtr.getClass().isActor())

View file

@ -130,8 +130,9 @@ namespace MWPhysics
velocity = velocity + inertia;
}
// dead actors underwater will float to the surface, if the CharacterController tells us to do so
if (actor.mMovement.z() > 0 && actor.mIsDead && actor.mPosition.z() < swimlevel)
// Dead and paralyzed actors underwater will float to the surface,
// if the CharacterController tells us to do so
if (actor.mMovement.z() > 0 && actor.mFloatToSurface && actor.mPosition.z() < swimlevel)
velocity = osg::Vec3f(0,0,1) * 25;
if (actor.mWantJump)

View file

@ -922,7 +922,9 @@ namespace MWPhysics
mFlying = world->isFlying(ptr);
mSwimming = world->isSwimming(ptr);
mWantJump = ptr.getClass().getMovementSettings(ptr).mPosition[2] != 0;
mIsDead = ptr.getClass().getCreatureStats(ptr).isDead();
auto& stats = ptr.getClass().getCreatureStats(ptr);
const bool godmode = ptr == world->getPlayerConstPtr() && world->getGodModeState();
mFloatToSurface = stats.isDead() || (!godmode && stats.isParalyzed());
mWasOnGround = actor->getOnGround();
}

View file

@ -88,7 +88,7 @@ namespace MWPhysics
bool mWasOnGround;
bool mWantJump;
bool mDidJump;
bool mIsDead;
bool mFloatToSurface;
bool mNeedLand;
bool mMoveToWaterSurface;
float mWaterlevel;

View file

@ -2917,7 +2917,7 @@ namespace MWWorld
mRendering->rebuildPtr(getPlayerPtr());
}
bool World::getGodModeState()
bool World::getGodModeState() const
{
return mGodMode;
}

View file

@ -619,7 +619,7 @@ namespace MWWorld
/// Returns true if levitation spell effect is allowed.
bool isLevitationEnabled() const override;
bool getGodModeState() override;
bool getGodModeState() const override;
bool toggleGodMode() override;