Skip to content

Commit

Permalink
Sync outward boost ramp drifts
Browse files Browse the repository at this point in the history
  • Loading branch information
malleoz committed Jun 17, 2024
1 parent b1879a0 commit dd35d3a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Test Case | Frames | |
[`bc-rta-2-08-697`](https://youtu.be/1DEReKemoeI) | 809 / 8126 | ❌ | KMP
[`bc-ng-rta-2-20-001`](https://youtu.be/028nClzy7B4) | 809 / 8803 | ❌ | KMP
[`rr-rta-1-24-751`](https://youtu.be/dgNMHyFda14) | 349 / 5491 | ❌ | Outward-drifting bike
[`rr-ng-rta-2-24-281`](https://youtu.be/O-BtWWsq82o) | 806 / 9060 | ❌ | Missing boost ramp check in calcTop
[`rr-ng-rta-2-24-281`](https://youtu.be/O-BtWWsq82o) | 1113 / 9060 | ❌ | KMP
[`rpb-rta-0-59-978`](https://youtu.be/Z-lVl-7B-So) | 1079 / 4007 | ❌ | Moving water
[`rpb-ng-rta-1-12-656`](https://youtu.be/LujU0kJx-hU) | 2492 / 4767 | ❌ | Moving water
[`ryf-rta-0-58-648`](https://youtu.be/3IKzbmawUbk) | 584 / 3927 | ❌ | Water
Expand Down
4 changes: 4 additions & 0 deletions source/game/kart/KartCollide.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ bool KartCollide::isRampBoost() const {
return m_rampBoost;
}

bool KartCollide::isTrickable() const {
return m_trickable;
}

bool KartCollide::isNotTrickable() const {
return m_notTrickable;
}
Expand Down
1 change: 1 addition & 0 deletions source/game/kart/KartCollide.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public:
u16 someNonSoftWallTimer() const;

bool isRampBoost() const;
bool isTrickable() const;
bool isNotTrickable() const;
/// @endGetters

Expand Down
11 changes: 7 additions & 4 deletions source/game/kart/KartMove.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ KartMove::KartMove() : m_smoothedUp(EGG::Vector3f::ey), m_scale(1.0f, 1.0f, 1.0f
m_bPadJump = false;
m_bSsmtCharged = false;
m_bSsmtLeeway = false;
m_bTrickableSurface = false;
m_bWallBounce = false;
m_jump = nullptr;
}
Expand Down Expand Up @@ -169,6 +170,7 @@ void KartMove::init(bool b1, bool b2) {
m_bPadJump = false;
m_bSsmtCharged = false;
m_bSsmtLeeway = false;
m_bTrickableSurface = false;
m_bWallBounce = false;
m_jump->reset();
m_rawTurn = 0.0f;
Expand Down Expand Up @@ -267,16 +269,16 @@ void KartMove::calcTop() {
if (state()->isHop() && m_hopPosY > 0.0f) {
stabilizationFactor = m_driftingParams->stabilizationFactor;
} else if (state()->isTouchingGround()) {
if (state()->trickableTimer() > 0 && inputTop.dot(m_dir) > 0.0f && m_speed > 50.0f &&
collide()->isNotTrickable()) {
if ((m_bTrickableSurface || state()->trickableTimer() > 0) &&
inputTop.dot(m_dir) > 0.0f && m_speed > 50.0f && collide()->isNotTrickable()) {
inputTop = m_up;
} else {
m_up = inputTop;
}

f32 scalar = 0.8f;

if (!state()->isBoost() && !state()->isWheelie()) {
if (!state()->isBoost() && !state()->isRampBoost() && !state()->isWheelie()) {
f32 topDotZ = 0.8f - 6.0f * (EGG::Mathf::abs(inputTop.dot(componentZAxis())));
scalar = std::min(0.8f, std::max(0.3f, topDotZ));
}
Expand All @@ -300,6 +302,7 @@ void KartMove::calcTop() {
dynamics()->setStabilizationFactor(stabilizationFactor);

m_nonZipperAirtime = state()->airtime();
m_bTrickableSurface = collide()->isTrickable();
}

/// @addr{0x8057D888}
Expand Down Expand Up @@ -1278,7 +1281,7 @@ void KartMove::calcHopPhysics() {
void KartMove::calcVehicleRotation(f32 turn) {
f32 tiltMagnitude = 0.0f;

if (state()->isAnyWheelCollision()) {
if (!state()->isSoftWallDrift() && state()->isAnyWheelCollision()) {
EGG::Vector3f front = componentZAxis();
front = front.perpInPlane(m_up, true);
EGG::Vector3f frontSpeed = velocity().rej(front).perpInPlane(m_up, false);
Expand Down
7 changes: 4 additions & 3 deletions source/game/kart/KartMove.hh
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ protected:
bool m_bPadBoost; ///< Caches whether the player is currently interacting with a boost pad.
bool m_bRampBoost;
bool m_bPadJump;
bool m_bSsmtCharged; ///< Set after holding a stand-still mini-turbo for 75 frames.
bool m_bSsmtLeeway; ///< If set, activates SSMT when not pressing A or B.
bool m_bWallBounce; ///< Set when our speed loss from wall collision is > 30.0f.
bool m_bSsmtCharged; ///< Set after holding a stand-still mini-turbo for 75 frames.
bool m_bSsmtLeeway; ///< If set, activates SSMT when not pressing A or B.
bool m_bTrickableSurface; ///< Set when driving on a trickable surface.
bool m_bWallBounce; ///< Set when our speed loss from wall collision is > 30.0f.
KartJump *m_jump;
const DriftingParameters *m_driftingParams; ///< Drift-type-specific parameters.
f32 m_rawTurn; ///< Float in range [-1, 1]. Represents stick magnitude + direction.
Expand Down
2 changes: 1 addition & 1 deletion testCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Flare RR NG RTA WR": {
"rkgPath": "samples/rr-ng-rta-2-24-281.rkg",
"krkgPath": "samples/rr-ng-rta-2-24-281.krkg",
"targetFrame": 806
"targetFrame": 1113
},
"Logan rMC NG RTA WR": {
"rkgPath": "samples/rmc-ng-rta-1-30-272.rkg",
Expand Down

0 comments on commit dd35d3a

Please sign in to comment.