Area of Effect
An area of effect hurts everything inside a circle around one spot. It warns first, goes off, and a lingering zone hits again at a fixed beat until its time is up. Damage is highest in the middle and falls toward the edge, the edge of a body counts, and cover and allies take only a share.

Paste this to your AI
Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.
Add "Area of Effect" to my game.
What it should do: An area of effect lets one attack hit a crowd, punishes standing together and gives the player a way to answer many enemies. The warning, the falloff and the cover rules are what make it readable and fair instead of a surprise from nowhere.
Build it exactly as this state machine. First check that it fits my game, then build it like this:
```mermaid
stateDiagram-v2
[*] --> warning
warning: Warning
active: Active
over: Over
warning --> warning: counting down
warning --> active: goes off
warning --> over: all within one long step
active --> active: ticking
active --> over: time is up
over --> over: nothing more
over --> [*]
```
Use these starting values:
- radius: 4 units
- damage: 30
- edgeShare: 0.4
- coverShare: 0.25
- allyShare: 0
- warnTime: 0.8 s
- duration: 3 s
- tickInterval: 0.5 s
Watch out for these common mistakes:
- Measuring to the middle of the body: Tell your AI: measure to the edge of the body, its distance to the middle minus its own radius.
- One character with several parts: Tell your AI: give all parts of one character the same id, and hit each id once per beat with its nearest part.
- Hits that depend on the frame rate: Tell your AI: keep a time for the next hit, and deliver every hit that falls inside the step.
- The last hit: Tell your AI: only hit while the hit time is below the duration, and make the first hit at zero.
- Friendly fire by accident: Tell your AI: mark every target with a side, and give allies their own share of the damage.
- Warning that arrives too late: Tell your AI: do no damage during the warning, and go off in the same step the warning ends.
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
An area of effect lets one attack hit a crowd, punishes standing together and gives the player a way to answer many enemies. The warning, the falloff and the cover rules are what make it readable and fair instead of a surprise from nowhere.
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
- Warning → Warning: counting down
- Warning → Active: goes off
- Warning → Over: all within one long step
- Active → Active: ticking
- Active → Over: time is up
- Over → Over: nothing more
Good starting values
| Value | Start with | What it changes |
|---|---|---|
| radius | 4 units | How far the zone reaches from its middle. Four is wide enough to catch a group and small enough that the player can step out of it before the next hit. |
| damage | 30 | Damage in the middle. Pick it against your health numbers: here a target with 100 health survives three hits at the middle and eight at the edge, so a lingering zone punishes standing in it but not one mistake. |
| edgeShare | 0.4 | How much of the damage is left at the very edge. At 0.4 a target at the rim still takes 40 percent, so the edge is a warning and not a free pass. At 1 there is no falloff, at 0 the edge does nothing. |
| coverShare | 0.25 | The share of the damage that gets through cover. A quarter makes cover worth hiding behind without making the zone harmless. At 0 cover blocks everything, which turns every blast into a game of hiding. |
| allyShare | 0 | The share of the damage allies take. Zero is the safe start: the player's own blasts do not hurt friends. Raise it for a game where careless blasts should cost something. |
| warnTime | 0.8 s | How long the zone shows before it goes off. Under half a second the player cannot read it, and over two seconds the blast is too easy to avoid. Zero means no warning at all. |
| duration | 3 s | How long the zone lasts after it goes off. A one-time blast uses a time shorter than one beat, so it hits exactly once. |
| tickInterval | 0.5 s | The time between two hits of a lingering zone. Half a second gives six hits in three seconds: often enough to feel like fire on the ground, rarely enough to read each hit. |
What usually goes wrong
Measuring to the middle of the body
A big enemy whose middle is outside the circle but whose arm is inside it takes nothing, and the player learns that large enemies are immune.
Fix: Tell your AI: measure to the edge of the body, its distance to the middle minus its own radius.
One character with several parts
A boss made of a head, two arms and a body is hit four times by one blast, and takes four times the damage you planned.
Fix: Tell your AI: give all parts of one character the same id, and hit each id once per beat with its nearest part.
Hits that depend on the frame rate
A zone that hits once per step hurts three times as much on a fast screen. A zone that checks time only once per step loses hits on a slow one.
Fix: Tell your AI: keep a time for the next hit, and deliver every hit that falls inside the step.
The last hit
A zone of 3 seconds with a hit every half second hits at 0, 0.5 and so on up to 2.5. A hit at exactly 3 would be a seventh one, after the zone is over.
Fix: Tell your AI: only hit while the hit time is below the duration, and make the first hit at zero.
Friendly fire by accident
The player's own blast hurts friends, or the player, because nobody asked whose side a body is on. Or the opposite: a trap hurts only the player and never the enemies that walk in.
Fix: Tell your AI: mark every target with a side, and give allies their own share of the damage.
Warning that arrives too late
A blast that appears and hurts in the same moment gives the player no chance to read it. A blast that hurts before the warning is over looks unfair.
Fix: Tell your AI: do no damage during the warning, and go off in the same step the warning ends.
How to check it works
- A zone of 30 damage that has just gone off. A target stands in the middle: It takes 30.
- The same zone with a radius of 4. Targets stand 1, 2 and 4 units from the middle: They take less and less: 21 at 2 units and 12 at the edge.
- The same zone. A target stands 4.01 units away and another far away: Neither takes any damage.
- A target with a body of 1 unit, whose middle is 4.8 units away. The zone goes off: It is hit, as its edge is 3.8 units away, and a point-sized target there is not.
- A target in the middle with cover in the way. The zone goes off: It takes a quarter of the damage: 7.5.
- An ally stands in the middle of a zone. The zone goes off, with the ally share at 0 and then at 0.5: At first the ally takes nothing, then half the damage: 15.
- One enemy with three parts under the same id, 1, 2 and 3 units from the middle. The zone goes off: The enemy is hit once, by the nearest part.
- A zone that is still warning for 0.8 seconds. 0.7 seconds pass with a target in the middle, then 0.2 more: No damage at first, then the full damage in the same step the warning ends.
- A zone of 3 seconds with a hit every half second. A target stays in the middle until it is over: It is hit six times, 180 damage in all, and then nothing more.
- A zone and a target in the middle. One very long step of 10 seconds goes by: All six hits arrive, 180 damage, and the zone is over.
- A zone that is over. A target stands in the middle: It takes no damage.
Works well with
- Health and Damage: Send every hit as damage to the character, so armor and protection apply to blasts too. Let this decide who is hit and for how much, and let health and damage take it from there.
- Knockback: A blast that hurts but does not move anything feels weak. Push each target away from the middle of the zone, scaled by the same falloff.
- Invincibility Frames: Without protection a zone with a beat of half a second drains the character at every beat. With it the beat and the protection should be set together. A lingering zone hits through the protection rules like any hazard.
- Ability Cooldowns: Starting it at the blast would let the player stack zones during the warning. Let an ability create the zone, and let the cooldown start when it is created.
Common questions
how does area of effect damage work
Pick a spot and a radius, and hurt everything whose body reaches inside the circle. Damage is highest in the middle and falls toward the edge, and cover and allies can take a share.
how do i make a damage zone that hurts over time
Give the zone a duration and a beat, say 3 seconds and half a second. Keep the time of the next hit and deliver every hit that falls inside a step, so the damage does not depend on the frame rate.
why does my boss take too much damage from explosions
Each part of it is probably hit on its own. Give all parts the same id and hit each id once per beat, with the part that takes the most damage.
what do i tell my ai to add area damage
Paste this: Add a zone with a radius of 4 and 30 damage in the middle, falling in a straight line to 40 percent at the edge. Measure to the edge of the body. Cover lets a quarter through and allies take none. It warns 0.8 seconds, then hits every half second for 3 seconds.
Where it comes from
We could not find a reliable origin for this one yet.
What was checked
- 18 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