This page displays the source code for the Basic D&D/Labyrinth Lord custom class generator
and the D&D 3.5/d20 custom class generator.
source code for becmi.php
 
<html>
<head>
<title>custom class generator for Basic D&D / Labyrinth Lord</title>
</head>
<body>
<div align=center>This page generates a random character class for Basic or Expert Dungeons & Dragons,<br>
or for the free game <a href="http://www.goblinoidgames.com/labyrinthlord.htm" target="_blank">Labyrinth Lord</a></div>
<div>&nbsp</div>
<div align=center>It's based on an article by Paul Crabaugh.</div>
<div>&nbsp</div>
<div align=center>Characters created using these rules might be altogether better, or altogether worse, than those created using the official rules.<br>
So you're recommended to use these classes for all player characters, or none (you might use it for NPCs only).</div>
<div>&nbsp</div>
<div align=center>If you want a dungeon to send the characters through, look at my <a href="http://www.apolitical.info/webgame/dungeon/index2?mode=2">Labyrinth Lord/Mutant Future dungeon generator</a>.</div>
<?php

// NOTE: all abilities gained at a particular level must be
// gained at level 3 as a minimum. This is because, if they
// were gained at level 2, there'd be no XP difference to if
// they were gained at the start (level 1).
// This isn't in the original article.

// if (!isset($n)) {
// $n=1;
// }

$xp=array("null",0,400,800,1600,3200,6400,12800,25000,50000,75000,100000,125000);
// $xp[$x] is how many XP are needed to get to level X.

$perc=array();

$line="<div>&nbsp</div>";

$attribute=array("null","STR","INT","DEX","CON","WIS","CHA");

$hp=array(
1=> array (3,0,0),
2=> array (4,.5,25),
3=> array (6,1,50),
4=> array (8,2,100),
5=> array (10,3,200),
);
// slot 0 is the hit dice,
// slot 1 is hit points once stop gaining hd,
// slot 2 is the percentage add for the previous 2.

$armour=array("not wear any armour","carry a shield, but may not wear any armour","wear leather armour, but may not carry a shield","wear leather armour and carry a shield","wear any armour, but may not carry a shield","wear any armour and carry a shield");
// 10% x number in array.

$weapons=array(
1=> array ("axes",10),
2=> array ("daggers",5),
3=> array ("swords",15),
4=> array ("pole weapons (polearm, lance, javelin, spear)",10),
5=> array ("impact weapons (mace, club, hammer)",5),
6=> array ("staves",5),
);
// in the original there was also 'catapults' (5%).

$demi=array("null"," halfing (hide, possible bonus to initiative, +1 on missile attacks, -2 AC vs creatures larger than human size"," dwarf (60 foot infravision, detect traps, false walls etc","n elf (60 foot infravision, detect hidden and secret doors, immune to paralysis as from ghouls");
// costs 10 * $x.

$magic=array(
1=> array ("weapons",10),
2=> array ("armour",2.5),
3=> array ("shields",2.5),
4=> array ("potions/rings",15),
5=> array ("misc. magic",10),
6=> array ("wands, staves and rods",15),
7=> array ("protection scrolls",5),
8=> array ("other scrolls",10),
);

$mu=array(
1=> array ("null",1),
2=> array ("null",2),
3=> array ("null",2,1),
4=> array ("null",2,2),
5=> array ("null",2,2,1),
6=> array ("null",2,2,2),
7=> array ("null",3,2,2,1),
8=> array ("null",3,3,2,2),
9=> array ("null",3,3,3,2,1),
10=> array ("null",3,3,3,3,2),
11=> array ("null",4,3,3,3,2,1),
12=> array ("null",4,4,3,3,3,2),
);
// $mu[$x][$y] is how many spells of level y
// a level x magic-user can cast.
// the highest spell level dealt with here is 6.
// magic-user spells cost +250.

$cl=array(
1=> array ("null",1,),
2=> array ("null",2,),
3=> array ("null",2,1),
4=> array ("null",3,2),
5=> array ("null",3,2,1),
6=> array ("null",3,3,2),
7=> array ("null",4,3,2,1),
8=> array ("null",4,3,3,2),
9=> array ("null",4,4,3,2,1),
10=> array ("null",5,4,3,3,2),
11=> array ("null",5,4,4,3,2,1),
12=> array ("null",5,5,4,3,3,2),
);
// this is for cleric spells.
// It's laid out exactly as for $mu above.

$thief=array(
1=> array ("pick locks",17,23,27,31,35,45,55,65,75,85,95,97),
2=> array ("find/remove traps",14,17,20,23,33,43,53,63,73,83,93,95),
3=> array ("pick pockets",23,27,30,37,40,43,53,63,73,83,93,105),
4=> array ("move silently",23,27,30,37,40,43,53,63,73,83,93,95),
5=> array ("climb walls",87,88,89,90,91,92,93,94,95,96,97,98),
6=> array ("hide in shadows",13,17,20,27,30,37,47,57,67,77,87,90),
7=> array ("hear noise",2,2,3,3,3,4,4,4,4,5,5,5),
);
// each costs 10.
// hear noise has to be printed as 1-x.

$saveas=array(
1=> array (" cleric",15),
2=> array (" dwarf or halfling",40),
3=> array ("n elf",30),
4=> array (" fighter",25),
5=> array (" magic-user",5),
6=> array (" thief",10),
7=> array (" Normal Man, regardless of their level.",0),
);

$spec=array(
1=> array ("n alchemist",50,47),
2=> array (" blacksmith",20,48),
3=> array ("n animal trainer",30,48),
4=> array ("n engineer",50,48),
5=> array (" sage",100,48),
6=> array (" spy",40,48),
7=> array (" sailor",10,48),
8=> array (" captain",50,48),
9=> array (" navigator",40,48),
);

// slot 0 is the name
// slot 1 is the cost
// slot 2 is the page in LL.

// original article also has rowers, but they're 'unskilled' according to LL.

// for ($z=1;$z<=$n;$z++) {
for ($y=1;$y<=12;$y++) {
$perc[$y]=100;
}

// requirements and Prime Requisites.
$ptype=rand(1,7);
if (rand(1,3)==1) {
$ptype=1;
}
// 1: no requirements, A is prime requisite.
// 2: req A at least 9, A is prime requisite.
// 3: req A at least 9, B is prime requisite.
// 4: req A at least 9, A & B are primes.
// 5: req A and B at least 9, A & B are primes.
// 6: req A and B at least 9, B & C are primes.
// 7: no requirements, A & B are primes.

// 3, 4, 5, 7 gives a 10% 'discount' on XP needed.
// 6 gives a 20% discount.

if ($ptype>2) {
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]-10;
if ($ptype==6) {
$perc[$y]=$perc[$y]-10;
}
}
}

do {
$aprime=$attribute[rand(1,6)];
$bprime=$attribute[rand(1,6)];
$cprime=$attribute[rand(1,6)];
} while ($aprime==$bprime OR $bprime==$cprime OR $cprime==$aprime);

print "Requirements: ";
if ($ptype==1 OR $ptype==7) {
print "none";
} else {
print $aprime." 9";
if ($ptype>4) {
print ", ".$bprime." 9";
}
}
print "<br>Prime Requisite";
if ($ptype>3) {
print "s";
}
print ": ";
if ($ptype<>3 AND $ptype<>6) {
print $aprime;
if ($ptype>3) {
print ", ";
}
}
if ($ptype>2) {
print $bprime;
if ($ptype==6) {
print ", ".$cprime;
}
}
print "<br>";
if ($ptype>3) {
print "Members of this class must have at least 13 in one or the other prime requisite to get the 5% bonus to experience.<br>";
print "If both prime requisites are at least 13, members of this class will gain a 10% bonus to experience.";
}
print $line;

// Hit Points.
$x2=rand(1,5);
$x1=rand(8,12);
if ($x1==12) {
$x3=1;
// because any adds wouldn't be shown, since
// levels are only displayed up to 12.
} elseif ($x1==11) {
do {
$x3=rand(1,5);
} while ($x3==2 OR $x3==3);
// because adds of half and of one both give +1 hp
// on the first level, so they couldn't be told apart.
} else {
$x3=rand(1,5);
}

// $x1 is the highest level where the character gains a Hit Dice.
// it costs ($x1-8)*10 for all those levels, plus the add for
// the hit dice itself.
// x2 is the hit dice (from hp array)
// x3 is the addition (from hp array)

print "<b>Hit Points</b>";
print "<table border=2>";
print "<tr><td>Level</td><td>Hit Points</td></tr>";
for ($y=1;$y<=12;$y++) {
print "<tr><td>".$y."</td><td>";
if ($y<=$x1) {
print $y."d".$hp[$x2][0];
$perc[$y]=$perc[$y]+$hp[$x2][2]+(($x1-8)*10);
} else {
print $x1."d".$hp[$x2][0];
$hpadd=ceil($hp[$x3][1]*($y-$x1));
if ($hpadd>0) {
print "+".$hpadd;
}
$perc[$y]=$perc[$y]+$hp[$x3][2]+(($x1-8)*10);
}
print "</td></tr>";
}
print "</table>";
print $line;
print "<b>Armour</b><br>";
$arm=rand(0,5);
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+(10*$arm);
}
print "Members of this class may ".$armour[$arm].".";
print $line;
print "<b>Weapons</b><br>";
print "Members of this class may ";
if (rand(1,3)==1) {
print "use any weapons.";
$wadd=75;
} elseif (rand(1,3)==1) {
print "only use daggers.";
$wadd=5;
} else {
print "only use ";
if (rand(1,2)==1) {
$wadd=0;
} elseif (rand(1,2)==1) {
print "bows and ";
$wadd=15;
} else {
print "slings and ";
$wadd=5;
}
$y=rand(1,6);
$wadd=$wadd+$weapons[$y][1];
print $weapons[$y][0].".";
}
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+$wadd;
}
print $line;

print "<b>Attacking</b><br>";
print "Members of this class roll to attack as a ";
if (rand(1,3)==1) {
print "magic-user.";
$aadd=50;
} elseif (rand(1,2)==1) {
print "cleric or thief.";
$aadd=70;
} else {
print "dwarf, elf, fighter or halfling.";
$aadd=140;
}
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+$aadd;
}
print $line;

print "<b>Magic Items</b><br>";
if (rand(1,3)==1) {
print "Members of this class may not use any magic items.";
$madd=0;
} elseif (rand(1,2)==1) {
print "Members of this class have no restrictions on the use of magic items.";
$madd=70;
if ($arm<2) {
$madd=$madd-2.5;
}
if ($arm==0 OR $arm==2 OR $arm==4) {
$madd=$madd-2.5;
}
} else {
print "Members of this class may use the following magic items:<br>";
$madd=0;
print "<table border=2>";
for ($y=1;$y<=8;$y++) {
print "<tr><td>".$magic[$y][0]."</td><td>";
if (rand(1,2)==1 OR ($y==2 AND $arm<2) OR ($y==3 AND ($arm==0 OR $arm==2 OR $arm==4))) {
print "no";
} else {
print "<b>yes</b>";
$madd=$madd+$magic[$y][1];
}
print "</td></tr>";
}
print "</table>";
}
if ($madd>0) {
print "<br>Note that, for magic armour, weapons and shields, characters can only use a magic item if they could use the normal version of that item.";
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+$madd;
}
}
print $line;
if (rand(1,3)==1) {
print "<b>Magic-User Spells</b><br>";
print "Members of this class can cast magic-user spells as a magic-user of ";
if (rand(1,2)==1) {
print "their level.";
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+250;
}
} else {
$x=rand(1,9);
print $x."0% of their level - that is:";
print "<table border=2>";
print "<tr><td><div align=\"center\">Character<br>Level</div></td>";
print "<td colspan=6><div align=\"center\">Spell Level</div></td></tr>";
print "<tr><td></td>";
for ($y=1;$y<=6;$y++) {
print "<td>".$y."</td>";
}
print "</tr>";
for ($y=1;$y<=12;$y++) {
print "<tr><td>".$y."</td>";
$mulev=round($x*$y/10);
if ($mulev>0) {
$perc[$y]=$perc[$y]+(25*$x);
}
for ($w=1;$w<=6;$w++) {
print "<td>";
if ($mu[$mulev][$w]<1) {
print "-";
} else {
print $mu[$mulev][$w];
}
print "</td>";
}
}

print "</table>";
}
print $line;
}

if (rand(1,3)==1) {
print "<b>Cleric Spells</b><br>";
print "Members of this class can cast cleric spells as a cleric of ";
if (rand(1,2)==1) {
print "their level.";
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+175;
}
} else {
$x=rand(1,9);
print $x."0% of their level - that is:";
print "<table border=2>";
print "<tr><td><div align=\"center\">Character<br>Level</div></td>";
print "<td colspan=6><div align=\"center\">Spell Level</div></td></tr>";
print "<tr><td></td>";
for ($y=1;$y<=6;$y++) {
print "<td>".$y."</td>";
}
print "</tr>";
for ($y=1;$y<=12;$y++) {
print "<tr><td>".$y."</td>";
$cllev=round($x*$y/10);
if ($cllev>0) {
$perc[$y]=$perc[$y]+(17.5*$x);
}
for ($w=1;$w<=6;$w++) {
print "<td>";
if ($cl[$cllev][$w]<1) {
print "-";
} else {
print $cl[$cllev][$w];
}
print "</td>";
}
}

print "</table>";
}
print $line;
}

if (rand(1,4)==1) {
print "<b>Turning the Undead</b><br>";
print "Members of this class can attempt to turn the undead as if they were a cleric of ";
if (rand(1,2)==1) {
print " their level.";
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+50;
}
} else {
$x=rand(1,9);
print $x."0% of their actual level. That is:";
print "<table border=2>";
print "<tr><td>Character<br>Level</td><td>Turn Undead<br>As Cleric</td></tr>";
for ($w=1;$w<=12;$w++) {
print "<tr><td>";
print $w."</td><td>";
$ulev=round($w*$x/10);
if ($ulev==0) {
print "none";
} else {
print $ulev;
$perc[$w]=$perc[$w]+(5*$x);
}
print "</td></tr>";
}
print "</table>";
}
print $line;
}

if (rand(1,2)==1) {
print "<b>Thief Skills</b><br>";
if (rand(1,3)==1) {
print "Members of this class have the thief skills, including the bonus when attacking unnoticed from behind, of a thief of their level.";
$tadd=80;
} elseif (rand(1,2)==1) {
$y=rand(1,9);
$tadd=8*$y;
print "Members of this class have the same skills as a thief, but to a lesser extent. They gain the normal bonus when attacking unnoticed from behind, but their percentage chance with other skills is only ".$y."0% that of a thief of the same level. That is:";
print "<table border=2>";
print "<tr><td>Character<br>Level</td>";
for ($x=1;$x<=7;$x++) {
print "<td>".$thief[$x][0]."</td>";
}
print "</tr>";
for ($l=1;$l<=12;$l++) {
print "<tr><td>".$l."</td>";
for ($x=1;$x<=7;$x++) {
print "<td>";
$score=round($thief[$x][$l]*$y/10);
if ($x==7 AND $score>1) {
print "1-";
}
print $score;
print "</td>";
}
print "</tr>";
}
print "<table>";

} else {
$ns=rand(1,3);
$tadd=$ns*10;
do {
$x1=rand(1,7);
$x2=rand(1,7);
$x3=rand(1,7);
} while ($x1>=$x2 OR $x1>=$x3 OR $x2>=$x3);
print "Members of this class can ".$thief[$x1][0];
if ($ns==2) {
print " and ".$thief[$x2][0];
} elseif ($ns==3) {
print ", ".$thief[$x2][0]." and ".$thief[$x3][0];
}
print " as a thief of their level.";
}
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+$tadd;
}
print $line;
}

if (rand(1,4)==1) {
print "<b>Flying</b><br>";
if (rand(1,2)==1) {
$sf=1;
print "Members of this class can fly.";
} else {
$sf=rand(3,12);
print "At level ".$sf.", members of this class gain the ability to fly.";
}
for ($y=$sf;$y<=12;$y++) {
$perc[$y]=$perc[$y]+25;
}
print $line;
}

if (rand(1,4)==1) {
print "<b>Breathe Underwater</b><br>";
if (rand(1,2)==1) {
$sw=1;
print "Members of this class can breathe underwater.";
} else {
$sw=rand(3,12);
print "At level ".$sw.", members of this class gain the ability to breathe underwater.";
}
for ($y=$sw;$y<=12;$y++) {
$perc[$y]=$perc[$y]+15;
}
print $line;
}

if (rand(1,4)==1) {
print "<b>Regeneration</b><br>";
if (rand(1,2)==1) {
$rg=1;
print "Members of this class can regenerate 1 point of damage per turn, except for damage inflicted by fire.";
} else {
$rg=rand(3,12);
print "At level ".$rg.", members of this class gain the ability to regenerate 1 point of damage per turn, except for damage inflicted by fire.";
}
for ($y=$rg;$y<=12;$y++) {
$perc[$y]=$perc[$y]+100;
}
print $line;
}

print "<b>Saves</b><br>";
print "Members of this class save as a";
$sa=rand(1,7);
print $saveas[$sa][0];
if ($sa<7) {
print " of their level.";
for ($y=1;$y<=12;$y++) {
$perc[$y]=$perc[$y]+$saveas[$sa][1];
}
}
print $line;

if (rand(1,2)==1) {
print "<b>Special Abilities</b><br>";
$race=rand(1,3);
$when=1;
if (rand(1,2)==1) {
$when=rand(3,12);
print "At level ".$when.", members of this class gain";
} else {
print "Members of this class have";
}
print " the special abilities of a".$demi[$race].").";
for ($y=1;$y<=12;$y++) {
if ($y>=$when) {
$perc[$y]=$perc[$y]+(10*$race);
}
}
print $line;
}

if (rand(1,2)==1) {
print "<b>Professional Skills</b><br>";
if (rand(1,2)==1) {
$ss=1;
print "Members of this class have";
} else {
$ss=rand(3,12);
print "At level ".$ss.", members of this class gain";
}
$st=rand(1,9);
print " the special skills of a".$spec[$st][0]." (see p".$spec[$st][2]." of Labyrinth Lord).";
for ($y=$ss;$y<=12;$y++) {
$perc[$y]=$perc[$y]+$spec[$st][1];
}
print $line;
}


// each level must be at least 10% higher than the last.
// $newxp=0;
// $newxp is the last number printed.
print "<b>Advancement</b>";
print "<table border=2>";
print "<tr><td>Level</td><td>XP required</tr>";
for ($y=1;$y<=12;$y++) {
print "<tr><td>".$y."</td><td>";
$truexp=round($xp[$y]*$perc[$y]/100);
$newxp=max($truexp,round($newxp*11/10));
print $newxp;
print "</td></tr>";
}
print "</table>";

// }



print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame/class/becmi.php\">reload</a> this page for a new class.</div>";
print "<div>&nbsp</div>";
print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame\" onMouseover=\"window.status='back to the starting page'; return true\">return to Age of Fable</a> . <a href=\"http://www.apolitical.info/webgame?mode=7\" onMouseover=\"window.status='back to the library'; return true\">return to library</a> . <a href=\"http://www.apolitical.info/webgame/class/sourcecode\" target=\"_blank\" onMouseover=\"window.status='view the sourcecode'; return true\">view the sourcecode</a></div>";
@include "http://www.apolitical.info/webgame/footer.txt";
?>
<div>&nbsp</div>
</body>
</html>
 
source code for d20.php
 
<html>
<head>
<title>custom class generator for d20 / Dungeons & Dragons 3.5</title>
</head>
<body>
<div align=center>This page generates a random character class for Dungeons & Dragons 3.5 edition. It's based on the material <a href="http://www.d20srd.org/srd/variant/classes/genericClasses.htm" target="_blank">here</a>.</div>
<div>&nbsp</div>
<div align=center>Characters created using these rules might not be balanced with those created using the normal rules. So you're recommended to use these classes for every character, or none.</div>
<div>&nbsp</div>
<?php

$line="<div>&nbsp</div>";

$range=10;
// each of the 3 basic classes has 0-$range influence
// on the randomly generated class, to a total of $range.

$classtype=array();
// 1=spellcaster, 2=expert, 3=warrior.

$classtotal=0;
for ($z=1;$z<=3;$z++) {
$classtype[$z]=rand(1,$range);
if (rand(1,2)==1) {
$classtype[$z]=0;
}
$classtotal+=$classtype[$z];
}

while ($classtotal<>$range) {
$z=rand(1,3);
$classtotal=$classtotal-$classtype[$z];
$classtype[$z]=0;
$want=$range-$classtotal;
if ($want>=0 AND $want<=$range) {
$classtype[$z]=$want;
} else {
$classtype[$z]=rand(1,$range);
if (rand(1,2)==1) {
$classtype[$z]=0;
}
}
$classtotal=$classtotal+$classtype[$z];
}

$skillname=array(
1=> array ("Appraise","Int"),
2=> array ("Balance","Dex"),
3=> array ("Bluff","Cha"),
4=> array ("Climb","Str"),
5=> array ("Concentration","Con"),
6=> array ("Craft","Int"),
7=> array ("Decipher Script","Int"),
8=> array ("Diplomacy","Cha"),
9=> array ("Disable Device","Int"),
10=> array ("Disguise","Cha"),
11=> array ("Escape Artist","Dex"),
12=> array ("Forgery","Int"),
13=> array ("Gather Information","Cha"),
14=> array ("Handle Animal","Cha"),
15=> array ("Heal","Wis"),
16=> array ("Hide","Dex"),
17=> array ("Intimidate","Cha"),
18=> array ("Jump","Str"),
19=> array ("Knowledge (arcana)","Int"),
20=> array ("Knowledge (architecture and engineering)","Int"),
21=> array ("Knowledge (dungeoneering)","Int"),
22=> array ("Knowledge (geography)","Int"),
23=> array ("Knowledge (history)","Int"),
24=> array ("Knowledge (local)","Int"),
25=> array ("Knowledge (nature)","Int"),
26=> array ("Knowledge (nobility and royalty)","Int"),
27=> array ("Knowledge (religion)","Int"),
28=> array ("Knowledge (the planes)","Int"),
29=> array ("Listen","Wis"),
30=> array ("Move Silently","Dex"),
31=> array ("Open Lock","Dex"),
32=> array ("Perform","Cha"),
33=> array ("Profession","Wis"),
34=> array ("Ride","Dex"),
35=> array ("Search","Int"),
36=> array ("Sense Motive","Wis"),
37=> array ("Sleight of Hand","Dex"),
38=> array ("Speak Language","special"),
39=> array ("Spellcraft","Int"),
40=> array ("Spot","Wis"),
41=> array ("Survival","Wis"),
42=> array ("Swim","Str"),
43=> array ("Tumble","Dex"),
44=> array ("Use Magic Device","Cha"),
45=> array ("Use Rope","Dex"),
);

$manyskills=45;

$classskill=array();

$special=array(
1=> array ("null",1,4,5,5),
2=> array ("null",1,1,2,4),
3=> array ("null",1,1,2,2),
);
// slot 1 is the first level with a special (1 for all classes).
// slots 2-4 are the gaps between specials.
// once the end is reached, slot 4 is used from then on.

$cspec=array();

$domain=array(
1=>"Air",
2=>"Animal",
3=>"Chaos",
4=>"Death",
5=>"Destruction",
6=>"Earth",
7=>"Evil",
8=>"Fire",
9=>"Good",
10=>"Healing",
11=>"Knowledge",
12=>"Law",
13=>"Luck",
14=>"Magic",
15=>"Plant",
16=>"Protection",
17=>"Strength",
18=>"Sun",
19=>"Travel",
20=>"Trickery",
21=>"War",
22=>"Water",
);
$domnum=22;

$school=array("null","Abjuration","Conjuration","Divination","Enchantment","Evocation","Illusion","Necromancy","Transmutation");
$schoolnum=8;

$spday=array(
1=> array(4,2),
2=> array(5,3),
3=> array(5,4),
4=> array(6,5,2),
5=> array(6,5,3),
6=> array(6,6,4,2),
7=> array(6,6,5,3),
8=> array(6,6,5,4,2),
9=> array(6,6,6,5,3),
10=> array(6,6,6,5,4,2),
11=> array(6,6,6,6,5,3),
12=> array(6,6,6,6,5,4,2),
13=> array(6,6,6,6,6,5,3),
14=> array(6,6,6,6,6,5,4,2),
15=> array(6,6,6,6,6,6,5,3),
16=> array(6,6,6,6,6,6,5,4,2),
17=> array(6,6,6,6,6,6,6,5,3),
18=> array(6,6,6,6,6,6,6,5,4,2),
19=> array(6,6,6,6,6,6,6,6,5,3),
20=> array(6,6,6,6,6,6,6,6,6,5),
);

$spknown=array(
1=> array (4,2),
2=> array (5,2),
3=> array (5,3),
4=> array (6,3,1),
5=> array (6,4,2),
6=> array (7,4,2,1),
7=> array (7,5,3,2),
8=> array (8,5,3,2,1),
9=> array (8,5,4,3,2),
10=> array (9,5,4,3,2,1),
11=> array (9,5,5,4,3,2),
12=> array (9,5,5,4,3,2,1),
13=> array (9,5,5,4,4,3,2),
14=> array (9,5,5,4,4,3,2,1),
15=> array (9,5,5,4,4,4,3,2),
16=> array (9,5,5,4,4,4,3,2,1),
17=> array (9,5,5,4,4,4,3,3,2),
18=> array (9,5,5,4,4,4,3,3,2,1),
19=> array (9,5,5,4,4,4,3,3,3,2),
20=> array (9,5,5,4,4,4,3,3,3,3),
);

print "<b>Hit Die</b>";
print $line;
$ahp=(2.5*$classtype[1])+(3.5*$classtype[2])+(5.5*$classtype[3]);
$ahp=$ahp/$range;
$ahp=$ahp*2;
$ahp=round($ahp);
print "d".($ahp-1);
if ($ahp==6 OR $ahp==8 OR $ahp==10) {
print " (roll a d".$ahp." but ignore and re-roll results of ".$ahp.")";
}
print $line;
print "<b>Class Skills</b>";

// Spellcaster = 4 + ALL Knowledge skills (10) + Profession
// Expert = 12 + Profession.
// Warrior = 6 (NOT Profession)

$csk=round(((15*$classtype[1])+(13*$classtype[2])+(6*$classtype[3]))/$range);
// note that this doesn't include Craft, which everyone gets.
// wizards get a lot, but put a lot towards Knowledge skills (below).

// Craft
$classskill[6]=1;

// Profession.
if ($classtype[3]*2<$range) {
$csk=$csk-1;
$classskill[33]=1;
}

// starting Knowledge skills.
$sk=round(10*$classtype[1]/$range);

// if there are at least 6 Knowledge skills, make it 10.
if ($sk>5) {
$diff=10-$sk;
$csk=$csk+round($diff*.5);
$sk=10;
}

for ($z=1;$z<=$sk;$z++) {
do {
$y=rand(19,28);
} while ($classskill[$y]==1);
$classskill[$y]=1;
}
$csk=$csk-$sk;

// randomly choose remaining skills.
for ($z=1;$z<=$csk;$z++) {
do {
$y=rand(1,$manyskills);
$ok=1-$classskill[$y];
if ($y==5 OR $y==39) {
if ($classtype[1]*10<$range*3) {
$ok=0;
}
}
} while ($ok==0);
$classskill[$y]=1;
}

// if the class has all ten Knowledge skills, simplify.
$allk=1;
for ($z=19;$z<=28;$z++) {
$allk=$allk*$classskill[$z];
}
if ($allk==1) {
$skillname[19][0]="Knowledge (all skills, taken individually)";
for ($z=20;$z<=28;$z++) {
$classskill[$z]=2;
// not 0, because can still be given bonus.
}
}

// generate $sd (number of skills to list
// counts 'Knowledge (all)' as one. This is only for grammar.
$sd=0;
for ($z=1;$z<=$manyskills;$z++) {
$sd=$sd+$classskill[$z];
}

print $line;
print "This class's class skills (and the key ability for each skill) are ";
for ($z=1;$z<=$manyskills;$z++) {
if ($classskill[$z]==1) {
print $skillname[$z][0]." (".$skillname[$z][1].")";
$sd=$sd-1;
if ($sd==0) {
print ".";
} elseif ($sd==1) {
print " and ";
} else {
print ", ";
}
}
}
print $line;
print "<b>Skill Points</b>";
$skp=(2*$classtype[1])+(6*$classtype[2])+(2*$classtype[3]);
$skp=round($skp/$range);
print $line;
print "(".$skp." + Int modifier) x 4 at first level.";
print $line;
print $skp." + Int modifier at each additional level.";
print $line;
print "<b>Weapon and Armour Proficiency</b>";
print $line;
$wa=round(((2*$classtype[2])+(4*$classtype[3]))/$range);
$wp=rand(0,$wa);
$ap=$wa-$wp;
while ($ap>2) {
$ap=$ap-1;
$wp++;
}
while ($wp>2) {
$wp=$wp-1;
$ap++;
}
if ($wp==0) {
print "One simple weapon";
} elseif ($wp==1) {
print "All simple weapons, one martial weapon";
} else {
print "All simple and martial weapons";
}
print "; ";
if ($ap==0) {
print "no armour.";
} elseif ($ap==1) {
print "light armour.";
} else {
print "light and medium armour; shields (but not tower shields).";
}
print $line;
$bab=array(
1=> array (0,.5),
2=> array (0,.75),
3=> array (1,1),
);
// each class has an array.
// in each array, the first number is the BAB at level 0,
// the second is the amount added each level.
// BAB is rounded UP.


do {
$goodsave=rand(1,3);
$oksave=rand(1,3);
} while ($goodsave==$oksave);

// define when the character gets special abilities.
$clev=0;
$whichspec=1;
do {
// find next level.
for ($z=1;$z<=3;$z++) {
$clev=$clev+($special[$z][$whichspec]*$classtype[$z]/$range);
}
if (round($clev)<=20) {
$cspec[round($clev)]=1;
}
if ($whichspec<4) {
$whichspec++;
}
} while (round($clev)<20);

$feats=0;
// number of bonus feats the class gets.

print "<table border=2>";
print "<tr><td>Level</td><td>BAB</td><td>Fort.</td><td>Ref.</td><td>Will</td><td>Special</td></tr>";

for ($l=1;$l<=20;$l++) {
print "<tr><td>".$l."</td><td>";

// Base Attack Bonus.
$cb=0;
for ($z=1;$z<=3;$z++) {
$classbab=$bab[$z][0]+(($l-1)*$bab[$z][1]);
$cb=$cb+($classtype[$z]*$classbab);
}
$cb=ceil($cb/$range);
do {
print "+".$cb;
$cb=$cb-5;
if ($cb>0) {
print "/";
}
} while ($cb>0);
print "</td>";

// Saves.
for ($z=1;$z<=3;$z++) {
$goodval=2+(($l-1)/2);
$badval=($l-2)/3;
if ($z==$goodsave) {
$sv=$goodval;
} elseif ($z==$oksave) {
$sv=(($classtype[2]*$goodval)+(($range-$classtype[2])*$badval))/$range;
} else {
$sv=$badval;
}
print "<td>+".max(0,ceil($sv))."</td>";
// the 'max(0...' is to stop the initial 0 in the
// weak save printing as '+-0', which it was doing.

if ($z==2) {
$reflex=$sv;
}
// this is used for the class ability Evasion.
}

// Special.
print "<td>";
if ($cspec[$l]==0) {
print "--";
} else {
$roll=rand(1,30);
if ($roll==30 AND $turn<1) {
print "Turn undead";
$turn=$l;
} elseif ($roll==29 AND $familiar<1) {
print "Familiar";
$familiar=$l;
} elseif ($roll==28) {
print "Favoured Enemy";
$favoured=1;
} elseif ($roll==27 AND $uncanny==0) {
print "Uncanny Dodge";
$uncanny=1;
} elseif ($roll==26 AND $evasion==0 AND $reflex>2) {
print "Evasion";
$evasion=1;
} elseif ($evasion==1 AND $reflex>6) {
print "Improved Evasion";
$evasion=2;
} elseif ($roll<10) {
do {
$ska=rand(1,$manyskills);
$skb=rand(1,$manyskills);
} while ($ska>=$skb OR $classskill[$ska]*$classskill[$skb]==0);
$pska=$skillname[$ska][0];
$pskb=$skillname[$skb][0];
if ($pska=="Knowledge (all skills, taken individually)") {
$pska="Knowledge (arcana)";
} elseif ($pskb=="Knowledge (all skills, taken individually)") {
$pskb="Knowledge (arcana)";
}
print "+2 to ".$pska." and ".$pskb;
} elseif ($l>9 AND rand(1,$range)<=$classtype[2] AND rand(1,3)>1) {
print "Rogue Special Ability";
$rogue=1;
if ($feats>0) {
$cstrike=1;
}
} else {
print "Bonus feat";
$feats++;
}
}
print "</td>";

print "</tr>";
}
print "</table>";

// class abilities.
if ($feats>0) {
print $line;
print "<b>Bonus Feat</b>";
print $line;
print "This class may choose any feat that they qualify for as a bonus feat.";
// maybe change this later.
}
if ($rogue==1) {
print $line;
print "<b>Rogue Special Ability</b>";
print $line;
print "The character may pick one of the Special Abilities available to a rogue";
if ($classskill[16]*$classskill[30]<>1 OR $cstrike==0) {
print " except for Crippling Strike";
}
print ". Unlike a rogue, this class may not choose a bonus feat instead of a rogue special ability.";
} elseif ($favoured==1) {
print $line;
print "<b>Favoured Enemy</b>";
print $line;
print "This operates as the ranger class ability.";
}
if ($uncanny==1) {
print $line;
print "<b>Uncanny Dodge</b>";
print $line;
print "This combines the barbarian class abilities Uncanny Dodge and Improved Uncanny Dodge.";
}
if ($evasion>0) {
print $line;
print "<b>Evasion";
if ($evasion==2) {
print " and Improved Evasion";
}
print "</b>";
print $line;
if ($evasion==1) {
print "This operates as the monk ability.";
} else {
print "These operate as the monk abilities.";
}
}
if ($familiar>0) {
print $line;
print "<b>Familiar</b>";
print $line;
if ($familiar==1) {
print "M";
} else {
print "From level ".$familiar.", m";
}
print "embers of this class can gain a familiar, as a sorcerer of the same level.";
}
if ($turn>0) {
print $line;
print "<b>Turn Undead</b>";
print $line;
if ($turn==1) {
print "M";
} else {
print "From level ".$turn.", m";
}
print "embers of this class can attempt to turn the undead as a cleric of the same level.";
}
if ($classskill[14]==1 AND $feats>0) {
print $line;
print "<b>Wild Empathy</b>";
print $line;
print "Members of this class can choose to gain Wild Empathy instead of a bonus feat. It operates as the druid class ability. Prerequisite: Handle Animal 4 ranks.";
}
if ($classskill[16]*$classskill[30]==1 AND $feats>0) {
print $line;
print "<b>Sneak Attack</b>";
print $line;
print "Members of this class can choose to gain ";
if ($feats==1) {
print "Sneak attack instead of a bonus feat. It operates as the rogue class ability, except that it adds 2d6 to damage rolls. Prerequisites: Hide 4 ranks, Move Silently 4 ranks.";
} else {
print "the following abilities, instead of a bonus feat (one ability for each feat given up):";
print $line;
print "Sneak Attack: As the rogue ability, but +2d6 on damage rolls. Prerequisites: Hide 4 ranks, Move Silently 4 ranks.";
print $line;
print "Improved Sneak Attack: Sneak attacks now add 3d6 to damage rolls. Prerequisites: Hide 11 ranks, Move Silently 11 ranks, Sneak Attack.";
if ($feats>2) {
print $line;
print "Greater Sneak Attack: Sneak attacks now add 4d6 to damage rolls. Prerequisites: Hide 18 ranks, Move Silently 18 ranks, Sneak Attack, Improved Sneak Attack.";
}
}
}
if ($classskill[35]==1 AND $feats>0) {
print $line;
print "<b>Trap Sense</b>";
print $line;
print "Members of this class can choose to gain Trap Sense instead of a bonus feat. This ability combines the rogue class abilities Trap Sense and Trapfinding. Prerequisite: Search 4 ranks.";
}

if ($classtype[1]>0) {
do {
$major=rand(1,3);
$minor=rand(1,3);
} while ($major==$minor);
// 1: Sorcerer/Wizard: maj=any, min=bard only or certain schools.
// 2: Cleric: maj=any, min=paladin only or certain domains.
// 3: Druid: maj=any, min=ranger only.

print $line;
print "<b>Magic</b>";
print $line;
print "Members of this class learn and cast spells as a sorcerer";
if ($ap>0 AND ($major==1 OR $minor==1)) {
print " except that, like a bard, they can ignore arcane spell failure chances for light armour.";
} else {
print ".";
}
print $line;
print "They may select their spells known from the ";
if ($major==1) {
print "sorcerer/wizard";
} elseif ($major==2) {
print "cleric";
} else {
print "druid";
}
print " list, or from ";
if ($minor==1) {
if (rand(1,2)==1) {
print "the bard list.";
} else {
print "the ";
print $school[rand(1,$schoolnum)];
print " school of the sorcerer/wizard list.";
}
} elseif ($minor==2) {
if (rand(1,2)==1) {
print "the paladin list.";
} else {
print "the ";
do {
$z=rand(1,$domnum);
} while ($major==3 AND ($z==2 OR $z==6 OR $z==15));
// if the major is druid, the domain can't be
// Animals, Earth or Plants.
print $domain[$z];
print " domain of the cleric list.";
}
} else {
print "the ranger list.";
}
print $line;
print "They use ";
if (rand(1,3)==1) {
print "Intelligence";
} elseif (rand(1,2)==1) {
print "Wisdom";
} else {
print "Charisma";
}
print " to determine the highest-level spell they can learn or cast, and the DC of their spell's saving throws.";
print $line;
for ($ch=1;$ch<=2;$ch++) {
print "<b>Spells ";
if ($ch==1) {
$ct="Per Day";
} else {
$ct="Known";
}
print $ct;
print "</b>";
print "<table border=2>";
print "<tr><td rowspan=2>Caster<br>Level</td><td colspan=10 align=\"center\">Spells ".$ct."</td></tr>";
print "<tr>";
for ($z=0;$z<=9;$z++) {
print "<td>";
print $z;
print "</td>";
}
print "</tr>";
for ($z=1;$z<=20;$z++) {
print "<tr>";
print "<td>".$z."</td>";
$ca=round($z*$classtype[1]/$range);
for ($y=0;$y<=9;$y++) {
print "<td>";
if ($ch==1) {
$sp=$spday[$ca][$y];
} else {
$sp=$spknown[$ca][$y];
}
if ($sp==0) {
print "--";
} else {
print $sp;
}
print "</td>";
}
print "</tr>";
}
print "</table>";
if ($ch==1) {
print $line;
print $line;
}
}
}



print $line;
print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame/class/d20.php\">reload</a> this page for a new class.</div>";
print $line;
print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame\" onMouseover=\"window.status='back to the starting page'; return true\">return to Age of Fable</a> . <a href=\"http://www.apolitical.info/webgame?mode=7\" onMouseover=\"window.status='back to the library'; return true\">return to library</a> . <a href=\"http://www.apolitical.info/webgame/class/sourcecode\" target=\"_blank\" onMouseover=\"window.status='view the sourcecode'; return true\">view the sourcecode</a></div>";
@include "http://www.apolitical.info/webgame/footer.txt";
?>
<div>&nbsp</div>
</body>
</html>