Thursday, June 5, 2014

Embedded Micro Generators for Dungeons & Dragons Blogs

(If you want to read this post with a slightly more readable presentation, go here.)

JDJarvis over at Aeons & Augauries inspired me to write this with his little generators like the Foul Tomes of Carcosa.

You can include generated content in you blog posts by adding a script like the ones below. Put the code into your post using your blog editor's text/​HTML mode (on Blogger, click the "HTML" button next to the "Compose" button). Each example is entirely self-contained. Cut, paste, and tinker!

d20 Example

Here we click a button to generate a random number.


The Code for d20

<script>
function roll20() {
    var min = 1;
    var max = 20;
    var roll = Math.floor(Math.random() * (max - min + 1)) + min;
    var outputSpan = document.getElementById("d20result");
    outputSpan.innerHTML = roll;
}
</script>
<div>
<button onclick="roll20();">d20</button>
<span id="d20result"></span>
</div>

Magic Tower Example

Here we combine random selections from various lists, and do it without a button.

Click this paragraph to generate a Magic Tower (then click it again to generate another).

The Code for Magic Tower

<script>
function generateMagicTower() {
    function arnd(a) {
        // Return random element of array a.
        var i = Math.floor(Math.random() * (a.length));
        if (typeof a[i] === 'function') {
            return a[i]();
        }   
        return a[i];
    }
    var colors = ["Red", "Black", "White", "Gray", "Pearlescent", "Lurid", "Hoary"];
    var structures = ["Tower", "Spire", "Turret", "Belfry", "Citadel", "Seculsium"];
    var outputParagraph = document.getElementById("magictower");
    outputParagraph.innerHTML = "The " + arnd(colors) + " " + arnd(structures);
}
</script>
<p id="magictower" onclick="generateMagicTower();">Click this paragraph to generate a Magic Tower (then click it again to generate another).</p>

Dynamic Hit Points Example

In the paragraph below, the hit points are randomly generated each time the page loads. Reload this page to see the hit points change.

An Ogre (HP ; AC 5; Move 9"; HD 4+1) glowers from the cave entrance.

The Code for Dynamic Hit Points

<p>An Ogre (HP <span id="ogrehitpoints"></span>; AC 5; Move 9"; HD 4+1) glowers from the cave entrance.</p>
<script>
function rollHitPoints(hdNumber, hdPlus, hdSize) {
    hdNumber = hdNumber || 1;
    hdPlus = hdPlus || 0;
    hdSize = hdSize || 6;
    var hitPoints = 0;
    for (var i = 0; i < hdNumber; i++) {
        hitPoints = hitPoints + Math.floor(Math.random() * hdSize) + 1;
    }
    hitPoints = hitPoints + hdPlus;
    return hitPoints;
}
var ogreHitPoints = document.getElementById("ogrehitpoints");
ogreHitPoints.innerHTML = rollHitPoints(4, 1);
</script>

Learn More About JavaScript

You can learn a lot of JavaScript using free tutorials on the web.

Start a cheat sheet and keep track of what you learn. Refine it over time as your understanding increases. Here's my JavaScript cheat sheet, for example.

You may also want to keep a code clipping file to store useful and clever little bits of JavaScript to reuse.

Mozilla Developer Connection has a good JavaScript reference. It's a better than many of the alternatives that rank higher on Google results. (In fact, when I search for JavaScript reference info, I include "MDN" in my search terms.)

If you want to learn from books, these are good:

If you start writing scripts of more than a dozen lines, get yourself a good text editor. For Windows, try NotePad++. For Mac, try TextWrangler. If you're on Linux, you probably already have a favorite text editor, but if not try gEdit (or go all hardcore and learn vim).

Finally, you should at least be aware of JSLint and JSHint. They're alternative sites that find errors in JavaScript code. JSLint is more rigorous/harsher. If your JavaScript gets an error you can't solve, these tools may help you find it.

About These Micro Generators

This code was written by Paul Gorman. You may copy, reuse, redistribute, and modify the example code however you see fit.

Test

This is a test.

Friday, May 30, 2014

The Importance of Observation

There's a fun thread over the on the OD&D74 forum that starts with Mike Mornard recounting a recent game of TRACTICS. In the second comment, Chirine relates this anecdote from the Twin Cities:

In the 'straight RPG' sense, observation is just as important. Follow me back in time to the days of yesteryear, when it was a dull evening at the old house and we were bored. We were sitting around, and musing on the very best marching order for a party of player-characters, and the idea came about that we should try an Actual Real-life Experiment. So, Gronan gets into his coat of plates, Olaf gets into his mail, and I hand Alfric (Gronan's squire) and Keith the Cleric a couple of lit candle lanterns. We then unlimber the rattan arsenal, we turn off all the lights in the house, and I - The Monster - go and hide someplace with my treasure of plastic gold pieces. The boys count to fifty, and then come in after me. They go Fighter (Gronan), Squire (Alfric), Cleric (Keith), and Fighter (Olaf); perfectly sound as a marching order, and all in accordance with what was considered Best Dungeon-crawling Practice.

It was awful. Me, I had lots of fun killing all of them in succession, several times over. (I had picked out several ambush points in the house.) A guy would appear out of the gloom, I'd give them a quick double tap on the back of the head to let them know they were dead, and they - being very sporting types! - would keel over dead to the horror and bafflement of the rest of the party. The next guy would look down to check the casualty, and I'd nail him. Then the cleric would try to see what he could do, and he'd get it. last and not least, the last guy in the line would try to see what was going on, and then he'd get it.

In the really dark corners of the house (Remember those attic stairs, Gronan? Oh, my...), I started at the back of the party and worked my way to the front. Same results. Two very experienced fighters, one pretty experienced squire, and one decent cleric all dead as the proverbial doornails saver times over.

What got them killed was lack of observation - not that they didn't try really hard, but that we learned that two fighters in *** closed face helms *** can't see much of anything. If the two unarmored guys weren't looking in the right place in the right time with the lantern held in just the right place, they couldn't see anything either. Most of the time, they said in the post-mortem, the light blinded them and ruined their night vision.

So, the RPG lessions for today:

1) Open-faced helms; a nice burgonet is a good idea.
2) Put the lanterns on a short chain on a short stick; you can keep it low, out of your eyes, and stick it into dark corners while keeping back out of striking range of some nasty lad like me.
3) Put a lightly armored fighter in the front as a scout; they can see better, move faster, and get out of the way of the heavies when they need to.
4) Do the same at the back, and have them keep looking to their rear.

Success in RPGs, at least the way we used to play here in the northwoods, came from teamwork and communication back up by observation.

Thursday, May 29, 2014

Dreams in the Megadungeon

John Arendt of Dreams in the Lich House has a nice series of posts about designing and running a Megadungeon. Check it out if you're not burned out on the topic.

Tuesday, May 27, 2014

Greyhawk was FULL of weird sh*t

Wayne Rossi linked to Mike Mornard's comment on the odd74 forum that "Greyhawk was FULL of weird sh*t", and observed that over the years Greyhawk has earned an unfair reputation as vanilla fantasy.

Look at the "Trick and Traps" or the "Monstrous Tricks and Combination Monsters" sections of Supplement 1, for example! That's certainly wackier than most of the Greyhawk material we saw coming out of TSR in the AD&D era. I remember getting the AD&D Greyhawk box, and finding it pretty boring. Maybe I should take a second look....

Monday, May 26, 2014

Enhanced Dwarf-Land map

Scott of Huge Ruined Pile nuked his blog again today, as he is want to do from time to time. I expect we'll see him again eventually.

When working on his Dwarf-Land setting, Scott commissioned the great Russ Nicholson to do a wonderful map. Unfortunately, the scan was a lossy JPG of limited resolution. I tried to enhance it at the time, but didn't do the best possible job. Today, I went back and created a new enchanced Dwarf-Land map (6MB). It's a 600dpi lossless PNG carefully converted to 1-bit color for sharp printing. I printed some sample details, and it looks damn good. If you're inclined to print a big version of the map (24" x 36"), I recommend you use the new enhanced file. Short of a better scan of the original, this is about as good as it will get.

P.S. — If anyone is really desperate for the blog content, I did a PDF print and a wget. I'll put up a tarball if there's sufficient demand.

Thursday, May 22, 2014

Proceduralism

Brendan blogged about Proceduralism. It's worth reading.