Awesome
Hex Mapping
Many role-playing games use hex maps. Traditionally, D&D used hex maps for the wilderness and Traveller used a hex map for sectors and subsectors. They are everywhere.
This project collects the various tools I have used to work with hex maps. All of them are web applications (CGI scripts) written in Perl 5 and the maps are always SVG documents.
Bugs, feature requests, questions – all sorts of questions: please see the Software Wiki.
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->Table of Contents
<!-- markdown-toc end -->Text Mapper
This application takes a textual representation of a map and produces SVG output.
Example input:
0101 empty
0102 mountain
0103 hill "bone hills"
0104 forest
Text Maps from the Command Line
xmllint
allows us to extract text from XML and HTML documents. On a
Debian system, it's part of libxml2-utils
.
Generate a text file with a 20x20 alpine wilderness map:
perl text-mapper.pl get /alpine 2>/dev/null | xmllint --html --xpath '//textarea/text()' - > random-alpine-map.txt
You'll note that at the very end it contains the seed value.
You can regenerate the same map using this seed:
perl text-mapper.pl get "/alpine?seed=1499413794" 2>/dev/null | xmllint --html --xpath '//textarea/text()' - > 1499413794.txt
You can also modify the width and breadth of the map:
perl text-mapper.pl get "/alpine?width=10&height=5" 2>/dev/null | xmllint --html --xpath '//textarea/text()' - > random-alpine-map.txt
Let's define an alias to handle the encoding of the map for us:
alias encodeURIComponent='perl -pe '\''s/([^a-zA-Z0-9_.!~*()'\''\'\'''\''-])/sprintf("%%%02X",ord($1))/ge'\'
Make some changes to the text file generated above using a text editor and generate the updated map:
perl text-mapper.pl get --header 'Content-Type:application/x-www-form-urlencoded' --method POST --content map=$(cat 1499413794.txt|encodeURIComponent) /render 2>/dev/null > 1499413794.svg
You can use svgexport to generate a PNG image, if you want.
First, install it:
npm install svgexport -g
You need to tell it what quality to use when exporting. I use 100% for PNG files; I'd use less for JPG files.
svgexport 1499413794.svg 1499413794.png 100%
Hex Describe
This application takes a map generated by Text Mapper and a set of random tables to generate a textual description of the region. It's ideal if your players are wandering into unprepared regions, and it's great if you need some seed material to base your work on.
You can provide your own random tables if you have the file online somewhere in a Pastebin or shared it from Dropbox, etc.
The format is simple: every word in the map description and every two word combo from the map description is a potential table in your file. If it exists, it will be used.
Assuming the following description:
0101 dark-green trees village
The description will be generated from any tables that match:
- dark-green
- trees
- village
It would make sense to just provide tables for "trees" and "village", for example.
Tables looks like this:
;trees
1,some trees
1,you encounter [forest monster]
;forest monster
3,[3d6] bandits
1,an elf
A semicolon and some text begin a new table. A number, a comma, and some text are an entry in he table. The text needs to be on one line. The numbers are relative probabilities. The chances for an encounter in the forest are thus 50% and the chances to encounter an elf, if you are encountering anything at all, are 25%. The example also shows how you can link from one table to another using square brackets.
Square brackets are also used for dice rolls. A dice roll can look like this: 3d6, 3d6+5 3d6x10, or 3d6x10+5.
There's an built-in help page with more details for end users. If you
intend to host the application yourself, use perldoc hex-describe.pl
to get a more technical documentation based on the comments in the
code.
Traveller Subsector Generator
This application generates a random UWP list suitable for Traveller-style Science Fiction games.
It generates output like the following:
Tavomazupa 0103 D85D000-0 Ba Wa
Xeqqtite 0107 C858651-6 S Ag Ga NI
Baziezoti 0108 C467100-7 Lo A
Zuzinba 0109 D350697-3 S De Lt NI Po
Titutelu 0202 C75B988-6 Hi Wa
It also takes the UWP of a sector or subsector and generates a map for you. If possible, it also adds communication and trade routes based on some heuristics.
Subsectors from the Command Line
xmllint
allows us to extract text from XML and HTML documents. On a
Debian system, it's part of libxml2-utils
.
How to get a random UWP from the command line:
perl traveller.pl get /uwp/874568503 2>/dev/null | xmllint --html --xpath '//pre/text()' - | perl -MHTML::Entities -pe 'decode_entities($_);'
How to generate a SVG file from the command line:
perl traveller.pl get /map/874568503 2>/dev/null > 874568503.svg
Generating a simple SVG file from a map on the command line (URL-escaped):
perl traveller.pl get --header 'Content-Type:application/x-www-form-urlencoded' --method POST --content "map=Rezufa%200101%20E310000-0%20Ba" /map 2>/dev/null
Generating an SVG map from UWP in a text file:
perl traveller.pl get --header 'Content-Type:application/x-www-form-urlencoded' --method POST --content map=$(cat 874568503.txt|encodeURIComponent) /map
This assumes you defined the following alias:
alias encodeURIComponent='perl -pe '\''s/([^a-zA-Z0-9_.!~*()'\''\'\'''\''-])/sprintf("%%%02X",ord($1))/ge'\'
Old School Hex
This application takes an ASCII art representation of a map and turns it into a black-and-white hex map.
Example input:
n " " .
n-n O-. .
n-"-" .
Monones
This application generates an island using a Voronoi diagram. It's based on Amit Patel's post Polygonal Map Generation for Games (2010).
Names
This application generates a bunch of names based on a set of syllables. When you reload, it will generate a new set of syllables and a new set of names based on them. The effect is that these names all sound as if they're part of the same "language". This idea is based on the original Elite system name generator. One way to look at the relevant code would be Text Elite.