Tuesday, 2 December 2014

Mass Combat 3: Counter Punch

So, I said in the previous instalment that I prefer to use counters than figures, so here's how I make my counters - a bit of Perl and a bit of plainTeX. If you have a Mac or a Linux machine then you should be able to use these files without any real problem; it's possible that even Windows has managed to catch up with the 1980's enough to use them—I don't know. The end result should be a 2 page PDF (see here for example based on the defaults below) which you should be able to print to get double-sided counters with one side representing the unit at full strength and the other side half. My ancient Epson 1290 manages to produce accurate enough registration for this so I assume printers made this century (yes, it really is that old) will be able to cope.

Blogger can't handle this sort of thing very well, so you'll have to trust me that you can cut and paste from the following mess into a file editor to get usable results (this is also why there's no images in this post).

The first file is units.tex which sets up some macros for the later code:


\hsize 6.2677true in%
\vsize 9.69true in%
\special{papersize=210mm,297mm}%

\newdimen\csize
\newdimen\tsize
\newdimen\twidth
\def\setsize#1{\csize=#1
        \tsize=.93\csize
        \twidth=.87\csize
        \font\BODY=phvr at .222\csize
        \font\SMALL=phvr at .18\csize
        \setbox0=\hbox{\BODY ()1234567890}
        \global\setbox\strutbox=\hbox{\vrule height \ht0 depth \dp0 width 0pt}
}
\setsize{27pt} % default
\def\centre#1{\hfill\strut #1\hfill }
\def\inline#1{\setbox99=\hbox{\BODY #1}\ifdim\wd99<\twidth\hbox to
\tsize{\centre{\BODY #1}}\else\hbox to \tsize{\centre{\SMALL #1}}\fi}
\def\line#1{\hbox to \tsize{\thinspace\strut #1\thinspace }}
\def\slip{\hrule width 0pt height .4pt }
\footline{\hfil}
\BODY
\def\newline{\par\noindent}
\def\newpage{\par\vfill\break\noindent\parfillskip=0pt\leftskip=0pt
plus 1fil\rightskip=0pt}
\def\unit #1 #2,#3,#4,#5,#6 {\vbox{\hsize\csize\hrule height .8pt
\hbox to \csize{\vrule width.8pt\hfill\vbox to \csize{\hsize=\csize
\slip
\line{\BODY #3\hfill #4\strut}\vfill
\inline{#1}\slip\slip%%%% Max width<23.36pt
\inline{#2}\vfill
\line{\BODY #5\hfill #6}\slip
}\hfill\vrule width.8pt}%
\hrule height 0pt depth .8pt}\penalty0}%
\setbox12=\hbox{0000000}
\offinterlineskip\parindent=0pt\parfillskip=0pt plus 1fil\rightskip=\parfillskip\leftskip=0pt\noindent

\endinput
\bye

Then we have the main counter defining file makeunits.pl. This contains the hard coded definitions of the counters you want to to produce. The default ones in the file should be enough to work out how to modify it for your own use. The only slightly unclear parameter is probably "count" which is simply the number of copies of that unit you want; they will be numbered so you can track damage and so on.

#!/usr/bin/perl -w

@lines=();
@currentline=();
$width=shift || (27/72);

$maxline=6/$width;

$width*=72;

#Count, name, cl, ac, mv, number
units(30,"Kobold",0,7,6,40);
units(10,"Goblin",1,6,6,40);
units(10,"Orc",2,6,9,20);
units(5,"Lizardman",5,6,"6//12",20);
units(4,"Militia",0,5,9,20);
units(10,"Reserves",0,8,12,20);
units(10,"Mob",-2,10,12,20);
units(1,"Pixie",0,"1(5)","6/12",80);

print '\input units.tex';
print "\n";
print "\\setsize{$width pt}";
print '\newline';
print "\n";

pageone();
pagetwo();
print '\bye';

sub pageone
{
    if(@currentline)
    {
 push @lines,[@currentline];
 @currentline=();
    }
    for $l(@lines)
    {
 @currentline=@$l;
 for $u(@currentline)
 {
     print "$u";
 }
 print "\\newline\n";
    }
}

sub pagetwo
{
    print "\\newpage\n";
    for $l(@lines)
    {
 @currentline=@$l;
 for (1..@currentline)
 {
     $u=pop@currentline;
     ($s)=$u=~/,(\d+)\s*$/;
     $s/=2;
     $u=~s/,\d+\s*$/,$s /;
     print "$u";
 }
 print "\\newline\n";
    }
}

sub units
{
    my ($dups,$name,$cl,$ac,$mv,$size)=@_;
    local $i;
    for $i(1..$dups)
    {
 push @currentline,"\\unit {$name} $i,$ac,$mv,$cl,$size ";
 if(@currentline==$maxline)
 {
     push @lines,[@currentline];
     @currentline=();
 } 
    }
}

To use this, you pass the size of the counters you want as a fraction of an inch and redirect the output to some other file, for example

./makeunits.pl .626 >sheet.tex

Finally, you turn this TeX file into a pdf in whatever method you normally do, if nothing else then

pdftex sheet.tex

Should have a good chance of producing a file called sheet.pdf which you can print.

AC comes out at top-left; move rate top-right; combat ability (ie, the equivelant fighter ability) goes bottom-left; and the number of individuals represented by the unit goes in the bottom-right. The combat ability, as well as the tables in part 1, are intended for use with my combined combat tables but aren't hard to use with the standard tables.

Next post will probably be about something else, but in the post after that I plan to get down to some discussion of how to actually resolve some real combat with these rules (and one more table).

No comments:

Post a Comment