Worked examples
A turn-based fight
Weapons, a potion, and creatures with health and attack.
On this page
A fight is only numbers. You have health and an attack. Each creature has health and an attack. Every turn both sides hit, and a fork decides who is still standing. This example has two weapons, one health potion and two paths, so you can see the whole pattern in a small story.
Try it#
The hill
- health10
- attack3
- potions1
- ogre_health9
- goblin_health3
- wolf_health6
- ogre_attack4
- goblin_attack3
- wolf_attack3
The rules#
Everything the reader needs to decide is written in the scenes, and here it is in one place.
| Health | Hits for | |
|---|---|---|
| You, with the sword | 10 | 3 |
| You, with the war hammer | 8 | 5 |
| Ogre (front gate) | 9 | 4 |
| Goblin (back tunnel) | 3 | 3 |
| Wolf (back tunnel) | 6 | 3 |
You also have one health potion, which gives you 5 health. Drinking it does not cost you a turn.
The front gate is one hard fight. The back tunnel is a fight against the goblin and the wolf at the same time, so you take 6 damage every turn until one of them falls. You need the potion on both paths. In the tunnel you also have to pick who to attack first: kill the goblin first and, with the potion, you win. Kill the wolf first and you lose, even with the potion.
The map#
How it is built#
The values#
Add these number values.
health, starting at 10.attack, starting at 3.potions, starting at 1.- Two values per creature, one for its health and one for how hard it hits:
ogre_healthat 9 andogre_attackat 4,goblin_healthat 3 andgoblin_attackat 3,wolf_healthat 6 andwolf_attackat 3.
Keeping the creatures' stats in values means a creature's numbers live in one place. Change wolf_attack once and every fight it appears in changes with it. The scene text is plain writing, so update it by hand.
Choosing a weapon#
The hill has two choices. Each has two Set to effects.
- "Take the sword" sets
attackto 3 andhealthto 10. - "Take the war hammer" sets
attackto 5 andhealthto 8.
The scene text explains the trade: the hammer hits harder but tires you. The reader chooses knowing both numbers.
A fight scene#
Each creature has a scene with two choices. The scene text prints the numbers with Insert a value…: your health, the creature's health and your potions. The reader always sees the state of the fight before they act.
Attack the ogre has two effects.
- Subtract
attackfromogre_health. Pick the valueattackinstead of typing a number, so the sword and the hammer both work from one choice. - Subtract
ogre_attackfromhealth. The ogre hits back in the same turn.
It leads to the fork.
Drink the health potion has the check potions is at least 1, so it disappears when the potion is gone. Its effects are Add 5 to health and Subtract 1 from potions. It leads back to the same fight scene, so the reader can still attack.
The fork that decides#
Add a fork called "Who is still standing?" with three rules, in this order.
- If
healthis at most 0, send to "Defeated". - If
ogre_healthis at most 0, send to "The cage". - Otherwise, send back to "The ogre".
Order matters. If you and the ogre both reach 0 in the same turn, rule 1 comes first and you lose. Put the rules the other way round and a tie becomes a win.
Two creatures at once#
The tunnel is the same idea with one change: both creatures are in one fight scene, so both hit you every turn.
- Every attack choice has two Subtract effects on
health,goblin_attackandwolf_attack, because both creatures hit you. - The scene has one Attack choice per creature: "Attack the goblin" subtracts
attackfromgoblin_health, and "Attack the wolf" subtracts it fromwolf_health. The reader picks who to hit each turn. - The fork has three rules and an Otherwise, in this order. If
healthis at most 0, send to "Defeated". Ifgoblin_healthis at most 0, send to the wolf's one-on-one scene. Ifwolf_healthis at most 0, send to the goblin's one-on-one scene. Otherwise, send back to the tunnel.
Once one creature is down, the reader lands in a smaller fight scene with only the other one, built exactly like the ogre's: it costs only that creature's attack per turn.
Why the order matters: the goblin dies in one hit and the wolf takes two. Killing the goblin first removes its attack from every turn after that. Killing the wolf first leaves you taking both attacks for an extra turn. The numbers are chosen so the second order costs one hit too many, and no choice of weapon or potion timing fixes it.
To add a creature of your own, copy a one-on-one fight scene and its fork, add the creature's two values, and change the scene text.
Why it works#
- There is one rule for a fight and it is the same everywhere. The reader learns it once.
- The numbers are printed in the scene, so nothing is hidden. The reader can plan: "the hammer needs the potion here".
- Choices matter without any randomness. The result follows from the weapon, the path and when the reader drinks the potion, so a loss feels earned.
- Order is a real decision. In the tunnel the reader has to work out who is the bigger threat, and the story shows them every number they need.
- Two ways of playing are both possible. The hammer hits harder but has less health, and the sword is steadier.
Things to try#
- Add a shield. A third weapon choice can set
attackto 2 andhealthto 14. - Make the ogre hit harder or the potion heal more, and replay to see how the balance moves.
- Make the fight less predictable by rolling for damage. See Rolling dice.
- Add a secret ending for winning at the gate with the hammer, using a check on the story's choices. See Story history.
Make your own copy#
Want to take it apart? Copy this story into your Studio and change it however you like.
Next#
The last example puts all of these together. Read A full story, annotated.