1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 22:15:32 +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. /// Returns true if levitation spell effect is allowed.
virtual bool isLevitationEnabled() const = 0; virtual bool isLevitationEnabled() const = 0;
virtual bool getGodModeState() = 0; virtual bool getGodModeState() const = 0;
virtual bool toggleGodMode() = 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)) if (mFloatToSurface && cls.isActor() && cls.canSwim(mPtr))
moved.z() = 1.0; {
if (cls.getCreatureStats(mPtr).isDead()
|| (!godmode && cls.getCreatureStats(mPtr).isParalyzed()))
{
moved.z() = 1.0;
}
}
// Update movement // Update movement
if(!animationOnly && mMovementAnimationControlled && mPtr.getClass().isActor()) if(!animationOnly && mMovementAnimationControlled && mPtr.getClass().isActor())

View file

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

View file

@ -922,7 +922,9 @@ namespace MWPhysics
mFlying = world->isFlying(ptr); mFlying = world->isFlying(ptr);
mSwimming = world->isSwimming(ptr); mSwimming = world->isSwimming(ptr);
mWantJump = ptr.getClass().getMovementSettings(ptr).mPosition[2] != 0; 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(); mWasOnGround = actor->getOnGround();
} }

View file

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

View file

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

View file

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