Status Effects
Status effects are conditions that stay on a character for a while. Poison hurts in steps and builds up, slow holds the speed down, and stun takes away all action. Each one needs its own rule for being applied again, and a stun needs a short protection afterwards so nobody is locked in place for good.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Status Effects" to my game.
What it should do: Status effects give attacks a lasting result beyond the damage: a hit can leave the target hurt, slowed or helpless for a while, which lets fights be won by setting things up.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> clear
clear: No effects
afflicted: Under effects
stunned: Stunned
resisting: Stun protected
clear --> afflicted: poison or slow lands
afflicted --> clear: effects run out
clear --> stunned: stun lands
afflicted --> stunned: stun lands
stunned --> resisting: stun runs out
resisting --> clear: protection ends
resisting --> afflicted: protection ends
```
Use these starting values:
- maxHealth: 100
- poisonDamage: 3
- tickInterval: 1 s
- poisonTime: 5 s
- maxStacks: 3
- poisonFloor: 1
- slowFactor: 0.5
- slowTime: 3 s
- stunTime: 1 s
- stunImmunity: 1.5 s
Watch out for these common mistakes:
- Applying poison again: Tell your AI: a new application refreshes the time and adds a stack, but the step clock keeps running.
- Stun that never ends: Tell your AI: a stun in progress is not extended, and for a short time after it ends a new stun does nothing.
- A long tick between two poison steps: Tell your AI: count every step that falls inside the time that passed, and not just one per tick.
- Poison that outright kills: Tell your AI: give poison a floor it cannot take health below, or decide on purpose that it can kill and say so in the game.
- An effect that ends in the same moment as a new one: Tell your AI: add new effects to how the character stood when the tick began. An effect that would run out this tick still counts as active.
- A cleanse that also removes stun: Tell your AI: say which effects a cleanse can remove. Here it takes off poison and slow, and a stun runs its course.
Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
What it does
Status effects give attacks a lasting result beyond the damage: a hit can leave the target hurt, slowed or helpless for a while, which lets fights be won by setting things up.
How it runs, as a diagram
Everything it can be in, and what moves it on. Your AI builds from exactly this.
How it runs, as a diagram
- No effects → Under effects: poison or slow lands
- Under effects → No effects: effects run out
- No effects → Stunned: stun lands
- Under effects → Stunned: stun lands
- Stunned → Stun protected: stun runs out
- Stun protected → No effects: protection ends
- Stun protected → Under effects: protection ends
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| maxHealth | 100 | The character's full health. It sets how much a full poison is worth. |
| poisonDamage | 3 | Damage of one poison step, for each stack. Small, because many steps add up and the stacks multiply it. |
| tickInterval | 1 s | Time between poison steps. A whole second is slow enough to read each step as one event. |
| poisonTime | 5 s | How long poison lasts, and what applying it again resets it to. |
| maxStacks | 3 | The most poison stacks at once. Without a limit, a swarm of small hits becomes a certain kill. |
| poisonFloor | 1 | Poison never takes health below this. At 1 it hurts but cannot end the character by itself, which keeps it from feeling unfair. |
| slowFactor | 0.5 | The share of normal speed while slowed. Half is easy to see and still allows the character to move. |
| slowTime | 3 s | How long slow lasts. Applying it again starts the time over and does not stack. |
| stunTime | 1 s | How long a stun lasts. Long enough to be worth the hit, short enough that the player does not give up the controller. |
| stunImmunity | 1.5 s | After a stun ends, a new stun does nothing for this long. It gives the player a moment to act and prevents a lock that never ends. |
What usually goes wrong
Applying poison again
If every new application restarts the step clock, a character hit often enough is never hurt by any poison step, and the effect does nothing against fast attackers.
Fix: Tell your AI: a new application refreshes the time and adds a stack, but the step clock keeps running.
Stun that never ends
If a new stun lands every time the last one ends, or each one adds to the time, the player is stuck watching and cannot do anything for the rest of the fight.
Fix: Tell your AI: a stun in progress is not extended, and for a short time after it ends a new stun does nothing.
A long tick between two poison steps
If poison only checks once per tick, a slow frame, or a game running at a low rate, swallows steps and does less damage than the same poison on a fast computer.
Fix: Tell your AI: count every step that falls inside the time that passed, and not just one per tick.
Poison that outright kills
A character can be killed by something it already survived: the hit that did not kill it was followed by a poison step that did, with nobody there to blame.
Fix: Tell your AI: give poison a floor it cannot take health below, or decide on purpose that it can kill and say so in the game.
An effect that ends in the same moment as a new one
If time runs out first, a new application at the same moment starts from nothing and loses its stack. If the new one comes first, the effect lives on. Games that do both in different places feel random.
Fix: Tell your AI: add new effects to how the character stood when the tick began. An effect that would run out this tick still counts as active.
A cleanse that also removes stun
If a cleanse removes every effect, it also frees a stunned character at once, which makes stun worthless against anyone with a cleanse ready.
Fix: Tell your AI: say which effects a cleanse can remove. Here it takes off poison and slow, and a stun runs its course.
How to check it works
- Your character is poisoned, with 100 health. Wait 0.9 seconds, then wait another 0.2: Nothing happens during the first 0.9 seconds, and then one step takes 3 health, so 97 are left.
- Your character is poisoned and the poison lasts 5 seconds. Wait 10 seconds: Poison hurts exactly 5 times, 15 health in all, and then the character is back to normal.
- Your character is poisoned. Poison lands six more times, and then one step falls: There are 3 stacks, not 7, and the step takes 9 health.
- Your character is poisoned and poison lands again every third of a second. Wait 6 seconds: A poison step still falls about once a second, and the time left stays nearly full.
- Your character is poisoned with 4 health. Wait 8 seconds, then another attack deals 50: Poison stops at 1 health, and only the attack takes it to zero.
- Your character is slowed. Wait 3 seconds: The speed is half while the slow lasts and back to normal afterwards.
- Your character was slowed 2 seconds ago. Slow lands again: The time is nearly the full 3 seconds again, and the speed is still half, not a quarter.
- Your character is stunned. Wait 1.1 seconds: The character cannot act and has no speed for 1 second, and then can act again.
- Your character has been stunned for half a second. Stun lands again: The stun is not longer than before and keeps counting down.
- Your character has just come out of a stun. Stun lands again, and later, once 1.5 seconds have passed, again: The first one does nothing, and the second one stuns.
- Your character is poisoned, slowed and stunned. Use a cleanse: Poison and slow are gone and the stun is still there.
- Your character is clear. A cleanse and poison land in the same moment: The character is poisoned.
- Your character is poisoned and the game freezes for 2.5 seconds. The next tick comes: Two poison steps are counted, 6 health in all.
- Your character is poisoned and the poison would run out in the next instant. Poison lands in that same instant: The poison is not lost: it gets a second stack and its full time back.
- Your character is poisoned and slowed. Wait until the slow is over: The speed is normal again and the poison still runs.
Works well with
- Health and Damage: Poison is damage spread over time. If armour or resistances exist, decide whether they apply to each step. Run poison steps through the same damage rules as any other hit, but check the floor last.
- Health Regeneration: Poison and healing can fight each other. Decide whether healing pauses while poisoned, or whether the two just add up.
- Knockback: A stunned character can still be pushed. Keep the push separate from the effects so a stun does not cancel it.
Clashes with Dodge Roll: A roll that cannot be hurt can still be stunned or poisoned if effects are checked on their own and not as part of a hit. Make effects land only with a hit that got through, so a roll's protection also stops the effect.
Common questions
what do i tell my ai to add status effects
Paste this: Add poison, slow and stun. Poison hurts 3 per stack once a second for 5 seconds, stacks up to 3, refreshes its time when applied again without resetting its rhythm, and never takes health below 1. Slow halves the speed for 3 seconds and does not stack. Stun stops all action for 1 second, cannot be extended, and leaves 1.5 seconds of protection afterwards. A cleanse removes poison and slow.
how do i stop stun lock in my game
Do not let a running stun be extended, and give a short protection after it ends. A second and a half of protection after a one second stun lets the player act in between.
should status effects stack or refresh
That depends on the effect. A damage effect like poison can stack up to a limit, a speed effect like slow should just start its time over, and a stun should never be extended.
why does my damage over time do different damage on different computers
The game probably checks once per frame. Count every step that falls inside the time that passed, so the same poison does the same total damage at any frame rate.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 19 tests pass on the reference code.
- The state diagram was checked against the code, at the default values and at every listed low and high value.
Your AI gets the code
Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it