Status Effects (Buffs, Debuffs, Blobs)
Relevant source files
The following files were used as context for generating this wiki page:- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Buff.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Fire.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/duelist/ElementalStrike.java
- core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MonkEnergy.java
Status effects are temporary or persistent conditions that modify the state and behavior of characters or the environment. They are broadly categorized into Buffs, which are applied directly to characters (Char), and Blobs, which are area-of-effect hazards on the dungeon map. The Char class is central to managing these effects, handling their application, removal, and turn-based logic.
This system is fundamental to gameplay, introducing a wide array of tactical possibilities and challenges, from damage-over-time effects like Burning to complex class mechanics like the Monk's MonkEnergy.
Core Architecture
The status effect system is built around two main abstract classes: Buff for character-specific effects and Blob for tile-based effects. The Char class orchestrates the application and management of Buff instances.
Class Diagram
This diagram shows the inheritance and composition relationships between the core components of the status effect system.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Buff.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Fire.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/MonkEnergy.java
Buff System
Buffs are status effects applied directly to a Char instance. They can be positive (buffs), negative (debuffs), or neutral.
The Buff Class
The Buff class is an Actor that is attached to a Char. It defines the core lifecycle and properties of a status effect.
| Property/Method | Description |
|---|---|
type | An enum (POSITIVE, NEGATIVE, NEUTRAL) that categorizes the buff. |
act() | Called each game turn to execute the buff's logic (e.g., deal damage, decrement duration). |
attachTo(Char) | Attaches the buff to a character and adds it to the actor queue. |
detach() | Removes the buff from its character and the actor queue. |
resistances() | Returns a set of effect classes that this buff provides resistance to. |
immunities() | Returns a set of effect classes that this buff provides immunity to. |
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Buff.java:34-106
Buff Management in Char
The Char class manages all buffs affecting it. Buffs are stored in a LinkedHashSet<Buff> to maintain insertion order and prevent duplicates of the exact same buff instance.
| Method | Description |
|---|---|
add(Buff buff) | Attaches a buff to the character. Returns false if the character is immune or the buff is otherwise prevented. |
remove(Buff buff) | Detaches a buff from the character. |
buffs(Class<T> c) | Returns a HashSet of all buffs that are instances of the given class. |
buff(Class<T> c) | Returns a single buff instance of the exact given class, or null if not present. |
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java:1017-1080
Example Buff: Burning
The Burning buff is a simple negative effect that deals damage over time.
- Application: It is typically applied by the
Fireblob. - Logic: In its
act()method, it deals damage to the attached character. The damage amount is determined by thelevelof the buff. - Removal: The buff is removed if the character enters water. A change in v2.5.0 made it so the buff ends the moment water is entered, but still always deals at least one turn of damage.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java, core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v2_X_Changes.java:181-182
Blob System
Blobs are tile-based area-of-effect hazards. They are not attached to characters but can affect any character that enters their area.
The Blob Class
The Blob class is an Actor that manages a set of tiles on the map.
| Property/Method | Description |
|---|---|
mass | A HashMap<Integer, Integer> where the key is the tile position and the value is the "mass" or intensity of the blob on that tile. |
act() | The main logic loop. It handles spreading, dissipating, and affecting characters within its area. |
seed(int pos, int mass, Class<? extends Blob> type) | A static factory method to create a new blob at a specific position. |
affect(Char ch) | An abstract method called when a character is on a blob tile. Subclasses implement this to apply effects (e.g., apply a Buff). |
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java:44-131
Example Blob: Fire
The Fire blob is a common environmental hazard.
- Behavior: It spreads to adjacent flammable tiles and can be extinguished by water.
- Effect: Its
affect(Char ch)method applies theBurningbuff to any character standing on aFiretile.
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Fire.java:46-53
Interaction Flow: Fire and Burning
This diagram shows how a character stepping into a Fire blob receives the Burning buff.
Application & Interaction Examples
Status effects are applied through various game mechanics, including items, character abilities, and enemy attacks.
WandOfCorruption
The WandOfCorruption is an example of an item that applies a variety of debuffs. Its onZap method contains logic to determine which effect to apply.
The logic flow for WandOfCorruption is as follows:
- Calculate
corruptingPowerbased on the wand's level. - Calculate
enemyResistbased on the target's HP, EXP value, and existing debuffs. - If
corruptingPoweris greater thanenemyResist, the enemy is corrupted (or doomed if immune to corruption). - Otherwise, there is a chance to apply a major or minor debuff.
The wand can apply the following debuffs, which in turn reduce the target's resistance to future corruption attempts.
| Debuff Category | Debuffs | Resistance Weaken |
|---|---|---|
| Major | Amok, Slow, Hex, Paralysis | 1/2 |
| Minor | Weakness, Vulnerable, Cripple, Blindness, Terror | 1/4 |
Sources: core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java:59-90
ElementalStrike Ability
The Duelist's ElementalStrike armor ability demonstrates how status effects can be dynamically generated based on equipment. The ability's effect is determined by the enchantment on the Duelist's equipped melee weapon.
This diagram shows the logic for selecting an effect:
For example, a Blazing enchantment causes the ability to create a Fire blob, while a Vampiric enchantment heals the hero based on the number of targets hit.
MonkEnergy Buff
The MonkEnergy buff is a prime example of using the buff system to implement a core class mechanic. It is a permanent, positive buff for the Monk subclass that manages a resource called "energy".
- Energy Gain: Energy is gained by defeating enemies. The amount depends on the enemy type (e.g., bosses grant more).
- Energy Spending: Energy is spent to use the Monk's special abilities, such as
Flurry,Focus, orDragonKick. - Empowered Abilities: If the Monk's energy is above a certain threshold (determined by the
Monastic Vigortalent), their abilities become empowered, gaining enhanced effects.
This demonstrates the versatility of the Buff class, extending it beyond simple status ailments to manage complex resource systems.