Showing posts with label generators. Show all posts
Showing posts with label generators. Show all posts

Wednesday, February 19, 2020

Old-School Essentials Online Tools and SRD

My 2nd favorite incarnation, OSE, of my favorite D&D rule set, B/X.  [My 1st favorite is Necrotic Gnome's previous, B/X Essentials, cause it was soft backed, handier and cheaper.]  Have released the Old-School Essentials SRD (System Reference Document)  And a slew of cross-linked  Treasure, Encounter, Spell, Magic Item, Retainer OSE generators.



The /r/osr announcement.

Generators include:
These generators are cross-linked with the Old-School Essentials SRD.  Optimised for desktop, mobile, and tablet. Formated for Cut and Paste.

My initial review, Necrotic Gnome have rolled a nat 20!

Thursday, November 22, 2012

Wizardawn S&W Love

I've been watching Wizardawn (name makes me think of Dark Suns styled adventure based on Red Dawn) for a while now. While many of resources are system agnostic, the stuff I'd been wanting lately, treasure, encounters wasn't so much.

As if in answers to my appeals...


Books and Tomes is keen.  Wrapping it all up, Encounter Generation.  Love the vertical Dungeon Delve. For me, most useful of all is the aptly named [what's behind the] Dungeon Door.  A few pages of "make me look like I know what I'm doing when DMing on the fly".

Tuesday, September 4, 2012

Dungeon Plane

Long ago, in my 3.5 campaign, the party found itself on the "Dungeon Plane".  All I knew about that plane at the time was; it was "old school" (so only spells and powers/feats from base (DMG, PHB) books worked) and it needed to be randomly generated endless "mega dungeon".  Wanting to avoid distraction of rolling up during game but wanting the dungeon to be unknown even to me I wrote this little DMG Appx A Dungeon Generator program to automate things.

Here's what it looks like running.  It's text mode prompting "Adventure awaits:" which I either respond with to generate another "roll" on charts or respond with various commands that roll on specific sub-tables.
Random Dungeon Delve.
Based off of 1st edition AD&D Dungeon Master's Guide. A tool for DM's to use while generating random dungeons.

? for help.
 to explore!

Adventure awaits: 
Pit 10' deep with crushing sides. Check again after 30'.

Adventure awaits: onward
Straight ahead. Check again after 60'.

Adventure awaits: onward
Straight ahead. Check again after 60'.

Adventure awaits: onward
20'x20' chamber with a chance of (1-5 secret door, 6-10 one-way door, 11-20 nothing) per 10' abutting previously explored areas. 
  It contains: Oh no a monster! 250 gold/level in bags secret compartment. 750 electrum/level in sacks with gas strength +1d6 str. 
Check again after leaving for 30'.

Adventure awaits: opendoor
5' wide passage straight ahead.

Adventure awaits: trick_or_trap
20'x20' elevator room descends 2-5 levels plus 1 level per unsuccessful door opening attempt and will not ascend for 60 turns.

Adventure awaits: 
Dead end. Chance of a (1-5 secret door, 6-10 one-way door, 11-20 nothing) per 10' abutting previously explored areas.

Adventure awaits: 
Passage turns left 90 deg. Check again after 30'.

Adventure awaits: onward
Trap door down 1 level to a Door right leading to a 10' wide passage straight ahead. Check again after 30'. 
Passage continues check again after 30'.

Adventure awaits: chamber
40'x40' chamber with 1 exit: 
  In opposite wall a door. 
  It contains a Oh no a monster!

Adventure awaits: flee
Till next time...

Tuesday, August 28, 2012

Deathguards of K'jore

Long ago I ran a 3.5 campaign and needed "chaos paladins" for the bad guys, K'jore. Without any more explanation than that here's example output of the deathguard generator program I wrote:

Level 7 K'jore Deathguard Fighter (medium abberation) CR8
  Hits: 62 / 17
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 17 (+3)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 14 (+2)
  Fort +7, Ref +4, Will +7
  AC: +18, Touch +10, Flat +18
  SD: immune fear, disease, polymorph
  Attacks: Bab +7, Grap +10
    +11 (19-20) Polearm 1d10+5 +1 wound(vampire) [reach]
     +6 (19-20) Polearm 1d10+5 +1 wound(vampire) [reach]
  Powers:
    10' Darkness Despair(-1 actions) DC15 Will
    Wall of K'Jore(Chaos)
  Feats:
    Specialization Series +1/+2
  Equipment:
    Black Plate [Repulsion 10' (can't approach) / DC19 Will negate]

Level 8 K'jore Deathguard Fighter (medium abberation) CR9
  Hits: 69 / 18
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 18 (+4)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 14 (+2)
  Fort +8, Ref +4, Will +8
  AC: +20, Touch +10, Flat +20
  SD: immune fear, disease, polymorph
  Attacks: Bab +8, Grap +11
    +14 (19-20) Demon Axe 1d12+6 +1d6 Purple melt (acid/taint diseased / DC10+dam Fort negate) [opt reach]
     +9 (19-20) Demon Axe 1d12+6 +1d6 Purple melt (acid/taint diseased / DC10+dam Fort negate) [opt reach]
  Powers:
    10' Darkness Despair(-1 actions) DC16 Will
    Summon K'jore beasts
  Feats:
    Specialization Series +2/+2
  Equipment:
    +1 Black Plate [Repulsion 10' (can't approach) / DC19 Will negate]
    +1 weapon

Level 9 K'jore Deathguard Fighter (medium abberation) CR10
  Hits: 75 / 18
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 18 (+4)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 14 (+2)
  Fort +9, Ref +5, Will +8
  AC: +20, Touch +10, Flat +20
  SD: immune fear, disease, polymorph
  Attacks: Bab +9, Grap +12
    +15 Tenticle 1d8+6 [auto grapple]
    +10 Tenticle 1d8+6 [auto grapple]
  Powers:
    10' Darkness Despair(-1 actions) DC16 Will
    Stop Teleport/etc
  Feats:
    Specialization Series +2/+2
  Equipment:
    +1 Black Plate [Corona of Hate (10/heal, 10'r Attack random + Rage(+4 str/con, -2 AC) / DC15 Will negate]
    +1 weapon

Level 10 K'jore Deathguard Fighter (medium abberation) CR11
  Hits: 87 / 18
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 18 (+4)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 14 (+2)
  Fort +9, Ref +5, Will +9
  AC: +21, Touch +10, Flat +21
  SD: immune fear, disease, polymorph
  Attacks: Bab +10, Grap +13
    +16 (18-20) Pick 1d6+6 or (20) Flail 1d8+6 [+2 disarm, trip]
    +11 (18-20) Pick 1d6+6 or (20) Flail 1d8+6 [+2 disarm, trip]
  Powers:
    10' Darkness Despair(-1 actions) DC17 Will
    Contagion Taint disease d4 taint + same damage to random stat/day DC15 Fort
    Storm of Vengence
  Feats:
    Specialization Series +2/+2
    +3 wound points
  Equipment:
    +2 Demon Plate [Corona of Black (10/elec, 10'r 1d12 + shocked(-2 dex/str, 1/2 move) / DC15 Fort negate]
    +1 weapon

Level 11 K'jore Deathguard Fighter (medium abberation) CR12
  Hits: 109 / 18
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 18 (+4)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 14 (+2)
  Fort +10, Ref +6, Will +10
  AC: +22, Touch +11, Flat +22
  SD: immune fear, disease, polymorph
  Attacks: Bab +11, Grap +14
    +17 Three-piece-mace 1d8+6 clinging [trip, opt reach]
    +12 Three-piece-mace 1d8+6 clinging [trip, opt reach]
     +7 Three-piece-mace 1d8+6 clinging [trip, opt reach]
  Powers:
    10' Darkness Despair(-1 actions) DC17 Will
    Prismatic Spray DC19 varies
    Alter structure of world (move/create walls, + gravity + slow + animate etc.)
  Feats:
    Specialization Series +2/+2
    +3 wound points
  Equipment:
    +2 Demon Plate [Corona of Purple (10/-, 10'r 1d12 taint + Nauseated / DC15 Fort Sickened]
    +1 weapon
    +1 ring of protection

Level 12 K'jore Deathguard Fighter (medium abberation) CR14
  Hits: 121 / 18
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 18 (+4)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 15 (+2)
  Fort +11, Ref +7, Will +11
  AC: +24, Touch +11, Flat +24
  SD: immune fear, disease, polymorph
  Attacks: Bab +12, Grap +15
    +19 (19-20) Demon Axe 1d12+9 +1d6 Purple melt (acid/taint diseased / DC10+dam Fort negate) [opt reach]
    +14 (19-20) Demon Axe 1d12+9 +1d6 Purple melt (acid/taint diseased / DC10+dam Fort negate) [opt reach]
     +9 (19-20) Demon Axe 1d12+9 +1d6 Purple melt (acid/taint diseased / DC10+dam Fort negate) [opt reach]
  Powers:
    10' Darkness Despair(-1 actions) DC18 Will
    Animate world to attack foes +12 tohit 2d6 damage
    Dictum DC19 Will see chart
  Feats:
    Specialization Series +2/+4
    Whirlwind, attack all in reach
  Equipment:
    +3 Demon Plate [Cloak of K'jore (+4 AC, +4 save, SR 25 vs Ian, Ian confused 1rnd if he hits)]
    +2 weapon
    +1 ring of protection

Level 13 K'jore Deathguard Fighter (medium abberation) CR15
  Hits: 112 / 18
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 18 (+4)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 15 (+2)
  Fort +11, Ref +7, Will +11
  AC: +24, Touch +11, Flat +24
  SD: immune fear, disease, polymorph
  Attacks: Bab +13, Grap +16
    +20 Razor Chain 3d4+9 clinging [+2 disarm, trip, opt reach]
    +15 Razor Chain 3d4+9 clinging [+2 disarm, trip, opt reach]
    +10 Razor Chain 3d4+9 clinging [+2 disarm, trip, opt reach]
  Powers:
    10' Darkness Despair(-1 actions) DC18 Will
    Summon K'jore beasts
    True Strike +20
  Feats:
    Specialization Series +2/+4
    +3 wound points
  Equipment:
    +3 Demon Plate [Cloak of K'jore (+4 AC, +4 save, SR 25 vs Ian, Ian confused 1rnd if he hits)]
    +2 weapon
    +1 ring of protection

Level 14 K'jore Deathguard Fighter (medium abberation) CR16
  Hits: 132 / 18
  Move: 30'
  Str 16 (+3)
  Dex 10 (+0)
  Con 18 (+4)
  Int  8 (-1)
  Wis 10 (+0)
  Cha 15 (+2)
  Fort +11, Ref +7, Will +12
  AC: +25, Touch +11, Flat +25
  SD: immune fear, disease, polymorph
  Attacks: Bab +14, Grap +17
    +21 Razor Chain 3d4+9 [+2 disarm, trip, opt reach]
    +16 Razor Chain 3d4+9 [+2 disarm, trip, opt reach]
    +11 Razor Chain 3d4+9 [+2 disarm, trip, opt reach]
  Powers:
    10' Darkness Despair(-1 actions) DC19 Will
    Contagion Taint disease d4 taint + same damage to random stat/day DC15 Fort
    Anti-magic 5' sphere DC19 Will
  Feats:
    Specialization Series +2/+4
    Deflect Arrows
    Deflect Arrows
  Equipment:
    +4 Demon Plate [Corona of Cold (10/fire, 10'r 1d12 + shivers(-2 dex/str, 1/2 move) / DC15 Fort negate]
    +2 weapon
    +1 ring of protection

Friday, February 12, 2010

Didn't Even Cheat

I was messing around with RPG Dumping Ground's Character Generator for PBEM and check out the awesome roll 'f' got! Tripple 18's in the physicals, ok Int, Wis only bad stat is Cha aka the dump stat. It was 4d6 drop lowest but still I don't think I've ever rolled that well in my life.

Great little service PBE Games provides. Check out there other PBEM tools.

---- Signed section - include this line ----
Results displayed via web.
Summary: Characters generated by Play by Electron Games


--------------------------------------------------
Character One
Name: f
Method: 4d6 drop lowest, in order
STR: 18 DEX: 18 CON: 18 INT: 11 WIS: 13 CHA: 7

--------------------------------------------------
Character Two
Name: d
Method: 3d6 in order
STR: 14 DEX: 13 CON: 11 INT: 8 WIS: 10 CHA: 8

--------------------------------------------------
Character Three
Name: g
Method: 3d6 arranged
Arrange as desired: 13 14 10 8 4 9

---- Signed section - include this line ----

Signature: 772f402eb6da38aea7e07f1c82e87624
To verify: http://www.pbegames.com/verify/

---
Characters by: http://www.pbegames.com/character
Char Gen version 1.0

Saturday, November 21, 2009

Diablo II Magic Item Gnerator

Silly thing found by Chgowiz but none the less produced some interesting names that lead to the following.


Howling Maul - The ends of this giant maul are carved faces that "howl" as the maul is swung in battle.

Garnet Plate Boots - Have similar properties/effects as ruby red slippers. But, manly sized.

Stalking Gauntlets - They wearer of these hard leather gloves will be able to unerringly track the last person/creature struck across the face dueling challenge style with one of these gauntlets.

Halberd of the Sentinel - One holding this polearm will remain alert and never tire. They gain no benefits of rest however and as soon as halberd is let go they will suffer the accumulated effects of sleep/rest deprivation.

Weirdling Pike - The shaft of this pike bends, warps and twists through the air. Striking around shields, obstacles, attempts to parry, and corners.

Shield of the Colossus - Once per day when this 5' tall tower shield is planted in the ground and the word engraved on its face, "thermopylae", is spoken this metal shield will extend left and right upto 20' each direction until it makes contact and merges with a fixed surface (wall, tree, cliff face, etc.). Unless both sides so connect the shield will "retract". Otherwise the shield "wall" remains until the wielder is slain.

Amulet of Excellence - +1 to every roll.

Battle Axe of Simplicity - This large ax is great at chopping things. It is also cursed such that the owner will consider "chopping things" to be the simple solution to all problems.

Elixir of Fire - This liquid catches fire and burns intensely when exposed to air. If the container is thrown and shatters the resulting explosion will match the force of a fireball. If poured onto ground it will create sheets of fire similar to Wall of Fire. Other uses are left to creative players.


More generated names (and a couple I thought of in between) for which nothing particularly interesting came to mind. I'll store them away for now, unless you have an idea for one of them?

Prismatic Ring of the Mind
Drake's Leather Armor of Weakness
Studded Leather Armor of the Vulture
Silver Spear of the Vulture
Indigo Herb
Russet Herb
Crossbow of Pain
Scepter of Slaughter
Raven's Flail
Amber Kris of Unity
Book of Shivers
Amulet of Defiance
Helm of the Lion
Oil of Immunity
Ivory Bracers of Tears
Swift Blade
Lord's Long Staff
Vulpine
Glass Blade of the Cat
Meteoric Halberd
Gold Flag
Platinum Long Sword of Perfection
Bountiful Scepter of Wizardry
Whirling Halberd of Hate
Bored Sword

Sunday, May 31, 2009

The Miscellaneum of Cinder - A Review

What's it?
A compilation of randomness from the awesomely bizarre mind of Jeff Rients. 36 saddle-stitch pages in the fabulously old school 5.83" x 8.26" format, purple cover, b&w interior art.

I'm loath to list the contents as a goodly part of the joy to owning such a book is exploring its pages. But here's an example of the type of chart What are the Goblins up to? one might encounter within. Don't fret if that particular table didn't grab you. Jeff has crammed a diverse range of topics into this supplement. And with a product like this it's not unreasonable to expect that 50% of the content isn't something you'd immediately use.


Is it worth it?
First I'm not gonna judge the value of someone's original creation. As far as I'm concerned all creative endeavor is priceless. Below I'll consider the product's utility.

The PDF costs one dollar. If that amount of expenditure gives you pause you need to get a job. Otherwise you should probably buy this purplish pdf. [Edit: Wanted to make it clear that I in no way fault Mr. Rients for the pricing. I'd guessed it was probably the lowest possible price with Lulu (which Jeff confirms in a comment below). Paper costs money. My point below was that sometimes it's worth paying for despite hard logic saying it's not economical. And this little booklet has little to do with logic and everything to do with passion.] On the other hand the print booklet at $5.50 is probably not worth it considering you can get 100+ full sized pages of Fight On! for ~$10.00. But you don't buy something like TMoC cause it makes economic sense. I bought it cause it's fecking rad to pull a plum tome from my white box, contemplatively peruse its pages, after a moment exclaim "Yes, yes, here it is the 'Froggish demon-god Weirdoes of Chaos' chart, and gleefully roll some dice to the chorus of groans from hapless players.

It's purple!


I wants it!
Along with many other interesting bits of the Old-School Renaissance you may purchase your very own pdf or print version of The Miscellaneum of Cinder at Lulu.com


The challenge
In his introduction Jeff dares us to blur the line between reader and author (one old-school virtue I'm ecstatic is making a huge comeback). So, from my current 3.5 campaign a table extracted from the program I wrote to generate K'jore Death Guards (think Paladins of Chaos).

Chaos Powers (roll once per 4 levels)
1 "Discord" (target shaken)
2 "Contagion" (target contracts "Taint")
3 "Entropic Repulsion" (living matter can't approach within 10')
4 "Dictum" (as spell)
5 "Anti-magic Ray" (1 target nullifies magic 1d4 rnds)
6 "Anti-magic Sphere" (5' radius)
7 "Storm of Vengeance" (as spell)
8 "Prismatic Spray" (as spell)
9 "Slow" (as spell)
10 "True Strike" (+20 next tohit)
11 "Pandemonium" (Summon K'jore 2d4 beasties)
12 "Taint" (4d6 damage to any grapplers)
13 "Dimension Door" (as spell)
14 "Blacklight" (as spell)
15 "Wall of Turmoil" (wall of elemental Chaos)
16 "Dimensional Maelstrom" (stops Teleport/etc)
17 "Mini-Mayhem" (baby Beholder familiar w/ 4 stalks)
18 "Regeneration" (5hp/rnd)
19 "Baleful Regeneration" (2hp/per creature w/in 30')
20 "Reverse Gravity" (as spell)

Wednesday, December 31, 2008

Links O' Names

Ever since I read "All Games Need Names" by Katharine Kerr in my copy of Dragon #75 I've been facinated by fantasy name and language generation. Although I've rarely(ok never) put in the effort to create my own fantasy language naming scheme. I started a couple times but it was always tedious work instead of fun like drawing maps.

I've learned to appropriate names instead.


Hello my name is Oak Veneer Nightstand
I still tend to name dwarves out of my Ikea catalog.

Googling for baby names brings up lots of sites like this one for Indian Names. The cool part is they usually list meanings for the names. Which is esp awesome for players and a great incentive for them to create names that "fit" the cultural background of their characters yet still have personal attachment. And in case you don't find it here's the Canoical List of Evil Baby Names.

Kabalarian Philosophy goes one step beyond. Detailing the (I assume) Kabalistic importance of over 802,169 names. Sadly they want $15 bucks to see more than a sampling from each of 120 or so languages. Still, it's worth looking at. Did you know that if you were a Zoroastrian named Beezu that your questioning, critical, practical nature makes you prove all ideas to your own satisfaction, rarely accepting anyone's word or ideas. And, the name Beezu creates a dual nature. For you desire to systematize your life to progress step by step, but frequently you are taken into new experiences, instability, and change. Huh, I wonder if Norm is modern white boy for Beezu?

For my first campaign I went to the map library at the Univ. of Kansas. In addition to drooling over topo maps of fjords I copied down lists of place names from Norway and Finland. Using one each for the two big cultures of my world. It's an easy way to have consistent and reasonable sounding names. Although, I'm sure native speakers would laugh at my NPC's named "Big Forest" or "Valley of Red Trees". Today you might use google maps instead. But their maps tend to be a bit sparse for the more interesting parts of the world. Besides there are better sources of names, generators!


Walled City of Lord Lau
Villainesses, Gnomes such as Dwobbert and Wimmalkin, a bit silly Sword & Sorcerish Sites and the like can all be found at Nine French Boys. Well, slap my reptilian, pimply netherbits! they have a smattering of amusing non-name generators as well.

Inspiration Pad has a heap of generators including various name ones split up by culture and gender which is nice cause you know boys and girls are different. Harn Names, CyberPunk Corporations, Taverns, and many more.

Cult of the Squid generators let you choose between various cultures or themes. Using a specific unique generator for each culture really enhances the verisimilitude of a campaign world. For my current game I used related Roman and Latin name generators for the ancient and modern versions of the primary language.

But Philllip Riley's Page is probably the best source of real world name generators. From Teutonic to Basque, Egyptian, Hindu, Russian, Frankish, Norman(represent!), Yiddish, Persian, Hawaiian! Many more including a few fantastical ones such as always useful Medieval Street Names.


Lutzur's Primordial Enmity
Dying Earth Spell Names are a bit specialized but far too awesome not to mention. Some other interesting generators are linked from there. There's also PERL code and data to generate a slew of name styles from real world and fantasy languages.

The Seventh Sanctum I believe gots the most generators of all. Their "normal" name ones are kind of weak. But they have several unique generators. My favorites being Lovecraftian & Wrestlers. Who doesn't want to see the cage match Harold "Hateful Soldier" Perkins vs L'zothaach!


Garden of Forked Paths & Earthly Delights
Abulafia is the bomb, a very slow to load the bomb but none the less the BOMB! A wikified random generator, Zomg! I don't have enough adjectives, aphorisms, and acronyms to convey the awesome in my pants right now. Their name section, they have everything you are looking for. Cause if it ain't there it's up to you to add it. I'll have a pint of Ape Destroyer Ale. Quick wench! Before the Halfling Hippies stink up the bar. Can't wait for tonight's Wonderful Fraternity of Ultimate Man-at-Arms gathering. We're watching Tosyleelaneyptodplooopal's travel pics from the Dread Doldrums of Eternal Peril.


Frymorulor, huh?
I do not fancy(too random) the Bard's Tales Name Generators with standard, short, long, and "hard". But maybe just the thing for weird tales / pulp fantasy or any campaign were Kargen & Notor traveling to the Crystal Palace of Xithanm to steal back the red princess from Kortem the Twisted fits in just fine.

Yet more randomish fantasy names YAFNAG


Post a comment with your naming sources and check again next Wednesday for more semi-thematic links from my collection.

Sunday, December 28, 2008

DMG Based Dungeon Generator

In my current 3.5 campaign the players will be shortly chasing after the Keys of Time, which are spread all over various alternate dimensions. Since I totally got bit with the old-school bug I've decided one of the keys will be found in an old-style Dungeon Crawl Dimension. The characters will start in a 10'x10' dark room(hope they have someway to make light). In the corner will be a 10' pole, a lantern, bundle of torches and a backpack filled with 3 flasks of oil, 10 spikes, a hammer, 50' rope, flint&steel, 1 wk iron rations, and a potion of healing. In each wall will be a wooden door, stuck of course. From there I planned to use the random dungeon generation tables from the DMG. But they turned out to be too unwieldy for use during game. So, I whipped up this simple program to do all the rolls and table lookups for me.

After doing a couple of test runs, I'm a little disappointed with appendix A. Not enough stuff (monsters/treatures/traps), too many freaking wide passages. Too many levels up/down (for my purposes).

For v2 I'll change passages widths to 50% 5', 30% 10', 20% other. Make Traps/Treasures/Monsters more common. Add in room types and dungeon dressings from the other appendixes. Maybe simplified tables to generate magic items, wandering monsters.

There's probably a million of these, this one is mine. Python source dmg_dungeon_generator.py

Python is keen, by far my favorite programming language. It's a bit like modern rules lite RPG's, there's very little syntax and "rules" to it and what there is has a consistency. Makes it easier to tinker with. For instance the ability to redefine how objects are converted to strings, __str__, lets me define random tables that "roll" themselves when printed. Like so
Door = table_d20(
  ( 6, "Door left leading to a", Beyond_Door, ),
  (12, "Door right leading to a", Beyond_Door, ),
  (20, "Door ahead leading to a", Beyond_Door, ),
  )
Beyond_Door = table_d20(
  ( 4, Passage_Width, "parallel passage extending 30' in both directions. Or 10'x10'.", ),
  ( 8, Passage_Width, "passage straight ahead.", ),
  ( 9, Passage_Width, "passage ahead/behind 45deg.", ),
  (10, Passage_Width, "passage behind/ahead 45deg.", ),
  (18, Room, Contents, ),
  (20, Chamber, Contents, ),
  )
The simple python statement print Door will randomly roll a d20, say 11, look up matching row in Door table print "Door right leading to a ". Then roll another d20 this time on Beyond_Door table, which leads to other tables and text and so on.

Those are interpreted (along with a few helper classes/functions) by this relatively short class. Not stupendous but I like how simple/clean/flexible the table definitions are.
class Table(object):
  """Object that when evaluated into string will return random result from table"""
  def __init__(self, dice, *table):
      """@param dice: callable that returns something comparable to x.
      @param *table: list of tuples (x,foo1,foo2,fooN) where x is comparable to return value of dice and foo? are evaluatable into strings.
      """
      self.dice = dice
      self.table = table
  def __str__(self):
      """@return: foo1,foo2,fooN stringified and space separated, from row in table where x >= return value of dice.
      """
      return " ".join(str(s) for s in self.get_result())
  def get_result(self):
      roll = self.dice()
      for row in self.table:
          if row[0] >= roll:
              return row[1:]
      return self.table[-1][1:]

def table_d20(*table):
  return Table(lambda: random.randint(1, 20), *table)
The table_d20 is a helper function to return a Table object preset to use d20 for its dice rolls. It takes a list of arguments, *table, which in our case are the rows of the table. It passes those along with a lambda function that returns a number between 1 and 20 (our d20 die). We need to wrap the random.randint in a lambda so it's callable, since we want a new random number every time we "roll" on the table.

The Table classes __init__ is nothing special. And the __str__ function just applies the str builtin to each item in the list that self.get_result() returns. It then compiles them all into one string, added a space between each one. If you did now know __str__ gets called whenever the object is converted to a string. e.g str(obj) is basically obj.__str__()

The get_result has all the action. It "rolls the dice" then iterates over the table rows looking at the first item until it finds a match. It then returns all but the first of that row's items. There's a fail safe, if no matching row is found it returns items from the last row.

All Time Most Popular Posts