And so it begins…

Originally written on Dec 11, 2016. Edited on Dec 18, 2022. Original blog available at: https://theexcelrpg.wordpress.com/

So this post will be written in conjunction with me spreadsheeting, and so it’ll have a running commentary approach rather than a coherent summary written afterwards.

Now I’ve played a lot of video games in my time, but I’ve never made one, or displayed any interest in doing so. I don’t really have a clue where to begin, but if I had to hazard a guess it’d involve creating the game engine. Now I’m using D&D as an inspiration for this, and the D&D engine is really just the Dungeon Master (DM for short.) Dice rolls determine generally everything in the game, and this is done by rolling the relevant dice – whether 4, 6, 8, 10, 12 or 20 sided – and then adding modifiers to the result. This is then compared against a value – generally a difficulty check – and if greater than that the action succeeds, and if less than that the action fails. Starting from that – let’s go to the spreadsheet.

As you can see, the first thing I did was just to set up the spreadsheet and ensure its ready for the different modules to go in place. This wasn’t much work, but it sets a good precedent for later on. After that I began to work on the dice rolls, just to create a very brief game engine. The dice rolls could be done using Excel’s “RANDBETWEEN” function, which is very easy. The downside is that the numbers will refresh continuously and that will be a pain (and a waste of processing power much further down the line.) The proper way to do it would be to create macros to handle it.

In the end I decided to skip the RANDBETWEEN entirely and go straight to macros. The code was fairly simple, and the end result looked something like this:

Now this macro forms the basis of the game engine. However those of you who have played D&D will realise that multiple die rolls are very common – 4D8, 2D10, etc.

So this required some further tweaking. This wasn’t much of an issue, and could be done using a simple for loop.

This works reasonably well, however I find the current format quite clunky.

I’d like the end result to involve me inputting say 6D20, and then for excel to automatically read that as rolling a 20-sided die 6 times. Thankfully – Excel has a solution for that as well. This is done using the LEFT and RIGHT functions, which return the left or right characters from a string.

So say we have 4D6. LEFT(4D6) would return 4, and RIGHT(4D6) would return 6. The actual solution was a tad more complicated than that, but it essentially involved finding the D and then basing our results off of that.

And there we are. Done.

I think I’m gonna end this post here. The first two posts were posted very close together, mainly because I had them all written out, then just copied and pasted them in. I might do a bit more work today and post that as well – it really depends on how much I get done.

Generally I’ll be trying to post at least once a week, but that’ll vary with my spare time/enthusiasm.

Anyway  – I’m out for now.

P.S. – Other tabletop RPGs besides D&D are available.