Steps
Reads are expressions; writes are steps. The verbs that change the world.
Reading the world is an expression. Changing it is a step. A rule body is a list of steps.
$.adjustField({ field: "satiety", by: -1 });
$.damage({ amount: 3 });
$.narrate("the wound closes over");
Steps take named arguments. $.damage(3) is refused; write $.damage({ amount: 3 }). The
few exceptions (narrate, refuse, grantXp, passTime and a handful more) take one
plain value, as shown below.
The common ones
| Step | Does |
|---|---|
$.adjustField({ field, by }) |
Move a field by an amount |
$.setField({ field, to }) |
Set a field to a value (a number or a word) |
$.adjustStat({ stat, by }) / $.setStat({ stat, to }) |
Same, for stats; stat: "maxHealth" grows or shrinks the hit-point ceiling of one NPC or creature |
$.damage({ amount }) / $.heal({ amount }) |
Hurt or heal |
$.applyEffect({ effect }) |
Apply an effect by name; add turns, minutes or permanent: true to override how long it lasts |
$.removeEffect({ effect }) |
Remove one; leave effect out to remove all |
$.give({ item, quantity }) |
Give the player an item; who gives it to someone else, such as "source" in a hook |
$.consume({ item }) |
Use up one of a carried item; call it again for each one more |
$.transfer({ item, from, to }) |
Move a carried item from one character to another. from and to are self, target, party or a character's name |
$.spawnItem({ item }) |
Put an item in the world; at works as it does for $.spawn |
$.spawnMob({ mob }) |
Spawn a creature where the rule happens; at names a place, or "self" where whoever the rule is about stands; minutes is how long it stays |
$.reveal({ item }) / $.hide({ item }) |
Bring something hidden into sight, or hide something here. Also takes npc, mob or path |
$.teleport({ to }) |
Move whoever it lands on to a place, no walking. A player reached takes the whole party along. See Taking someone somewhere |
$.summon('Ironjaw') |
Bring a named NPC into the room where the rule or world event runs (revealing them if hidden) |
$.grantAbility({ ability }) |
Teach an ability |
$.grantXp(50) |
Award experience |
$.setWorld({ key, value, op, scope }) |
Set a world flag to a text value; op "add" or "subtract" counts instead, scope "location" keeps it to this place |
$.startQuest({ quest }) |
Open a quest |
$.failQuest({ quest }) |
Fail a quest for good |
$.endGame({ outcome, title, epilogue }) |
End the game: outcome "win" or "lose", title the ending's name, epilogue what it means. See Endings |
$.startTimer({ id, minutes }) |
Fire a timer later |
$.bond({ bond, by }) |
Change how an NPC feels |
$.remember({ text }) |
Give an NPC a memory |
$.leaveParty({ npc, hostile: true }) |
Turn an NPC against the party: they attack it on sight until pacified. Works on anyone, traveling with the party or not |
$.sound('thunder') |
Play a sound |
$.passTime(30) |
Advance the clock |
$.tool({ tool }) |
Run a generator |
$.narrate('...') |
Tell the narrator something happened |
$.refuse('...') |
Stop the action or plugin event that fired the hook, saying why in a standalone clause ("they are too winded to swing"). The roll card and the narrator show it as written. |
The editor's completion lists every step, with its arguments.
Who it lands on
Steps that act on somebody take an optional targets:
targets |
Lands on |
|---|---|
'target' (default) |
whoever was aimed at, or the user if none was targeted |
'self' |
always the user, whatever was aimed at |
'allies' / 'enemies' |
the user's side / the other side |
'buyer' |
whoever paid, inside a vendor service only |
'allies' and 'enemies' reach the whole side; add count to reach only that many of it, and
count on 'target' spreads from the one aimed at across their side. Whoever the player names
("I heal Mira and Tor") is picked first and the rest are drawn at random. Add random: true to
draw them all at random whoever was named, for chain lightning that leaps where it likes. A
ration uses 'self' so feeding someone else still feeds the eater. A fire bomb uses
targets: 'enemies', count: 3.
count is how many different targets receive the effect, not total hits. To strike one target three
times, write the step three times:
$.damage({ dice: { count: 1, sides: 4 } });
$.damage({ dice: { count: 1, sides: 4 } });
$.damage({ dice: { count: 1, sides: 4 } });
A world event's user is the player whose act set it off (shaking
the branches under a hornet nest). A bare step lands on them, 'allies' on their party and
'enemies' on everyone else here. When the world sets it off (a timer, an arrival, a chance
roll), 'enemies' is everyone here and every other side, the default included, is the party,
as long as the event fires where the party is.
To land on one particular character instead, name them with who. It beats targets, and a
name no living character or creature answers to lands on nobody:
$.damage({ amount: 5, who: "Ironjaw" });
Taking someone somewhere
$.teleport moves the step's target, selected like any other
step. Calling $.teleport("Old Well") moves the target, or the user when
untargeted. That's all a recall spell needs. Moving a player brings the entire party,
companions included, through the full arrival. An NPC or creature moved goes alone.
A guard's arrest is a cast aimed at the lawbreaker that takes the guard along too:
// Ability "Arrest": whoever is aimed at goes to the cell, and the guard goes with them.
if ($.subject.kind === "player") {
$.setWorld({ key: "JAIL_DOOR", value: "LOCKED" });
}
$.teleport("Town Jail");
$.teleport({ to: "Town Jail", targets: "self" });
The ability's description is what an NPC reads to decide when to use it, so state who it is for ("anyone who breaks the peace in front of him") without leaving it ambiguous.
Holding them there is a plugin: an onBeforeTravel hook that refuses while the
flag is set, and an action the player can roll to get out.
// Hook onBeforeTravel, gated on JAIL_DOOR = LOCKED
if ($.event.from === "Town Jail") {
$.refuse("the cell door is locked fast");
}
// Action "breakOut", afterRoll
if (
$.event.passed &&
$.world.JAIL_DOOR === "LOCKED" &&
$.location.name === "Town Jail"
) {
$.setWorld({ key: "JAIL_DOOR", value: "OPEN" });
$.narrate("the cell door gives way, and the road out is open");
}
Declare JAIL_DOOR in the game's starting world state first. An onTimePasses hook that opens
it after a night's rest lets a player who waits it out go free in the morning.
by vs to
$.adjustField({ field: "fever", by: 1 }); // one worse than before
$.setField({ field: "fever", to: 1 }); // exactly 1, whatever it was
Mix these up and you get a fever stuck at 1, or one that never stops climbing.
A field on one particular item, such as the rounds in the gun just fired or a torch burning
down, takes item with that item's key:
$.adjustField({ field: "rounds", by: -1, item: $.weapon.key }); // the gun in hand
$.adjustField({ field: "fray", by: 1, item: $.event.weaponKey }); // in onAttack: what swung
What refuse stops
refuse stops what the hook is answering. In a hook on the player's attempt, that is the
attempt. Inside a hook on a plugin's action or event (mechanisms:reload, rest:sleep), it
stops that one action or event and nothing else. A reload rejected for lack of a magazine
leaves the rest of the turn to run.
Spawning something that belongs to someone
$.spawnItem can say more than which item. Each option describes the one copy it makes:
| Option | Does |
|---|---|
at: "self" |
Put it on the ground where whoever the rule is about stands |
contents: { fromHolder: "self" } |
Move everything they carry into it (it must be a container) |
tags: { key: "value" } |
Stamp text variables on this copy |
fields: { key: expression } |
Stamp number variables on this copy, computed as it is made |
likeness: { of, mark } |
Make this copy show someone |
minutes: 90 |
Unmake this copy after that many in-game minutes, running its on destroyed rule |
minutesExpr: $.dial("bodyDecayMinutes") |
The same lifetime, computed as it is made. 0 or less keeps it forever |
A likeness gives one copy somebody's picture and titles it after them. of is a character, a
creature, a player, or "self" for whoever the rule is about. mark is an optional icon drawn
over the picture. The default item picture is used when that someone has none.
It is how the Bodies plugin's hook makes a body look like whoever died:
$.spawnItem({
item: "Corpse",
at: "self",
contents: { fromHolder: "self" },
likeness: { of: "self", mark: "rpg:skull-solid" },
});
That body shows up as "Corpse of Skitter" with Skitter's portrait under a skull. The same option makes a statue of a hero, a wanted poster of a bandit, or a painted portrait of a lost queen. The likeness is fixed when the copy is made. It stays accurate even after its subject has moved on.
Giving what you spawn an id
$.spawnItem and $.spawn take an id, a name you pick for the one item or creature they
make. Every later step and expression can then point at that exact copy, even when ten others of
its kind lie around.
$.spawnItem({ item: "Strongbox", id: "smugglers-box", at: "the cellar" });
$.spawnMob({ mob: "Hornet Swarm", side: "enemy", id: "nest-swarm" });
| Use | Does |
|---|---|
$.spawnItem({ item: "Coin", into: "smugglers-box" }) |
Makes something inside that container, wherever it is |
$.transfer({ item: "Key", from: "Ash", to: "smugglers-box" }) |
Moves a carried item into it (or from it, out) |
$.itemHealth({ item: "smugglers-box", by: -2 }) |
Wears or mends that copy only |
$.hide({ item: "smugglers-box" }), $.reveal(...) |
Hides or reveals that copy, wherever it lies |
$.drop("smugglers-box"), $.consume(...) |
Drops or spends that copy, when the actor has it |
who: "nest-swarm" on any step |
Lands on that creature |
$.exists("nest-swarm") |
Whether it is in the world |
$.alive("nest-swarm"), $.hasItem("smugglers-box") |
Whether it lives; whether it is in the subject's pack |
An id makes something once. While a copy with that id is in the world, a spawn with the same id is skipped. A rule that may run many times, such as a nest that releases its swarm on every blow, writes the spawn plainly and the swarm comes out once:
$.spawnMob({ mob: "Hornet Swarm", side: "enemy", id: "nest-swarm" });
Once the creature is despawned, or the item is used up or broken, the id is free and the next spawn makes it again. A creature's body still holds its id.
Rules for ids:
- An id names one copy. A spawn with an id makes one, whatever
quantitysays, and no stack joins it. - An id is not the name of any character, creature, item or place in your game. The editor flags one that is.
- Players never see an id. The narrator hears the item's or creature's name.
Revealing and hiding
A hidden thing is really there, just unseen. $.reveal brings
it into sight and $.hide takes something out of it. Name one item, NPC or creature:
$.reveal({ item: "Taped Keycard" });
$.hide({ npc: "Vuk" });
$.reveal({ mob: "Cave Lurker", at: "Sunken Crypt" });
$.reveal({ path: "Smugglers' Cove" });
$.hide({ path: "Old Mill", at: "Village Square" });
An item or creature is looked for where the rule happens, or at at. A creature name reveals
every one of that kind there. An NPC is found wherever they are. Someone in a fight can't be
hidden.
To reach one creature out of several that share a name, add who. In a hook about a creature,
"self" is that creature, wherever it stands. A lurker can give itself away while the others
stay hidden. "source" is whoever caused the event. An aggressive creature a rule reveals beside
the party strikes first, the same as one walking in on them.
// onTurnEnd: the lurker the party woke shows itself
if ($.subject.fields.awake) $.reveal({ mob: "Corpse Lurker", who: "self" });
The item appears in the scene the moment it's revealed, and the narrator is told it was found. A lever that opens a secret panel is a reveal; so is a potion of invisibility that hides whoever drinks it.
A path is the road between the place the rule happens (or at) and
the place named. Revealing it opens it and puts it on the map; hiding it closes it and takes it
off, even a road the author drew in plain sight. There has to be a road between the two already:
a reveal opens a road, it never builds one. The Reveal / hide step works this way in the form.
Narration never gets numbers
$.narrate("the fever's grip loosens"); // good
$.narrate("fever reduced by 2"); // bad
The narrator is never told the mechanics: no numbers, no cooldowns, no turn counts. That's what keeps the prose in voice. Write the sentence you want the player to read.
Damage is never zero
Damage has a floor of 1, so $.damage({ amount: 0 }) still costs a point. If a dial can be set
to zero, check it first:
if ($.dial("starvationDamagePerHour") > 0) {
$.damage({ amount: $.dial("starvationDamagePerHour") });
}
Next
Rule bodies: what else can go in a body.