Batting Mechanics

## Controls

Press A to do a normal swing (also known as a slap swing). Holding A will initiate a more powerful charge swing.

Use the control stick to move the character around the box. This controls where the contact zone of character's bat will be. To re-center the character, you can press L (the movement for this is 3x the speed of normal movement).

When making contact, the control stick influences which direction the ball will be hit to. Left and right influence the horizontal angle the ball will be hit more towards the direction of the control stick. Up and down influence the launch angle of the ball, but in the reverse direction (up to make ground balls more likely, down to increase pop-fly likeliness).

Holding the R button while hitting the ball toggles the character's star swing ability. Enough stars are required for the star swing to activate. Pressing this button automatically sets the charge percentage to 0%. Therefore, if there aren’t enough stars to trigger a star swing, this can be used to force a 0% charge hit, which can sometimes increase the exact velocity of the hit (more details below)

Hold B to attempt to bunt the ball.

Pressing Y will instruct on-base characters to steal. If you only want 1 character to steal, point control stick to their next base when pressing Y. The X button will cancel the steal.

## Batter Stats

Each character in the game has a unique combination of batting attributes that control how they hit. Here are what they mean

The full batter stat breakdown can be found at the Batter Stats page.

### Star Swings

Specifies the type of star hit when one is triggered. For captain characters, the type in brackets shows what star hit they have in Challenge Mode before their actual star swing is bought in the shop.

### Swing Power

Each character has a slap, charge and bunt power statistic that influences how hard they will hit the ball. How this translates into exit velocity can be found below.

#### Charge Swing Power

Charge hit power depends on the timing of the contact with the pitch and will be somewhere between (1) the Charge Hit Power stat and (2) the average of the Charge Hit Power and the Slap Hit Power stats.

* While charging up, the power is the average (2) until full charge is achieved.
* At full charge, the power jumps up to be the Charge Hit Power Stat (1). It remains here for generally 30 frames for most characters.
* Once over-charging starts, the power slowly goes from the Charge Hit Power Stat (1) to the average (2)
* At fully overcharged, the power remains at the average (2).

##### Walu Tech Explained

For characters who have a higher Slap Power Stat compared to their Charge Power Stat, the average (2) is higher than the Charge Power Stat (1). This means their hardest hits aren't at max charge, as you would normally expect. Players with this characteristic are known as "tech characters" in the community. Because of how the power varies by frame, there are three main ways of getting max power with tech characters.

1. Holding R when there aren't enough team stars for a star hit: due to a bug in the code, holding R automatically sets the charge to be fully overcharged.
2. Overcharging: by starting a charge early enough for a full overcharge.
3. Undercharging (new discovery): Hitting the ball before the character was able to achieve max charge.

The graph on the right shows the progression of the power of a hit, depending on how long the character has been charging. Normal characters peak at their max charge timing, while tech characters have their lowest power at the max charge timing.

#### Charge time to achieve full power

The amount of time it takes to get to 100% charge and how long they stay there varies by character. These values can be found in the batting stats page.

### Trajectory Types

Each character has a vertical and horizontal trajectory statistic that influences the direction the ball will hit off of the bat.

#### Vertical Trajectory

This determines the angle above the ground that the ball will launch at off of the bat. Characters are classified as Low, Mid, and High. High trajectory characters tend to pop-up more often. Mid tends to make lines drives that will make it over the infield on slap hits. Low trajectory slap hits usually can't clear the infielders.

#### Horizontal Trajectory (Push/Pull hitters)

This statistic indicates the characters preferred field to hit it to. Multipliers are applied to the exit velocity based on if the character hit to their preferred field. For more information, see the batting algorithm below.

### Contact Size Multipliers

These values determine the widths of each hit quality zones, as explained in the Contact Algorithm Section.

## Star Hits

### Basic information

#### Star swing cost

Star hits are activated by making contact when holding the R button and the player has enough stars built up. For characters who can be a captain, their star swing will cost 1 point if they are the captain of their team, and 2 stars if not. The star swings of non-captain characters costs 1 per use. A missed star swing costs 1 star for every character.

#### Starting stars

The game will start each team out with stars. The number of stars is determined by the average strength of the chemistry between the captain and the rest of the characters on the team.

Let C = average chemistry

C >= 70 -> 5 starting stars

55<= C < 70 -> 4 starting stars

35 < = C < 55 -> 3 starting stars

15 <= C < 35 -> 2 starting stars

C < 15 -> 1 starting star

#### Accumulating Stars

When there are no runners on base and one of the players doesn't have a full star gauge, there is a 1/3 chance that an at-bat will be a "Star Chance". The only exception to this is the first at-bat of the game, in which case the game will never give a star chance.

If a player reaches base safely on the star chance, they will be awarded with a star. More comprehensive testing needs to be done to confirm all of the situations where a star is awarded (like fielders choices), but in general, hits, walks, or hit by pitches award stars. After getting a single, if the batter is thrown out on the bases during the same play, a star chance will not be awarded.

### Types of Star Swings

#### [Green] Fireball

This is the ability of Mario and Luigi. The ball will catch fire for a period of time, causing the fielder to automatically bobble the ball.

Mario's ball will be a line drive that usually makes it to the outfield while still on fire. Since the bobble is usually high in the air, a common defense against the fire ball is to try to block the ball with a jumping infielder, or to run towards the infield with an outfielder to try to make the bobble catchable by another player, resulting in an out.

Luigi's ball will be a groundball to the infield. Since it moves fairly slowly, the ball will usually return to normal if the infielder backs up, and there is usually enough time left over to throw Luigi out at first.

#### Banana/Boomerang Ball

This is the ability of Donkey and Diddy Kong. The ball will turn into a banana and will have a severe curve, which makes it hard for the outfielders to catch. The direction of the curve depends on the handedness of the batter. If left handed, the ball will curve from right to left, and vise-versa for right handed batters.

Donkey Kong's version generally has a higher trajectory, but both make it to the outfield. The specific contact frame will determine where the ball will land.

#### Heart/Flower Ball

This is the ability of Peach and Daisy. On contact, the ball will be popped up and be replaced with hearts/flowers. The drop spot will disappear, and the ball will not reappear until it is close to the ground. It won't be in the center of the heart/flower animations, so it is difficult for the fielders to catch.

The game will choose a random spot 5m-12m away from where the ball will drop to set where the fielder will auto-run towards if no input is selected.

#### Egg/Weird Ball

This is the ability of Yoshi and Birdo. On contact, the ball will turn into an egg. If not caught, the ball will bounce in random directions 3 times. Birdo's initial ball initially lands just beyond the infield, and has higher subsequent bounces compared to Yoshi's hit that generally stays in the infield for all three bounces.

#### Killer [Jr.] Ball

This is the ability of Bowser and Bowser Jr.. On contact, the ball will turn into a Bullet Bill that travels very fast on a line drive. It will remain in bullet bill form until hitting the wall or being caught by a fielder. If caught, the fielder will experience push-back 4x longer than normal, which will paralyze them until the animation ends. Despite getting out, this is useful for sacrifice flies to advance other runners.

Both versions of the ability are the same except for Jr's ball having a bandana on the Bullet Bill.

#### Phony/Liar Ball

This is the star hit of Wario and Waluigi. On contact, the ball will pop up, and at it's apex it will split into two balls. Shortly before hitting the ground, one will randomly turn into a piece of garlic or an eggplant. The garlic/eggplant will temporarily stun a fielder that tries to catch it. Wario's ability travels considerably further than Waluigi's version.

#### Pop Fly

Players with this ability will always pop the ball up on contact and will reach the outfield. If contact with the pitch is sour, this is known as a Falcon Pop, and lands for a hit the majority of the time.

Players with this ability: Dry Bones (R) Hammer Bro, King Boo, Koopa Troopa (R) Noki (R), Petey, Pianta (R), Shy Guy (Black, R), Toad (P, R).

#### Line Drive

Players with this ability hit a hard, curving line drive that will land in the outfield. Since the trajectory is lower, it is at risk of being caught by infielders, but it still has a reasonably high chance of success.

Players with this ability: Boomerang Bro, Dry Bones (Green), Koopa Paratroopa (G), Magikoopa, Noki (G), Toadsworth,

#### Grounder

This ability will cause the character to hit a hard ground ball.

Players with this star hit: Baby Luigi, Baby Mario, Boo, Dixie Kong, Dry Bones (Gray, Blue), Fire Bro, Goomba, Koopa Paratroopa (R), Koopa Troopa (G), Monty Mole, Noki (B), Paragoomba, Pianta (B), Shy Guy (Blue, G, Y), Toad (B, Y), Toadette.

#### 5-Star Dinger / Moonshot

When the batter has 5 stars, charging and making perfect contact with the ball will trigger an automatic home run. This will use all 5 of the stars.

If perfect contact isn’t made, non-captain characters will trigger a lazy pop fly. This is known as a Texas Leaguer in the community.

## Bunting

Bunting makes the batter hold their bat still over the plate instead of swinging at the ball. It is useful to sacrifice the batter to advance another runner, or to try to get a fast character on base since they are tricky to defend. Since it is easier to make contact with bunts, the batter is out if they bunt the ball foul on 2 strikes

### Glitch Bunting

When bunting, the game’s fielder select sometimes avoids picking the pitcher who would otherwise be able to get the player out easily. This can be exploited to consistently get on base.

Using modifications, manual fielder select has been able to make glitch bunts irrelevant.

### Dingus/Fake Bunting

When bunting, the 1B and 3B fielders move closer to the plate to defend the small hits better. This can be taken advantage of by pretending to bunt before pulling back and slap hitting, which is known as dingus bunting. Since the fielders are closer to the plate, it is easier to hit the ball by them.

## Contact frames

https://discord.com/channels/628353660698624020/747305360255352832/960677652744773663

There is a window of time in which the batter will make contact with the ball. The window is 9 frames long for slap swings and 7 frames long for charge swings. The actual timing of the contact is constant, but the swinging animation will be lengthened/shortened it order for the bat to make contact with the pitch.

The contact frame variable that the game tracks is stored as "frames before contact". In these terms, frame 10 is the earliest a player can hit the ball using slap swings, and frame 2 is the latest. The range is 9 to 3 on charge swings.

## Batting Algorithm

### Contact Determination

When calculating contact, the game looks at the batter's X position, and the ball's X position.

For righty hitters, the ball's X position is negative on the left side of the screen, and positive on the right. Otherwise the batter's X position is flipped.

If the batter has a non trimmed bat, they have a bat body/bat tip hitbox of [-0.85, 0.15]. This means that the bat body extends 0.85 units towards the player, and the bat tip extends 0.15 units away from the player.

If the batter has a trimmed bat, they have a bat body/bat tip hitbox of [-0.35, 0.35].

If the ball is outside this region, it will not make contact.

### Contact Quality

Not only does the specific contact spot matter, but the classification for sour, nice, and perfect is also used in many calculations. Each bat is split into 5 zones: left sour, left nice, perfect, right nice, and right sour (although, usually at least 1 zone isn’t possible to hit during any given at bat depending on the character and their handedness). The zones are different for each character, and are usually not symmetric.

The basic algorithm for the zones is to scale the basic zones according to the "Contact Size Multiplier" (Batter Stats) and then scale the left and right zones according to the "Horizontal Reach" values.

The full algorithm can be found here: Contact Zones Calculations

**Uses:**

* Initial exit velocity
* The balls flight path through added gravity
* Launch angles
* Horizontal angles
* Moonshot trigger for 5-star hits
* Pitch influence on adjusted power

### Ball trajectory

If the game determines that contact was made, it then calculates 3 basic values that largely determine what direction the ball will be hit: horizontal angle, launch angle, and exit velocity. These can be visualized in the graphic on the right. After these initial quantities are determined, the ball physics will determine how the ball will travel in the air.

#### Horizontal Angle

The horizontal angle represents the initial angle towards the field that the ball is hit at, with the back corner of home plate being the focal point. Straight ahead (towards 2B) is 0°, and the angles increase towards 3B. The 3B foul line is at 45°, and the 1B foul line is at -45°.

The horizontal angle of a hit is determined by the contact frame, the input stick direction at the time of contact, the type of swing (slap/charge), and a random number. The angles aren't necessarily where the ball will land due to the balls having curves.

The graphics on the right show a good overview of all the possible angles for each situation. The zones for right-handed batters are the exact opposite angles. For the exact values, see this page: Horizontal Angles.

##### Slice Hits

The angles have a quirk where the ball goes straight toward 2B with no variation. These are known as "Slice hits". For slap hits, the can be performed on the 10th frame while holding the push direction. They are also empirically known to happen on non-captain, grounder and pop-up star swings on frame 2 (and presumably can't happen for for line-drive-types), but the ranges for them haven't been decoded yet.

Shout-out to Roeming for working out the details of the batting formula.

#### Launch Angle

The launch angle of the hit depends on the vertical trajectory type of the batter, slap vs charge, the type of contact made, the control stick direction being up or down, and potentially if the batter is player- or CPU-controlled (this factor seems unused in the game).

##### Overview of the calculation

Other than control stick influence, all of the factors listed above combine to determine 5 possible ranges of angles and each of their probabilities of occurring. The stick influence then adjusts the probabilities - holding down makes the higher angles more likely, and holding up makes the lower angles more likely. After the range of angles is determined, the game will uniformly choose the final launch angle from that range. It will then normalize the final value and make sure it will be in the direction of the field (which is why there are no foul balls back into the stands).

##### Angle Ranges and their Probabilities

The complete list of angles can be found here: Batting Launch Angles

**Stick Influence:** holding up on the control stick (or the d-pad)\* at the time A is pressed takes the highest two ranges and moves their probabilities to the lowest range. Holding down on the control stick at the time of contact takes the probability of the lowest range and moves it to the highest range.

For example, if you hold down on a mid-trajectory character on a right-nice slap hit, the 4.39° <-> 13.18° range will have its probability dropped from 20% to 0% and the 26.37° <-> 30.76° range will have its probability increased from 20% to 40%.

There is one exception to the stick influence: when holding down for a change-up pitch, a sour-contact slap will ignore the stick influence.

\*Note, if both the control stick and the d-pad are pressed at the same time, the control stick input gets priority.

#### Normalization Algorithm (to ensure hits are always directed toward the stadium)

The code always re-bases the vertical angle to be between 0 and 360. Further, if the pre-re-based vertical angle was more than 90 degrees or less than -90 degrees, the algorithm will turn the horizontal angle around by 180 degrees, too, and re-base that angle to make sure it is between 0 and 360.

#### Exit Velocity

The last variable calculated for hit balls is the exit velocity. This is how fast the ball is initially travelling at the moment of contact.

##### Basic form of the formula

Exit velocity = Unadjusted Exit Velocity \* (0.8 + 0.2 \*(Adjusted Power/100)) \* Horizontal Trajectory Factor \* Moonshot Factor

Where Adjusted Power = Initial power \* Cursed ball factor \* Chemistry Factor \* Pitch Type Factor

##### Details of the calculation

(Check out the associated links for more details)

Before calculating exit velocity, adjusted power must be calculated first. This comes from the power stats of each character with several factors multiplied to it.

###### Adjusted Power

1. **Initial power**: this is the starting value for the calculation. For dull details, see the Initial Power page. This value depends on the type of swing:
	1. *Slap hits and non-captain star hits*: the value is equal to slap hit power
	2. *Charge hits*: For charge hits, the value starts at the charge hit power and moves towards the slap hit power for how overcharged you are. The value can only move half way towards the slap hit power value.
		1. Initial power = Charge power - 0.5 \* (Charge Power - Slap Power) \* (1 - charge %)
			1. Notice that charge % = 100% will make the subtracted part equal to 0, meaning the initial power will equal the charge power stat.
			2. Interestingly, characters with slap power greater than their charge power (like Waluigi) will have higher initial power for overcharging.
				1. Pro Tip: if the star gauge is empty, the game automatically sets charge % to 0 if the player presses R while charging, which is an easy way to overcharge
				2. The extra details page has a calculation for how much a 0% charge increases power vs 100% charge.
	3. *Captain star hits*: value is always set to 100.
2. **Cursed Ball Impact to Power**: Each pitcher has a cursed ball statistic that dampens the power for non-perfect swings. The factors that are multiplied to initial power are:
	1. *Nice contact*: cursed ball factor = 1 - cursed ball stat \* 0.2
	2. *Sour contact*: cursed ball factor = 1 - cursed ball stat \* 0.5
	3. *Perfect contact*: cursed ball factor = 1
		1. More info on cursed ball
3. **Chemistry Links on Base Impact to Power**: For charge swings only, Power will be multiplied by a factor that is based on the number of chemistry links on base.
	1. The factors are 1x, 1.1x, 1.25x, and 1.5x for 0, 1, 2, 3 chemistry links, respectively.
4. **Pitch type Impact to Power**: The type of pitch the pitcher threw combines with the swing type and contact type to give another factor that influences power.
	1. There are 13 factors that range between 0.6 (perfect pitch, sour contact, slap hit) and 1.1 (perfect pitch, perfect contact, charge hit)
	2. The list of factors can be found here: Pitch Type Impact to Exit Velocity
5. **Summary**: Adjusted power = initial power \* cursed ball impact \* chemistry impact \* pitch impact

Now that the adjusted power is calculated, the exit velocity calculation can begin.

###### Exit Velocity

1. **Unadjusted Exit Velocity**: Each contact type has a range of starting exit velocities. The exact value is picked from the range by determining how close the player was from contacting the ball in the next level of contact quality (for example, for a left sour hit, how close was the player from making it a nice left hit?).
	1. The ranges are at the bottom of the section. (Note, this step also determines an increased gravity factor that is used in the ball physics later. This can be ignored for the exit velocity calculation, but it's mentioned here to demonstrate why it makes sense that the ranges overlap)
	2. For an example, suppose the player makes nice contact with a slap hit, and they were half way to achieving a perfect hit. They will have a in unadjusted exit velocity of 142.5 (half way between 140 and 145).
	3. The details of this step can be found here: Unadjusted Exit Velocity
2. **Incorporation of Adjusted Power**: the unadjusted exit velocity is then combined with the adjusted power that was calculated earlier. 80% of the unadjusted velocity remains the same, and the remaining 20% is scaled by the power value divided by 100.
	1. For example, suppose the unadjusted exit velocity is 142.5, and the adjusted power is 75. The resulting intermediate exit velocity is 142.5 \* (.80 + 0.2 \* 0.75) = 135.375
		1. Superstarring characters adds 50 to the power stats, but caps at 100. Therefore, the unadjusted velocity is the maximum velocity possible. If the cap of 100 isn’t reached, the superstarred exit velocity will be 10% faster than the non-superstarred version.
3. **Preferred Horizontal Trajectory Impact**: Each batter has a preferred side of the field that they hit to, and a factor is applied depending on what direction the hit is.
	1. The field is split into 4 equally-sized slices. Each slice has a range of multipliers, and the initial horizontal angle is used to calculate the exact factor applied to the velocity using linear interpolation. The ranges are found at the end of this section.
4. **Moonshot impact**: if a 5-star homerun was triggered, then the exit velocity is multiplied by 1.5.
5. **Final exit velocity**: The integer value is the exit velocity of the ball. (coming soon: how to translate this into mph)

The final exit velocity is then used in the physicals calculation, which is described in the next section

**Tables for unadjusted exit velocity**

Slap hit unadjusted exit velocity ranges
 Nice
 Perfect

Charge hit unadjusted exit velocity ranges
 Nice
 Perfect

###### Bunt exit velocity

For bunts, the exit velocity is simply based on this table. A final value is selected randomly from the ranges.

 Nice
 Perfect

#### Hit ball physics

After the initial quantities above are calculated, the game calculates the ball's velocity and acceleration to determine how it will fly through the air.

**Velocity**

The game uses half of the exit velocity calculated earlier and separates it into the x, y, z components according to the launch and horizontal angles.

Example: exit velocity=100, launch angle = 0 (straight ahead for simplicity), horizontal angle = 45.

1: split exit velocity in half -> 50

2: Since 45 degrees is half way between the x and z direction, the x and z component velocities will take 50% of the velocity, each -> 25 for x and z.

**Acceleration**

The game calculates acceleration for each direction. Part of each direction is an air resistance factor, which impacts then velocity by x0.996 each frame. For the y direction, there is the standard gravity of 0.00275, plus the added gravity factor from the exit velo algorithm divided by 100,000.

On top of the air resistance, the x and z directions are impacted by ball curve when not bunting.

There are 4 components contributing to the degree of curve a ball has. Each is explained in depth here: Ball curve on hits.

* Contact Spot: the closer to perfect contact, the more curve the ball will have. Characters with the Super-Curve attribute get a boost to this factor.
* Launch angle: The curve starts to decrease once the launch angle is above 33.75 degrees, constantly decreasing until 78.75 degrees, at which point there will be no curve.
* Horizontal angle: this determines which direction the curve will go, and its magnitude. The point at which the curve direction flips is at 8.4 degrees to the batters pull side. The further away the ball is from this point, the more dramatic the curve is.
* Super-curve: Each ball hit has some degree of curve, but the characters with super-curve have a higher curve factor.

All of the quantities above are multiplied together to get the acceleration in the x and z direction. The sign of the accelerations are adjusted to match the left-right polarity determined from the horizontal angle, and the z curve is always set to be back towards home plate.

**Flight path of the ball**

After determining the velocity and acceleration for each direction in the last step, the game iteratively updates the ball's position in the air.

Hit balls start at the pitch height (a pitcher stat) and the contact x and z coordinates of the ball.

Then, the game adds the component velocity values to each position to get the new position.

p

n

=

p

n
−
1

v

n

{\displaystyle p\_{n}=p\_{n-1}+v\_{n}}

The velocity is then adjusted based on the acceleration factors.

x velocity:

v

n

=

v

n
−
1

∗
A
i
r
R
e
s
i
s
t
a
n
c
e

a

x

{\displaystyle v\_{n}=v\_{n-1}\*AirResistance+a\_{x}}

y velocity

v

n

=
(

v

n
−
1

−
G
r
a
v
i
t
y
)
∗
A
i
r
R
e
s
i
s
t
a
n
c
e

a

y

=
(

v

n
−
1

−
0.00275
)
∗
0.996
A
d
d
e
d
G
r
a
v
i
t
y
F
a
c
t
o
r

{\displaystyle v\_{n}=(v\_{n-1}-Gravity)\*AirResistance+a\_{y}=(v\_{n-1}-0.00275)\*0.996+AddedGravityFactor}

z velocity:

v

n

=

v

n
−
1

∗
A
i
r
R
e
s
i
s
t
a
n
c
e

a

z

{\displaystyle v\_{n}=v\_{n-1}\*AirResistance+a\_{z}}

After the ball hits the ground (y=0) or is caught, these calculations stop. We presume the flight paths for throws and groundballs have a different algorithm.

**Longer distance for Super-Curve batters**

Super-curve increases the acceleration in the x direction but it decreases the acceleration in the z direction. While this might intuitively imply that the ball will travel less, it actually makes balls travel further from home plate. This is due to the fact that while the z-distance is impacted slightly, the added x-distance means the overall effect is that the ball lands further from home. A demonstration is shown in the graphic on the right.

#### Landed Ball Physics

The gravity factor is 0.00275. There is an air resistance factor that slows the ball down by 0.4% each frame.

## Movement in the batters box

**Under construction**. Ideas: Move speed, hit boxes, how some players can get closer to the plate than others

## To Be Confirmed

Full star chance possibilities (like what happens on a fielders choice?)

Falcon pop name, and why its best for righties.

1. ↑ https://discord.com/channels/628353660698624020/628354009865912350/946843561486331914
2. ↑ https://discord.com/channels/628353660698624020/747305360255352832/991026994630238278
3. ↑ https://discord.com/channels/628353660698624020/747305360255352832/991869651795591240