Count and Outs

In short

These are derby rules, not real baseball. Only home runs are good: any fair ball that stays in the park is an out. Three strikes is an out. A foul is a strike but can’t be strike three. Four balls just reset the count (no walk). An inning has 3 outs by default, plus the Extra Outs stat, minus one on Hard.

How it works

CountTracker holds a CountState (balls, strikes, outs, outsAllowed). Every change raises GameEvents.CountChanged for the HUD.

What happenedRuleHeadline
Take, pitch in the zonestrike; the third is an outSTRIKE LOOKING / STRUCK OUT LOOKING
Take, pitch out of the zoneball; the fourth resets balls and strikesBALL / BALL FOUR - COUNT RESETS
Swing and missstrike; the third is an outSWING AND A MISS / STRUCK OUT!
Foul (contact, lands outside the foul lines)strike, but not with 2 strikes alreadyFOUL BALL
Cleared the wall on the fly, inside the poleshome run: score it, reset the countHOME RUN!
Fair, anything elseout, reset the countOFF THE WALL - OUT / GROUND OUT / FLY BALL - OUT
  • In the zone is decided when the pitch is created: StrikeZone.Contains(plateLocation). The zone counts a pitch that touches it (the ball’s radius is added to every edge). See Pitching.
  • Fair or foul comes from where the ball actually goes: a home run if it clears the wall inside the poles, else fair if it first lands within 45 degrees of centre. A ball can start fair and hook foul (see Hit Physics). A swing way early or late (spray beyond 45 degrees) heads foul, and holding A/D can’t aim it back (see Batting Explained).
  • Out type: “OFF THE WALL” if the ball hit the outfield wall before it landed; “GROUND OUT” if it never got 12 ft high; otherwise “FLY BALL”.
  • Any out (strikeout or ball in play) resets balls and strikes.
  • The round ends when outs >= outsAllowed (checked between pitches). See At-Bat Loop.

Outs per inning

  • Solo: max(1, RunConfig.outsPerInning + Difficulties.OutsDelta(difficulty)) + ExtraOuts.
  • Co-op: each turn gets CoopRules.OutsForTurn outs from a shared team pool. See Co-op Rules.
  • Batting cage: 999 outs (never ends in practice). See Batting Cage.
  • Outs you didn’t need pay a coin each when you clear an inning. See Shop and Economy.

The HUD draws outs as baseballs (white = left, red = used) and balls / strikes as lights: 3 for balls, 2 for strikes.

Numbers

WhatValueWhere to tune
Strikes for an out3CountTracker.StrikesForOut
Balls that reset the count4CountTracker.BallsForWalk
Outs per inning (Normal, Medium)3RunConfig.outsPerInning
Outs change on Hard-1 (never below 1)Difficulties.OutsDelta
Extra outs+ ExtraOuts stat (base 0)upgrades, synergies, batter perks
Co-op outs per turn2 if ExtraOuts > 0, else 1CoopRules.OutsForTurn
Ground-out heightbelow 12 ft max heightAtBatController.GroundBallMaxHeightFt
Fair territorylanding point within +/-45 degrees, or over the wall inside the polesHitPhysics.FoulLineDeg

In the code

FileWhat it does
Assets/_Project/Scripts/Batting/CountTracker.csAddStrike(isFoul), AddBall(), AddOut(), ResetCount(), AddOutsAllowed() (dev)
Assets/_Project/Scripts/Batting/AtBatController.csPlayOutcome (takes and whiffs), ResolvePlay (balls in play)
Assets/_Project/Scripts/Run/RunManager.csOutsPerInning, sets context.outsAllowed
Assets/_Project/Scripts/UI/HudView.csDrawCount: outs, B and S lights, coins, HR count

Gotchas

  • Ball four gives the batter nothing except a fresh count. There is no walk and no base runner.
  • A foul with 2 strikes leaves the count unchanged but still raises CountChanged.
  • A foul or an out can still be a GREEN and keeps the green streak going. It just scores nothing.
  • Each result also has its own stamp, sound and play card. See Batting Feedback.
  • The ExtraOuts stat is rounded with GetInt (Mathf.RoundToInt).
  • AddOutsAllowed (dev menu) never drops outs allowed below the outs already made. See Dev Menu and Shortcuts.