46 virtual void init(
bool b1,
bool b2);
218 constexpr f32 LIMIT = 120.0f;
366 TrickableSurface = 6,
375 WaitingForBackwards = 2,
515 void onHop()
override;
520 void init(
bool b1,
bool b2)
override;
521 void clear()
override;
527 constexpr f32 WHEELIE_SPEED_BONUS = 0.15f;
533 constexpr f32 WHEELIE_ROTATION_FACTOR = 0.2f;
549 constexpr f32 WHEELIE_THRESHOLD = 0.3f;
constexpr bool onBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are on.
constexpr bool offAnyBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are off.
State management for boosts (start boost, mushrooms, mini-turbos).
Calculates the duration of burnout and rotation induced when holding acceleration too long during the...
Handles the physics and boosts associated with zippers.
Manages trick inputs and state.
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 leanRot() const override
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...
f32 getWheelieSoftSpeedLimitBonus() const override
Returns what % to raise the speed cap when wheeling.
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.
const EGG::Vector3f & vel1Dir() const
void setKCLWheelRotFactor(f32 val)
bool calcPreDrift()
Each frame, checks for hop or slipdrift. Computes drift direction based on player input.
f32 m_shockSpeedMultiplier
u16 floorCollisionCount() const
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.
virtual f32 leanRot() const
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.
f32 kclSpeedFactor() const
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.
void setKCLWheelSpeedFactor(f32 val)
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.
s16 respawnPostLandTimer() const
const EGG::Vector3f & lastDir() const
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.
EGG::TBitFlag< u32, ePadType > PadType
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 softSpeedLimit() const
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
virtual bool canWheelie() const
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.
void setUp(const EGG::Vector3f &v)
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 setPadType(PadType type)
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.
f32 speedRatioCapped() const
DriftState driftState() const
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.
f32 m_speedRatioCapped
m_speedRatio but capped at 1.0f.
void setSmoothedUp(const EGG::Vector3f &v)
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.
KartScale * kartScale() const
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 setDir(const EGG::Vector3f &v)
void setOffroadInvincibility(s16 timer)
Ignores offroad KCL collision for a set amount of time.
EGG::TBitFlag< u16, eFlags > Flags
void tryStartJumpPad()
Applies calculations to start interacting with a jump pad.
static constexpr f32 MINIMUM_DRIFT_THRESOLD
void setVel1Dir(const EGG::Vector3f &v)
virtual void setTurnParams()
KartHalfPipe * halfPipe() const
void setFloorCollisionCount(u16 count)
f32 hardSpeedLimit() const
const EGG::Vector3f & smoothedForward() const
virtual void calcWheelie()
DrivingDirection
The direction the player is currently driving in.
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.
const EGG::Vector3f & prevPos() const
const EGG::Vector3f & pos() const
Pertains to handling reject road.
Mainly responsible for calculating scaling for the squish/unsquish animation.
Pertains to kart-related functionality.
@ Wheelie
Set while we are in a wheelie (even during the countdown).
@ HopStart
Set if m_bDriftInput was toggled on this frame.
@ TouchingGround
Set when any part of the vehicle is colliding with floor KCL.
A quaternion, used to represent 3D rotation.
Wrapper around an integral type with an enum corresponding to its bits.
Stores information pertaining to a collision.
Represents turning information which differs only between inside/outside drift.
Houses parameters that vary between the drift type (inward bike, outward bike, kart).
Various character/vehicle-related handling and speed stats.