#!perl # # subsector v1.0 # generates a random subsector in mapmaker format. Default occurence # is 4+ but can be set on the command line. Can be piped to mapmaker # or to a file for modification, storage, and addition of X-boat paths. # # Revision 1.1 08-09-2007 bjm Fixed law level trouble use strict; use warnings; our $occ = shift || 4; # stars occur on a 4+ on 1d6 our @spt = qw(A A A B B C C D E E X); our @nbt = qw(. . . . . . N N N N N); our @sbt = qw(. . . . . S S S S S S); our @ggt = qw(G G G G G G G G . . .); our %sptl = ('A' => 6, 'B' => 4, 'C' => 2, 'D' => 0, 'E' => 0, 'X' => -4); our @sztl = (2,2,1,1,1,0,0,0,0,0,0,0,0,0,0,0); our @attl = (1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1); our @hytl = (0,0,0,0,0,0,0,0,0,1,2); our @potl = (0,1,1,1,1,1,0,0,0,2,4); our @gvtl = (1,0,0,0,0,1,0,0,0,0,0,0,0,-2,0,0,0,0,0,0); for my $c (1..8) { for my $r (1..10) { if (d6()+1 >= $occ) { my $loc = sprintf("%02d%02d", $c, $r); my $sp = $spt[d6()+d6()]; # starport lookup my $sz = d6() + d6(); # size my $at = d6() + d6() - 5 + $sz; # atmosphere if ($at < 0) { $at = 0; } my $hy = d6() + d6() - 5 + $at; # hydrographics if ($sz == 0) { $hy = 0; } elsif ($at < 2 || $at > 9) { $hy -= 4; } if ($hy < 0) { $hy = 0; } if ($hy > 10) { $hy = 10; } my $po = d6() + d6(); # population my $gv = d6() + d6() - 5 + $po; # government if ($gv < 0) { $gv = 0; } my $ll = d6() + d6() - 5 + $gv; # law level if ($ll < 0) { $ll = 0; } my $tl = d6() + 1 # tech level + $sptl{$sp} + $sztl[$sz] + $attl[$at] + $hytl[$hy] + $potl[$po] + $gvtl[$gv]; my $upp = $sp # generate UPP . phex($sz) . phex($at) . phex($hy) . phex($po) . phex($gv) . phex ($ll) . '-' . phex($tl); my $nsg; # naval base? if ($sp eq 'A' || $sp eq 'B') { $nsg = $nbt[d6() + d6()]; } else { $nsg = '.'; } my $sbv = d6() + d6(); # scout base? if ($sp eq 'E' || $sp eq 'X') { $sbv = 0; } elsif ($sp eq 'A') { $sbv += -3; } elsif ($sp eq 'B') { $sbv += -2; } elsif ($sp eq 'C') { $sbv += -1; } if ($sbv < 0) { $sbv = 0; } $nsg .= $sbt[$sbv]; $nsg .= $ggt[d6() + d6()]; print "$loc $upp $nsg\n"; } } } sub phex { my $n = shift; return 0 if ($n < 0); return $n if ($n < 10); return chr($n + ord('A') - 10); } sub d6 { return int(rand(6)); }