XP and Levels

In short

Every finished run earns XP twice: once for the account and once for the batter who played it. The account level (max 50) decides which batters and cosmetics can be bought and which call signs can be worn. A batter’s character level (max 10) adds small trait perks at levels 2, 5 and 10. Only XP is saved; levels are always worked out from it, so curves can be retuned without breaking saves.

How it works

  1. Run XP (Leveling.RunXp), the same amount for both tracks:

    xp = round((inningsCleared x 25 + homeRuns x 5 + (won ? 150 : 0)) x MetaPoints(difficulty))
    
  2. MetaProgression.AwardXp adds it to SaveData.accountXp and to the batter’s BatterProgress.xp, fills the XP fields of the RunSummary, and returns lines for the results screen: ACCOUNT LEVEL 3!, NEW ITEMS TO BUY: NERD GLASSES, TOP HAT, NEW BATTER TO BUY: BAKED BEAN, NEW CALL SIGN: BIG STICK, STRING BEAN LEVEL 2: +2% CONTACT.

  3. Account curve. The step from level L to L+1 costs 100 + 75 x (L - 1) XP. Total to reach level L:

    steps = L - 1
    AccountXpForLevel(L) = 100 x steps + 75 x steps x (steps - 1) / 2
    
  4. Character curve. A fixed table (below), level 10 at 4,500 XP.

  5. Level perks. Each batter has levelPerks (a level and a stat modifier). MetaProgression.LevelBonus returns every perk at or below the batter’s level; RunState adds them to the run’s stats at run start, and the batting cage and the title screen stat bars use them too.

  6. Results screen. Two bars fill one after the other: ACCOUNT LV n then BATTER LV n, each with +n XP (or MAX). LEVEL UP! pops with a chime at each new level. A click on the card or Space skips to the end. XP is already saved when the bars fill: it is awarded before the end-of-game cutscene (Cutscenes).

Numbers

WhatValueWhere to tune
XP per inning cleared25Leveling.XpPerInning
XP per home run5Leveling.XpPerHomeRun
XP for beating the map150Leveling.XpForWin
Difficulty multiplierx1 / x1.5 / x2.5Difficulties.MetaPoints
Max account level50Leveling.MaxAccountLevel
Max character level10Leveling.MaxCharacterLevel
Account first step / growth100 / +75 per levelLeveling.FirstStep, StepGrowth
Perk levels2, 5, 10DefaultContent.PerkLevels

Total account XP per level (from the formula; the test checks 100 and 3,600):

Level2345678910152050
XP1002755258501250172522752900360082251472593100

Total character XP per level (Leveling.CharacterXp):

Level12345678910
XP03006501050150020002550315038004500

Default perks (each applies from its level on):

BatterLevel 2Level 5Level 10
Peapod+2% Timing Window+2% Timing Window+2% Timing Window
Baked Bean+1% Power+1% Power+1% Power
String Bean+2% Contact+2% Contact+2% Contact
Pinto+1 Coins per HR+1 Coins per HR+1 Extra Outs

Example: a Normal win with 15 home runs earns 9 x 25 + 15 x 5 + 150 = 450 XP, taking a new account from level 1 to 3 and a new batter from level 1 to 2.

In the code

FileWhat it does
Assets/_Project/Scripts/Progression/Leveling.csCurves: RunXp, AccountXpForLevel, AccountLevel, AccountProgress, CharacterXpForLevel, CharacterLevel, CharacterProgress
Assets/_Project/Scripts/Progression/MetaProgression.csAwardXp, AccountLevel, BatterLevel, LevelBonus, NextPerk, CanBuy, SelectedCallSign
Assets/_Project/Scripts/Data/BatterDefinition.csrequiredLevel, levelPerks, LevelPerk
Assets/_Project/Scripts/Data/DefaultContent.csPerks, batter and cosmetic requiredLevel, call sign levels
Assets/_Project/Scripts/UI/RunOverView.csThe two animated XP bars
Assets/_Project/Editor/ProgressionXpTest.csCurves, run XP, perks, level gates, call signs, AwardXp lines, old saves

Gotchas

  • Percent perks add to the batter’s own percent: a level 10 Baked Bean has +23% Power, not 1.2 x 1.03.
  • Level perks are fixed when a run starts; levels gained at the end of a run apply from the next run.
  • Pinto’s extra out only comes at level 10 because outs are whole numbers.
  • In co-op each player earns XP from the team’s innings and their own home runs.
  • A save from before levels existed loads at account level 1, every batter level 1, wearing ROOKIE.
  • Dev menu can add XP or set the account or a batter to a level, and reset levels. See Dev Menu and Shortcuts.