#!/usr/bin/perl srand(time); $usage="usage: $0 number maxhd\n"; $ARGV[0]=~/^(\d+)$/ && ($numb = $1) || die $usage; $ARGV[1]=~/^(\d+)$/ && ($maxhd = $1) || die $usage; %rule = ( 'W','CT CT CX CDF CVFT CDFU CTU IT ICT A', 'A','KVKVtion', 'K','b c d f g j l m n p qu r s t v sP', 'I','ex in un re de', 'T','VF VEe', 'U','er ish ly en ing ness ment able ive', 'C','b c ch d f g h j k l m n p qu r s sh t th v w y sP Rr Ll', 'E','b c ch d f g dg l m n p r s t th v z', 'F','b tch d ff g gh ck ll m n n ng p r ss sh t tt th x y zz rR sP lL', 'P','p t k c', 'Q','b d g', 'L','b f k p s', 'R','P Q f th sh', 'V','a e i o u', 'D','aw ei ow ou ie ea ai oy', 'X','e i o aw ow oy' ); for (1..$numb) { print &parse('W'), " : ", &stats, "\n"; } sub parse { $_=pop(@_); /[^A-Z]/ && return $_; @TMP=split(/\s+/, $rule{$_}); $_=splice(@TMP, rand @TMP, 1); for (split('')) { print &parse($_); } } sub stats { $hd = int(rand()*$maxhd)+1; $hp = int($hd*4.5)+int(rand()*4*$hd); $ac = 10+$hd+int(rand()*5); $tohit = $hd+int(rand()*4); $dmg = int(rand()*2)+1 . 'd' . (int(rand()*6)+1)*2 . (rand>0.6?'+':'-') . (int(rand()*4)+2); $type = (rand>0.6?"By weapon":"Natural"); return "HD$hd (${hp}hp), AC$ac, $type +$tohit ($dmg)"; }