Spielerando

Block and Guard

Block and guard lets a character hold up a guard that cuts down hits from the front. A hit in the first moments after raising it costs nothing, which is a parry. Each block drains a guard meter, and a hit the meter cannot pay for breaks the guard. A short wait after letting go stops free parries from tapping.

Also called: Blocking, Guard, Parry, Shield block.

A small green badger knight holds up a round tin shield as a huge stone troll's club bounces off it in a burst of white and gold sparks, the troll thrown off balance.
Quillmarrow Bastion, an invented shield-duel game. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Block and Guard" to my game.

What it should do: Guarding gives the player a way to take a hit instead of avoiding it, and the parry rewards good timing. The meter and the break keep it from being a way to stand still forever.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> open
  open: Guard down
  parry: Parry window
  guard: Guarding
  lowering: Lowering
  broken: Guard broken
  open --> parry: raises the guard
  parry --> guard: window ends
  parry --> lowering: lets go early
  guard --> lowering: lets go
  guard --> broken: meter too low
  lowering --> open: wait is over
  broken --> open: break wears off
```

Use these starting values:
- parryWindow: 0.15 s
- guardReduction: 0.8
- guardMeter: 60 units
- meterRegen: 15 units/s
- breakTime: 1.2 s
- lowerTime: 0.3 s

Watch out for these common mistakes:
- Tapping the button for free parries: Tell your AI: after letting go, make the guard wait a short while before it can go up again, and open the parry window only when the guard goes up.
- Guarding hits from behind: Tell your AI: only count a hit as guarded when it comes from the side the character faces. Other hits go through in full and cost no meter.
- A hit the meter cannot pay for: Tell your AI: if the meter is smaller than the hit, let the whole hit through, empty the meter and break the guard. Never let the meter go below zero.
- A press and a hit in the same moment: Tell your AI: decide the tick from how it began. A hit that arrives while the guard is not up is a full hit, even if the press is in the same tick.
- Holding the button through a break: Tell your AI: after a break, wait for the button to be let go once before a new guard can start.

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

Guarding gives the player a way to take a hit instead of avoiding it, and the parry rewards good timing. The meter and the break keep it from being a way to stand still forever.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

raises the guardwindow endslets go earlylets gometer too lowwait is overbreak wears offGuard downParry windowGuardingLoweringGuard broken
How it runs, as a diagram
  • Guard down → Parry window: raises the guard
  • Parry window → Guarding: window ends
  • Parry window → Lowering: lets go early
  • Guarding → Lowering: lets go
  • Guarding → Guard broken: meter too low
  • Lowering → Guard down: wait is over
  • Guard broken → Guard down: break wears off

Good starting values

ValueStart withWhat it changes
parryWindow0.15 sHow long after raising the guard a hit from the front costs nothing. About a seventh of a second is tight enough to be a skill and wide enough to learn. Longer, and the player simply holds the button down and always parries.
guardReduction0.8The share of a blocked hit that does not get through. Four fifths leaves a little chip damage, so a long guard still wears the player down. At 1 a block costs only meter.
guardMeter60 unitsHow much the guard can take before it breaks. Sixty holds about three ordinary hits of twenty, so the player has to look for a gap instead of waiting behind the guard.
meterRegen15 units/sHow fast the meter fills while the guard is down. Slow enough that a pause matters, fast enough that a good fight never ends with a meter stuck at empty.
breakTime1.2 sHow long a broken guard leaves the character open. This is the price of letting the meter run out, so it should be long enough for the enemy to make use of it.
lowerTime0.3 sThe wait after letting go before the guard can go up again. Without it the player taps the button over and over and gets a parry window every time.

What usually goes wrong

Tapping the button for free parries

If the parry window opens every time the button goes down, the player taps it again and again and parries everything without ever timing anything.

Fix: Tell your AI: after letting go, make the guard wait a short while before it can go up again, and open the parry window only when the guard goes up.

Guarding hits from behind

The guard stops a hit that came from behind the character, so turning around is never a risk and the guard has no direction.

Fix: Tell your AI: only count a hit as guarded when it comes from the side the character faces. Other hits go through in full and cost no meter.

A hit the meter cannot pay for

A big hit lands on a nearly empty meter. The game either blocks it for free and the meter goes below zero, or it takes only the part the meter could not pay, and the guard never really breaks.

Fix: Tell your AI: if the meter is smaller than the hit, let the whole hit through, empty the meter and break the guard. Never let the meter go below zero.

A press and a hit in the same moment

The hit and the press arrive in the same tick. If the game raises the guard first, the player is saved by a press that came too late to count.

Fix: Tell your AI: decide the tick from how it began. A hit that arrives while the guard is not up is a full hit, even if the press is in the same tick.

Holding the button through a break

The player keeps holding the button while the guard is broken. The moment the break is over the guard goes straight up again, with a parry window the player never asked for.

Fix: Tell your AI: after a break, wait for the button to be let go once before a new guard can start.

How to check it works

Works well with

Clashes with Jump Buffering: A remembered press from earlier could raise the guard the instant the wait is over, and open a parry window the player did not time. Do not remember guard presses. The player holds the button, and the guard goes up when the wait is over.

Common questions

what do i tell my ai to add blocking with a parry

Paste this: Add a guard: while the button is held, hits from the front are cut by four fifths and paid for from a guard meter. In the first fifth of a second after raising it, a front hit costs nothing. If the meter is too low for a hit, the hit goes through in full and the guard breaks. After letting go, make the guard wait a moment before it can go up again.

how long should a parry window be

Start with about a seventh of a second. That is a little under ten frames at sixty a second, which a player can learn without it feeling like luck. If players never manage it, widen it a little. If everyone parries everything, shrink it.

why can the player parry everything by tapping the button

Because the parry window opens every time the button goes down. Make the guard wait a short moment after letting go, so the window cannot open again straight away.

what happens when a hit is bigger than the guard meter

The whole hit goes through, the meter empties and the guard breaks for a while. Do not block part of it. A half-broken guard is hard to read and feels unfair.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

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