D16 Rolling System

Hi guys! It’s been a super long time since I’ve been around, but I am writing a personal project for a friend. I thought it would be neat to share what I made for it! I saw a few threads similar to this (I saw Breach’s way of doing it in a thread last year), but I’m dumping more on to the pile.

I use a d16 rolling system (which I chose because I haven’t seen any, probably for a good reason). Like it says on the tin, the player rolls a 16-sided die and tries to hit the DC, the target score. I also threw in a morale system (because that was part of the game I’m supposed to be making for a friend), and though it isn’t relevant to the rolling system, I thought it was a good example of addons or modifications to the original code.

You can see all this in action here!

The code for the .txt file I reference with *gosub_scene is here, and the code for the *gosub I paste on every chapter is here.

What It Does

So what this does is that all you have to do is plug in a few numbers in a single line of code everytime you want to make a die-rolling check, and you’re good to go! It rolls for you, adds in the modifiers, writes the text out for you, the whole package. It’ll look something like:

*gosub rolling <first_stat> <second_stat> <DC>

For this, I used two things: a .txt file (called upon with *gosub_scene) that does the bulk of the computation, and a *gosub at the end of every chapter to make my life just a touch easier–that is, so I don’t have to write a couple of *set. Instead, I can just plug in numbers.

This’ll make it easier not only to write wherever there are checks, but it’s also flexible for whenever I want to add a new stat! No need to rewrite the subroutines to accommodate for the new stat, just make a few new variables.

Setup

Let’s say my game has three stats: Charm, Cunning, and Athletics. All the stats are 8 by default.

  1. First, I make an array for the “true values” of each stat. Arrays are “lists” for variables, and this will be a list of your stats’ true values. All of them are 8 by default in this case, and those are its true values. I’ll write up a list for my variables (would be good to write them in some comments), and then assign them numbers. Charm is stat #1, Cunning stat #2, and Athletics stat #3 and so on. Then, I *create truestats_1, truestats_2, and true_stats3. There you go!

  2. Next, I make an array for the modifiers. Modifiers are numbers that you add on to your roll, which depend on how high or low your truestat is. I make one for each stat. For my d16 system, the modifiers are decided with round((<truestat> - 8) / 2.5). This is recalculated every time there is a roll, in case the truestats change. So the Charm modifier variable is modifier_1, Cunning is modifier_2, and Athletics is modifier_3.

  3. Then, I make an array for the names of the skills. This will also help with your memorization, if you didn’t happen to write it down. Charm is stat #1, right? So *create statname_1 "Charm". statname_2 is "Cunning". statname_3 is "Athletics". Yes, these are string variables (variables that have values that are WORDS).

  4. I create a few variables more. dieroll is what you randomize, the “die.” stat_select1 and stat_select2 select the stats that you want to check. DC is the target score. result is whether you get a crit success, success, fail, or crit fail (which are represented as 2, 1, 0, and “-1” respectively). morale_mod is a modifier that is added/subtracted from the roll if morale is high/low, so it’s optional for you to actually make that a variable (just remember to take out the morale_mod part of the code).

  5. After I created all these variables, I paste the *gosub (NOT *gosub_scene) code on every chapter for the ultimate lazy coding. At least, on the ones that you want to roll a die. The reason I have this *gosub is because *gosub_scene doesn’t allow for *params; *gosub does. What it does, basically, is take the *temp variables that *params creates and sets the global variables (the variables we created in startup) to them.

Preview #1-#4

Preview #5

image

I don’t fancy copying the entire *gosub_scene routine onto every chapter, but this tiny bit of *gosub will prepare it, and for that, I can make a bit of space.

How to Apply

Great! So now we have the gosub and then the gosub_scene prepared. How do we use it? I’ve written some instructions for myself in the actual txt file because I’m so absentminded. Here is the argument:

*gosub rolling <first_stat> <second_stat> <DC>

  1. <first_stat> is basically one stat that you want to test for. Ignoring the misnomer, though, it can be the only stat you test for if you choose for it. Remember the list and numbers we assigned to each stat? So if I want to test Charm, stat #1, then I put here 1.
  2. <second_stat> is optional. If you want to only test for one stat, you leave this as 0 (zero).
  3. <DC> (difficulty class) is also known as the target score. This is the score that players need to get or exceed to succeed.

Remember to use *rand dieroll 1 16 before you use this initially! This is so that the first roll actually has a ready roll and that it can’t be exploited easily. Afterwards, it will randomize future rolls by itself.

That’s basically it! Let’s see some examples.

So let’s say I want the player to do a Charm check.

  1. As it is stat #1, the first parameter, <first_stat>, is 1. That is its assigned number.
  2. As I am only testing for one stat, the second parameter, <second_stat>, is 0.
  3. In my d16 system, a medium difficulty check is a DC of 12. Therefore, I will set the DC to that fair challenge.

The end result will be:

*gosub rolling 1 0 12

Preview

image

But how about a Cunning and Athletics for some SICK thief moves?

  1. The first stat I’ll check can either be Cunning or Athletics, whatever. For this, though, I’ll pick Cunning. It is stat #2, so I will type 2.
  2. As I am testing for a second stat too, I will put down Athletics’ assigned number: 3.
  3. I’ll up the ante a little! The DC will be 14.

The end result will be:

*gosub rolling 2 3 14

Preview

image

And there you have it!

One more thing to keep in mind is if you want to change the truestats (aka add on or subtract from it), then:
*set <stat_you_want_to_modify> + <number>
*set stat_select1 = <the_assigned_number_of_the_stat_you_want_to_modify>
*gosub_scene dieroll update_modifiers

This will reflect the change in modifiers on the Stats screen. There’s a more efficient way about this in my head right now, but it’ll be too much at this point. So let it slide!

General Notes
  • Modifiers are calculated with round((<truestat> - 8) / 2.5). Not too sure about this yet, need to test with the balancing a bit more.
  • An easy DC is 8; a medium DC is 12; a harder DC is 14; very hard is 16; and extremely hard can even be beyond.
  • Default stats begin with 8. An exceptionally good starting stat is 15; great is 12; decent is 10. A bad stat is 6; worse is 4; worst is 1. Modifiers are 3, 2, 1 and -1, -2, and -3 respectively. I project the maximum you can get is 25 in my game specifically, so as a percentage, people begin at 32% default in all stats.

((Very sorry for any trouble, I tried looking around and reading the rules and seeing what other people posted in this category, but this felt right after I searched through! Just wanted to share it (and if other people want to use it for reference, I wrote up lots of instructions!!))

I’m still a beginner at coding (one year in computer class BABEY), so let me know what you think! … preferrably gently, but let me know, anyway!

Extra

Also, apparently I just learned of curly parens references just like, yesterday?? Opens up an entirely new world for me. Now, I’d still prefer to just write down numbers because hello, laziness. In terms of readability, though, it’s likely possible to modify this so it looks more like *gosub rolling "charm" "none" 15. Easier on the eyes, and if I come back to this in 3 months, I won’t be going, huh???

8 Likes