Hero Progression
Relevant source files
The following files were used as context for generating this wiki page:
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroSubClass.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/ArmorAbility.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v0_9_X_Changes.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v2_X_Changes.java
Hero progression encompasses the various mechanics by which the player character grows in power and specialization throughout a run. This includes gaining experience and levels, increasing core attributes, and making significant choices regarding class, talents, and abilities. These systems are primarily managed within the Hero class, which serves as the central hub for all player character data and state changes.
The progression is marked by several key milestones: starting with a base HeroClass, choosing a HeroSubClass after defeating the fourth boss, and selecting a powerful ArmorAbility after defeating the fifth boss. Layered on top of this is the Talent system, which provides incremental bonuses and new abilities as the hero levels up.
This diagram illustrates the main components of the hero's progression system and their relationships.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:87-91, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroSubClass.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/ArmorAbility.java
Leveling and Experience
The most fundamental form of progression is leveling up by gaining experience (XP). The hero gains XP primarily by defeating enemies. The process is managed by the earnExp method in the Hero class.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:1010-1061
Experience Gain Flow
The following diagram shows the logic flow when a hero earns experience.
Key Leveling Mechanics
- Max Level: The hero's level is capped at 30.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:82 - XP per Level: The experience required to level up is calculated by the
maxExp()method, which returns5 + lvl * 5.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:1062-1064 - Level Up Bonuses: Upon leveling up, the hero's
attackSkillanddefenseSkilleach increase by one, and their maximum health (HT) is recalculated. The player also gains a talent point to spend.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:1053-1055
Core Attributes
The hero's combat effectiveness is determined by several core attributes that increase during progression.
Health (HP/HT)
- HT (Max Health): The hero's maximum health. It is recalculated upon leveling up. The formula is
(20 + 5 * (lvl - 1) + HTBoost) * RingOfMightMultiplier.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:204-215 - HP (Current Health): The hero's current health, which cannot exceed
HT.
Strength (STR)
- Base STR: The hero starts with a base strength of 10. Strength is increased by consuming Potions of Strength.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:84 - Effective STR: The
STR()method calculates the hero's effective strength, which includes bonuses from items like the Ring of Might, buffs like Adrenaline Surge, and talents like Strongman.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:224-238
Attack and Defense Skills
attackSkill: A base value used in accuracy calculations. It starts at 10 and increases by 1 with each level.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:87, 1054defenseSkill: A base value used in evasion calculations. It starts at 5 and increases by 1 with each level.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:88, 1055
Major Progression Milestones
Throughout a run, the player makes several key choices that define their hero's build.
This state diagram shows the major stages of a hero's progression throughout a game.
Class and Subclass Selection
Every run begins with a chosen HeroClass. After defeating the fourth boss, Tengu, the player is prompted to choose one of two HeroSubClass specializations.
| Hero Class | Subclass 1 | Subclass 2 |
|---|---|---|
| WARRIOR | GLADIATOR | BERSERKER |
| MAGE | BATTLEMAGE | WARLOCK |
| ROGUE | ASSASSIN | FREERUNNER |
| HUNTRESS | SNIPER | WARDEN |
| DUELIST | CHAMPION | MONK |
| CLERIC | PALADIN | PRIEST |
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroSubClass.java:28-85, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v0_9_X_Changes.java:200
Talents
Talents are passive bonuses or abilities that the hero gains by spending talent points earned from leveling up. The talent system is divided into four tiers, each unlocked at a specific level range.
| Tier | Level Range | Points per Level | Max Points per Talent | Notes |
|---|---|---|---|---|
| 1 | 2-6 | 1 | 2 | General utility talents. |
| 2 | 7-12 | 1 | 2 | More powerful, class-specific talents. |
| 3 | 13-20 | 1 | 3 | Subclass-specific talents. |
| 4 | 21-30 | 1 | 4 | Armor ability-specific talents. |
The number of available talent points is calculated by the talentPointsAvailable(int tier) method in Hero.java. This method checks the hero's level against the tier thresholds and subtracts any points already spent.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java:51-56, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:284-298
Armor Abilities
After defeating the fifth boss, the Dwarf King, the player chooses one of three powerful ArmorAbility options. These abilities consume armor energy to use and can be further enhanced by investing in Tier 4 talents. The chosen ability is stored in the armorAbility field of the Hero object.
Each armor ability has three associated talents, plus a shared talent (HEROIC_ENERGY) that improves charge speed.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v0_9_X_Changes.java:179-184, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:89, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/ArmorAbility.java:56-58
Data Persistence
Hero progression data is stored and retrieved via the storeInBundle and restoreFromBundle methods in the Hero class. This includes level, experience, stats, class choices, and spent talent points, ensuring the character's state is preserved across game sessions.
// core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:245-271
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( CLASS, heroClass );
bundle.put( SUBCLASS, subClass );
bundle.put( ABILITY, armorAbility );
Talent.storeTalentsInBundle( bundle, this );
bundle.put( ATTACK, attackSkill );
bundle.put( DEFENSE, defenseSkill );
bundle.put( STRENGTH, STR );
bundle.put( LEVEL, lvl );
bundle.put( EXPERIENCE, exp );
bundle.put( HTBOOST, HTBoost );
belongings.storeInBundle( bundle );
}
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java:245-271