top expert

a biting cat website

who gets to go first?

More thoughts on a combat system.

adding combatants to the system

Our simple example from last time simulated violent exchanges in which a player attacks an enemy during the course of a usual Inform turn. Enemies, meanwhile, retaliated during the every turn phase of action processing. I think this is a typical arrangement, combat or otherwise. Action processing responds to the player’s command, and every turn is often used to handle whatever the rest of the world gets up to. It’s a very protagonist-centered arrangement that makes perfect sense in nearly every Inform game.

It does get a little awkward, sometimes, where we have to think of multiple in-game characters doing things that affect each-other. One idea might be to have characters telegraph their intent and then allow the possibility of reaction. Victor Gijsbers’s Kerkerkruip operates in this way. Players can dodge attacks or attack, and from that initial, seeming simplicity some marvelously complex possibilities emerge.

I have something a little different in mind, which is fortunate, as I doubt I could improve upon the mechanics of Kerkerkruip even if I wished. I’d like to make a simpler system that places heavy emphasis on which actor gets to go first. To start, we need a way to define combatants and assign them relevant properties. We can do this with tables. I’d like to use these tables on a per-kind basis. “Protagonist” can be a kind, as can “zombie.” Other types of enemies can be handled in a similar way.

a protagonist is a kind of person.
some protagonists are defined by the table of player characters.

Next, the table itself. What should go in there? In the previous post, we discussed “speed” and “accuracy” statistics, so let’s keep those. I think we could also use a “defense” statistic to reflect an enemy’s ability to resist damage. Finally, we should assign our creations a finite measure of health.

table of player characters
protagonist max health current health accuracy speed defense
Chad 45 45 7 5 7

This will create a person named “Chad” while granting them the specified values for accuracy and whatnot. Authors might want to account for other properties, such as gender, but we’ll leave that for now.

We can make some enemies in the same way.

an enemy is a kind of person.
a zombie is a kind of enemy.

some zombies are defined by the table of z-types.

table of z-types
enemy max health current health accuracy speed defense
gurgler 5 5 7 3 2
groaner 7 7 7 3 2

Where are these people? Unless otherwise specified, the player appears in the first room mentioned by the program. We will need to add something like

the player is Chad.
Chad is in the Foyer.

What about the zombies? Until otherwise specified, things created by sentences like some zombies are defined by the table of z-types will begin nowhere, or out-of-play. We could add a location to our sentence, ie, some zombies in the foyer are..., but chances we don’t mean to make separate tables for every room. There are several ways to place the zombies ourselves, including declarations like gurgler is in the filthy kitchen. We’ll come back to this eventually.

but seriously. who goes first.

My first tabletop roleplaying experience was with Gygax-era Advanced Dungeons & Dragons, and though a great many advances have taken place over the years, I still reach for the terms I learned in those days. Determining the order in which multiple combatants act is, in that idiom, a question of determining initiative. A person‘s speed statistic should influence initiative, obviously. Weapons probably have speed, too, though we haven’t gotten that far. I’ll proceed as if we’ve worked that out already. I think we’ll need more than just an ordered list of people. What if the player chooses to do something slow or clunky, or else just ignores combat altogether? We should leave ourselves room to adjust the order on the fly if we need to. Note that I am assuming multiple—several, even—combatants active at once. This would be overkill otherwise.

That sounds like a table to me.

table of initiative
ranking (a number) combatant (a person) initiative (a number) pending (a truth state)
-- -- -- --
with 10 blank rows

Here’s my initial thinking on these items:

  • Ranking: the order. A “1” value should correspond to the person acting first, “2” should correspond to the person acting second, and so forth. I’m adding this in case I need to easily find out if X goes before Y, or is acting first in the turn. I can have some definitions that let me work these things out on the fly.
  • Combatant: the actor in question
  • Initiative: a number determined by some as-yet unwritten rules.
  • Pending: I’m going to update this when any actor does something. This will provide an easy way to determine how many actions remain in the turn.

Let’s make a rulebook!

initiative is a rulebook.

This will be the default rule, but we can always make new rules for exceptions later.

an initiative rule (this is the default initiative check rule):
blank out the whole of the table of initiative;

I’m going to calculate the player initiative separate from the initiative of other actors. I don’t really need to do this, but I might want to do things differently later. I’m just leaving myself room for that here.

	let P be the speed of the player;
let S be the speed of the equipped weapon of the player;
let player's initiative is dice roll plus (P + S);

*needle skip* What is “dice roll,” you say? That’s just a method for grabbing a random number. A dice roll. For the purpose of this blog, let’s just make it a simple random number.

to decide what number is dice roll:
decide on a random number from 1 to 8;

Why eight, and not six, or ten, or 20? My vibes-based answer is that it will make an actor’s speed statistic sufficiently impactful without dominating: sometimes fast characters will still go last, but they won’t do so often.

Alright, back to our rule. We have a dice roll, a weapon speed, and player speed, and that gives us an initiative number for our player. Let’s put it in the table.

	choose blank row from the table of initiative;
now combatant entry is the player;
now initiative entry is player's initiative;
now pending entry is true;

Great! Let’s get the other combatants’ values in the table.

	repeat with E running through enemies in the location:
let P be the speed of E;
let S be the speed of the equipped weapon of E;
let enemy's initiative be dice roll plus (S + P);
choose a blank row from the table of initiative;
now combatant entry is E;
now initiative entry is enemy's initiative;
now pending entry is true;

We’ve used a repeat loop to add an entry for every enemy in the player’s location. Our first “ranking” column is empty, though, so let’s fill that in now. We do this by sorting the table by initiative, high values first, then follow up by adding in our ranks.

	sort the table of initiative in reverse initiative order;
let N be 1;
repeat through the table of initiative:
now ranking entry is N;
increment N;

The rulebook exists, but we haven’t yet set it to run anywhere. Where should it run? That is probably a question for next time. For the sake of simulation, I’ll put it in a debugging out of world action.

initiative debugging is an action out of world applying to nothing.
understand "dbg initiative" as initiative debugging.

carry out initiative debugging:
follow the initiative rules;
showme the contents of the table of initiative;

This will yield up something like this (the numbers, being random, will vary):

>dbg initiative
table of initiative
(row 1) | 1 | yourself | 12 | true |
(row 2) | 2 | groaner | 10 | true |
(row 3) | 3 | gurgler | 7 | true |
(row 4) | -- -- -- --
(row 5) | -- -- -- --
(row 6) | -- -- -- --

These zombies are slow, but I suppose that’s a fairly common state of affairs. We probably want to think about exceptional cases: someone using a healing item probably shouldn’t benefit from their weapon’s speed rating. And so forth.

We still can’t use this, though. How are we supposed to orchestrate the actions of various actors? Next time, I’ll try to come up with a good way of directing the “traffic” of multiple actors.

Leave a comment