37 {500.0f, 0.0f, 6000.0f, -1.0f},
38 {500.0f, 5000.0f, 6000.0f, -1.0f},
39 {120.0f, 2000.0f, 1000.0f, 45.0f},
103 if (
state()->isDrifting()) {
114 if (!
state()->isDrifting()) {
125 static constexpr std::array<DriftingParameters, 3> DRIFTING_PARAMS_ARRAY = {{
126 {10.0f, 0.5f, 0.5f, 1.0f},
127 {10.0f, 0.5f, 0.5f, 0.2f},
128 {10.0f, 0.22f, 0.5f, 0.2f},
286 for (
u16 tireIdx = 0; tireIdx <
suspCount(); ++tireIdx) {
347 constexpr float RESPAWN_HEIGHT = 700.0f;
354 respawnPos.
y += RESPAWN_HEIGHT;
366 constexpr f32 LAKITU_VELOCITY = 1.5f;
367 constexpr u16 RESPAWN_DURATION = 110;
376 newPos.
y -= LAKITU_VELOCITY;
390 constexpr s16 RESPAWN_BOOST_DURATION = 30;
391 constexpr s16 RESPAWN_BOOST_INPUT_LENIENCY = 4;
438 f32 stabilizationFactor = 0.1f;
468 scalar = std::clamp(topDotZ, 0.3f, 0.8f);
476 if (bodyDotFront < -0.1f) {
477 stabilizationFactor += std::min(0.2f, EGG::Mathf::abs(bodyDotFront) * 0.5f);
481 stabilizationFactor = 0.4f;
511 if (
m_up.
y <= 0.99f) {
570 if (dirDiff.
squaredLength() <= std::numeric_limits<f32>::epsilon()) {
581 if (origDirCross.
dot(newDirCross) < 0.0f) {
605 f32 angle = EGG::Mathf::atan2(crossDot, dot);
606 angle = EGG::Mathf::abs(angle);
627 constexpr f32 STICKY_RADIUS = 200.0f;
640 EGG::Mathf::abs(
m_speed) <= 20.0f) {
649 bool stickyRoad =
false;
651 for (
size_t i = 0; i < 3; ++i) {
715 auto *psea = objDir->psea();
722 for (
u16 wheelIdx = 0; wheelIdx < count; ++wheelIdx) {
724 if (wheelIdx == 0 || tmp <
pos) {
729 if (objDir->risingWaterKillPlaneHeight() >
pos) {
733 f32 dist = -objDir->distAboveRisingWater(
pos);
735 f32 speedScale = std::min(1.0f, dist / 100.0f);
789 constexpr s16 MAX_SSMT_CHARGE = 75;
790 constexpr s16 SSMT_BOOST_FRAMES = 30;
791 constexpr s16 LEEWAY_FRAMES = 1;
792 constexpr s16 DISABLE_ACCEL_FRAMES = 20;
960 constexpr s16 AUTO_DRIFT_START_DELAY = 12;
970 EGG::Mathf::abs(
state()->stickX()) > 0.85f) {
981 if (
state()->stickX() < 0.0f) {
1031 f32 angle = EGG::Mathf::atan2(rejCrossDirMag, driftRej.
dot(rotZ));
1033 if ((rotZ.
z * (rotZ.
x - driftRej.
x)) - (rotZ.
x * (rotZ.
z - driftRej.
z)) > 0.0f) {
1097 constexpr f32 OUTSIDE_DRIFT_BONUS = 0.5f;
1103 f32 driftAngle = 0.0f;
1139 constexpr f32 SMT_LENGTH_FACTOR = 3.0f;
1151 mtLength *= SMT_LENGTH_FACTOR;
1165 if (
state()->airtime() > 5) {
1173 if (angle > targetAngle) {
1175 }
else if (angle < targetAngle) {
1182 if (targetAngle > angle) {
1184 }
else if (targetAngle < angle) {
1205 turn = autoDrift ? stats.driftAutomaticTightness : stats.driftManualTightness;
1207 turn = autoDrift ? stats.handlingAutomaticTightness : stats.handlingManualTightness;
1215 bool forwards =
true;
1229 bool noTurn =
false;
1231 EGG::Mathf::abs(
m_speed) < 1.0f) {
1237 if (forwards && !noTurn) {
1241 turn += (1.0f - (
m_speed - 20.0f) / 50.0f) * turn;
1244 turn = (turn * 0.4f) + (
m_speed / 20.0f) * (turn * 0.6f);
1257 f32 stickX = EGG::Mathf::abs(
state()->stickX());
1258 if (autoDrift && stickX > 0.3f) {
1259 f32 stickScalar = (stickX - 0.3f) / 0.7f;
1260 stickX = drifting ? 0.2f : 0.5f;
1271 if (airtime >= 70) {
1273 }
else if (airtime >= 30) {
1274 turn = std::max(0.0f, turn * (1.0f - (airtime - 30) * 0.025f));
1281 angle = EGG::Mathf::abs(angle) * RAD2DEG;
1283 if (angle > 60.0f) {
1284 turn *= std::max(0.0f, 1.0f - (angle - 60.0f) / 40.0f);
1302 EGG::Mathf::abs(speedFix) >= 3.0f) &&
1342 if (
state()->airtime() > 5) {
1373 m_speed *= stats.turningSpeed + (1.0f - stats.turningSpeed) * x;
1389 initialVel = std::min(initialVel * 2.0f, 2.0f);
1391 vel *= std::clamp(-
bodyFront().y, -0.5f, 0.5f);
1405 std::span<const f32> as;
1406 std::span<const f32> ts;
1407 if (
state()->isDrifting()) {
1418 for (; i < ts.size(); ++i) {
1419 if (ratio < ts[i]) {
1420 acceleration = as[i] + ((as[i + 1] - as[i]) / (ts[i] - t_curr)) * (ratio - t_curr);
1434 constexpr f32 ROTATION_SCALAR_NORMAL = 0.5f;
1435 constexpr f32 ROTATION_SCALAR_MIDAIR = 0.2f;
1436 constexpr f32 ROTATION_SCALAR_BOOST_RAMP = 4.0f;
1437 constexpr f32 OOB_SLOWDOWN_RATE = 0.95f;
1438 constexpr f32 TERMINAL_VELOCITY = 90.0f;
1484 scaleMultiplier *= 0.7f;
1494 f32 boostSpeed = ignoreScale ? 1.0f : scaleMultiplier;
1498 speedLimit = boostSpeed;
1504 speedLimit = std::max(speedLimit, 100.0f);
1509 f32 local_c8 = 1.0f;
1535 crossVec = -crossVec;
1538 f32 rotationScalar = ROTATION_SCALAR_NORMAL;
1540 rotationScalar = ROTATION_SCALAR_BOOST_RAMP;
1542 rotationScalar = ROTATION_SCALAR_MIDAIR;
1561 nextSpeed.
y = std::min(nextSpeed.
y, maxSpeedY);
1599 if (wallNrm.
y > 0.0f) {
1607 f1 = std::max(0.0f, dot + 1.0f);
1639 if (speedDiff > 30.0f) {
1646 speedDiff = std::min(60.0f, speedDiff);
1664 f32 bumpDeviation = 0.0f;
1698 scalar = std::clamp(speedDiff, -3.0f, 3.0f);
1701 next = (scalar * 0.15f) * 0.25f;
1706 next = (scalar * 0.15f) * 0.08f;
1711 constexpr s16 MAX_SSMT_CHARGE = 75;
1712 next = 0.015f * (-
static_cast<f32>(
m_ssmtCharge) /
static_cast<f32>(MAX_SSMT_CHARGE));
1727 constexpr f32 DIVE_LIMIT = 0.8f;
1741 stickY = std::min(1.0f, stickY + 0.4f);
1747 if (EGG::Mathf::abs(stickY) < 0.1f) {
1751 stickY *= (airtime / 50.0f);
1760 if (
state()->airtime() < 50) {
1769 f32 angle = EGG::Mathf::abs(EGG::Mathf::atan2(crossNorm, upDotTop));
1771 f32 fVar1 = angle * RAD2DEG - 20.0f;
1772 if (fVar1 <= 0.0f) {
1776 f32 mult = std::min(1.0f, fVar1 / 20.0f);
1777 if (forwardRotated.
y > 0.0f) {
1823 return colDir->checkSphereFullPush(radius,
pos,
prevPos, flags, colInfo, maskOut, 0);
1828 f32 dotNorm = std::clamp(from.
dot(to), -1.0f, 1.0f);
1829 f32 acos = EGG::Mathf::acos(dotNorm);
1830 return acos > 0.0f ? std::min(0.1f,
scale / acos) : 0.1f;
1835 constexpr s16 BUMP_COOLDOWN = 5;
1854 f32 tiltMagnitude = 0.0f;
1863 if (frontSpeed.
squaredLength() > std::numeric_limits<f32>::epsilon()) {
1864 tiltMagnitude = frontSpeed.
length();
1866 if (front.
z * frontSpeed.
x - front.
x * frontSpeed.
z > 0.0f) {
1867 tiltMagnitude = -tiltMagnitude;
1870 tiltMagnitude = std::clamp(tiltMagnitude, -1.0f, 1.0f);
1900 constexpr u16 MAX_MT_CHARGE = 270;
1901 constexpr u16 MAX_SMT_CHARGE = 300;
1902 constexpr u16 BASE_MT_CHARGE = 2;
1903 constexpr u16 BASE_SMT_CHARGE = 2;
1904 constexpr f32 BONUS_CHARGE_STICK_THRESHOLD = 0.4f;
1905 constexpr u16 EXTRA_MT_CHARGE = 3;
1916 if (-BONUS_CHARGE_STICK_THRESHOLD <= stickX) {
1917 if (BONUS_CHARGE_STICK_THRESHOLD < stickX &&
m_hopStickX == -1) {
1936 if (-BONUS_CHARGE_STICK_THRESHOLD <= stickX) {
1937 if (BONUS_CHARGE_STICK_THRESHOLD < stickX &&
m_hopStickX == -1) {
1984 totalForce.
y = 0.0f;
1990 constexpr s16 BOOST_PANEL_DURATION = 60;
2004 constexpr s16 BOOST_RAMP_DURATION = 60;
2022 static constexpr std::array<JumpPadProperties, 8> JUMP_PAD_PROPERTIES = {{
2023 {50.0f, 50.0f, 35.0f},
2024 {50.0f, 50.0f, 47.0f},
2025 {59.0f, 59.0f, 30.0f},
2026 {73.0f, 73.0f, 45.0f},
2027 {73.0f, 73.0f, 53.0f},
2028 {56.0f, 56.0f, 50.0f},
2029 {55.0f, 55.0f, 35.0f},
2030 {56.0f, 56.0f, 50.0f},
2043 if (jumpPadVariant == 3 || jumpPadVariant == 4) {
2047 static constexpr std::array<JumpPadProperties, 2> JUMP_PAD_PROPERTIES_SHROOM_BOOST = {{
2048 {100.0f, 100.0f, 70.0f},
2049 {100.0f, 100.0f, 65.0f},
2057 if (jumpPadVariant == 4) {
2065 totalForce.
y = 0.0f;
2070 if (jumpPadVariant != 3) {
2097 newExtVel.
y += 20.0f;
2131 constexpr s16 MUSHROOM_DURATION = 90;
2148 constexpr s16 BASE_DURATION = 50;
2149 constexpr s16 TRICK_DURATION = 100;
2235 static constexpr std::array<s16, 3> KART_TRICK_BOOST_DURATION = {{
2240 static constexpr std::array<s16, 3> BIKE_TRICK_BOOST_DURATION = {{
2288 if (sizeScale.
z != 1.0f) {
2392 if (forwardLength < 30.0f || local94.
dot(forwardXZ) <= 0.0f) {
2399 const auto *cannonPoint =
2401 size_t cannonParameterIdx = std::max<s16>(0, cannonPoint->parameterIdx());
2404 f32 newSpeed = cannonParams.speed;
2405 if (forwardLength < cannonParams.decelFactor) {
2406 f32 factor = std::max(0.0f, forwardLength / cannonParams.decelFactor);
2408 newSpeed = cannonParams.endDecel;
2409 if (newSpeed <= 0.0f) {
2413 newSpeed += factor * (cannonParams.speed - newSpeed);
2414 if (cannonParams.endDecel > 0.0f) {
2422 if (cannonParams.height > 0.0f) {
2423 f32 fVar9 = EGG::Mathf::SinFIdx(
2442 EGG::Vector3f local60 = local54 + ((local48 - local54) * 0.3f);
2484 constexpr f32 MAX_WHEELIE_ROTATION = 0.07f;
2485 constexpr u16 WHEELIE_COOLDOWN = 20;
2523 EGG::Mathf::abs(
m_speed) < 5.0f) {
2536 f32 extVelXFactor = 0.0f;
2545 }
else if (!
state()->isDrifting()) {
2546 if (stickX <= 0.2f) {
2547 if (stickX >= -0.2f) {
2562 leanRotMin = -leanRotMax;
2566 if (stickX == 0.0f) {
2572 }
else if (stickX == 0.0f) {
2580 bool capped =
false;
2609 scalar = std::min(1.0f, scalar);
2612 if (std::numeric_limits<f32>::epsilon() < top.
squaredLength()) {
2625 static constexpr std::array<TurningParameters, 2> TURNING_PARAMS_ARRAY = {{
2626 {0.8f, 0.08f, 1.0f, 0.1f, 1.2f, 0.8f, 0.08f, 0.6f, 0.15f, 1.6f, 0.9f, 180},
2627 {1.0f, 0.1f, 1.0f, 0.05f, 1.5f, 0.7f, 0.08f, 0.6f, 0.15f, 1.3f, 0.9f, 180},
2670 constexpr u32 FAILED_WHEELIE_FRAMES = 15;
2671 constexpr f32 AUTO_WHEELIE_CANCEL_STICK_THRESHOLD = 0.85f;
2679 bool cancelAutoWheelie =
false;
2682 EGG::Mathf::abs(
state()->stickX()) <= AUTO_WHEELIE_CANCEL_STICK_THRESHOLD) {
2686 cancelAutoWheelie =
true;
2748 constexpr u16 MAX_MT_CHARGE = 270;
2749 constexpr u16 BASE_MT_CHARGE = 2;
2750 constexpr f32 BONUS_CHARGE_STICK_THRESHOLD = 0.4f;
2751 constexpr u16 EXTRA_MT_CHARGE = 3;
2760 if (-BONUS_CHARGE_STICK_THRESHOLD <= stickX) {
2761 if (BONUS_CHARGE_STICK_THRESHOLD < stickX &&
m_hopStickX == -1) {
2783 constexpr s16 COOLDOWN_FRAMES = 20;
@ COL_TYPE_MOVING_WATER
Koopa Cape and DS Yoshi Falls.
@ COL_TYPE_STICKY_ROAD
Player sticks if within 200 units (rBC stairs).
@ COL_TYPE_SPECIAL_WALL
Various other wall types, determined by variant.
#define KCL_TYPE_FLOOR
0x20E80FFF - Any KCL that the player or items can drive/land on.
constexpr void setAxisRotation(f32 angle, const EGG::Vector3f &axis)
Rotates the matrix about an axis.
constexpr Vector3f multVector(const Vector3f &vec) const
Multiplies a vector by a matrix.
constexpr Vector3f multVector33(const Vector3f &vec) const
Multiplies a 3x3 matrix by a vector.
constexpr void makeOrthonormalBasis(const Vector3f &forward, const Vector3f &up)
Sets a 3x3 orthonormal basis for a local coordinate system.
constexpr bool offBit(Es... es) const
Checks if all of the corresponding bits for the provided enum values are off.
constexpr bool onBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are on.
constexpr bool onAllBit(Es... es) const
Checks if all of the corresponding bits for the provided enum values are on.
constexpr TBitFlagExt< N, E > & resetBit(Es... es)
Resets the corresponding bits for the provided enum values.
constexpr TBitFlagExt< N, E > & setBit(Es... es)
Sets the corresponding bits for the provided enum values.
constexpr bool offAnyBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are off.
bool checkSphereFullPush(f32 radius, const EGG::Vector3f &v0, const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut, u32 timeOffset)
static CollisionDirector * Instance()
static ObjectDirector * Instance()
KartItem & kartItem(size_t idx)
static ItemDirector * Instance()
bool start(Action action)
Starts an action.
bool calc()
Computes the current frame's boost multiplier, acceleration, and speed limit.
bool activate(Type type, s16 frames)
Starts/restarts a boost of the given type.
void activateOob(bool detachCamera, Field::KCLTypeMask *mask, bool somethingCPU, bool somethingBullet)
void startFloorMomentRate()
KartPullPath & pullPath()
void setExtVel(const EGG::Vector3f &v)
const EGG::Vector3f & totalForce() const
const EGG::Vector3f & extVel() const
void setAngVel2(const EGG::Vector3f &v)
const EGG::Vector3f & movingObjVel() const
void setNoGravity(bool isSet)
void setTotalForce(const EGG::Vector3f &v)
void setTop(const EGG::Vector3f &v)
const EGG::Vector3f & angVel2() const
void setAngVel0(const EGG::Vector3f &v)
const EGG::Vector3f & pos() const
const EGG::Quatf & fullRot() const
void resetInternalVelocity()
void setStabilizationFactor(f32 val)
void setMovingObjVel(const EGG::Vector3f &v)
const EGG::Vector3f & angVel0() const
void addForce(const EGG::Vector3f &pos)
void setIntVel(const EGG::Vector3f &v)
void setPos(const EGG::Vector3f &pos)
void setMovingRoadVel(const EGG::Vector3f &v)
void setFullRot(const EGG::Quatf &q)
void applyWrenchScaled(const EGG::Vector3f &p, const EGG::Vector3f &f, f32 scale)
Applies a force linearly and rotationally to the kart.
void setGravity(f32 gravity)
void setMainRot(const EGG::Quatf &q)
const EGG::Quatf & mainRot() const
void setKillExtVelY(bool isSet)
void setTop_(const EGG::Vector3f &v)
static consteval f32 TerminalVelocity()
bool isBoostRampEnabled() const
SurfaceVariant variant() const
void tryStart(const EGG::Vector3f &left)
void createSubsystems(const KartParam::Stats &stats) override
f32 m_wheelieRot
X-axis rotation from wheeling.
const TurningParameters * m_turningParams
Inside/outside drifting bike turn info.
void init(bool b1, bool b2) override
virtual void startWheelie()
STAGE 1+ - Sets the wheelie bit flag and some wheelie-related variables.
f32 m_wheelieRotDec
The wheelie rotation decrementor, used after a wheelie has ended.
virtual void cancelWheelie()
Clears the wheelie bit flag and resets the rotation decrement.
void tryStartWheelie()
STAGE 1+ - Every frame, checks player input to see if we should start or stop a wheelie.
f32 m_leanRotInc
The incrementor for leaning rotation.
f32 wheelieRotFactor() const
void onWallCollision() override
Called when you collide with a wall. All it does for bikes is cancel wheelies.
void calcMtCharge() override
Every frame during a drift, calculates MT charge based on player input.
f32 m_maxWheelieRot
The maximum wheelie rotation.
void onHop() override
Virtual function that just cancels wheelies when you hop.
void setTurnParams() override
On init, sets the bike's lean rotation cap and increment.In addition to setting the lean rotation cap...
u32 m_wheelieFrames
Tracks wheelie duration and cancels the wheelie after 180 frames.
bool canWheelie() const override
Checks if the kart is going fast enough to wheelie.
f32 m_leanRot
Z-axis rotation of the bike from leaning.
s16 m_wheelieCooldown
The number of frames before another wheelie can start.
void calcWheelie() override
STAGE 1+ - Every frame, checks player input for wheelies and computes wheelie rotation.
void calcVehicleRotation(f32) override
Every frame, calculates rotation, EV, and angular velocity for the bike.
f32 m_leanRotCap
The maximum leaning rotation.
s16 m_autoHardStickXFrames
u16 m_floorCollisionCount
The number of tires colliding with the floor.
f32 m_processedSpeed
Offset 0x28. It's only ever just a copy of m_speed.
bool calcPreDrift()
Each frame, checks for hop or slipdrift. Computes drift direction based on player input.
f32 m_shockSpeedMultiplier
void calcWallCollisionStart(f32 param_2)
If we started to collide with a wall this frame, applies rotation.
void deactivateShock(bool resetSpeed)
s32 m_hopStickX
A ternary for the direction of our hop, 0 if still neutral hopping.
s16 m_offroadInvincibility
How many frames until the player is affected by offroad.
const JumpPadProperties * m_jumpPadProperties
EGG::Vector3f m_scale
Normally the unit vector, but may vary due to crush animations.
virtual void onWallCollision()
EGG::Vector3f m_smoothedForward
f32 m_kclWheelSpeedFactor
The slowest speed multiplier of each wheel's floor collision.
f32 m_divingRot
Induces x-axis angular velocity based on up/down stick input.
f32 m_speed
Current speed, restricted to the soft speed limit.
void calcDisableBackwardsAccel()
Computes the current cooldown duration between braking and reversing.
void calcStandstillBoostRot()
STAGE Computes the x-component of angular velocity based on the kart's speed.
f32 m_lastSpeed
Last frame's speed, cached to calculate angular velocity.
void calc()
Each frame, calculates the kart's movement.
f32 m_outsideDriftBonus
Added to angular velocity when outside drifting.
f32 m_hopPosY
Relative position as the result of a hop. Starts at 0.
EGG::Vector3f m_smoothedUp
A smoothed up vector, mostly used after significant airtime.
DrivingDirection m_drivingDirection
Current state of driver's direction.
f32 calcWallCollisionSpeedFactor(f32 &f1)
Every frame, computes a speed scalar if we are colliding with a wall.
void calcOffroad()
Each frame, computes rotation and speed scalars from the floor KCL.
s16 m_backwardsAllowCounter
Tracks the 15f delay before reversing.
virtual bool canHop() const
f32 m_outsideDriftAngle
The facing angle of an outward-drifting vehicle.
void calcSsmt()
Calculates standstill mini-turbo components, if applicable.
s16 m_bumpTimer
Set when a SmallBump collision occurs.
f32 m_acceleration
Captures the acceleration from player input and boosts.
s16 m_ssmtLeewayTimer
Frames to forgive letting go of A before clearing SSMT charge.
void applyForce(f32 force, const EGG::Vector3f &hitDir, bool stop)
void tryStartBoostPanel()
s32 getAppliedHopStickX() const
Factors in vehicle speed to retrieve our hop direction and magnitude.
void calcManualDrift()
Each frame, handles hopping, drifting, and mini-turbos.
void setInitialPhysicsValues(const EGG::Vector3f &position, const EGG::Vector3f &angles)
Initializes the kart's position and rotation. Calls tire suspension initializers.
EGG::Vector3f m_lastDir
m_speed from the previous frame but with signed magnitude.
void calcVehicleSpeed()
Every frame, computes speed based on acceleration and any active boosts.
f32 m_weightedTurn
Magnitude+direction of stick input, factoring in the kart's stats.
s32 m_hopFrame
A timer that can prevent subsequent hops until reset.
void calcSpecialFloor()
Every frame, calculates any boost resulting from a boost panel.
virtual void init(bool b1, bool b2)
void calcDive()
Responds to player input to handle up/down kart tilt mid-air.
f32 m_softSpeedLimit
Base speed + boosts + wheelies, restricted to the hard speed limit.
s16 m_timeInRespawn
The number of frames elapsed after position snap from respawn.
EGG::Vector3f m_cannonProgress
u16 m_smtCharge
A value between 0 and 300 representing current SMT charge.
f32 m_jumpPadBoostMultiplier
f32 m_kclWheelRotFactor
The slowest rotation multiplier of each wheel's floor collision.
KartBurnout m_burnout
Manages the state of start boost burnout.
EGG::Vector3f m_outsideDriftLastDir
Used to compute the next m_outsideDriftAngle.
void applyShrink(u16 timer)
void activateCrush(u16 timer)
void calcAutoDrift()
Each frame, handles automatic transmission drifting.
void applyStartBoost(s16 frames)
void startManualDrift()
Called when the player lands from a drift hop, or to start a slipdrift.
void calcSsmtStart()
Calculates whether we are starting a standstill mini-turbo.
void clearOffroadInvincibility()
f32 m_jumpPadSoftSpeedLimit
const EGG::Vector3f & smoothedUp() const
f32 m_speedDragMultiplier
After 5 frames of airtime, this causes speed to slowly decay.
void controlOutsideDriftAngle()
Every frame, handles mini-turbo charging and outside drifting bike rotation.
f32 m_jumpPadMinSpeed
Snaps the player to a minimum speed when first touching a jump pad.
f32 m_totalScale
[Unused] Always 1.0f
EGG::Vector3f m_cannonEntryOfs
EGG::Vector3f m_hopDir
Used for outward drift. Tracks the forward vector of our rotation.
const EGG::Vector3f & scale() const
f32 calcSlerpRate(f32 scale, const EGG::Quatf &from, const EGG::Quatf &to) const
s16 m_ssmtCharge
Increments every frame up to 75 when charging stand-still MT.
virtual void hop()
Initializes hop information, resets upwards EV and clears upwards force.
u16 m_mtCharge
A value between 0 and 270 representing current MT charge.
f32 m_cannonEntryOfsLength
virtual void calcMtCharge()
Every frame during a drift, calculates MT/SMT charge based on player input.
void activateBoost(KartBoost::Type type, s16 frames)
u16 m_mushroomBoostTimer
Number of frames until the mushroom boost runs out.
f32 m_kclRotFactor
Float between 0-1 that scales the player's turning radius on offroad.
bool canStartDrift() const
bool calcZipperCollision(f32 radius, f32 scale, EGG::Vector3f &pos, EGG::Vector3f &upLocal, const EGG::Vector3f &prevPos, Field::CollisionInfo *colInfo, Field::KCLTypeMask *maskOut, Field::KCLTypeMask flags) const
void calcAcceleration()
Every frame, applies acceleration to the kart's internal velocity.
f32 m_rawTurn
Float in range [-1, 1]. Represents stick magnitude + direction.
s16 m_respawnPostLandTimer
Counts up to 4 if not accelerating after respawn landing.
virtual f32 getWheelieSoftSpeedLimitBonus() const
Returns the % speed boost from wheelies. For karts, this is always 0.
void calcRotCannon(const EGG::Vector3f &forward)
void activateZipperBoost()
void releaseMt()
Stops charging a mini-turbo, and applies boost if charged.
u16 m_crushTimer
Number of frames until player will be uncrushed.
EGG::Vector3f m_cannonOrthog
f32 m_speedRatio
The ratio between current speed and the player's base speed stat.
void calcAirtimeTop()
Calculates rotation of the bike due to excessive airtime.
EGG::Vector3f m_up
Vector perpendicular to the floor, pointing upwards.
s16 m_autoDriftStartFrameCounter
void setScale(const EGG::Vector3f &v)
f32 m_hopVelY
Relative velocity due to a hop. Starts at 10 and decreases with gravity.
KartScale * m_kartScale
Manages scaling due to TF stompers and MH cars.
@ DriftReset
Set when a wall bonk should cancel your drift.
@ SsmtCharged
Set after holding a stand-still mini-turbo for 75 frames.
@ TrickableSurface
Set when driving on a trickable surface.
@ SsmtLeeway
If set, activates SSMT when not pressing A or B.
@ WallBounce
Set when our speed loss from wall collision is > 30.0f.
@ Respawned
Set when Lakitu lets go of the player, cleared when landing.
f32 m_speedRatioCapped
m_speedRatio but capped at 1.0f.
void calcRotation()
Every frame, calculates kart rotation based on player input.
KartHalfPipe * m_halfPipe
Pertains to zipper physics.
EGG::Vector3f m_cannonEntryPos
f32 m_hopGravity
Always main gravity (-1.3f).
const EGG::Vector3f & dir() const
void calcOffroadInvincibility()
Checks a timer to see if we are still ignoring offroad slowdown.
f32 m_kclSpeedFactor
Float between 0-1 that scales the player's speed on offroad.
virtual void createSubsystems(const KartParam::Stats &stats)
f32 calcVehicleAcceleration() const
Every frame, computes acceleration based off the character/vehicle stats.
s16 m_ssmtDisableAccelTimer
Counter that tracks delay before starting to reverse.
virtual void calcTurn()
Each frame, looks at player input and kart stats. Saves turn-related info.
void calcMushroomBoost()
Checks a timer to see if we are still boosting from a mushroom.
s16 m_respawnPreLandTimer
Counts down from 4 when pressing A before landing from respawn.
virtual void calcVehicleRotation(f32 turn)
Every frame, calculates rotation, EV, and angular velocity for the kart.
void resetDriftManual()
Clears drift state. Called when touching ground and drift is canceled.
void tryStartBoostRamp()
Sets offroad invincibility and enables the ramp boost bitfield flag.
void setOffroadInvincibility(s16 timer)
Ignores offroad KCL collision for a set amount of time.
void tryStartJumpPad()
Applies calculations to start interacting with a jump pad.
static constexpr f32 MINIMUM_DRIFT_THRESOLD
virtual void setTurnParams()
virtual void calcWheelie()
@ WaitingForBackwards
Holding reverse but waiting on a 15 frame delay.
f32 m_hardSpeedLimit
Absolute speed cap. It's 120, unless you're in a bullet (140).
f32 m_realTurn
The "true" turn magnitude. Equal to m_weightedTurn unless drifting.
const DriftingParameters * m_driftingParams
Drift-type-specific parameters.
f32 m_baseSpeed
The speed associated with the current character/vehicle stats.
const EGG::Vector3f & up() const
EGG::Vector3f m_landingDir
EGG::Vector3f m_hopUp
The up vector when hopping.
CollisionData & collisionData()
Field::KCLTypeMask wallKclType() const
const EGG::Vector3f & extVel() const
const EGG::Vector3f & prevPos() const
const EGG::Vector3f & componentZAxis() const
KartDynamics * dynamics()
const EGG::Vector3f & angVel2() const
void setInertiaScale(const EGG::Vector3f &scale)
const EGG::Vector3f & pos() const
std::pair< EGG::Vector3f, EGG::Vector3f > getCannonPosRot()
EGG::Vector3f bodyUp() const
Returns the second column of the rotation matrix, which is the "up" direction.
const System::KPad * inputs() const
const EGG::Vector3f & componentYAxis() const
u32 wallKclVariant() const
void setPos(const EGG::Vector3f &pos)
const EGG::Vector3f & intVel() const
const EGG::Vector3f & wheelEdgePos(u16 idx) const
KartSuspension * suspension(u16 suspIdx)
EGG::Vector3f bodyFront() const
Returns the third column of the rotation matrix, which is the facing vector.
const EGG::Quatf & mainRot() const
const EGG::Vector3f & velocity() const
const EGG::Vector3f & wheelPos(u16 idx) const
void setRot(const EGG::Quatf &q)
const EGG::Vector3f & componentXAxis() const
const Stats & stats() const
void composeExtraRot(const EGG::Quatf &rot)
void setPos(const EGG::Vector3f &pos)
void setVelocity(const EGG::Vector3f &vel)
f32 roadSpeedDecay() const
void startShrink(s32 unk)
const EGG::Vector3f & sizeScale() const
const EGG::Vector3f & pressScale() const
const EGG::Vector3f & top() const
f32 startBoostCharge() const
s32 jumpPadVariant() const
static CourseMap * Instance()
MapdataCannonPoint * getCannonPoint(u16 i) const
const RaceInputState & currentState() const
MapdataJugemPoint * jugemPoint() const
static RaceManager * Instance()
void egg_delete(const T *ptr)
T * egg_new(Args &&...args)
Pertains to kart-related functionality.
static constexpr std::array< CannonParameter, 3 > CANNON_PARAMETERS
@ Wheelie
Set while we are in a wheelie (even during the countdown).
@ HopStart
Set if m_bDriftInput was toggled on this frame.
@ RejectRoad
Collision which causes a change in the player's pos and rot.
@ DisableBackwardsAccel
Enforces a 20f delay when reversing after charging SSMT.
@ HalfPipeRamp
Set while colliding with zipper KCL.
@ SoftWallPush
Tracks whether we are being pushed by a soft wall or HWG.
@ Boost
Set while in a boost.
@ BoostOffroadInvincibility
Set if we should ignore offroad slowdown this frame.
@ HWG
Set when "Horizontal Wall Glitch" is active.
@ ZipperTrick
Set while tricking mid-air from a zipper.
@ SlipdriftCharge
Currently in a drift w/ automatic.
@ Hop
Set while we are in a drift hop. Clears when we land.
@ MushroomBoost
Set while we are in a mushroom boost.
@ SoftWallUnlockRotation
Set when we are in "Barrel Roll" state.
@ StickyRoad
Like the rBC stairs.
@ JumpPadDisableYsusForce
@ StickLeft
Set on left stick input. Mutually exclusive to m_bStickRight.
@ RespawnKillY
Set while respawning to cap external velocity at 0.
@ JumpPadMushroomCollision
@ VehicleBodyFloorCollision
Set if the vehicle body is colliding with the floor.
@ RejectRoadTrigger
e.g. DK Summit ending, and Maple Treeway side walls.
@ GroundStart
Set first frame landing from airtime.
@ Accelerate
Accel button is pressed.
@ StickRight
Set on right stick input. Mutually exclusive to m_bStickLeft.
@ ActionMidZipper
Set when we enter an action while mid-air from a zipper.
@ DriftInput
A "fake" button, normally set if you meet the speed requirement to hop.
@ AirtimeOver20
Set after 20 frames of airtime, resets on landing.
@ ZipperBoost
Set when boosting after landing from a zipper.
@ DriftManual
Currently in a drift w/ manual.
@ OverZipper
Set while mid-air from a zipper.
@ ChargingSSMT
Tracks whether we are charging a stand-still mini-turbo.
@ AccelerateStart
Set if m_bAccelerate was toggled on this frame.
@ Burnout
Set during a burnout on race start.
@ WallCollisionStart
Set if we have just started colliding with a wall.
@ AnyWheelCollision
Set when any wheel is touching floor collision.
@ AutoDrift
True if auto transmission, false if manual.
@ Wall3Collision
Set when colliding with wall KCL COL_TYPE_WALL_2.
@ TouchingGround
Set when any part of the vehicle is colliding with floor KCL.
@ ZipperInvisibleWall
Set when colliding with invisible wall above a zipper.
@ BeforeRespawn
Set on respawn collision, cleared on position snap.
@ WallCollision
Set if we are colliding with a wall.
@ BikeSideStuntTrick
A side StuntTrick with a bike.
A quaternion, used to represent 3D rotation.
constexpr f32 dot(const Quatf &q) const
Computes .
constexpr void setAxisRotation(f32 angle, const EGG::Vector3f &axis)
Set the quat given angle and axis.
constexpr void makeVectorRotation(const Vector3f &from, const Vector3f &to)
Captures rotation between two vectors.
constexpr void normalise()
Scales the quaternion to a unit length.
constexpr Vector3f rotateVector(const Vector3f &vec) const
Rotates a vector based on the quat.
static constexpr Quatf FromRPY(const EGG::Vector3f &rpy)
constexpr Quatf multSwap(const Vector3f &vec) const
constexpr Quatf slerpTo(const Quatf &q1, f32 t) const
Performs spherical linear interpolation.
constexpr bool offBit(Es... es) const
Checks if all of the corresponding bits for the provided enum values are off.
constexpr bool onBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are on.
constexpr TBitFlag< T, E > & setBit(Es... es)
Sets the corresponding bits for the provided enum values.
constexpr TBitFlag< T, E > & changeBit(bool on, Es... es)
Changes the state of the corresponding bits for the provided enum values.
constexpr void makeAllZero()
Resets all the bits to zero.
constexpr TBitFlag< T, E > & resetBit(Es... es)
Resets the corresponding bits for the provided enum values.
constexpr f32 squaredLength() const
The dot product between the vector and itself.
static const Vector3f zero
static const Vector3f inf
constexpr void set(f32 val)
constexpr f32 dot(const Vector3f &rhs) const
The dot product between two vectors.
constexpr f32 length() const
The square root of the vector's dot product.
constexpr Vector3f proj(const Vector3f &rhs) const
The projection of this vector onto rhs.
constexpr f32 normalise()
Normalizes the vector and returns the original length.
constexpr Vector3f cross(const Vector3f &rhs) const
constexpr Vector3f rej(const Vector3f &rhs) const
The rejection of this vector onto rhs.
constexpr Vector3f perpInPlane(const EGG::Vector3f &rhs, bool normalise) const
Calculates the orthogonal vector, based on the plane defined by this vector and rhs.
constexpr std::pair< Vector3f, Vector3f > projAndRej(const Vector3f &rhs) const
Stores information pertaining to a collision.
EGG::Vector3f tangentOff
The net "push out" vector.
EGG::Vector3f floorNrm
Colliding floor's up vector.
EGG::BoundBox3f bbox
Bounding box of "push out" vectors.
Information about the current collision and its properties.
Various character/vehicle-related handling and speed stats.
std::array< f32, 32 > kclRot
Rotation scalars, indexed using KCL attributes.
f32 driftAutomaticTightness
Affects turn radius when automatic drifting.
std::array< f32, 32 > kclSpeed
Speed multipliers, indexed using KCL attributes.
f32 driftReactivity
A weight applied to turn radius when drifting.
f32 driftOutsideTargetAngle
f32 driftOutsideDecrement
std::array< f32, 2 > accelerationDriftA
f32 speed
Base full speed of the character/vehicle combo.
f32 handlingReactivity
A weight applied to turn radius when not drifting.
std::array< f32, 1 > accelerationDriftT
f32 driftManualTightness
Affects turn radius when manual drifting.
std::array< f32, 4 > accelerationStandardA
std::array< f32, 3 > accelerationStandardT
u32 miniTurbo
The framecount duration of a charged mini-turbo.