Skip to content

Commit 5fb0654

Browse files
committed
Bunch of fixes
1 parent 5095886 commit 5fb0654

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
9292

9393
- The Signal Hunt activity no longer has a preview image, as it was not formatted correctly and spoiled the interior structure of the cave.
9494

95-
- Removed `AHUman` property MaxCrouchRotation. CrouchRotAngleTarget is now used.
95+
- Removed `AHuman` property `MaxCrouchRotation`. `CrouchRotAngleTarget` is now used instead.
9696

9797
</details>
9898

Source/Entities/AHuman.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ void AHuman::UpdateCrouching() {
14071407
desiredWalkPathYOffset = m_CrouchAmountOverride * m_MaxWalkPathCrouchShift;
14081408
} else if (!m_Controller.IsState(BODY_PRONE)) {
14091409
if (m_Controller.IsState(BODY_CROUCH)) {
1410-
// Manually crouch fully is the crouch controller state is set
1410+
// Manually crouch fully when the crouch controller state is set
14111411
desiredWalkPathYOffset = m_MaxWalkPathCrouchShift;
14121412
} else if (!m_Controller.IsState(BODY_JUMP) && m_pHead) {
14131413
// Otherwise figure out auto crouching
@@ -1435,20 +1435,14 @@ void AHuman::UpdateCrouching() {
14351435
}
14361436

14371437
float finalWalkPathYOffset = std::clamp(Lerp(0.0F, 1.0F, -m_WalkPathOffset.m_Y, desiredWalkPathYOffset, 0.3F), 0.0F, m_MaxWalkPathCrouchShift);
1438+
m_CrouchAmount = std::clamp(0.0F, 1.0F, finalWalkPathYOffset / m_MaxWalkPathCrouchShift - 0.5F); // because it's lerped, it never hits 1 exactly. thus the -0.5F
14381439
m_WalkPathOffset.m_Y = -finalWalkPathYOffset;
1439-
1440-
m_CrouchAmount = desiredWalkPathYOffset / m_MaxWalkPathCrouchShift;
14411440

14421441
// Adjust our X offset to try to keep our legs under our centre-of-mass
14431442
const float ratioBetweenBodyAndHeadToAimFor = 0.15F;
14441443
Vector headPos = m_pHead ? m_pHead->GetPos() : m_Pos;
14451444
float predictedPosition = ((headPos.m_X - m_Pos.m_X) * ratioBetweenBodyAndHeadToAimFor) + m_Vel.m_X;
14461445
m_WalkPathOffset.m_X = predictedPosition;
1447-
if (m_CrouchAmount > 0.9F && !m_MoveState == WALK ) {
1448-
// Let the CrouchLimbPath take over here
1449-
m_WalkPathOffset.m_Y = 0.0F;
1450-
m_WalkPathOffset.m_X = 0.0F;
1451-
}
14521446
}
14531447

14541448
void AHuman::UpdateLimbPathSpeed() {
@@ -1457,9 +1451,13 @@ void AHuman::UpdateLimbPathSpeed() {
14571451
m_Paths[BGROUND][m_MoveState].SetTravelSpeedMultiplier(1.0F);
14581452

14591453
if (m_MoveState == WALK || m_MoveState == RUN || m_MoveState == CRAWL) {
1454+
float travelSpeedMultiplier = 1.0F;
1455+
14601456
// If crouching, move at reduced speed
1461-
const float crouchSpeedMultiplier = 0.7F;
1462-
float travelSpeedMultiplier = Lerp(0.0F, m_MaxWalkPathCrouchShift, 1.0F, crouchSpeedMultiplier, -m_WalkPathOffset.m_Y);
1457+
if (m_MoveState == WALK) {
1458+
const float crouchSpeedMultiplier = 0.7F;
1459+
travelSpeedMultiplier *= Lerp(0.0F, 1.0F, 1.0F, crouchSpeedMultiplier, m_CrouchAmount);
1460+
}
14631461

14641462
// If we're moving slowly horizontally, move at reduced speed (otherwise our legs kick about wildly as we're not yet up to speed)
14651463
// Calculate a min multiplier that is based on the total walkpath speed (so a fast walkpath has a smaller multipler). This is so a slow walkpath gets up to speed faster
@@ -1575,7 +1573,7 @@ void AHuman::PreControllerUpdate() {
15751573
if (prone) {
15761574
// Don't go back to prone if we're already prone, the player has to let go of the crouch button first. If already laying down, just stay put.
15771575
m_MoveState = m_ProneState == NOTPRONE ? PRONE : NOMOVE;
1578-
} else if (m_CrouchAmount > 0.9F) {
1576+
} else if (m_CrouchAmount >= 1.0F) {
15791577
// Fully crouching will set the appropriate state so we can use CrouchLimbPath
15801578
m_MoveState = CROUCH;
15811579
} else {
@@ -1706,13 +1704,15 @@ void AHuman::PreControllerUpdate() {
17061704

17071705
// TODO: make the delay data driven by both the actor and the device!
17081706
//
1709-
if (isSharpAiming && m_Status == STABLE && (m_MoveState == STAND || m_MoveState == PRONE || m_MoveState == NOMOVE || m_MoveState == WALK) && m_Vel.MagnitudeIsLessThan(5.0F) && GetEquippedItem()) {
1707+
if (isSharpAiming && m_Status == STABLE && m_Vel.MagnitudeIsLessThan(5.0F) && GetEquippedItem() &&
1708+
(m_MoveState == STAND || m_MoveState == CROUCH || m_MoveState == PRONE || m_MoveState == NOMOVE || m_MoveState == WALK)) {
17101709
float aimMag = analogAim.GetMagnitude();
17111710

17121711
// If aim sharp is being done digitally, then translate to full analog aim mag
17131712
if (aimMag < 0.1F) {
17141713
aimMag = 1.0F;
17151714
}
1715+
17161716
if (m_MoveState == WALK) {
17171717
aimMag *= 0.3F;
17181718
}
@@ -1991,6 +1991,11 @@ void AHuman::PreControllerUpdate() {
19911991

19921992
UpdateCrouching();
19931993

1994+
Vector pathOffset;
1995+
if (m_MoveState == WALK) {
1996+
pathOffset = m_WalkPathOffset;
1997+
}
1998+
19941999
if (m_Status == STABLE && !m_LimbPushForcesAndCollisionsDisabled && m_MoveState != NOMOVE) {
19952000
// This exists to support disabling foot collisions if the limbpath has that flag set.
19962001
if ((m_pFGFootGroup->GetAtomCount() == 0 && m_BackupFGFootGroup->GetAtomCount() > 0) != m_Paths[FGROUND][m_MoveState].FootCollisionsShouldBeDisabled()) {
@@ -2033,7 +2038,7 @@ void AHuman::PreControllerUpdate() {
20332038
m_StrideTimer.Reset();
20342039
}
20352040
Vector jointPos = m_Pos + RotateOffset(m_pFGLeg->GetParentOffset());
2036-
m_ArmClimbing[BGROUND] = !m_pFGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][movementPath], deltaTime, &restarted, false, Vector(0.0F, m_Paths[FGROUND][movementPath].GetLowestY()), m_WalkPathOffset);
2041+
m_ArmClimbing[BGROUND] = !m_pFGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][movementPath], deltaTime, &restarted, false, Vector(0.0F, m_Paths[FGROUND][movementPath].GetLowestY()), pathOffset);
20372042
} else {
20382043
m_ArmClimbing[BGROUND] = false;
20392044
}
@@ -2044,7 +2049,7 @@ void AHuman::PreControllerUpdate() {
20442049
m_StrideTimer.Reset();
20452050
}
20462051
Vector jointPos = m_Pos + RotateOffset(m_pBGLeg->GetParentOffset());
2047-
m_ArmClimbing[FGROUND] = !m_pBGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][movementPath], deltaTime, &restarted, false, Vector(0.0F, m_Paths[BGROUND][movementPath].GetLowestY()), m_WalkPathOffset);
2052+
m_ArmClimbing[FGROUND] = !m_pBGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][movementPath], deltaTime, &restarted, false, Vector(0.0F, m_Paths[BGROUND][movementPath].GetLowestY()), pathOffset);
20482053
} else {
20492054
if (m_pBGLeg) {
20502055
m_pBGFootGroup->FlailAsLimb(m_Pos, RotateOffset(m_pBGLeg->GetParentOffset()), m_pBGLeg->GetMaxLength(), m_PrevVel, m_AngularVel, m_pBGLeg->GetMass(), deltaTime);
@@ -2208,12 +2213,12 @@ void AHuman::PreControllerUpdate() {
22082213

22092214
if (m_pFGLeg) {
22102215
Vector jointPos = m_Pos.GetFloored() + m_pFGLeg->GetParentOffset().GetXFlipped(m_HFlipped);
2211-
m_pFGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][STAND], deltaTime, nullptr, !m_pBGLeg, Vector(0.0F, m_Paths[FGROUND][STAND].GetLowestY()), m_WalkPathOffset);
2216+
m_pFGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[FGROUND], m_Paths[FGROUND][STAND], deltaTime, nullptr, !m_pBGLeg, Vector(0.0F, m_Paths[FGROUND][STAND].GetLowestY()), pathOffset);
22122217
}
22132218

22142219
if (m_pBGLeg) {
22152220
Vector jointPos = m_Pos.GetFloored() + m_pBGLeg->GetParentOffset().GetXFlipped(m_HFlipped);
2216-
m_pBGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][STAND], deltaTime, nullptr, !m_pFGLeg, Vector(0.0F, m_Paths[FGROUND][STAND].GetLowestY()), m_WalkPathOffset);
2221+
m_pBGFootGroup->PushAsLimb(jointPos, m_Vel, m_WalkAngle[BGROUND], m_Paths[BGROUND][STAND], deltaTime, nullptr, !m_pFGLeg, Vector(0.0F, m_Paths[FGROUND][STAND].GetLowestY()), pathOffset);
22172222
}
22182223
}
22192224
}
@@ -2383,7 +2388,7 @@ void AHuman::Update() {
23832388
m_SharpAimMaxedOut = true;
23842389
} else if (m_MoveState == WALK) {
23852390
maxLength *= 0.7F;
2386-
} else if (m_MoveState == CROUCH) {
2391+
} else if (m_MoveState == CROUCH || m_MoveState == PRONE) {
23872392
// Only when crouching still, otherwise it's WALK
23882393
maxLength *= 1.2F;
23892394
}
@@ -2488,7 +2493,7 @@ void AHuman::Update() {
24882493
}
24892494

24902495
float rotDiff = rot - rotTarget;
2491-
if (std::abs(rotDiff) > c_PI) {
2496+
if (std::abs(rotDiff) > c_PI * 0.75F) {
24922497
// We've h-flipped, so just snap to new orientation
24932498
rot = rotTarget;
24942499
} else {

0 commit comments

Comments
 (0)