Status Effect System
Overview
Complete buff/debuff system supporting stacking, duration, tick damage/heal, stat modifiers, and VFX integration.
When to Use
- Use when implementing buffs (speed boost, damage up)
- Use when implementing debuffs (slow, poison, burn)
- Use when abilities apply status effects
- Use when enemies apply conditions to player
- Use when environmental hazards apply effects
Architecture
┌─────────────────────────────────────────────────────────────┐
│ StatusEffectSO │
│ (ScriptableObject Asset) │
├─────────────────────────────────────────────────────────────┤
│ Identity: ID, Name, Icon, Type (Buff/Debuff) │
│ Duration: Time, IsPermanent, Stacking │
│ Tick: Interval, Damage, Heal │
│ Stats: [{Stat, Type, Value}, ...] │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ StatusEffectHandler │
│ (On Entity) │
├─────────────────────────────────────────────────────────────┤
│ ApplyEffect(effect, stacks) │
│ RemoveEffect(effect) │
│ Update: Process ticks, decrement duration │
│ Events: OnEffectApplied, OnEffectRemoved, OnEffectTick │
└─────────────────────────────────────────────────────────────┘
Effect Types
| Type | Examples |
|------|----------|
| Buff | Speed Up, Damage Up, Shield |
| Debuff | Slow, Poison, Burn, Stun |
| DoT | Poison, Burn, Bleed (tick damage) |
| HoT | Regeneration (tick heal) |
Stack Behaviors
- RefreshDuration: Reset timer (default)
- AddDuration: Extend existing
- AddStack: Increase intensity
- Ignore: No effect if already applied
Best Practices
- ✅ Use ScriptableObjects for effect definitions
- ✅ Connect OnEffectTick to damage/heal system
- ✅ Show active effects in UI with duration
- ✅ Use VFX anchor for particle positioning
- ❌ NEVER modify StatusEffectSO at runtime
- ❌ NEVER forget to integrate tick with health system
Few-Shot Examples
Example 1: Apply Poison
User: "Enemy attack applies poison."
Agent:
// In EnemyAttack.cs
if (hit.TryGetComponent<StatusEffectHandler>(out var handler))
{
handler.ApplyEffect(poisonEffectSO, 1);
}
Example 2: Speed Buff
User: "Potion gives 20% speed for 10 seconds."
Agent:
// StatusEffectSO asset:
// Duration: 10, Type: Buff
// StatModifiers: [{MovementSpeed, Percent, 0.2}]
Example 3: Stacking Bleed
User: "Each hit adds a bleed stack, max 5."
Agent:
// StatusEffectSO asset:
// IsStackable: true, MaxStacks: 5
// StackBehavior: AddStack
// HasTick: true, TickDamage: 5 per stack
TDD Contract
⚠️ Legacy Skill — Refactor Pending
Este skill NO tiene tests automatizados aún. El siguiente boilerplate es un punto de partida.
// Escribe estos tests ANTES de implementar:
// Test 1: should [expected behavior] when [condition]
[Test]
public void StatusEffectSystem_Should{ExpectedBehavior}_When{Condition}()
{{
// Arrange
// TODO: Setup test fixtures
// Act
// TODO: Execute system under test
// Assert
Assert.Fail("Not implemented — write test first");
}}
// Test 2: should handle [edge case]
[Test]
public void StatusEffectSystem_ShouldHandle{EdgeCase}()
{{
// Arrange
// TODO: Setup edge case scenario
// Act
// TODO: Execute
// Assert
Assert.Fail("Not implemented");
}}
// Test 3: should throw when [invalid input]
[Test]
public void StatusEffectSystem_ShouldThrow_When{InvalidInput}()
{{
// Arrange
var invalidInput = default;
// Act & Assert
Assert.Throws<Exception>(() => {{ /* execute */ }});
}}
Pasos para completar el TDD:
- Descomenta los tests above
- Implementa la funcionalidad mínima para que compile
- Ejecuta los tests — deben fallar (RED)
- Implementa la funcionalidad real
- Verifica que los tests pasen (GREEN)
- Refactorea manteniendo los tests verdes
Nota: Este skill fue marcado como tdd_first: false durante la auditoría v2.0.1. La sección TDD fue agregada automáticamente pero requiere customización manual para reflejar el comportamiento real del skill.
Related Skills
@damage-health-framework- Tick damage integration@ability-skill-system- Abilities that apply effects@scriptableobject-architecture- SO patterns
Template Files
templates/StatusEffectSO.cs.txt- Effect definitiontemplates/StatusEffectHandler.cs.txt- Effect management