From 6e81927d60d7df17195f16f8436430f173443807 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 16 Feb 2024 13:06:48 +0300 Subject: [PATCH 1/4] Make extra sure to ignore movement input for scripted animations (#7833) --- apps/openmw/mwmechanics/character.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index cbd09b30d8..be3652b0a9 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -2070,7 +2070,7 @@ namespace MWMechanics vec.x() *= speed; vec.y() *= speed; - if (isKnockedOut() || isKnockedDown() || isRecovery()) + if (isKnockedOut() || isKnockedDown() || isRecovery() || isScriptedAnimPlaying()) vec = osg::Vec3f(); CharacterState movestate = CharState_None; From 78737141034169ee844b7e67b91c77ab48f30400 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 16 Feb 2024 13:34:41 +0300 Subject: [PATCH 2/4] Restore vertical movement reset for various movement states (#7833) Note getJump already handles incapacitation states (dead/paralyzed/KO) --- apps/openmw/mwmechanics/character.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index be3652b0a9..49221cbae9 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -2144,6 +2144,10 @@ namespace MWMechanics bool wasInJump = mInJump; mInJump = false; + const float jumpHeight = cls.getJump(mPtr); + if (jumpHeight <= 0.f || sneak || inwater || flying || !solid) + vec.z() = 0.f; + if (!inwater && !flying && solid) { // In the air (either getting up —ascending part of jump— or falling). @@ -2162,20 +2166,16 @@ namespace MWMechanics vec.z() = 0.0f; } // Started a jump. - else if (mJumpState != JumpState_InAir && vec.z() > 0.f && !sneak) + else if (mJumpState != JumpState_InAir && vec.z() > 0.f) { - float z = cls.getJump(mPtr); - if (z > 0.f) + mInJump = true; + if (vec.x() == 0 && vec.y() == 0) + vec.z() = jumpHeight; + else { - mInJump = true; - if (vec.x() == 0 && vec.y() == 0) - vec.z() = z; - else - { - osg::Vec3f lat(vec.x(), vec.y(), 0.0f); - lat.normalize(); - vec = osg::Vec3f(lat.x(), lat.y(), 1.0f) * z * 0.707f; - } + osg::Vec3f lat(vec.x(), vec.y(), 0.0f); + lat.normalize(); + vec = osg::Vec3f(lat.x(), lat.y(), 1.0f) * jumpHeight * 0.707f; } } } From aae74224e8cebb590e9f31b99225453d0f10934a Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 16 Feb 2024 14:28:43 +0300 Subject: [PATCH 3/4] Prevent swim upward correction from causing false-positive jumping events (#7833) --- apps/openmw/mwmechanics/character.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 49221cbae9..d1f41ad514 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -2146,7 +2146,12 @@ namespace MWMechanics mInJump = false; const float jumpHeight = cls.getJump(mPtr); if (jumpHeight <= 0.f || sneak || inwater || flying || !solid) + { vec.z() = 0.f; + // Following code might assign some vertical movement regardless, need to reset this manually + // This is used for jumping detection + movementSettings.mPosition[2] = 0; + } if (!inwater && !flying && solid) { From d7bd50e45fc5d020358824ec312f998f807eaf3b Mon Sep 17 00:00:00 2001 From: uramer Date: Tue, 20 Feb 2024 20:20:38 +0100 Subject: [PATCH 4/4] Only set controls.jump to true for one frame when jumping --- files/data/scripts/omw/input/playercontrols.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/files/data/scripts/omw/input/playercontrols.lua b/files/data/scripts/omw/input/playercontrols.lua index 311b5a16a9..202e604087 100644 --- a/files/data/scripts/omw/input/playercontrols.lua +++ b/files/data/scripts/omw/input/playercontrols.lua @@ -83,6 +83,7 @@ end local movementControlsOverridden = false local autoMove = false +local attemptToJump = false local function processMovement() local movement = input.getRangeActionValue('MoveForward') - input.getRangeActionValue('MoveBackward') local sideMovement = input.getRangeActionValue('MoveRight') - input.getRangeActionValue('MoveLeft') @@ -97,6 +98,7 @@ local function processMovement() self.controls.movement = movement self.controls.sideMovement = sideMovement self.controls.run = run + self.controls.jump = attemptToJump if not settings:get('toggleSneak') then self.controls.sneak = input.getBooleanActionValue('Sneak') @@ -115,7 +117,7 @@ end input.registerTriggerHandler('Jump', async:callback(function() if not movementAllowed() then return end - self.controls.jump = Player.getControlSwitch(self, Player.CONTROL_SWITCH.Jumping) + attemptToJump = Player.getControlSwitch(self, Player.CONTROL_SWITCH.Jumping) end)) input.registerTriggerHandler('ToggleSneak', async:callback(function() @@ -223,6 +225,7 @@ local function onFrame(_) if combatAllowed() then processAttacking() end + attemptToJump = false end local function onSave()