mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-29 04:06:40 +00:00
Merge branch 'nojumpallowed' into 'master'
Reduce false-positive jumping events (#7833) Closes #7833 See merge request OpenMW/openmw!3869
This commit is contained in:
commit
a6c9e63520
2 changed files with 22 additions and 14 deletions
|
@ -2070,7 +2070,7 @@ namespace MWMechanics
|
||||||
vec.x() *= speed;
|
vec.x() *= speed;
|
||||||
vec.y() *= speed;
|
vec.y() *= speed;
|
||||||
|
|
||||||
if (isKnockedOut() || isKnockedDown() || isRecovery())
|
if (isKnockedOut() || isKnockedDown() || isRecovery() || isScriptedAnimPlaying())
|
||||||
vec = osg::Vec3f();
|
vec = osg::Vec3f();
|
||||||
|
|
||||||
CharacterState movestate = CharState_None;
|
CharacterState movestate = CharState_None;
|
||||||
|
@ -2144,6 +2144,15 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool wasInJump = mInJump;
|
bool wasInJump = mInJump;
|
||||||
mInJump = false;
|
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)
|
if (!inwater && !flying && solid)
|
||||||
{
|
{
|
||||||
// In the air (either getting up —ascending part of jump— or falling).
|
// In the air (either getting up —ascending part of jump— or falling).
|
||||||
|
@ -2162,20 +2171,16 @@ namespace MWMechanics
|
||||||
vec.z() = 0.0f;
|
vec.z() = 0.0f;
|
||||||
}
|
}
|
||||||
// Started a jump.
|
// 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;
|
mInJump = true;
|
||||||
if (vec.x() == 0 && vec.y() == 0)
|
if (vec.x() == 0 && vec.y() == 0)
|
||||||
vec.z() = z;
|
vec.z() = jumpHeight;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::Vec3f lat(vec.x(), vec.y(), 0.0f);
|
osg::Vec3f lat(vec.x(), vec.y(), 0.0f);
|
||||||
lat.normalize();
|
lat.normalize();
|
||||||
vec = osg::Vec3f(lat.x(), lat.y(), 1.0f) * z * 0.707f;
|
vec = osg::Vec3f(lat.x(), lat.y(), 1.0f) * jumpHeight * 0.707f;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ end
|
||||||
local movementControlsOverridden = false
|
local movementControlsOverridden = false
|
||||||
|
|
||||||
local autoMove = false
|
local autoMove = false
|
||||||
|
local attemptToJump = false
|
||||||
local function processMovement()
|
local function processMovement()
|
||||||
local movement = input.getRangeActionValue('MoveForward') - input.getRangeActionValue('MoveBackward')
|
local movement = input.getRangeActionValue('MoveForward') - input.getRangeActionValue('MoveBackward')
|
||||||
local sideMovement = input.getRangeActionValue('MoveRight') - input.getRangeActionValue('MoveLeft')
|
local sideMovement = input.getRangeActionValue('MoveRight') - input.getRangeActionValue('MoveLeft')
|
||||||
|
@ -97,6 +98,7 @@ local function processMovement()
|
||||||
self.controls.movement = movement
|
self.controls.movement = movement
|
||||||
self.controls.sideMovement = sideMovement
|
self.controls.sideMovement = sideMovement
|
||||||
self.controls.run = run
|
self.controls.run = run
|
||||||
|
self.controls.jump = attemptToJump
|
||||||
|
|
||||||
if not settings:get('toggleSneak') then
|
if not settings:get('toggleSneak') then
|
||||||
self.controls.sneak = input.getBooleanActionValue('Sneak')
|
self.controls.sneak = input.getBooleanActionValue('Sneak')
|
||||||
|
@ -115,7 +117,7 @@ end
|
||||||
|
|
||||||
input.registerTriggerHandler('Jump', async:callback(function()
|
input.registerTriggerHandler('Jump', async:callback(function()
|
||||||
if not movementAllowed() then return end
|
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))
|
end))
|
||||||
|
|
||||||
input.registerTriggerHandler('ToggleSneak', async:callback(function()
|
input.registerTriggerHandler('ToggleSneak', async:callback(function()
|
||||||
|
@ -223,6 +225,7 @@ local function onFrame(_)
|
||||||
if combatAllowed() then
|
if combatAllowed() then
|
||||||
processAttacking()
|
processAttacking()
|
||||||
end
|
end
|
||||||
|
attemptToJump = false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onSave()
|
local function onSave()
|
||||||
|
|
Loading…
Reference in a new issue