D&D inspired Skill Checks using tables

Hello!

I’m trying to make a D&D inspired game where Stats and Skill Checks are important. I’ve got a few major stats.

A person has a number called Strength.
A person has a number called Dexterity.
A person has a number called Constitution.
A person has a number called Intelligence.
A person has a number called Willpower.
A person has a number called Charisma.
A person has a number called Luck.

Each of these stats will have a corresponding number, and the value of that number will give plusses or negatives to skill checks.

I plan on creating a table of everyone and everything’s statistics for rolling against, but I’m very new to Tables and don’t exactly know how they function.

Currently, my table only has the player’s stats.

Table of Main Stats
Person	Strength	Dexterity	Constitution	Intelligence	Wisdom	Charisma
"The Player"	16	14	18	10	12	8

In order to calculate bonuses, I’m using Ability_Score and Ability_Modifier.

Ability_Score is a number that varies. Ability_Score is 0.
Ability_Modifier is a number that varies. Ability_Modifier is 0.

Ability Score will take on the number of the Stat being rolled i.e Strength, and calculate the value of Ability Modifier based on that number. If X is greater than Y, Ability Modifier is 1, or 2, etc.

The roll itself is thus far very simple. I have a number called D20_1 (In case I ever need more dice rollers)

Check Rolling:
	Now d20_1 is a random number from 1 to 20;
 	Let result be d20_1 + Ability_Modifier;

But I’m running into the problem where I don’t know the best way to get the value from the table into the dice roller. My plan is that events will have a trigger to roll, put the corresponding Stat into the ability_score, and then depending on who or what is in the event, pull the numbers from the table. I figured people here know a lot more about tables and might be able to give me a nudge in the right direction.

In short, I want to simulate “Roll a stat, add your bonuses” and then I’ll put it against the difficulty of the check to decide the outcome.

3 Likes

The key thing here is that you want to use the table to define a bunch of characters, at which point you won’t need to refer to the table again, just the characters. Here’s the key bit of the docs.

One wrinkle is that you can’t use this approach to define the player, since they already exist in the game by default. There are two ways around this - either just manually set the player’s attributes, or if you want to make sure they’re included in the table, just give them a name (doesn’t matter what, the player ordinarily won’t be able to see it) and then tell Inform that that character is the player.

I’m not sure exactly how you want to set up the skill checks – you could do them as a generic to-decide phrase being passed an ability and a difficulty, I guess? But that seems like it could get awkward given how many situational bonuses and stuff like that there are in D&D. Anyway, I coded up a minimal example to show a basic approach, though of course it would need to be significantly extended.

A person has a number called Strength.
A person has a number called Dexterity.
A person has a number called Constitution.
A person has a number called Intelligence.
A person has a number called Willpower.
A person has a number called Charisma.
A person has a number called Luck.

Arena is a room.  Some people are defined by the Table of Main Stats. 

Table of Main Stats
Person	Strength	Dexterity	Constitution	Intelligence	Wisdom	Charisma	Luck
Thad	16	14	18	10	12	8	0
Xanathar	15	14	12	20	10	16	0

Thad is in the Arena.  The player is Thad.  Xanathar is in the arena.

To decide what number is the ability modifier of (A - a number):
	Let result be A minus 10;
	Let result be result divided by two;
	Decide on result. 	

The block kissing rule does nothing.

Carry out kissing:
	Let X be the ability modifier of the charisma of the player;
	Let Y be a random number from 1 to 20;
	Let difficulty be 10 plus the ability modifier of the charisma of the noun;
	If X + Y is at least difficulty: 
		say "Xanathar succumbs to your smooches!";
		End the story finally;
	Otherwise:
		Say "Getting personal with a beholder may have been a bad move.";
		End the story.
2 Likes

This sort of thing gets much simpler to implement when making use of tools presented in later chapters of the documentation. Also, Graham Nelson released a very useful method of handling die rolls in the source code of his game Reliques of Tolti-Aph.

Difficulty Checks
Section - Abilities for characters

A person has a number called Strength.
A person has a number called Dexterity.
A person has a number called Constitution.
A person has a number called Intelligence.
A person has a number called Willpower.
A person has a number called Charisma.
A person has a number called Luck.

To decide which K is (stat - arithmetic value of kind K valued property) for (P - person): [note "for" not "of"]
	(- ({P}.{stat}) -).

Section - Characters

Some people are defined by the Table of Main Stats.

Table of Main Stats
Person	Strength	Dexterity	Constitution	Intelligence	Willpower	Charisma	Luck
PlayerCharacter	16	14	18	10	12	8	10

The player is PlayerCharacter.

Section - Ability bonuses and penalties

Table of Ability Modifiers
score	modifier
18	3
16	2
13	1
9	0
7	-1
4	-2
3	-3

To decide which number is the modifier for (N - number):
	repeat through the Table of Ability Modifiers:
		if N is at least score entry, decide on modifier entry;
	say "(BUG: lookup of ability modifier failed.)";
	decide on zero.

Section - Ability checks

[this is a non-random method but you can change the logic; see "difficulty checks" below]
To decide whether (P - person) passes (stat - arithmetic value of kind K valued property) check at difficulty (N - number):
	if stat for P is at least N, decide yes;
	decide no.

Section 1(b) - Dice (as defined in Reliques of Tolti-Aph by Graham Nelson)

A die roll is a kind of value. 3d20+9 specifies a die roll[* RPGs are games of chance as well as skill, and the actual rolling of the dice is as much a part of the experience as the randomised outcome. The polyhedral four-, six-, eight-, ten-, twenty- and even hundred-sided dice ubiquitous to RPGs are pleasingly exotic in the hand, but also make possible a wide range of random distributions. W&W uses the traditional notation for such rolls (which evolved as the D&D rules went through successive printings, but became standard around 1980): "3d6+2" means we should roll three six-sided dice, add up the scores showing, then add 2.] with parts dice, sides (without leading zeros), adds (without leading zeros, optional, preamble optional).[* The optional nature of the adds part of a die roll means that "2d4", for instance, is also a legal form. Again, this is a convention imitating the tables which appear in printed RPG rulebooks. What Inform means by the preamble to the adds part is the plus sign: if this had not been specified to be optional, "2d4+" would be legal.]

To decide which number is roll of (dr - a die roll):
	let the total be the adds part of dr;
	say "[dr]: ";
	repeat with counter running from 1 to the dice part of dr:
		let the roll be a random number from 1 to the sides part of dr;
		unless the counter is 1, say ",";
		say the roll;
		increase the total by the roll;
	if the adds part of dr is 0 and the dice part of dr is 1, decide on the total;
	if the adds part of dr is not 0, say "+", adds part of dr;
	say "=", total;
	decide on the total.

Section - Difficulty checks

[this is a random method]
To decide whether (P - person) succeeds a/an (DR - die roll) check adjusted by (stat - arithmetic value of kind K valued property) needing at least (DC - number):
	let roll be roll of DR;
	let mod be modifier for stat for P;
	let adj roll be roll plus mod;
	[say "(raw roll [roll] including bonus/penalty of [mod] = adjusted [adj roll] vs DC [DC])";]
	if adj roll is at least DC, decide yes;
	decide no.

Section - Tests

When play begins:
	showme whether or not PlayerCharacter passes Luck check at difficulty 9;
	showme whether or not PlayerCharacter passes Luck check at difficulty 11;
	showme whether or not PlayerCharacter succeeds a 1d20 check adjusted by strength needing at least 12;
	showme whether or not PlayerCharacter succeeds a 1d20 check adjusted by willpower needing at least 12;
	showme whether or not PlayerCharacter succeeds a 1d20 check adjusted by charisma needing at least 12;
4 Likes

LOL, let’s give some more love tho the cinderella of DND ztat, Charisma, please… :wink:

Best regards from Italy,
dott. Piergiorgio.

2 Likes