From 22476281da55ea908ae60d1072c6e6e0fd50d9f4 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Tue, 22 Dec 2020 06:19:18 +0300 Subject: [PATCH] Fix paralyze for swimming actors --- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwmechanics/character.cpp | 10 ++++++++-- apps/openmw/mwphysics/movementsolver.cpp | 5 +++-- apps/openmw/mwphysics/physicssystem.cpp | 4 +++- apps/openmw/mwphysics/physicssystem.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 2 +- apps/openmw/mwworld/worldimp.hpp | 2 +- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 619bbbdf5..958fcfb0e 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -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; diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 9b3c8576e..178486965 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -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()) diff --git a/apps/openmw/mwphysics/movementsolver.cpp b/apps/openmw/mwphysics/movementsolver.cpp index e55ec9166..1feaf3c94 100644 --- a/apps/openmw/mwphysics/movementsolver.cpp +++ b/apps/openmw/mwphysics/movementsolver.cpp @@ -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) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 0b3cdbff5..cc4d6bba8 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -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(); } diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 9ebd587f5..2de8d153b 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -88,7 +88,7 @@ namespace MWPhysics bool mWasOnGround; bool mWantJump; bool mDidJump; - bool mIsDead; + bool mFloatToSurface; bool mNeedLand; bool mMoveToWaterSurface; float mWaterlevel; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 2ac6cca79..8b95ee122 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2917,7 +2917,7 @@ namespace MWWorld mRendering->rebuildPtr(getPlayerPtr()); } - bool World::getGodModeState() + bool World::getGodModeState() const { return mGodMode; } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 75717b16b..9f0501413 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -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;