This page displays the source code for the Tunnels & Trolls/Labyrinth Lord + Mutant Future dungeon generator.
source code for index.php
 
<head>
<link rel="shortcut icon" href="http://www.apolitical.info/webgame/favicon.ico" type="image/vnd.microsoft.icon">
<title>Random Dungeon Generator, by Age of Fable.</title>
</head>
<body link="#8888ff" alink="#8888ff" vlink="#8888ff" text="ffffff" bgcolor="000000">
<table align="center">
<tr><td align="center"><a href="http://www.apolitical.info/webgame/dungeon/index2"><img src="http://www.apolitical.info/webgame/dungeon/title.jpg"></a></td>
<td width=5></td>
<td align="center"><a href="http://www.apolitical.info/webgame/dungeon/index2?mode=2"><img src="http://www.apolitical.info/webgame/dungeon/title-ll.jpg"></a></td>
</tr>
<tr></td><td align="center">character pictures by <a href="http://toybox-sw.blogspot.com//" target="_blank">gwindel</a></td>
<td width=5></td>
<td align="center">character pictures by <a href="http://www.threeheadedtroll.com/" target="_blank">Jason Braun</a></td>
</tr></table>
<div>&nbsp</div>
<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/dungeon/sourcecode" target="_blank" onMouseover="window.status='view the sourcecode'; return true">view the sourcecode</a></div>
<div>&nbsp</div>
<div align="center">
<!-- Project Wonderful Ad Box Code -->
<div id="pw_adbox_1077_2_0"></div>
<!-- End Project Wonderful Ad Box Code -->
</body>
 
source code for index2.php
 
<head>
<link rel="shortcut icon" href="http://www.apolitical.info/webgame/favicon.ico" type="image/vnd.microsoft.icon">
<title>Random Dungeon Generator, by Age of Fable.</title>
</head>
<body link="#8888ff" alink="#8888ff" vlink="#8888ff" text="ffffff" bgcolor="000000">
<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/dungeon/sourcecode" target="_blank" onMouseover="window.status='view the sourcecode'; return true">view the sourcecode</a></div>
<div>&nbsp</div>
<?php
print "<div align=\"center\"><img src=\"http://www.apolitical.info/webgame/dungeon/title";
if ($mode>1) {
print "-ll";
}
print ".jpg\" border=1></div><div align=\"center\">character pictures by ";
if ($mode>1) {
print "<a href=\"http://www.threeheadedtroll.com\" target=\"_blank\">Jason Braun</a></div>";
} else {
print "<a href=\"http://www.gwindel.eu\" target=\"_blank\">gwindel</a></div>";
}
?>
<form name="input" action="create" method="get">
<table align="center">
<tr><td align="right">What average character level should the dungeon be designed for?</td>
<td width=10></td>
<td><input type="text" size=2 name="s" value=1></td></tr>
<tr><td align="right">What group size should the dungeon be designed for?</td>
<td width=10></td>
<td><input type="text" size=2 name="c" value=4></td></tr>
<?php
if ($mode==2 or $mode==3) {
print "<tr><td align=\"right\">For both the above numbers, count hired NPCs who<br>fight, but not those who only carry torches etc.</td></tr>";
}
?>
<tr><td align="right">How many levels should the dungeon have?</td>
<td width=10></td>
<td><input type="text" size=2 name="l" value=4></td></tr>
<?php
if ($mode<>2 AND $mode<>3) {
print "<tr><td align=\"right\">Average strength of a group of monsters<br>(as a percentage of the delvers' likely strength)?</td>";
print "<td width=10></td>";
print "<td><input type=\"text\" size=2 name=\"ha\" value=60></td></tr>";
}
?>
<tr><td align="right">Roughly how many areas should each level have?</td>
<td width=10></td>
<td><input type="text" size=2 name="r" value=20></td></tr>
<?php
if ($mode==2 OR $mode==3) {
print "<input type=\"hidden\" name=\"system\" value=\"ll\">";
} else {
print "<tr><td align=\"right\">What attributes should monsters have?</td>";
print "<td width=10></td>";
print "<td><input type=\"radio\" name=\"stormr\" value=3>MR only<br>";
print "<input type=\"radio\" name=\"stormr\" value=1>full stats<br>";
print "<input type=\"radio\" name=\"stormr\" value=2 checked>either</td></tr>";
print "<tr><td align=\"right\">Should Wizardry be used as an attribute?</td>";
print "<td width=10></td>";
print "<td><input type=\"radio\" name=\"wiz\" value=1 checked>Yes<br>";
print "<input type=\"radio\" name=\"wiz\" value=0>No<td></tr>";
print "<tr><td align=\"right\">Should Speed contribute to combat adds?</td>";
print "<td width=10></td>";
print "<td><input type=\"radio\" name=\"spd\" value=1 checked>Yes<br>";
print "<input type=\"radio\" name=\"spd\" value=0>No</td></tr>";
print "<tr><td align=\"right\">What should the default method of working out<br>Monster Rated monsters' dice and adds be?</td>";
print "<td width=10></td>";
print "<td><input type=\"radio\" name=\"adds\" value=1>4th edition<br>";
print "<input type=\"radio\" name=\"adds\" value=4 checked>5th edition<br>";
print "<input type=\"radio\" name=\"adds\" value=3>7th edition</td></tr>";
}
print "<tr><td align=\"right\">Should the creatures of the dungeon have a theme?</td>";
print "<td width=10></td>";
print "<td><input type=\"radio\" name=\"theme\" value=1>yes<br>";
print "<input type=\"radio\" name=\"theme\" value=0>no<br>";
print "<input type=\"radio\" name=\"theme\" value=2 checked>random</td></tr>";
if ($mode<>2 AND $mode<>3) {
print "<tr><td align=\"right\">Should standard creatures be used if possible?<br>(they'll have full stats, and won't fit into any theme)</td>";
print "<td width=10></td>";
print "<td><input type=\"radio\" name=\"smo\" value=1>yes<br>";
print "<input type=\"radio\" name=\"smo\" value=0 checked>no<br>";
print "<input type=\"radio\" name=\"smo\" value=2>random</td></tr>";
print "<tr><td align=\"right\">Gods</td>";
print "<td width=10></td>";
print "<td><input type=\"radio\" name=\"godd\" value=1 checked>Specific - eg \"Thoth, the ibis-headed god of magic.\"<br>";
print "<input type=\"radio\" name=\"godd\" value=0>General - eg \"The god of magic.\"<br>";
print "<input type=\"radio\" name=\"godd\" value=2>No gods.</td></tr>";
}
?>
</table>
<div align="center"><input type="submit" value="submit"></div>
</form>
<div align="center">If you want a world to put your dungeon in, you could use my <a href="http://www.apolitical.info/webgame/map" target="_blank">Random Map Generator</a>.</div>
<div>&nbsp</div>
<?php
if ($mode==2 OR $mode==3) {
print "<div align=\"center\">For more individual characters, see my <a href=\"http://www.apolitical.info/webgame/class/becmi.php\" target=\"_blank\">D&D/Labyrinth Lord random class generator</a>.</div>";
print "<div>&nbsp</div>";
print "<div align=\"center\">You can generate characters of any level quickly using this <a href=\"http://truculent.org/llchar\" target=\"_blank\">Labyrinth Lord character generator</a>.</div>";
print "<div>&nbsp</div>";
}
?>
<div align="center">A lot of the ideas in the dungeon generator come from my collection of <a href="http://www.apolitical.info/webgame/tables" target="_blank">random tables</a>.</div>
<?php
$line="<div>&nbsp</div>";
print $line;
if (!isset($mode)) {
print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame/dungeon/index2?mode=1\">Credits, and What's Tunnels & Trolls?</a></div>";
} elseif ($mode==1) {
print "Tunnels & Trolls is a pen-and-paper role-playing game that's been around since the 70s. The main attraction of it is that it's very easy, unlike Dungeons & Dragons and other similar games. There's a free set of cut-down rules at <a href=\"http://www.freedungeons.com/rules\" target=\"_blank\">freedungeons.com</a>. The main things that are in this generator, and aren't in the rules there, are:";
print "<ul>";
print "<li>A lot of people use an extra attribute, called Wizardry (or WIZ), which is reduced when you cast spells (Strength is used this way in the freedungeons rules).";
print "<li>You can count Speed towards your Combat Adds in the same way that Strength, Dexterity and Luck are counted. If you use this rule, you might also want to let characters increase their SPD (by the new level number) when they gain a level.";
print "<li>As well as Warriors and Wizards, there are Rogues. Rogues aren't thieves (as in a lot of games). Instead, they're halfway between Warriors and Wizards. They can use any weapon like Warriors, but they don't get the Warrior's bonus for armour. They can learn spells, but they don't start knowing all the first level spells like Wizards do. They also can't automatically buy spells - they have to find them during their adventures.";
print "<li>As well as humans, dwarves, elves and hobbits, you can be a fairy or a leprechaun.";
print "<ul><li>Fairies change their attributes as follows: STR x 1/4, LK x 3/2, CON x 1/4, DEX x 3/2.";
print "<li> Leprechauns change their attributes as follows: STR x 1/2, CON x 3/2, DEX x 3/2.";
print "<li> Fairies can fly, if their equipment weighs less than half of their Weight Possible.";
print "<li> Leprechauns have to be Wizards - but, like Rogues, they can't buy spells automatically. They start knowing the spell Wink-Wing, and it only 'costs' them 5 WIZ points (or 5 STR, if you're not using WIZ).";
print "</ul>";
print "<li>Spite Damage: fights where both sides are heavily armoured can end in stalemate. Spite Damage is designed to get around this. When characters are fighting hand-to-hand, each 6 rolled (by either side) counts as an extra point of damage, which isn't reduced by armour. Hit Point Totals are still compared in the normal way.";
print "</ul>";
print "The main places on the internet where people talk about Tunnels & Trolls seem to be the <a href=\"http://trollbridge.proboards44.com\" target=\"_blank\">Trollbridge forum</a>, and the <a href=\"http://games.groups.yahoo.com/group/radiofreetrollworld\" target=\"_blank\">Radio Free Trollworld</a> email list. I'm on Trollbridge, so if you want to ask me a question you can do it via that.";
print $line;
print "You can buy the rules, which have some extra equipment and spells etc, from <a href=\"http://www.flyingbuffalo.com/tandt.htm\" target=\"_blank\">Flying Buffalo Inc.</a> (also known as FBI).";
print $line;
print "Tunnels & Trolls is by Ken St Andre, with editing by Liz Danforth. The misfire table for pistols, the rules for bullwhips, and some of the standard creatures, are adapted from material by Toad-Killer-Dog from Trollbridge. Some jewels taken from a list by mahrundl from Trollbridge. The 'Eyes' are inspired by those in M.A.R. Barker's <a href=\"http://www.tekumel.com\" target=\"_blank\">Tekumel</a>. Magic of Odand adapted, with permission, from <a href=\"http://www.lulu.com/content/2791099\" target=\"_blank\">Eldritch Weirdness</a> by Matthew J. Finch (originally written for Dungeons & Dragons). Everything else by Age of Fable.";
print $line;
print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame/dungeon/index2\">close this</a>";
} elseif ($mode==2) {
print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame/dungeon/index2?mode=3\">What Are Labyrinth Lord and Mutant Future?</a></div>";
} else {
print "Labyrinth Lord and Mutant Future are free pen-and-paper role-playing games. Labyrinth Lord repeats the rules from an old version of Dungeons & Dragons.";
print $line;
print "Mutant Future is set after a nuclear war. It's not supposed to be realistic: characters can be robots, intelligent plants, mutants with powers like being able to fly, and so on. It's similar to an old game called Gamma World. However the rules of Mutant Future are almost the same as the rules for Labyrinth Lord. So you can use the same adventure for either game. The main difference is that in Mutant Future you start a lot more powerful than in Labyrinth Lord.";
print $line;
print "This generator creates dungeons that are sort of half-and-half - with both magic and technology.";
print $line;
print "You should look at Section 9 of Mutant Future especially, because it gives rules for combining the two games (by making the 'mutant' characters less powerful).";
print $line;
print "The rules for Labyrinth Lord are <a href=\"http://www.goblinoidgames.com/labyrinthlord.html\" target=\"_blank\">here</a>, the Mutant Future rules are <a href=\"http://www.goblinoidgames.com/mutantfuture.html\" target=\"_blank\">here</a>. Both games are in pdf format, which needs Acrobat Reader. In the highly unlikely event that your computer doesn't have Acrobat Reader, it's <a href=\"http://www.adobe.com/products/acrobat/readstep2.html\" target=\"_blank\">here</a> (and also free).";
print $line;
print "<div align=\"center\"><a href=\"http://www.apolitical.info/webgame/dungeon/index2?mode=2\">close this</a>";
}
?>
<div>&nbsp</div>
<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/dungeon/sourcecode" target="_blank" onMouseover="window.status='view the sourcecode'; return true">view the sourcecode</a></div>
<div>&nbsp</div>
<div align="center">
<!-- Project Wonderful Ad Box Code -->
<div id="pw_adbox_1077_2_0"></div>
<!-- End Project Wonderful Ad Box Code -->
</body>
 
source code for create.php
 
<head>
<title>Random Dungeon Generator, for Tunnels & Trolls or Labyrinth Lord / Mutant Future, by Age of Fable.</title>
</head>
<body>
<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></div>
<div>&nbsp</div>
<?php
// LL/MF MONSTERS SHOULD HAVE CHANCE TO
// BE STATUES (maybe jewel, normal, or statue)
// however none of the other special stuff.

// LL/MF: make special attacks correlated to appearance.
// eg scorpion-like creatures likely to have poison.

// features to add:

// magic instruments - extra magic items in general.

// if the creature does extra damage to unarmoured foes, or poison, and uses weapons, specify whether the power is in their weapons.

// if a creature is ghostly or demonic, their weapon (if they have one) may have effects in the same way as their armour.

// 'stuck in body' - reduce chance or eliminate if the creature
// wears armour and/or has tough skin (may require re-ordering).
//
// poison darts which generate damage total, but don't do damage.
// instead, if damage gets through armour and shields, delusion.
// (for example, forbidden to climb stairs).

// as per Trollbridge, 'first aid' rules - probably have a manual
// of first aid, which requires a week eg to study.

// book on herbs. once leave dungeon can take a week and
// make a save and if succeed pay half cost for poisons.
// book on first aid, as above.
// put these in same bit as phrasebook.

// poison: put who can recognise as poison / specific poison,
// and effect of drinking. Ditto holy water.

// mythic items.

// have an array which keeps track of 'when the delvers enter the
// monsters will be...', and choose ones which haven't been chosen
// as often rather than completely randomly.

if (!isset($system)) {
$system="tt";
}

$level=array();
$mr=array();
$pow=array();
$rn=array();
$rb=array();
$tr=array();
$eye=array();
$eyeval=500;
$eyedesc=array(
1=> array ("Stealing Fae Glamour","If the target of this Eye is an elf, leprechaun or fairy, he or she will lose 1 dice worth of CHR, and the Eye will <b>gain</b> a charge instead of losing it. Unlike most Eyes, being hit by this Eye <i>doesn't</i> make the target immune.<br>If the target is a statted creature who rolls their initial CHR with a multiplier of x 1 or less, the target will gain 1 dice worth of LK. Their LK will slowly fall to their normal level, at the rate of 1 point every 24 hours."),
2=> array ("Overwhelming Horror","Anyone hit by this beam must make a save on INT, at the level of the character holding it, or be overcome with fear and horror of that character. Anyone overcome by such fear will run from the character as fast as they can, at all costs, and will only fight if cornered. The effect will last 1-6 minutes of in-game time.<br>If a Monster-Rated monster is holding the Eye, divide its MR by 30, rounding up, and treat that as its level. If the victim is a Monster-Rated monster, the character holding it should make a save on CHR, at a level equal to the target's MR divided by 30 and rounded up. If both holder and victim are Monster Rated, the one with the higher MR will prevail."),
3=> array ("Arriving By the Nameless Path","Anyone hit by this beam will notice no change in themselves or their environment whatsoever. Yet they will find that when travelling, they reach their destination in half the time they would otherwise. Anyone travelling with them will likewise arrive in half the time. The effect will last 1-6 weeks, and won't 'stack' - two characters who've been hit by this Eye and travel together won't arrive in a quarter of the time for example."),
4=> array ("Overcoming All Physical Adversity","Anyone hit by this beam, if they're sick, will instantly be cured of their sickness. If they're not sick, they will heal any wounds at twice the normal rate for the next 1-6 days. If they're not sick or wounded, the beam will have no effect."),
5=> array ("the Ecstatic Madness of Love","Anyone hit by this beam, if they're statted, will treat their CHR and LK as if they were double their real value, but also treat their INT and DEX as if they were half their real value (rounded up), for 1-6 days of in-game time."),
6=> array ("Climbing the Wall of Tongues","Any statted creature hit by this beam will find, for 1-6 days of in-game time, that they can work out what any other creature who has also been hit by the beam is saying, and manage to communicate with them, even if the two characters have no language in common."),
7=> array ("Neither Rising Nor Falling","Anyone hit by this beam will be unable to move upwards or downwards for any significant distance, for a number of hours equal to the roll of 2 dice. They may, however, be carried. Otherwise they must stay on the same dungeon level."),
8=> array ("Striving With Chivalry","Any creature hit by this beam will be unable to use ranged weapons, magic items or spells in combat, for a number of minutes equal to the roll of a dice. If they fight anyone who breaks any of these 'rules', they will be freed from the Eye's effects at the end of the relevant Combat Round."),
);
$eyenum=8;
$mo=array();
$traps=array(
1=> "A hidden trapdoor in this room will open if @@FD steps on it.<br><br>The victim will fall down to room @@L, taking @@D damage. Armour will reduce this damage, shields won't.<br><br>If the room is searched, the trapdoor will be found on a successful level @@1 save on INT.<br><br>If the trapdoor isn't found, a successful level @@2 save on LK will avoid it. Characters must make this roll every time they walk across the room without having found the trap, or if they search and no one finds the trap. If more than one character fails their LK save, the victim will be the one who misses it by the most. If the group is walking across the room in single file, only the person in the lead need save.<br><br>If the trapdoor is sprung, a level @@3 save on @@DS will allow the victim to leap free.<br><br>Once the trapdoor is discovered, delvers may choose to leap down deliberately. If they do so, they should make a level @@4 save on DEX. If they succeed, they take no damage. If they fail, roll for damage as above but halve the result (round up).<br><br>Climbing up from the room below requires a level @@5 save on DEX. Failure doesn't result in any damage, but will make enough noise that the GM should roll twice for wandering monsters. If any result, they'll arrive in @@TT minutes. This roll is as well as, not instead of, the regular roll for wandering monsters.",
2=> "A hideous wailing starts up as soon as anyone enters the room. The GM should roll twice for wandering monsters immediately, then roll every five minutes of in-game time, as long as the delvers stay in the room. Any monsters that result will arrive in @@TT minutes. This roll is as well as, not instead of, the regular roll for wandering monsters.<br><br>Searching the room for the mechanism to turn the alarm off requires a successful level @@1 save on the lower of INT or LK.",
3=> "Invisible beams of light cross the centre of the room, at about knee height for a human. If anyone breaks the beams, a jet of liquid will spray at them from the walls. A successful level @@1 save on @@DS is required to dodge. If they fail, they won't suffer any damage, but their clothes, skin and/or armour will be soaked in the liquid. Its strong, meaty smell means that the GM should roll for wandering monsters twice as often as usual. The victim will also be unable to hide. This will last until the liquid has been washed off (which will take an hour), or three days have passed. Clothing or armour can of course be abandoned. 'Smoking' clothes over a fire will also get rid of the smell in an hour.",
4=> "A machine in the centre of the room will shoot laser beams at anyone who enters, which do @@D damage. It will shoot @@6 beams per Combat Round. If there's more than one target, choose randomly. Treat this as a missile attack, with the machine having a DEX of @@MD. Any object bigger than a human fist thrown into its gears will jam it up (throwing stars aren't big enough, a throwing knife is). Treat the machine as a 'gigantic' target. If the delvers haven't encountered one before, a level @@2 save on INT will reveal the machine's function as a guardian used by the Ancients. Once it has shot at least once, a level @@3 save on INT will reveal the effect of the beams.",
5=> "A machine in the centre of the room will shoot beams at anyone who enters. Anyone hit by a beam will fall unconscious. They'll wake up in 10 minutes. If the entire party is hit by the beams, they'll wake up in area @@L. It will shoot @@6 beams per Combat Round. It will ignore unconscious characters. If there's more than one target, choose randomly. Treat this as a missile attack, with the machine having a DEX of @@MD. Any object bigger than a human fist thrown into its gears will jam it up (throwing stars aren't big enough, a throwing knife is). Treat the machine as a 'gigantic' target. If the delvers haven't encountered one before, a level @@2 save on INT will reveal the machine's function as a guardian used by the Ancients. Once it has shot at least once, a level @@3 save on INT will reveal the effect of the beams.",
6=> "A machine in the centre of the room will shoot beams at anyone who enters. Anyone hit by a beam will fall unconscious, and take @@6 damage (armour or shields won't reduce the damage). They'll wake up in 10 minutes. If the entire party is hit by the beams, they'll wake up outside the dungeon. It will shoot @@6 beams per Combat Round. It will ignore unconscious characters. If there's more than one target, choose randomly. Treat this as a missile attack, with the machine having a DEX of @@MD. Any object bigger than a human fist thrown into its gears will jam it up (throwing stars aren't big enough, a throwing knife is). Treat the machine as a 'gigantic' target. If the delvers haven't encountered one before, a level @@2 save on INT will reveal the machine's function as a guardian used by the Ancients. Once it has shot at least once, a level @@3 save on INT will reveal the effect of the beams.",
7=> "A machine in the centre of the room will shoot rays of pure logic at anyone who enters. Anyone hit by a ray must make a level @@1 save on the lower of INT or CHA. If they fail, they'll be unable to cast spells, learn any spells, or use any magic items. Fairies will also be unable to fly. After 12 hours of in-game time they can make the save again, adding 2 to their roll. If they fail again, they can try again in 12 hours with a bonus of 4, and so on until they make the save. A delver who's hit by a ray but has already failed their save will instead take @@D damage, reduced as normal by shields and armour.<br><br>The machine will shoot @@6 beams per Combat Round. If there's more than one target, choose randomly. Treat this as a missile attack, with the machine having a DEX of @@MD. Any object bigger than a human fist thrown into its gears will jam it up (throwing stars aren't big enough, a throwing knife is). Treat the machine as a 'gigantic' target.<br><br>If the delvers haven't encountered one before, a level @@2 save on INT will reveal the machine's function as a guardian used by the Ancients. Once it has shot at least once, a level @@3 save on INT will reveal the effect of the beams.",
8=> "When the delvers first enter the room, unless the group is entirely Warriors bolts of lightning will shoot from the walls, aimed at all the Rogues and Wizards in the group. A successful level @@1 save on @@DS is required to dodge. If a delver fails they won't suffer any damage, but they'll be unable to use any magic (including using runestones, but not including learning spells from scrolls) for 6 hours of in-game time.",
9=> "A dart will fly out of the room at @@FD who steps on a particular part of the floor.<br><br>Anyone who crosses the room must make a level @@1 save on LK to avoid stepping on the relevant part of the floor (unless the delvers move in single file, in which case only the character in front needs to save, or they've already triggered the trap once and know where to avoid).<br><br>A level @@6 roll on @@DS is required to dodge the dart.<br><br>If the delvers search the room, roll for the delvers one at a time in a random order. Each delver should make a level @@2 roll on INT to find the mechanism which releases the darts. If they fail they should make the LK save to avoid stepping on the wrong part of the floor and setting it off.<br><br>Anyone who keeps an eye on the walls will notice where the dart comes from, meaning that they can find the mechanism easily. Disabling the mechanism once it's found doesn't require any roll. The dart does @@D dice worth of damage, reduced as normal by armour and shields. The trap can be triggered any number of times.",
10=> "As the delvers cross this room, it will suddenly be filled with magic light. Anyone who fails to make a level @@1 save on INT, and so avert their eyes in time, will be dazzled for 1-6 hours of in-game time. A dazzled character won't be blind, but will see spots in front of their eyes, find it difficult to focus etc. This means that, whenever they make a saving roll related to a physical action (including rolls to hit with a missile weapon), they add one level to the difficulty. They also take 5 from their Hit Point Total when fighting hand-to-hand.<br><br>Once the delvers have experienced this kind of trap once, they'll be prepared for it and don't need to save.",
11=> "As the delvers cross this room, it will suddenly be filled with magic light. Anyone who fails to make a level @@1 save on @@DS, and so avert their eyes in time, will be dazzled for 1-6 hours of in-game time. A dazzled character won't be blind, but will see spots in front of their eyes, find it difficult to focus etc. This means that, whenever they make a saving roll related to a physical action (including rolls to hit with a missile weapon), they add one level to the difficulty. They also take 5 from their Hit Point Total when fighting hand-to-hand.<br><br>Once the delvers have experienced this kind of trap once, they'll be prepared for it and don't need to save.",
);
$trapnum=11;
// @@L a room on the lower level, or choose another trap if this is rolled on the lowest level.
// @@1, @@2, @@3, @@4, @@5 random numbers, 0 to current level.
// @@6 as above, but a minimum result of two.
// @@D damage
// @@DS means SPD if using SPD, DEX if not.
// @@TT means 'travel time'
// @@FD means randomly "any delver", or "any delver bigger than a fairy".
// @@MD machine DEX: ($level*5)+(10-20)

$lltraps=array(
1=> "<b>Basic Arrow Trap</b> An arrow fires from a hidden location, attacking as a level 1 Fighter, for 1d6 damage.",
2=> "<b>Bricks From Ceiling</b> Every character in a 3 yard/metre radius must save vs petrify or suffer 2d6 damage.",
3=> "<b>Camouflaged Pit Trap</b> This pit is @XX feet deep.",
4=> "<b>Poison Dart Trap</b> A dart fires from a hidden location, dealing 1d4 damage, and the character must save vs poison or die.",
5=> "<b>Poison Needle Trap</b> The character must save vs poison or die.",
6=> "<b>Rolling Rock Trap</b> A rock rolls out from a hidden location, and the characters must save vs petrify or suffer 2d6 damage.",
7=> "<b>Spiked Pit Trap</b> This pit is @XX feet deep, and has @YY spikes (1d6 damage each in addition to the damage from falling).",
8=> "<b>Scything Blade Trap</b> Each character must save vs petrify or suffer 1d8 damage.",
);
$lltrapnum=8;

$mftraps=array(
1=> "<b>Anti-Gravity Trap</b> An automated motion sensor causes the gravity in this room to reverse. Characters 'fall' upwards, suffering 1d6 damage per yard/metre 'fallen'. The gravity will return to normal in 1-6 minutes, causing the same damage unless the characters can 'climb' out of the room.",
2=> "<b>Cryo-Freeze Trap</b> A covered pit causes a character to fall into a small chamber, which seals automatically. The character will be frozen automatically, and will stay that way until they can be thawed out.",
3=> "<b>Decompression Chamber</b> Hidden, sliding doors will seal this room off, and all air will leave the room. Characters will suffer 1d4 damage per round, as well as the possibility of suffocation. Characters suffocate in CON/2 rounds (rounded down), unless they can break down one of the doors.",
4=> "<b>Electrified Walls</b> The walls of this room are electrified, and if touched will do 4d6 damage. Anyone who searches the room. A successful save vs breath attacks halves the damage (rounded down). Assume that anyone who searches the room touches the walls, unless they say otherwise beforehand. Touching the walls is necessary to find secret doors.",
5=> "<b>Gas Trap</b> When the characters enter this room, a gas trap is triggered which mimics the effects of a blood agent grenade (see p118 of Mutant Future).",
6=> "<b>Gas Trap</b> When the characters enter this room, a gas trap is triggered which mimics the effects of a nerve gas grenade (see p118 and 119 of Mutant Future).",
7=> "<b>Gas Trap</b> When the characters enter this room, a gas trap is triggered which mimics the effects of a bio-toxin bomb (see p120 of Mutant Future).",
8=> "<b>Laser Gun Trap</b> A laser in the wall fires on characters who enter the room. It attacks as a monster with 4 Hit Dice, and does 5d6 damage. It has an AC of 5 and 12 Hit Points.",
9=> "<b>Motion-Sensing Rifles</b> An automatic rifle in the wall fires on characters who enter the room. It attacks as a monster with 4 Hit Dice, and does 1d12 damage. It has an AC of 5 and 15 Hit Points.",
10=> "<b>Radiation Trap</b> A radiation-emitting globe drops and suspends from the ceiling releasing a blast of class @UU radiation each round (see p51 of Mutant Future). It has an AC of 5 and 30 Hit Points.",
11=> "<b>Warp-Field Scything Blade</b> Each character must save vs petrify or suffer 30 damage.",
);
$mftrapnum=11;

// $traps is for Tunnels & Trolls.
// $lltraps and $mftraps are for LL/MF -
// $mftraps tend to appear on higher levels.
// @XX is a number close to the level number x 10.
// @YY is 2-5.
// @UU is 1-10.

$unguarded=array(
1=> array (2,4,100,1,4,10,50,1,4,7,1,4,5,3),
2=> array (2,6,100,1,6,100,50,1,6,13,1,6,8,5),
3=> array (2,8,100,2,4,100,50,1,6,15,1,6,10,7),
4=> array (1,8,1000,3,4,100,100,1,8,20,1,8,10,7),
5=> array (1,8,1000,3,4,100,100,1,8,20,1,8,10,7),
6=> array (1,8,2000,1,4,1000,100,1,8,30,1,8,15,15),
7=> array (1,8,2000,1,4,1000,100,1,8,30,1,8,15,15),
8=> array (1,8,4000,2,4,1000,100,2,6,40,2,6,20,20),
9=> array (1,8,4000,2,4,1000,100,2,6,40,2,6,20,20),
);
// $unguarded is an array representing LL/MF unprotected treasure
// (this includes treasure in the same room as a trap).
// slots 0-2 silver pieces: 2d4 x 100 would be 2,4,100 eg.
// 3-6 gold pieces, in the same format - slot 6 is % chance.
// 7-9 gems: 1d4 (30% chance) would be 1,4,30 eg.
// 10-12 jewelry: in the same format.
// 13: percentage chance of a magic item or artifact
// (always 1, always any).

$guarded=array(
1=> array (4,6,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
2=> array (0,0,0,2,8,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
3=> array (0,0,0,0,0,0,1,10,100,0,0,0,0,0,0,0,0,0,0,0,0),
4=> array (0,0,0,0,0,0,0,0,0,1,8,100,0,0,0,0,0,0,0,0,0),
5=> array (0,0,0,0,0,0,0,0,0,0,0,0,1,6,100,0,0,0,0,0,0),
6=> array (1,100,70,1,100,5,0,0,0,1,100,5,0,0,0,1,6,7,1,4,3),
7=> array (0,0,0,1,100,15,1,100,7,1,100,8,1,100,5,1,6,15,1,4,5),
// 1-7 are 'small hoards' - individuals.
// 8-22 are 'larger hoards' - lairs.
8=> array (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
9=> array (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
10=> array (0,0,0,0,0,0,0,0,0,1,8,50,3,12,40,2,8,60,1,12,40),
11=> array (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,40,0,0,0),
12=> array (0,0,0,1,8,25,1,4,20,0,0,0,0,0,0,0,0,0,0,0,0),
13=> array (1,6,25,1,4,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
14=> array (0,0,0,0,0,0,0,0,0,0,0,0,2,4,30,1,12,55,1,12,45),
15=> array (2,12,25,1,100,60,1,8,40,1,4,60,4,6,30,1,8,55,1,8,45),
16=> array (0,0,0,0,0,0,0,0,0,1,6,55,1,4,45,2,8,30,1,10,45),
17=> array (0,0,0,3,6,15,1,6,25,2,6,45,1,4,25,4,6,25,1,8,10),
18=> array (2,6,7,1,10,35,1,6,20,1,6,30,0,0,0,1,8,15,1,8,10),
19=> array (1,10,10,1,10,15,0,0,0,1,8,55,0,0,0,1,6,40,1,6,40),
20=> array (1,12,25,1,6,30,1,6,15,0,0,0,0,0,0,1,6,20,1,6,20),
21=> array (1,10,45,1,4,25,1,4,30,1,4,20,0,0,0,1,8,30,1,4,20),
22=> array (1,8,30,1,4,20,1,6,25,1,12,40,1,4,20,5,8,55,5,8,45),
);
// $guarded is an array representing guarded treasure,
// except for magic items (it has its own array because it's
// otherwise too much to fit on the one screen).

// 0-2 is copper pieces. 1d4 (30%) would be 1,4,30 eg.
// 3-5 is silver pieces, in the same format.
// 6-8 is electrum pieces.
// 9-11 gold pieces.
// 12-14 platinum pieces.
// 15-17 gems.
// 18-20 jewelry.

// NOTE 1: several things aren't noted in the array. Done 'by hand':
// Hoard Class 2 is 2d8+1 SP
// Hoard Class 3 is 1d10+1 EP.
// HC 15 : EP, GP, Gems and Jewelry all x 10.
// HC 16: GP x 10.
// HC 10: Gems 2d8 + 4.

// NOTE 2: For Hoard Classes over 7, multiply coins x 1000.
// except for Platinum Pieces, which should be x 100.

$mitem=array(
1 => array (0,0,0,0,0,0),
2 => array (0,0,0,0,0,0),
3 => array (0,0,0,0,0,0),
4 => array (0,0,0,0,0,0),
5 => array (0,0,0,0,0,0),
6 => array (3,1,0,0,0,0),
7 => array (7,1,0,0,0,0),
8 => array (45,0,0,0,-1,0),
9 => array (45,0,0,0,0,-2),
10 => array (0,0,0,0,0,0),
11 => array (0,0,0,0,0,0),
12 => array (0,0,0,0,0,0),
13 => array (0,0,0,0,0,0),
14 => array (20,1,0,0,0,0),
15 => array (18,4,0,0,1,1),
16 => array (30,5,0,0,1,0),
17 => array (30,0,3,0,1,1),
18 => array (30,3,0,0,1,0),
19 => array (15,2,0,0,0,2),
20 => array (12,2,0,0,0,0),
21 => array (12,0,0,1,0,0),
22 => array (25,3,0,0,0,0),
);
// this array (LL/MF only) is for magic items by Hoard Type.
// slot 0 = % chance of magic items being present.

// slots 1-5 are the number present of various types:
// 1 - any
// 2 - any except weapons
// 3 - armour, sword or weapon
// 4 - scroll for LL, gizmos for MF
// 5 - potion for LL, drugs & chemicals for MF
// a negative number = that many d4.


$llitems=array(
1=> array ("potion",21),
2=> array ("ring",26),
3=> array ("scroll",57),
4=> array ("rodstavewand",62),
5=> array ("misc magic",67),
6=> array ("sword",88),
7=> array ("misc weapon",93),
8=> array ("armour",101),
);
// 0=type (never printed - only used 'internally')
// 1=any magic items are this type of item
// if d100 is under this number, and not under the equivalent
// number for the previous entry.
// only used for LL/MF.

$mfitems=array(
1=> array ("firearm",6),
2=> array ("melee",18),
3=> array ("pistol",26),
4=> array ("rifle",34),
5=> array ("armour",42),
6=> array ("power",51),
7=> array ("grenade",60),
8=> array ("bomb",69),
9=> array ("gizmo",80),
10=> array ("chem",91),
11=> array ("foodjunk",101),
);
// means the same as for $llitems.

$bditems=array();
// this is number of items or artifacts.
// it's added to when doing treasure type,
// then broken down.
// 1 - any
// 2 - any except weapons
// 3 - armour, sword or weapon (for MF, not grenades or bombs)
// 4 - scroll for LL, gizmos for MF
// 5 - potion for LL, drugs & chemicals for MF


$magicitems=array();
$artifacts=array();
// both these arrays are numerical.
// they're the number of items of various
// kinds present in a horde of treasure.
// the numbers match up with $llitemsd and $mfitemsd respectively.

// the following has single elements where $llitemsd has arrays
// because it's 'meant' to have other details eg page number.
$mfitemsd=array(
1=> array(
1=> "ammunition",
2=> "ammunition",
3=> "ammunition",
4=> "ammunition",
5=> "ammunition",
6=> "ammunition",
7=> "ammunition",
8=> "automatic pistol",
9=> "automatic pistol",
10=> "automatic pistol",
11=> "automatic pistol",
12=> "automatic pistol",
13=> "automatic pistol",
14=> "automatic pistol",
15=> "automatic pistol",
16=> "automatic pistol",
17=> "automatic pistol",
18=> "black powder pistol",
19=> "black powder pistol",
20=> "black powder pistol",
21=> "revolver",
22=> "revolver",
23=> "revolver",
24=> "revolver",
25=> "revolver",
26=> "revolver",
27=> "revolver",
28=> "revolver",
29=> "revolver",
30=> "revolver",
31=> "submachinegun",
32=> "submachinegun",
33=> "submachinegun",
34=> "submachinegun",
35=> "submachinegun",
36=> "submachinegun",
37=> "carbine",
38=> "carbine",
39=> "carbine",
40=> "carbine",
41=> "carbine",
42=> "automatic rifle",
43=> "automatic rifle",
44=> "automatic rifle",
45=> "automatic rifle",
46=> "automatic rifle",
47=> "automatic rifle",
48=> "automatic rifle",
49=> "automatic rifle",
50=> "black powder rifle",
51=> "black powder rifle",
52=> "black powder rifle",
53=> "sport rifle",
54=> "sport rifle",
55=> "sport rifle",
56=> "sport rifle",
57=> "sport rifle",
58=> "sport rifle",
59=> "sport rifle",
60=> "shotgun",
61=> "shotgun",
62=> "shotgun",
63=> "shotgun",
64=> "shotgun",
65=> "shotgun",
66=> "shotgun",
67=> "shotgun",
68=> "shotgun",
69=> "shotgun",
70=> "automatic shotgun",
71=> "automatic shotgun",
72=> "automatic shotgun",
73=> "automatic shotgun",
74=> "automatic shotgun",
75=> "automatic shotgun",
76=> "automatic shotgun",
77=> "automatic shotgun",
78=> "automatic shotgun",
79=> "cannon",
80=> "cannon",
81=> "cannon",
82=> "grenade launcher",
83=> "grenade launcher",
84=> "grenade launcher",
85=> "grenade launcher",
86=> "grenade launcher",
87=> "grenade launcher",
88=> "grenade launcher",
89=> "grenade launcher",
90=> "grenade launcher",
91=> "machinegun",
92=> "machinegun",
93=> "machinegun",
94=> "machinegun",
95=> "machinegun",
96=> "machinegun",
97=> "machinegun",
98=> "machinegun",
99=> "machinegun",
100=> "machinegun",
),
2=> array(
1=> "energy baton",
2=> "energy baton",
3=> "energy baton",
4=> "energy baton",
5=> "energy baton",
6=> "energy baton",
7=> "energy baton",
8=> "energy baton",
9=> "energy baton",
10=> "energy baton",
11=> "energy baton",
12=> "shock gloves",
13=> "shock gloves",
14=> "shock gloves",
15=> "shock gloves",
16=> "shock gloves",
17=> "shock gloves",
18=> "shock gloves",
19=> "shock gloves",
20=> "shock gloves",
21=> "shock gloves",
22=> "shock gloves",
23=> "shock gloves",
24=> "shock-field glove",
25=> "shock-field glove",
26=> "shock-field glove",
27=> "shock-field glove",
28=> "shock-field glove",
29=> "shock-field glove",
30=> "shock-field glove",
31=> "shock-field glove",
32=> "shock-field glove",
33=> "shock-field glove",
34=> "shock-field glove",
35=> "shock-field glove",
36=> "stun baton",
37=> "stun baton",
38=> "stun baton",
39=> "stun baton",
40=> "stun baton",
41=> "stun baton",
42=> "stun baton",
43=> "stun baton",
44=> "stun baton",
45=> "stun baton",
46=> "stun baton",
47=> "stun baton",
48=> "vibro dagger",
49=> "vibro dagger",
50=> "vibro dagger",
51=> "vibro dagger",
52=> "vibro dagger",
53=> "vibro dagger",
54=> "vibro dagger",
55=> "vibro dagger",
56=> "vibro dagger",
57=> "vibro dagger",
58=> "vibro dagger",
59=> "vibro dagger",
60=> "vibro sword",
61=> "vibro sword",
62=> "vibro sword",
63=> "vibro sword",
64=> "vibro sword",
65=> "vibro sword",
66=> "vibro sword",
67=> "vibro sword",
68=> "vibro sword",
69=> "vibro sword",
70=> "vibro sword",
71=> "vibro sword",
72=> "warp-field dagger",
73=> "warp-field dagger",
74=> "warp-field dagger",
75=> "warp-field dagger",
76=> "warp-field dagger",
77=> "warp-field dagger",
78=> "warp-field dagger",
79=> "warp-field dagger",
80=> "warp-field dagger",
81=> "warp-field dagger",
82=> "warp-field mace",
83=> "warp-field mace",
84=> "warp-field mace",
85=> "warp-field mace",
86=> "warp-field mace",
87=> "warp-field mace",
88=> "warp-field mace",
89=> "warp-field mace",
90=> "warp-field mace",
91=> "warp-field mace",
92=> "warp-field sword",
93=> "warp-field sword",
94=> "warp-field sword",
95=> "warp-field sword",
96=> "warp-field sword",
97=> "warp-field sword",
98=> "warp-field sword",
99=> "warp-field sword",
100=> "warp-field sword",
),
3=> array(
1=> "Gauss Machine Pistol",
2=> "Gauss Machine Pistol",
3=> "Gauss Machine Pistol",
4=> "Gauss Machine Pistol",
5=> "Gauss Machine Pistol",
6=> "Gauss Machine Pistol",
7=> "Gauss Machine Pistol",
8=> "Gauss Machine Pistol",
9=> "Gauss Machine Pistol",
10=> "Gauss Machine Pistol",
11=> "Gauss Machine Pistol",
12=> "Gauss Machine Pistol",
13=> "Gauss Machine Pistol",
14=> "Gauss Machine Pistol",
15=> "Gauss Machine Pistol",
16=> "Gauss Pistol Mk 1",
17=> "Gauss Pistol Mk 1",
18=> "Gauss Pistol Mk 1",
19=> "Gauss Pistol Mk 1",
20=> "Gauss Pistol Mk 1",
21=> "Gauss Pistol Mk 1",
22=> "Gauss Pistol Mk 1",
23=> "Gauss Pistol Mk 1",
24=> "Gauss Pistol Mk 1",
25=> "Gauss Pistol Mk 1",
26=> "Gauss Pistol Mk 1",
27=> "Gauss Pistol Mk 1",
28=> "Gauss Pistol Mk 1",
29=> "Gauss Pistol Mk 1",
30=> "Gauss Pistol Mk 1",
31=> "Laser Pistol Mk 1",
32=> "Laser Pistol Mk 1",
33=> "Laser Pistol Mk 1",
34=> "Laser Pistol Mk 1",
35=> "Laser Pistol Mk 1",
36=> "Laser Pistol Mk 1",
37=> "Laser Pistol Mk 1",
38=> "Laser Pistol Mk 2",
39=> "Laser Pistol Mk 2",
40=> "Laser Pistol Mk 2",
41=> "Laser Pistol Mk 2",
42=> "Laser Pistol Mk 2",
43=> "Laser Pistol Mk 2",
44=> "Laser Pistol Mk 2",
45=> "Laser Pistol Mk 2",
46=> "Laser Pistol Mk 2",
47=> "Laser Pistol Mk 2",
48=> "Laser Pistol Mk 2",
49=> "Laser Pistol Mk 2",
50=> "Laser Pistol Mk 2",
51=> "Laser Pistol Mk 2",
52=> "Laser Pistol Mk 2",
53=> "Laser Pistol Mk 2",
54=> "Laser Pistol Mk 2",
55=> "Maser Pistol",
56=> "Maser Pistol",
57=> "Maser Pistol",
58=> "Maser Pistol",
59=> "Maser Pistol",
60=> "Maser Pistol",
61=> "Maser Pistol",
62=> "Maser Pistol",
63=> "Maser Pistol",
64=> "Maser Pistol",
65=> "Maser Pistol",
66=> "Maser Pistol",
67=> "Maser Pistol",
68=> "Maser Pistol",
69=> "Maser Pistol",
70=> "Plasma Pistol",
71=> "Plasma Pistol",
72=> "Plasma Pistol",
73=> "Plasma Pistol",
74=> "Plasma Pistol",
75=> "Plasma Pistol",
76=> "Plasma Pistol",
77=> "Plasma Pistol",
78=> "Plasma Pistol",
79=> "Plasma Pistol",
80=> "Plasma Pistol",
81=> "Plasma Pistol",
82=> "Plasma Pistol",
83=> "Plasma Pistol",
84=> "Plasma Pistol",
85=> "Stun Pistol",
86=> "Stun Pistol",
87=> "Stun Pistol",
88=> "Stun Pistol",
89=> "Stun Pistol",
90=> "Stun Pistol",
91=> "Stun Pistol",
92=> "Stun Pistol",
93=> "Stun Pistol",
94=> "Stun Pistol",
95=> "Stun Pistol",
96=> "Stun Pistol",
97=> "Stun Pistol",
98=> "Stun Pistol",
99=> "Stun Pistol",
100=> "Stun Pistol",
),
4=> array(
1=> "Blaster Rifle",
2=> "Blaster Rifle",
3=> "Blaster Rifle",
4=> "Blaster Rifle",
5=> "Blaster Rifle",
6=> "EMP Rifle",
7=> "EMP Rifle",
8=> "EMP Rifle",
9=> "EMP Rifle",
10=> "EMP Rifle",
11=> "EMP Rifle",
12=> "EMP Rifle",
13=> "EMP Rifle",
14=> "EMP Rifle",
15=> "EMP Rifle",
16=> "EMP Rifle",
17=> "Fusion Rifle",
18=> "Fusion Rifle",
19=> "Fusion Rifle",
20=> "Fusion Rifle",
21=> "Fusion Rifle",
22=> "Fusion Rifle",
23=> "Plasma Rifle",
24=> "Plasma Rifle",
25=> "Plasma Rifle",
26=> "Plasma Rifle",
27=> "Plasma Rifle",
28=> "Plasma Rifle",
29=> "Plasma Rifle",
30=> "Gauss Auto Rifle",
31=> "Gauss Auto Rifle",
32=> "Gauss Auto Rifle",
33=> "Gauss Auto Rifle",
34=> "Gauss Auto Rifle",
35=> "Gauss Auto Rifle",
36=> "Gauss Auto Rifle",
37=> "Gauss Auto Rifle",
38=> "Gauss Auto Rifle",
39=> "Gauss Auto Rifle",
40=> "Gauss Auto Rifle",
41=> "Gauss Auto Rifle",
42=> "Gauss Auto Rifle",
43=> "Gauss Rifle",
44=> "Gauss Rifle",
45=> "Gauss Rifle",
46=> "Gauss Rifle",
47=> "Gauss Rifle",
48=> "Gauss Rifle",
49=> "Gauss Rifle",
50=> "Gauss Rifle",
51=> "Gauss Rifle",
52=> "Gauss Rifle",
53=> "Gauss Rifle",
54=> "Gauss Rifle",
55=> "Gauss Rifle",
56=> "Gauss Rifle",
57=> "Gauss Rifle",
58=> "Laser Rifle",
59=> "Laser Rifle",
60=> "Laser Rifle",
61=> "Laser Rifle",
62=> "Laser Rifle",
63=> "Laser Rifle",
64=> "Laser Rifle",
65=> "Laser Rifle",
66=> "Laser Rifle",
67=> "Laser Rifle",
68=> "Laser Rifle",
69=> "Maser Rifle",
70=> "Maser Rifle",
71=> "Maser Rifle",
72=> "Maser Rifle",
73=> "Maser Rifle",
74=> "Maser Rifle",
75=> "Maser Rifle",
76=> "Maser Rifle",
77=> "Maser Rifle",
78=> "Maser Rifle",
79=> "Maser Rifle",
80=> "Radiation Rifle",
81=> "Radiation Rifle",
82=> "Radiation Rifle",
83=> "Radiation Rifle",
84=> "Radiation Rifle",
85=> "Stun Rifle",
86=> "Stun Rifle",
87=> "Stun Rifle",
88=> "Stun Rifle",
89=> "Stun Rifle",
90=> "Stun Rifle",
91=> "Stun Rifle",
92=> "Stun Rifle",
93=> "X-Laser Rifle",
94=> "X-Laser Rifle",
95=> "X-Laser Rifle",
96=> "X-Laser Rifle",
97=> "X-Laser Rifle",
98=> "X-Laser Rifle",
99=> "X-Laser Rifle",
100=> "X-Laser Rifle",
),
5=> array(
1=> "Ballistic Nylon Armour",
2=> "Ballistic Nylon Armour",
3=> "Ballistic Nylon Armour",
4=> "Ballistic Nylon Armour",
5=> "Ballistic Nylon Armour",
6=> "Ballistic Nylon Armour",
7=> "Ballistic Nylon Armour",
8=> "Ballistic Nylon Armour",
9=> "Ballistic Nylon Armour",
10=> "Ballistic Nylon Armour",
11=> "Ballistic Nylon Armour",
12=> "Metal Insert Armour",
13=> "Metal Insert Armour",
14=> "Metal Insert Armour",
15=> "Metal Insert Armour",
16=> "Metal Insert Armour",
17=> "Metal Insert Armour",
18=> "Metal Insert Armour",
19=> "Metal Insert Armour",
20=> "Metal Insert Armour",
21=> "Metal Insert Armour",
22=> "Metal Insert Armour",
23=> "Metal Insert Armour",
24=> "Plastic Plate Armour",
25=> "Plastic Plate Armour",
26=> "Plastic Plate Armour",
27=> "Plastic Plate Armour",
28=> "Plastic Plate Armour",
29=> "Plastic Plate Armour",
30=> "Plastic Plate Armour",
31=> "Plastic Plate Armour",
32=> "Plastic Plate Armour",
33=> "Plastic Plate Armour",
34=> "Plastic Plate Armour",
35=> "Plastic Plate Armour",
36=> "Plastex Armour",
37=> "Plastex Armour",
38=> "Plastex Armour",
39=> "Plastex Armour",
40=> "Plastex Armour",
41=> "Plastex Armour",
42=> "Plastex Armour",
43=> "Plastex Armour",
44=> "Plastex Armour",
45=> "Plastex Armour",
46=> "Plastex Armour",
47=> "Plastex Armour",
48=> "Advanced Metal Armour",
49=> "Advanced Metal Armour",
50=> "Advanced Metal Armour",
51=> "Advanced Metal Armour",
52=> "Advanced Metal Armour",
53=> "Advanced Metal Armour",
54=> "Advanced Metal Armour",
55=> "Advanced Metal Armour",
56=> "Advanced Metal Armour",
57=> "Advanced Metal Armour",
58=> "Advanced Metal Armour",
59=> "Advanced Metal Armour",
60=> "LazAb Armour",
61=> "LazAb Armour",
62=> "LazAb Armour",
63=> "LazAb Armour",
64=> "LazAb Armour",
65=> "LazAb Armour",
66=> "LazAb Armour",
67=> "LazAb Armour",
68=> "LazAb Armour",
69=> "LazAb Armour",
70=> "LazAb Armour",
71=> "Environmental Armour",
72=> "Environmental Armour",
73=> "Environmental Armour",
74=> "Environmental Armour",
75=> "Environmental Armour",
76=> "Environmental Armour",
77=> "Environmental Armour",
78=> "Environmental Armour",
79=> "Environmental Armour",
80=> "Environmental Armour",
81=> "Scout EMA",
82=> "Scout EMA",
83=> "Scout EMA",
84=> "Scout EMA",
85=> "Scout EMA",
86=> "Light EMA",
87=> "Light EMA",
88=> "Light EMA",
89=> "Light EMA",
90=> "Light EMA",
91=> "Medium EMA",
92=> "Medium EMA",
93=> "Medium EMA",
94=> "Medium EMA",
95=> "Medium EMA",
96=> "Heavy EMA",
97=> "Heavy EMA",
98=> "Heavy EMA",
99=> "Heavy EMA",
100=> "Heavy EMA",
),
6=> array(
1=> "Power Cell",
2=> "Power Cell",
3=> "Power Cell",
4=> "Power Cell",
5=> "Power Cell",
6=> "Power Cell",
7=> "Power Cell",
8=> "Power Cell",
9=> "Power Cell",
10=> "Power Cell",
11=> "Power Cell",
12=> "Power Cell",
13=> "Power Cell",
14=> "Power Cell",
15=> "Power Cell",
16=> "Power Pack",
17=> "Power Pack",
18=> "Power Pack",
19=> "Power Pack",
20=> "Power Pack",
21=> "Power Pack",
22=> "Power Pack",
23=> "Power Pack",
24=> "Power Pack",
25=> "Power Pack",
26=> "Power Pack",
27=> "Power Pack",
28=> "Power Pack",
29=> "Power Pack",
30=> "Power Pack",
31=> "Power Clip",
32=> "Power Clip",
33=> "Power Clip",
34=> "Power Clip",
35=> "Power Clip",
36=> "Power Clip",
37=> "Power Clip",
38=> "Power Clip",
39=> "Power Clip",
40=> "Power Clip",
41=> "Power Clip",
42=> "Power Clip",
43=> "Power Clip",
44=> "Power Clip",
45=> "Power Clip",
46=> "Power Beltpack",
47=> "Power Beltpack",
48=> "Power Beltpack",
49=> "Power Beltpack",
50=> "Power Beltpack",
51=> "Power Beltpack",
52=> "Power Beltpack",
53=> "Power Beltpack",
54=> "Power Beltpack",
55=> "Power Beltpack",
56=> "Power Beltpack",
57=> "Power Beltpack",
58=> "Power Beltpack",
59=> "Power Beltpack",
60=> "Power Beltpack",
61=> "Power Backpack",
62=> "Power Backpack",
63=> "Power Backpack",
64=> "Power Backpack",
65=> "Power Backpack",
66=> "Power Backpack",
67=> "Power Backpack",
68=> "Power Backpack",
69=> "Power Backpack",
70=> "Power Backpack",
71=> "Power Backpack",
72=> "Power Backpack",
73=> "Power Backpack",
74=> "Power Backpack",
75=> "Power Backpack",
76=> "Minifusion Cell",
77=> "Minifusion Cell",
78=> "Minifusion Cell",
79=> "Minifusion Cell",
80=> "Minifusion Cell",
81=> "Minifusion Cell",
82=> "Minifusion Cell",
83=> "Minifusion Cell",
84=> "Minifusion Cell",
85=> "Minifusion Cell",
86=> "Minifusion Cell",
87=> "Minifusion Cell",
88=> "Minifusion Cell",
89=> "Minifusion Cell",
90=> "Minifusion Cell",
91=> "Plutonium Clip",
92=> "Plutonium Clip",
93=> "Plutonium Clip",
94=> "Plutonium Clip",
95=> "Plutonium Clip",
96=> "Plutonium Clip",
97=> "Plutonium Clip",
98=> "Plutonium Clip",
99=> "Radioactive Battery",
100=> "Radioactive Battery",
),
7=> array(
1=> "Blood Agent Grenade",
2=> "Blood Agent Grenade",
3=> "Blood Agent Grenade",
4=> "Blood Agent Grenade",
5=> "Blood Agent Grenade",
6=> "Blood Agent Grenade",
7=> "Concussion Grenade",
8=> "Concussion Grenade",
9=> "Concussion Grenade",
10=> "Concussion Grenade",
11=> "Concussion Grenade",
12=> "Concussion Grenade",
13=> "Concussion Grenade",
14=> "Dynamite",
15=> "Dynamite",
16=> "Dynamite",
17=> "Dynamite",
18=> "Dynamite",
19=> "Dynamite",
20=> "Energy Grenade",
21=> "Energy Grenade",
22=> "Energy Grenade",
23=> "Energy Grenade",
24=> "Energy Grenade",
25=> "Energy Grenade",
26=> "Frag Grenade",
27=> "Frag Grenade",
28=> "Frag Grenade",
29=> "Frag Grenade",
30=> "Frag Grenade",
31=> "Frag Grenade",
32=> "Inferno Grenade",
33=> "Inferno Grenade",
34=> "Inferno Grenade",
35=> "Inferno Grenade",
36=> "Inferno Grenade",
37=> "Inferno Grenade",
38=> "Irritant Gas Grenade",
39=> "Irritant Gas Grenade",
40=> "Irritant Gas Grenade",
41=> "Irritant Gas Grenade",
42=> "Irritant Gas Grenade",
43=> "Irritant Gas Grenade",
44=> "Molotov Cocktail",
45=> "Molotov Cocktail",
46=> "Molotov Cocktail",
47=> "Molotov Cocktail",
48=> "Molotov Cocktail",
49=> "Molotov Cocktail",
50=> "Mutation Grenade",
51=> "Mutation Grenade",
52=> "Mutation Grenade",
53=> "Mutation Grenade",
54=> "Mutation Grenade",
55=> "Mutation Grenade",
56=> "Nerve Gas Grenade",
57=> "Nerve Gas Grenade",
58=> "Nerve Gas Grenade",
59=> "Nerve Gas Grenade",
60=> "Nerve Gas Grenade",
61=> "Nerve Gas Grenade",
62=> "Photon Grenade (Lethal)",
63=> "Photon Grenade (Lethal)",
64=> "Photon Grenade (Lethal)",
65=> "Photon Grenade (Lethal)",
66=> "Photon Grenade (Lethal)",
67=> "Photon Grenade (Lethal)",
68=> "Photon Grenade (Non-Lethal)",
69=> "Photon Grenade (Non-Lethal)",
70=> "Photon Grenade (Non-Lethal)",
71=> "Photon Grenade (Non-Lethal)",
72=> "Photon Grenade (Non-Lethal)",
73=> "Photon Grenade (Non-Lethal)",
74=> "Photon Grenade (Non-Lethal)",
75=> "Photon Grenade (Non-Lethal)",
76=> "Plasma Grenade",
77=> "Plasma Grenade",
78=> "Plasma Grenade",
79=> "Plasma Grenade",
80=> "Plasma Grenade",
81=> "Plasma Grenade",
82=> "Plasma Grenade",
83=> "Shock Grenade",
84=> "Shock Grenade",
85=> "Shock Grenade",
86=> "Shock Grenade",
87=> "Shock Grenade",
88=> "Shock Grenade",
89=> "Smoke Grenade",
90=> "Smoke Grenade",
91=> "Smoke Grenade",
92=> "Smoke Grenade",
93=> "Smoke Grenade",
94=> "Smoke Grenade",
95=> "Smoke Grenade",
96=> "Smoke Grenade",
97=> "Smoke Grenade",
98=> "Smoke Grenade",
99=> "Smoke Grenade",
100=> "Smoke Grenade",
),
8=> array(
1=> "Bio Toxin Bomb",
2=> "Bio Toxin Bomb",
3=> "Bio Toxin Bomb",
4=> "Bio Toxin Bomb",
5=> "Bio Toxin Bomb",
6=> "Bio Toxin Bomb",
7=> "Bio Toxin Bomb",
8=> "Bio Toxin Bomb",
9=> "Concussion Bomb",
10=> "Concussion Bomb",
11=> "Concussion Bomb",
12=> "Concussion Bomb",
13=> "Concussion Bomb",
14=> "Concussion Bomb",
15=> "Concussion Bomb",
16=> "Concussion Bomb",
17=> "Concussion Bomb",
18=> "Light Anti-Tank Weapon",
19=> "Light Anti-Tank Weapon",
20=> "Light Anti-Tank Weapon",
21=> "Light Anti-Tank Weapon",
22=> "Mutation Bomb",
23=> "Mutation Bomb",
24=> "Mutation Bomb",
25=> "Mutation Bomb",
26=> "Mutation Bomb",
27=> "Mutation Bomb",
28=> "Mutation Bomb",
29=> "Mutation Bomb",
30=> "Mutation Bomb",
31=> "Mutation Bomb",
32=> "Negation Bomb",
33=> "Negation Bomb",
34=> "Negation Bomb",
35=> "Negation Bomb",
36=> "Negation Bomb",
37=> "Negation Bomb",
38=> "Negation Bomb",
39=> "Negation Bomb",
40=> "Negation Bomb",
41=> "Negation Bomb",
42=> "Plasma Bomb",
43=> "Plasma Bomb",
44=> "Plasma Bomb",
45=> "Plasma Bomb",
46=> "Plasma Bomb",
47=> "Plasma Bomb",
48=> "Plasma Bomb",
49=> "Radiation Bomb (Dirty)",
50=> "Radiation Bomb (Dirty)",
51=> "Radiation Bomb",
52=> "Radiation Bomb",
53=> "Radiation Bomb",
54=> "Radiation Bomb",
55=> "Radiation Bomb",
56=> "Radiation Bomb",
57=> "Radiation Bomb",
58=> "Radiation Bomb",
59=> "Radiation Bomb",
60=> "Rocket-Propelled Grenade Launcher",
61=> "Rocket-Propelled Grenade Launcher",
62=> "Rocket-Propelled Grenade Launcher",
63=> "Rocket-Propelled Grenade Launcher",
64=> "Rocket-Propelled Grenade Launcher",
65=> "Rocket-Propelled Grenade Launcher",
66=> "Rocket-Propelled Grenade Launcher",
67=> "Rocket-Propelled Grenade Launcher",
68=> "Rocket-Propelled Grenade Launcher",
69=> "Rocket-Propelled Grenade Launcher",
70=> "Satchel A",
71=> "Satchel A",
72=> "Satchel A",
73=> "Satchel A",
74=> "Satchel A",
75=> "Satchel A",
76=> "Satchel A",
77=> "Satchel A",
78=> "Satchel A",
79=> "Satchel A",
80=> "Satchel A",
81=> "Satchel A",
82=> "Satchel A",
83=> "Satchel A",
84=> "Satchels B,C,D",
85=> "Satchels B,C,D",
86=> "Satchels B,C,D",
87=> "Satchels B,C,D",
88=> "Satchels B,C,D",
89=> "Satchels B,C,D",
90=> "Satchels B,C,D",
91=> "Satchels B,C,D",
92=> "Satchels B,C,D",
93=> "Satchels B,C,D",
94=> "Micro-Missile Launcher",
95=> "Micro-Missile Launcher",
96=> "Mini-Missile Launcher",
97=> "Mini-Missile Launcher",
98=> "Missile Launcher",
99=> "Missile Launcher",
100=> "Missile Launcher",
),
9=> array(
1=> "Advanced Breathing Apparatus",
2=> "Advanced Breathing Apparatus",
3=> "Advanced Breathing Apparatus",
4=> "Advanced Breathing Apparatus",
5=> "Advanced Breathing Apparatus",
6=> "Autograpnel",
7=> "Autograpnel",
8=> "Autograpnel",
9=> "Autograpnel",
10=> "Boron Solution Spray",
11=> "Boron Solution Spray",
12=> "Boron Solution Spray",
13=> "Boron Solution Spray",
14=> "Cigarette Lighter",
15=> "Cigarette Lighter",
16=> "Cigarette Lighter",
17=> "Cigarette Lighter",
18=> "Cigarette Lighter",
19=> "Clones",
20=> "Clones",
21=> "Clones",
22=> "Clones",
23=> "Clones",
24=> "Communicator",
25=> "Communicator",
26=> "Communicator",
27=> "Communicator",
28=> "Electronically Responsive Notation Instrument",
29=> "Electronically Responsive Notation Instrument",
30=> "Electronically Responsive Notation Instrument",
31=> "Electronically Responsive Notation Instrument",
32=> "Firestarter Cube",
33=> "Firestarter Cube",
34=> "Firestarter Cube",
35=> "Firestarter Cube",
36=> "Flashlight",
37=> "Flashlight",
38=> "Flashlight",
39=> "Force Screen Belt",
40=> "Force Screen Belt",
41=> "Force Screen Belt",
42=> "Force Screen Belt",
43=> "Gas Mask",
44=> "Gas Mask",
45=> "Gas Mask",
46=> "Gas Mask",
47=> "Gas Mask",
48=> "Gas Mask",
49=> "Gas Mask Filter",
50=> "Gas Mask Filter",
51=> "Gas Mask Filter",
52=> "Gas Mask Filter",
53=> "Gas Mask Filter",
54=> "Chemical Sensor",
55=> "Chemical Sensor",
56=> "Chemical Sensor",
57=> "Chemical Sensor",
58=> "Geiger Counter",
59=> "Geiger Counter",
60=> "Geiger Counter",
61=> "Geiger Counter",
62=> "Rad Tab",
63=> "Rad Tab",
64=> "Rad Tab",
65=> "Rad Tab",
66=> "Rad Tab",
67=> "Infra-Red Goggles",
68=> "Infra-Red Goggles",
69=> "Infra-Red Goggles",
70=> "Infra-Red Goggles",
71=> "Infra-Red Goggles",
72=> "Motion Detector",
73=> "Motion Detector",
74=> "Motion Detector",
75=> "Motion Detector",
76=> "Motion Detector",
77=> "Optic Scanner",
78=> "Optic Scanner",
79=> "Optic Scanner",
80=> "Optic Scanner",
81=> "Optic Scanner",
82=> "Portable Detection Radar",
83=> "Portable Detection Radar",
84=> "Portable Detection Radar",
85=> "Portable Detection Radar",
86=> "Portable Detection Radar",
87=> "Power Fist",
88=> "Power Fist",
89=> "Power Fist",
90=> "Power Fist",
91=> "Power Fist",
92=> "UV Sterilizer",
93=> "UV Sterilizer",
94=> "UV Sterilizer",
95=> "UV Sterilizer",
96=> "Water Purifier",
97=> "Water Purifier",
98=> "Water Purifier",
99=> "X-Ray Goggles",
100=> "X-Ray Goggles",
),
10=> array(
1=> "Antitox",
2=> "Antitox",
3=> "Antitox",
4=> "Antitox",
5=> "Antitox",
6=> "Antitox",
7=> "Filter-Dose",
8=> "Filter-Dose",
9=> "Filter-Dose",
10=> "Filter-Dose",
11=> "Filter-Dose",
12=> "Filter-Dose",
13=> "Hercurin",
14=> "Hercurin",
15=> "Hercurin",
16=> "Hercurin",
17=> "Hercurin",
18=> "Hercurin",
19=> "K-O shot",
20=> "K-O shot",
21=> "K-O shot",
22=> "K-O shot",
23=> "K-O shot",
24=> "K-O shot",
25=> "K-O shot",
26=> "Medi-Spray I",
27=> "Medi-Spray I",
28=> "Medi-Spray I",
29=> "Medi-Spray I",
30=> "Medi-Spray I",
31=> "Medi-Spray I",
32=> "Medi-Spray I",
33=> "Medi-Spray II",
34=> "Medi-Spray II",
35=> "Medi-Spray II",
36=> "Medi-Spray II",
37=> "Medi-Spray II",
38=> "Medi-Spray II",
39=> "Medi-Spray II",
40=> "Medi-Spray II",
41=> "Proton Energy Pill",
42=> "Proton Energy Pill",
43=> "Proton Energy Pill",
44=> "Proton Energy Pill",
45=> "Proton Energy Pill",
46=> "Proton Energy Pill",
47=> "Rad-Purge Shot",
48=> "Rad-Purge Shot",
49=> "Rad-Purge Shot",
50=> "Rad-Purge Shot",
51=> "Rad-Purge Shot",
52=> "Rad-Purge Shot",
53=> "Stimshot A",
54=> "Stimshot A",
55=> "Stimshot A",
56=> "Stimshot A",
57=> "Stimshot A",
58=> "Stimshot A",
59=> "Stimshot B",
60=> "Stimshot B",
61=> "Stimshot B",
62=> "Stimshot B",
63=> "Stimshot B",
64=> "Superegen",
65=> "Superegen",
66=> "Superegen",
67=> "Superegen",
68=> "Superegen",
69=> "Superegen",
70=> "Truth Serum",
71=> "Truth Serum",
72=> "Truth Serum",
73=> "Truth Serum",
74=> "Truth Serum",
75=> "Truth Serum",
76=> "Diagnostic Scanner",
77=> "Diagnostic Scanner",
78=> "Diagnostic Scanner",
79=> "Diagnostic Scanner",
80=> "Diagnostic Scanner",
81=> "Diagnostic Scanner",
82=> "Diagnostic Scanner",
83=> "Diagnostic Scanner",
84=> "Healing Pack",
85=> "Healing Pack",
86=> "Healing Pack",
87=> "Healing Pack",
88=> "Healing Pack",
89=> "Healing Pack",
90=> "Healing Pack",
91=> "Healing Pack",
92=> "Ready Syringe",
93=> "Ready Syringe",
94=> "Ready Syringe",
95=> "Ready Syringe",
96=> "Ready Syringe",
97=> "Ready Syringe",
98=> "Ready Syringe",
99=> "Regeneration Tank",
100=> "Regeneration Tank",
),
11=> array(
1=> "canned foods",
2=> "canned foods",
3=> "canned foods",
4=> "canned foods",
5=> "canned foods",
6=> "canned foods",
7=> "canned foods",
8=> "canned foods",
9=> "canned foods",
10=> "canned foods",
11=> "dehydrated pills",
12=> "dehydrated pills",
13=> "dehydrated pills",
14=> "dehydrated pills",
15=> "dehydrated pills",
16=> "dehydrated pills",
17=> "dehydrated pills",
18=> "goo tube",
19=> "goo tube",
20=> "goo tube",
21=> "goo tube",
22=> "goo tube",
23=> "goo tube",
24=> "goo tube",
25=> "salt pills",
26=> "salt pills",
27=> "salt pills",
28=> "salt pills",
29=> "salt pills",
30=> "salt pills",
31=> "soup mixes",
32=> "soup mixes",
33=> "soup mixes",
34=> "soup mixes",
35=> "soup mixes",
36=> "soup mixes",
37=> "soup mixes",
38=> "soup mixes",
39=> "synthihol",
40=> "synthihol",
41=> "synthihol",
42=> "synthihol",
43=> "synthihol",
44=> "synthihol",
45=> "synthihol",
46=> "hologram projector",
47=> "hologram projector",
48=> "hologram projector",
49=> "hologram projector",
50=> "hologram projector",
51=> "hologram projector",
52=> "identity card",
53=> "identity card",
54=> "identity card",
55=> "identity card",
56=> "identity card",
57=> "ion bonding tape",
58=> "ion bonding tape",
59=> "ion bonding tape",
60=> "ion bonding tape",
61=> "ion bonding tape",
62=> "ion bonding tape",
63=> "ion bonding tape",
64=> "ion bonding tape",
65=> "ion bonding tape",
66=> "ion bonding tape",
67=> "ion bonding tape",
68=> "light rod",
69=> "light rod",
70=> "light rod",
71=> "light rod",
72=> "light rod",
73=> "light rod",
74=> "light rod",
75=> "light rod",
76=> "light rod",
77=> "light stick",
78=> "light stick",
79=> "light stick",
80=> "light stick",
81=> "light stick",
82=> "light stick",
83=> "magnesium firestarter",
84=> "magnesium firestarter",
85=> "magnesium firestarter",
86=> "magnesium firestarter",
87=> "magnesium firestarter",
88=> "portable stove",
89=> "portable stove",
90=> "portable stove",
91=> "portable stove",
92=> "portable stove",
93=> "portable stove",
94=> "portable stove",
95=> "survival kit",
96=> "survival kit",
97=> "survival kit",
98=> "survival kit",
99=> "survival kit",
100=> "survival kit",
),
);

$llitemsd=array(
1=> array (
1=> array ("Potion of Animal Control",109),
2=> array ("Potion of Animal Control",109),
3=> array ("Potion of Animal Control",109),
4=> array ("Potion of Clairaudience",109),
5=> array ("Potion of Clairaudience",109),
6=> array ("Potion of Clairaudience",109),
7=> array ("Potion of Clairvoyance",109),
8=> array ("Potion of Clairvoyance",109),
9=> array ("Potion of Clairvoyance",109),
10=> array ("Potion of Climbing",109),
11=> array ("Potion of Climbing",109),
12=> array ("Potion of Climbing",109),
13=> array ("Potion of Delusion",109),
14=> array ("Potion of Delusion",109),
15=> array ("Potion of Delusion",109),
16=> array ("Potion of Delusion",109),
17=> array ("Potion of Delusion",109),
18=> array ("Potion of Diminution",109),
19=> array ("Potion of Diminution",109),
20=> array ("Potion of Diminution",109),
21=> array ("Potion of Dragon Control",110),
22=> array ("Potion of Dragon Control",110),
23=> array ("Potion of Dragon Control",110),
24=> array ("Potion of ESP",110),
25=> array ("Potion of ESP",110),
26=> array ("Potion of ESP",110),
27=> array ("Potion of Extra-healing",110),
28=> array ("Potion of Extra-healing",110),
29=> array ("Potion of Fire Resistance",110),
30=> array ("Potion of Fire Resistance",110),
31=> array ("Potion of Fire Resistance",110),
32=> array ("Potion of Flying",110),
33=> array ("Potion of Flying",110),
34=> array ("Potion of Flying",110),
35=> array ("Potion of Flying",110),
36=> array ("Potion of Flying",110),
37=> array ("Potion of Gaseous Form",110),
38=> array ("Potion of Gaseous Form",110),
39=> array ("Potion of Gaseous Form",110),
40=> array ("Potion of Gaseous Form",110),
41=> array ("Potion of Giant Control",110),
42=> array ("Potion of Giant Control",110),
43=> array ("Potion of Giant Control",110),
44=> array ("Potion of Giant Strength",110),
45=> array ("Potion of Giant Strength",110),
46=> array ("Potion of Giant Strength",110),
47=> array ("Potion of Giant Strength",110),
48=> array ("Potion of Growth",110),
49=> array ("Potion of Growth",110),
50=> array ("Potion of Growth",110),
51=> array ("Potion of Healing",110),
52=> array ("Potion of Healing",110),
53=> array ("Potion of Healing",110),
54=> array ("Potion of Healing",110),
55=> array ("Potion of Heroism",110),
56=> array ("Potion of Heroism",110),
57=> array ("Potion of Heroism",110),
58=> array ("Potion of Heroism",110),
59=> array ("Potion of Human Control",110),
60=> array ("Potion of Human Control",110),
61=> array ("Potion of Human Control",110),
62=> array ("Potion of Invisibility",110),
63=> array ("Potion of Invisibility",110),
64=> array ("Potion of Invisibility",110),
65=> array ("Potion of Invulnerability",110),
66=> array ("Potion of Invulnerability",110),
67=> array ("Potion of Levitation",111),
68=> array ("Potion of Levitation",111),
69=> array ("Potion of Levitation",111),
70=> array ("Potion of Longevity",111),
71=> array ("Potion of Longevity",111),
72=> array ("Oil of Etherealness",111),
73=> array ("Oil of Etherealness",111),
74=> array ("Oil of Slipperiness",111),
75=> array ("Oil of Slipperiness",111),
76=> array ("Philter of Love",111),
77=> array ("Philter of Love",111),
78=> array ("Philter of Love",111),
79=> array ("Potion of Plant Control",111),
80=> array ("Potion of Plant Control",111),
81=> array ("Potion of Plant Control",111),
82=> array ("Poison",111),
83=> array ("Poison",111),
84=> array ("Potion of Polymorph",111),
85=> array ("Potion of Polymorph",111),
86=> array ("Potion of Speed",111),
87=> array ("Potion of Speed",111),
88=> array ("Potion of Speed",111),
89=> array ("Potion of Super-heroism",111),
90=> array ("Potion of Super-heroism",111),
91=> array ("Sweet Water",111),
92=> array ("Sweet Water",111),
93=> array ("Sweet Water",111),
94=> array ("Potion of Treasure Finding",111),
95=> array ("Potion of Treasure Finding",111),
96=> array ("Potion of Undead Control",111),
97=> array ("Potion of Undead Control",111),
98=> array ("Potion of Water Breathing",111),
99=> array ("Potion of Water Breathing",111),
100=> array ("Potion of Water Breathing",111),
),
2=> array (
1=> array ("Ring of Animal Command",112),
2=> array ("Ring of Animal Command",112),
3=> array ("Ring of Animal Command",112),
4=> array ("Ring of Animal Command",112),
5=> array ("Ring of Command Human",112),
6=> array ("Ring of Command Human",112),
7=> array ("Ring of Command Human",112),
8=> array ("Ring of Command Human",112),
9=> array ("Ring of Command Human",112),
10=> array ("Ring of Command Plant",112),
11=> array ("Ring of Command Plant",112),
12=> array ("Ring of Command Plant",112),
13=> array ("Ring of Command Plant",112),
14=> array ("Ring of Command Plant",112),
15=> array ("Ring of Command Plant",112),
16=> array ("Ring of Delusion",112),
17=> array ("Ring of Delusion",112),
18=> array ("Ring of Delusion",112),
19=> array ("Ring of Delusion",112),
20=> array ("Ring of Delusion",112),
21=> array ("Ring of Delusion",112),
22=> array ("Ring of Delusion",112),
23=> array ("Ring of Delusion",112),
24=> array ("Ring of Delusion",112),
25=> array ("Ring of Delusion",112),
26=> array ("Ring of Djinni Calling",112),
27=> array ("Ring of Djinni Calling",112),
28=> array ("Ring of Fire Resistance",112),
29=> array ("Ring of Fire Resistance",112),
30=> array ("Ring of Fire Resistance",112),
31=> array ("Ring of Fire Resistance",112),
32=> array ("Ring of Fire Resistance",112),
33=> array ("Ring of Fire Resistance",112),
34=> array ("Ring of Fire Resistance",112),
35=> array ("Ring of Fire Resistance",112),
36=> array ("Ring of Fire Resistance",112),
37=> array ("Ring of Fire Resistance",112),
38=> array ("Ring of Fire Resistance",112),
39=> array ("Ring of Invisibility",112),
40=> array ("Ring of Invisibility",112),
41=> array ("Ring of Invisibility",112),
42=> array ("Ring of Invisibility",112),
43=> array ("Ring of Invisibility",112),
44=> array ("Ring of Invisibility",112),
45=> array ("Ring of Invisibility",112),
46=> array ("Ring of Invisibility",112),
47=> array ("Ring of Invisibility",112),
48=> array ("Ring of Invisibility",112),
49=> array ("Ring of Invisibility",112),
50=> array ("Ring of Protection",112),
51=> array ("Ring of Protection",112),
52=> array ("Ring of Protection",112),
53=> array ("Ring of Protection",112),
54=> array ("Ring of Protection",112),
55=> array ("Ring of Protection",112),
56=> array ("Ring of Protection",112),
57=> array ("Ring of Protection",112),
58=> array ("Ring of Protection",112),
59=> array ("Ring of Protection",112),
60=> array ("Ring of Protection",112),
61=> array ("Ring of Protection",112),
62=> array ("Ring of Protection",112),
63=> array ("Ring of Protection",112),
64=> array ("Ring of Protection",112),
65=> array ("Ring of Protection",112),
66=> array ("Ring of Protection",112),
67=> array ("Ring of Protection",112),
68=> array ("Ring of Protection",112),
69=> array ("Ring of Protection",112),
70=> array ("Ring of Protection",112),
71=> array ("Ring of Regeneration",112),
72=> array ("Ring of Regeneration",112),
73=> array ("Ring of Spell Storing",112),
74=> array ("Ring of Spell Storing",112),
75=> array ("Ring of Spell Turning",112),
76=> array ("Ring of Spell Turning",112),
77=> array ("Ring of Spell Turning",112),
78=> array ("Ring of Spell Turning",112),
79=> array ("Ring of Spell Turning",112),
80=> array ("Ring of Telekinesis",112),
81=> array ("Ring of Telekinesis",112),
82=> array ("Ring of Water Walking",112),
83=> array ("Ring of Water Walking",112),
84=> array ("Ring of Water Walking",112),
85=> array ("Ring of Water Walking",112),
86=> array ("Ring of Water Walking",112),
87=> array ("Ring of Water Walking",112),
88=> array ("Ring of Weakness",112),
89=> array ("Ring of Weakness",112),
90=> array ("Ring of Weakness",112),
91=> array ("Ring of Weakness",112),
92=> array ("Ring of Weakness",112),
93=> array ("Ring of Weakness",112),
94=> array ("Ring of Weakness",112),
95=> array ("Ring of Wishes",112),
96=> array ("Ring of Wishes",112),
97=> array ("Ring of Wishes",112),
98=> array ("Ring of X-Ray Vision",112),
99=> array ("Ring of X-Ray Vision",112),
100=> array ("Ring of X-Ray Vision",112),
),
3=> array (
1=> array ("Cursed Scroll",113),
2=> array ("Cursed Scroll",113),
3=> array ("Cursed Scroll",113),
4=> array ("Cursed Scroll",113),
5=> array ("Cursed Scroll",113),
6=> array ("Scroll of Ward Against Elementals",113),
7=> array ("Scroll of Ward Against Elementals",113),
8=> array ("Scroll of Ward Against Elementals",113),
9=> array ("Scroll of Ward Against Elementals",113),
10=> array ("Scroll of Ward Against Elementals",113),
11=> array ("Scroll of Ward Against Elementals",113),
12=> array ("Scroll of Ward Against Elementals",113),
13=> array ("Scroll of Ward Against Elementals",113),
14=> array ("Scroll of Ward Against Elementals",113),
15=> array ("Scroll of Ward Against Elementals",113),
16=> array ("Scroll of Ward Against Lycanthropes",113),
17=> array ("Scroll of Ward Against Lycanthropes",113),
18=> array ("Scroll of Ward Against Lycanthropes",113),
19=> array ("Scroll of Ward Against Lycanthropes",113),
20=> array ("Scroll of Ward Against Lycanthropes",113),
21=> array ("Scroll of Ward Against Lycanthropes",113),
22=> array ("Scroll of Ward Against Lycanthropes",113),
23=> array ("Scroll of Ward Against Lycanthropes",113),
24=> array ("Scroll of Ward Against Lycanthropes",113),
25=> array ("Scroll of Ward Against Lycanthropes",113),
26=> array ("Scroll of Ward Against Magic",113),
27=> array ("Scroll of Ward Against Magic",113),
28=> array ("Scroll of Ward Against Magic",113),
29=> array ("Scroll of Ward Against Magic",113),
30=> array ("Scroll of Ward Against Magic",113),
31=> array ("Scroll of Ward Against Undead",113),
32=> array ("Scroll of Ward Against Undead",113),
33=> array ("Scroll of Ward Against Undead",113),
34=> array ("Scroll of Ward Against Undead",113),
35=> array ("Scroll of Ward Against Undead",113),
36=> array ("Scroll of Ward Against Undead",113),
37=> array ("Scroll of Ward Against Undead",113),
38=> array ("Scroll of Ward Against Undead",113),
39=> array ("Scroll of Ward Against Undead",113),
40=> array ("Scroll of Ward Against Undead",113),
41=> array ("Scroll of Spells",113),
42=> array ("Scroll of Spells",113),
43=> array ("Scroll of Spells",113),
44=> array ("Scroll of Spells",113),
45=> array ("Scroll of Spells",113),
46=> array ("Scroll of Spells",113),
47=> array ("Scroll of Spells",113),
48=> array ("Scroll of Spells",113),
49=> array ("Scroll of Spells",113),
50=> array ("Scroll of Spells",113),
51=> array ("Scroll of Spells",113),
52=> array ("Scroll of Spells",113),
53=> array ("Scroll of Spells",113),
54=> array ("Scroll of Spells",113),
55=> array ("Scroll of Spells",113),
56=> array ("Scroll of Spells",113),
57=> array ("Scroll of Spells",113),
58=> array ("Scroll of Spells",113),
59=> array ("Scroll of Spells",113),
60=> array ("Scroll of Spells",113),
61=> array ("Scroll of Spells",113),
62=> array ("Scroll of Spells",113),
63=> array ("Scroll of Spells",113),
64=> array ("Scroll of Spells",113),
65=> array ("Scroll of Spells",113),
66=> array ("Scroll of Spells",113),
67=> array ("Scroll of Spells",113),
68=> array ("Scroll of Spells",113),
69=> array ("Scroll of Spells",113),
70=> array ("Scroll of Spells",113),
71=> array ("Scroll of Spells",113),
72=> array ("Scroll of Spells",113),
73=> array ("Scroll of Spells",113),
74=> array ("Scroll of Spells",113),
75=> array ("Scroll of Spells",113),
76=> array ("Scroll of Spells",113),
77=> array ("Treasure Map",113),
78=> array ("Treasure Map",113),
79=> array ("Treasure Map",113),
80=> array ("Treasure Map",113),
81=> array ("Treasure Map",113),
82=> array ("Treasure Map",113),
83=> array ("Treasure Map",113),
84=> array ("Treasure Map",113),
85=> array ("Treasure Map",113),
86=> array ("Treasure Map",113),
87=> array ("Treasure Map",113),
88=> array ("Treasure Map",113),
89=> array ("Treasure Map",113),
90=> array ("Treasure Map",113),
91=> array ("Treasure Map",113),
92=> array ("Treasure Map",113),
93=> array ("Treasure Map",113),
94=> array ("Treasure Map",113),
95=> array ("Treasure Map",113),
96=> array ("Treasure Map",113),
97=> array ("Treasure Map",113),
98=> array ("Treasure Map",113),
99=> array ("Treasure Map",113),
100=> array ("Treasure Map",113),
),
4=> array (
1=> array ("Rod of Cancellation",114),
2=> array ("Rod of Cancellation",114),
3=> array ("Rod of Cancellation",114),
4=> array ("Rod of Cancellation",114),
5=> array ("Rod of Cancellation",114),
6=> array ("Rod of Cancellation",114),
7=> array ("Rod of Resurrection",114),
8=> array ("Rod of Resurrection",114),
9=> array ("Staff of Commanding (C)",114),
10=> array ("Staff of Commanding (C)",114),
11=> array ("Staff of Healing (C)",114),
12=> array ("Staff of Healing (C)",114),
13=> array ("Staff of Healing (C)",114),
14=> array ("Staff of Healing (C)",114),
15=> array ("Staff of Healing (C)",114),
16=> array ("Staff of Healing (C)",114),
17=> array ("Staff of Healing (C)",114),
18=> array ("Staff of Healing (C)",114),
19=> array ("Staff of Healing (C)",114),
20=> array ("Staff of Healing (C)",114),
21=> array ("Staff of Power (MU/E)",114),
22=> array ("Staff of Power (MU/E)",114),
23=> array ("Staff of Striking (C)",114),
24=> array ("Staff of Striking (C)",114),
25=> array ("Staff of Striking (C)",114),
26=> array ("Staff of Striking (C)",114),
27=> array ("Staff of Withering (C)",114),
28=> array ("Staff of Withering (C)",114),
29=> array ("Staff of Wizardry (MU/E)",114),
30=> array ("Staff of the Serpent (C)",114),
31=> array ("Staff of the Serpent (C)",114),
32=> array ("Staff of the Serpent (C)",114),
33=> array ("Staff of the Serpent (C)",114),
34=> array ("Staff of the Serpent (C)",114),
35=> array ("Staff of the Serpent (C)",114),
36=> array ("Staff of the Serpent (C)",114),
37=> array ("Wand of Cold",114),
38=> array ("Wand of Cold",114),
39=> array ("Wand of Cold",114),
40=> array ("Wand of Cold",114),
41=> array ("Wand of Detecting Enemies",114),
42=> array ("Wand of Detecting Enemies",114),
43=> array ("Wand of Detecting Enemies",114),
44=> array ("Wand of Detecting Enemies",114),
45=> array ("Wand of Detecting Enemies",114),
46=> array ("Wand of Detecting Magic",115),
47=> array ("Wand of Detecting Magic",115),
48=> array ("Wand of Detecting Magic",115),
49=> array ("Wand of Detecting Magic",115),
50=> array ("Wand of Detecting Magic",115),
51=> array ("Wand of Detecting Metals",115),
52=> array ("Wand of Detecting Metals",115),
53=> array ("Wand of Detecting Metals",115),
54=> array ("Wand of Detecting Metals",115),
55=> array ("Wand of Detecting Metals",115),
56=> array ("Wand of Detecting Secret Doors",115),
57=> array ("Wand of Detecting Secret Doors",115),
58=> array ("Wand of Detecting Secret Doors",115),
59=> array ("Wand of Detecting Secret Doors",115),
60=> array ("Wand of Detecting Secret Doors",115),
61=> array ("Wand of Detecting Traps",115),
62=> array ("Wand of Detecting Traps",115),
63=> array ("Wand of Detecting Traps",115),
64=> array ("Wand of Detecting Traps",115),
65=> array ("Wand of Device Negation",115),
66=> array ("Wand of Device Negation",115),
67=> array ("Wand of Device Negation",115),
68=> array ("Wand of Device Negation",115),
69=> array ("Wand of Device Negation",115),
70=> array ("Wand of Fear",115),
71=> array ("Wand of Fear",115),
72=> array ("Wand of Fear",115),
73=> array ("Wand of Fear",115),
74=> array ("Wand of Fear",115),
75=> array ("Wand of Fireballs",115),
76=> array ("Wand of Fireballs",115),
77=> array ("Wand of Fireballs",115),
78=> array ("Wand of Fireballs",115),
79=> array ("Wand of Fireballs",115),
80=> array ("Wand of Illusion",115),
81=> array ("Wand of Illusion",115),
82=> array ("Wand of Illusion",115),
83=> array ("Wand of Illusion",115),
84=> array ("Wand of Illusion",115),
85=> array ("Wand of Lightning Bolts",115),
86=> array ("Wand of Lightning Bolts",115),
87=> array ("Wand of Lightning Bolts",115),
88=> array ("Wand of Lightning Bolts",115),
89=> array ("Wand of Magic Missiles",115),
90=> array ("Wand of Magic Missiles",115),
91=> array ("Wand of Magic Missiles",115),
92=> array ("Wand of Magic Missiles",115),
93=> array ("Wand of Magic Missiles",115),
94=> array ("Wand of Paralysation",115),
95=> array ("Wand of Paralysation",115),
96=> array ("Wand of Paralysation",115),
97=> array ("Wand of Polymorphing",115),
98=> array ("Wand of Polymorphing",115),
99=> array ("Wand of Polymorphing",115),
100=> array ("Wand of Polymorphing",115),
),
5=> array (
1=> array ("Amulet versus Crystal Balls and ESP",115),
2=> array ("Amulet versus Crystal Balls and ESP",115),
3=> array ("Apparatus of the Crab",115),
4=> array ("Bag of Devouring",115),
5=> array ("Bag of Devouring",115),
6=> array ("Bag of Holding",115),
7=> array ("Bag of Holding",115),
8=> array ("Bag of Holding",115),
9=> array ("Bag of Holding",115),
10=> array ("Bag of Holding",115),
11=> array ("Folding Boat",115),
12=> array ("Boots of Levitation",116),
13=> array ("Boots of Levitation",116),
14=> array ("Boots of Levitation",116),
15=> array ("Boots of Speed",116),
16=> array ("Boots of Speed",116),
17=> array ("Boots of Speed",116),
18=> array ("Boots of Travelling and Springing",116),
19=> array ("Boots of Travelling and Springing",116),
20=> array ("Boots of Travelling and Springing",116),
21=> array ("Bowl of Commanding Water Elementals",116),
22=> array ("Bracers of Armour",116),
23=> array ("Bracers of Armour",116),
24=> array ("Brazier of Commanding Fire Elementals",116),
25=> array ("Brooch of Shielding",116),
26=> array ("Brooch of Shielding",116),
27=> array ("Broom of Flying",116),
28=> array ("Broom of Flying",116),
29=> array ("Broom of Flying",116),
30=> array ("Censer of Controlling Air Elementals",116),
31=> array ("Chime of Opening",116),
32=> array ("Cloak of Protection",116),
33=> array ("Cloak of Protection",116),
34=> array ("Crystal Ball",116),
35=> array ("Crystal Ball",116),
36=> array ("Crystal Ball",116),
37=> array ("Crystal Ball with Clairaudience",116),
38=> array ("Crystal Ball with Clairaudience",116),
39=> array ("Crystal Ball with ESP",116),
40=> array ("Cube of Force",117),
41=> array ("Cube of Frost Resistance",117),
42=> array ("Decanter of Endless Water",117),
43=> array ("Decanter of Endless Water",117),
44=> array ("Displacer Cloak",117),
45=> array ("Displacer Cloak",117),
46=> array ("Drums of Panic",117),
47=> array ("Dust of Appearance",117),
48=> array ("Dust of Appearance",117),
49=> array ("Dust of Appearance",117),
50=> array ("Dust of Disappearance",117),
51=> array ("Dust of Disappearance",117),
52=> array ("Dust of Disappearance",117),
53=> array ("Efreeti Bottle",117),
54=> array ("Elven Cloak",117),
55=> array ("Elven Cloak",117),
56=> array ("Elven Cloak",117),
57=> array ("Elven Cloak",117),
58=> array ("Elven Boots",117),
59=> array ("Elven Boots",117),
60=> array ("Elven Boots",117),
61=> array ("Elven Boots",117),
62=> array ("Eyes of Charming",117),
63=> array ("Eyes of the Eagle",118),
64=> array ("Eyes of the Eagle",118),
65=> array ("Eyes of Petrification",118),
66=> array ("Eyes of Petrification",118),
67=> array ("Eyes of Petrification",118),
68=> array ("Flying Carpet",118),
69=> array ("Flying Carpet",118),
70=> array ("Flying Carpet",118),
71=> array ("Flying Carpet",118),
72=> array ("Gauntlets of Ogre Power",118),
73=> array ("Gauntlets of Ogre Power",118),
74=> array ("Gauntlets of Ogre Power",118),
75=> array ("Girdle of Giant Strength",118),
76=> array ("Girdle of Giant Strength",118),
77=> array ("Girdle of Giant Strength",118),
78=> array ("Helm of Alignment Changing",118),
79=> array ("Helm of Alignment Changing",118),
80=> array ("Helm of Alignment Changing",118),
81=> array ("Helm of Comprehend Languages and Read Magic",118),
82=> array ("Helm of Comprehend Languages and Read Magic",118),
83=> array ("Helm of Comprehend Languages and Read Magic",118),
84=> array ("Helm of Comprehend Languages and Read Magic",118),
85=> array ("Helm of Telepathy",118),
86=> array ("Helm of Teleportation",118),
87=> array ("Horn of Blasting",118),
88=> array ("Medallion of Thoughts (30')",118),
89=> array ("Medallion of Thoughts (30')",118),
90=> array ("Medallion of Thoughts (30')",118),
91=> array ("Medallion of Thoughts (90')",118),
92=> array ("Medallion of Thoughts (90')",118),
93=> array ("Mirror of Life Trapping",118),
94=> array ("Mirror of Opposition",118),
95=> array ("Necklace of Adaptation",118),
96=> array ("Rope of Climbing",119),
97=> array ("Rope of Climbing",119),
98=> array ("Scarab of Protection",119),
99=> array ("Scarab of Protection",119),
100=> array ("Stone of Controlling Earth Elementals",119),
),
6=> array (
1=> array ("arrows +1",119),
2=> array ("arrows +1",119),
3=> array ("arrows +1",119),
4=> array ("arrows +1",119),
5=> array ("arrows +1",119),
6=> array ("arrows +1",119),
7=> array ("arrows +1",119),
8=> array ("arrows +1",119),
9=> array ("arrows +1",119),
10=> array ("arrows +1",119),
11=> array ("arrows +1",119),
12=> array ("arrows +1",119),
13=> array ("arrows +2",119),
14=> array ("arrows +2",119),
15=> array ("arrows +2",119),
16=> array ("arrows +2",119),
17=> array ("arrows +2",119),
18=> array ("arrows +2",119),
19=> array ("arrows +3",119),
20=> array ("arrows +3",119),
21=> array ("arrows +3",119),
22=> array ("Arrow +3, Slaying Arrow",119),
23=> array ("Axe +1",119),
24=> array ("Axe +1",119),
25=> array ("Axe +1",119),
26=> array ("Axe +1",119),
27=> array ("Axe +1",119),
28=> array ("Axe +1",119),
29=> array ("Axe +1",119),
30=> array ("Axe +1",119),
31=> array ("Axe +1",119),
32=> array ("Axe +2",119),
33=> array ("Axe +2",119),
34=> array ("Axe +2",119),
35=> array ("Bow +1",119),
36=> array ("Bow +1",119),
37=> array ("Bow +1",119),
38=> array ("Bow +1",119),
39=> array ("Bow +1",119),
40=> array ("Bow +1",119),
41=> array ("Bow +1",119),
42=> array ("crossbow bolts +1",119),
43=> array ("crossbow bolts +1",119),
44=> array ("crossbow bolts +1",119),
45=> array ("crossbow bolts +1",119),
46=> array ("crossbow bolts +1",119),
47=> array ("crossbow bolts +1",119),
48=> array ("crossbow bolts +1",119),
49=> array ("crossbow bolts +1",119),
50=> array ("crossbow bolts +1",119),
51=> array ("crossbow bolts +1",119),
52=> array ("crossbow bolts +1",119),
53=> array ("crossbow bolts +1",119),
54=> array ("crossbow bolts +2",119),
55=> array ("crossbow bolts +2",119),
56=> array ("crossbow bolts +2",119),
57=> array ("crossbow bolts +2",119),
58=> array ("crossbow bolts +2",119),
59=> array ("crossbow bolts +2",119),
60=> array ("crossbow bolts +2",119),
61=> array ("crossbow bolts +3",119),
62=> array ("crossbow bolts +3",119),
63=> array ("crossbow bolts +3",119),
64=> array ("Dagger +1",119),
65=> array ("Dagger +1",119),
66=> array ("Dagger +1",119),
67=> array ("Dagger +1",119),
68=> array ("Dagger +1",119),
69=> array ("Dagger +2, +3 vs goblins, kobolds and orcs",119),
70=> array ("Sling +1",119),
71=> array ("Sling +1",119),
72=> array ("Sling +1",119),
73=> array ("Slint +1",119),
74=> array ("Sling +1",119),
75=> array ("Sling +1",119),
76=> array ("Spear +1",119),
77=> array ("Spear +1",119),
78=> array ("Spear +1",119),
79=> array ("Spear +1",119),
80=> array ("Spear +1",119),
81=> array ("Spear +1",119),
82=> array ("Spear +1",119),
83=> array ("Spear +2",119),
84=> array ("Spear +2",119),
85=> array ("Spear +2",119),
86=> array ("Spear +2",119),
87=> array ("Spear +3",119),
88=> array ("War Hammer +1",119),
89=> array ("War Hammer +1",119),
90=> array ("War Hammer +1",119),
91=> array ("War Hammer +1",119),
92=> array ("War Hammer +1",119),
93=> array ("War Hammer +1",119),
94=> array ("War Hammer +1",119),
95=> array ("War Hammer +1",119),
96=> array ("War Hammer +1",119),
97=> array ("War Hammer +1",119),
98=> array ("War Hammer +1",119),
99=> array ("War Hammer +1",119),
100=> array ("War Hammer +2, Dwarven Thrower",119),
),
7=> array (
1=> array ("Sword +1",119),
2=> array ("Sword +1",119),
3=> array ("Sword +1",119),
4=> array ("Sword +1",119),
5=> array ("Sword +1",119),
6=> array ("Sword +1",119),
7=> array ("Sword +1",119),
8=> array ("Sword +1",119),
9=> array ("Sword +1",119),
10=> array ("Sword +1",119),
11=> array ("Sword +1",119),
12=> array ("Sword +1",119),
13=> array ("Sword +1",119),
14=> array ("Sword +1",119),
15=> array ("Sword +1",119),
16=> array ("Sword +1",119),
17=> array ("Sword +1",119),
18=> array ("Sword +1",119),
19=> array ("Sword +1",119),
20=> array ("Sword +1",119),
21=> array ("Sword +1",119),
22=> array ("Sword +1",119),
23=> array ("Sword +1",119),
24=> array ("Sword +1",119),
25=> array ("Sword +1",119),
26=> array ("Sword +1",119),
27=> array ("Sword +1",119),
28=> array ("Sword +1",119),
29=> array ("Sword +1",119),
30=> array ("Sword +1",119),
31=> array ("Sword +1",119),
32=> array ("Sword +1",119),
33=> array ("Sword +1",119),
34=> array ("Sword +1",119),
35=> array ("Sword +1",119),
36=> array ("Sword +1",119),
37=> array ("Sword +1",119),
38=> array ("Sword +1",119),
39=> array ("Sword +1",119),
40=> array ("Sword +1, +2 vs lycanthropes",119),
41=> array ("Sword +1, +2 vs lycanthropes",119),
42=> array ("Sword +1, +2 vs lycanthropes",119),
43=> array ("Sword +1, +2 vs lycanthropes",119),
44=> array ("Sword +1, +2 vs lycanthropes",119),
45=> array ("Sword +1, +2 vs spell casters",119),
46=> array ("Sword +1, +2 vs spell casters",119),
47=> array ("Sword +1, +2 vs spell casters",119),
48=> array ("Sword +1, +2 vs spell casters",119),
49=> array ("Sword +1, +2 vs spell casters",119),
50=> array ("Sword +1, +3 vs undead",119),
51=> array ("Sword +1, +3 vs undead",119),
52=> array ("Sword +1, +3 vs undead",119),
53=> array ("Sword +1, +3 vs undead",119),
54=> array ("Sword +1, +3 vs dragons",119),
55=> array ("Sword +1, +3 vs dragons",119),
56=> array ("Sword +1, +3 vs dragons",119),
57=> array ("Sword +1, +3 vs dragons",119),
58=> array ("Sword +1, +3 vs regenerating monsters",119),
59=> array ("Sword +1, +3 vs regenerating monsters",119),
60=> array ("Sword +1, +3 vs regenerating monsters",119),
61=> array ("Sword +1, +3 vs regenerating monsters",119),
62=> array ("Sword +1, +3 vs regenerating monsters",119),
63=> array ("Sword +1, +3 vs magical monsters",119),
64=> array ("Sword +1, +3 vs magical monsters",119),
65=> array ("Sword +1, +3 vs magical monsters",119),
66=> array ("Sword +1, +3 vs magical monsters",119),
67=> array ("Sword +1, +3 vs magical monsters",119),
68=> array ("Sword +1, <i>light</i> 30' radius",119),
69=> array ("Sword +1, <i>light</i> 30' radius",119),
70=> array ("Sword +1, <i>light</i> 30' radius",119),
71=> array ("Sword +1, <i>light</i> 30' radius",119),
72=> array ("Sword +1, <i>light</i> 30' radius",119),
73=> array ("Sword +1, <i>light</i> 30' radius",119),
74=> array ("Sword +1, <i>light</i> 30' radius",119),
75=> array ("Sword +1, <i>light</i> 30' radius",119),
76=> array ("Sword +1, Flame Tongue",119),
77=> array ("Sword +1, Flame Tongue",119),
78=> array ("Sword +1, Flame Tongue",119),
79=> array ("Sword +1, Flame Tongue",119),
80=> array ("Sword +1, Flame Tongue",119),
81=> array ("Sword +1, Life Drinker",119),
82=> array ("Sword +1, <i>locate objects</i>",119),
83=> array ("Sword +1, <i>locate objects</i>",119),
84=> array ("Sword +1, <i>locate objects</i>",119),
85=> array ("Sword +1, Luck Blade",119),
86=> array ("Sword +1, Luck Blade",119),
87=> array ("Sword +1, Wish Blade",119),
88=> array ("Sword +2",119),
89=> array ("Sword +2",119),
90=> array ("Sword +2",119),
91=> array ("Sword +2, <i>charm person</i>",119),
92=> array ("Sword +2, <i>charm person</i>",119),
93=> array ("Sword +3",119),
94=> array ("Sword +3",119),
95=> array ("Sword +3, Frost Brand",119),
96=> array ("Sword -1 (cursed)",119),
97=> array ("Sword -1 (cursed)",119),
98=> array ("Sword -2 (cursed)",119),
99=> array ("Sword -2 (cursed)",119),
100=> array ("Sapient Sword",120),
),
8=> array (
1=> array ("Armour +1",119),
2=> array ("Armour +1",119),
3=> array ("Armour +1",119),
4=> array ("Armour +1",119),
5=> array ("Armour +1",119),
6=> array ("Armour +1",119),
7=> array ("Armour +1",119),
8=> array ("Armour +1",119),
9=> array ("Armour +1",119),
10=> array ("Armour +1",119),
11=> array ("Armour +1",119),
12=> array ("Armour +1",119),
13=> array ("Armour +1",119),
14=> array ("Armour +1",119),
15=> array ("Armour +1",119),
16=> array ("Armour +1<br>* Shield +1",119),
17=> array ("Armour +1<br>* Shield +1",119),
18=> array ("Armour +1<br>* Shield +1",119),
19=> array ("Armour +1<br>* Shield +1",119),
20=> array ("Armour +1<br>* Shield +1",119),
21=> array ("Armour +1<br>* Shield +1",119),
22=> array ("Armour +1<br>* Shield +1",119),
23=> array ("Armour +1<br>* Shield +1",119),
24=> array ("Armour +1<br>* Shield +1",119),
25=> array ("Armour +1<br>* Shield +1",119),
26=> array ("Armour +1<br>* Shield +2",119),
27=> array ("Armour +1<br>* Shield +2",119),
28=> array ("Armour +1<br>* Shield +3",119),
29=> array ("Armour +2",119),
30=> array ("Armour +2",119),
31=> array ("Armour +2",119),
32=> array ("Armour +2",119),
33=> array ("Armour +2<br>* Shield +1",119),
34=> array ("Armour +2<br>* Shield +1",119),
35=> array ("Armour +2<br>* Shield +1",119),
36=> array ("Armour +2<br>* Shield +2",119),
37=> array ("Armour +2<br>* Shield +2",119),
38=> array ("Armour +2<br>* Shield +2",119),
39=> array ("Armour +2<br>* Shield +3",119),
40=> array ("Armour +3",119),
41=> array ("Armour +3<br>* Shield +1",119),
42=> array ("Armour +3<br>* Shield +2",119),
43=> array ("Armour +3<br>* Shield +2",119),
44=> array ("Shield +1",119),
45=> array ("Shield +1",119),
46=> array ("Shield +1",119),
47=> array ("Shield +1",119),
48=> array ("Shield +1",119),
49=> array ("Shield +1",119),
50=> array ("Shield +1",119),
51=> array ("Shield +1",119),
52=> array ("Shield +1",119),
53=> array ("Shield +1",119),
54=> array ("Shield +1",119),
55=> array ("Shield +1",119),
56=> array ("Shield +1",119),
57=> array ("Shield +1",119),
58=> array ("Shield +1",119),
59=> array ("Shield +1",119),
60=> array ("Shield +1",119),
61=> array ("Shield +1",119),
62=> array ("Shield +1",119),
63=> array ("Shield +1",119),
64=> array ("Shield +2",119),
65=> array ("Shield +2",119),
66=> array ("Shield +2",119),
67=> array ("Shield +2",119),
68=> array ("Shield +2",119),
69=> array ("Shield +2",119),
70=> array ("Shield +2",119),
71=> array ("Shield +2",119),
72=> array ("Shield +2",119),
73=> array ("Shield +2",119),
74=> array ("Shield +3",119),
75=> array ("Shield +3",119),
76=> array ("Shield +3",119),
77=> array ("Shield +3",119),
78=> array ("Shield +3",119),
79=> array ("Shield +3",119),
80=> array ("Armour -1 (cursed)",119),
81=> array ("Armour -1 (cursed)",119),
82=> array ("Armour -1 (cursed)",119),
83=> array ("Armour -2 (cursed)",119),
84=> array ("Armour -2 (cursed)",119),
85=> array ("Armour -2 (cursed)",119),
86=> array ("Armour -1 (cursed)<br>* Shield +1",119),
87=> array ("Armour -2 (cursed)<br>* Shield +1",119),
88=> array ("Armour AC9 (cursed)",119),
89=> array ("Armour AC9 (cursed)",119),
90=> array ("Armour AC9 (cursed)",119),
91=> array ("Shield -1 (cursed)",119),
92=> array ("Shield -1 (cursed)",119),
93=> array ("Shield -1 (cursed)",119),
94=> array ("Shield -1 (cursed)",119),
95=> array ("Shield -2 (cursed)",119),
96=> array ("Shield -2 (cursed)",119),
97=> array ("Shield -2 (cursed)",119),
98=> array ("Shield AC9 (cursed)",119),
99=> array ("Shield AC9 (cursed)",119),
100=> array ("Shield AC9 (cursed)",119),
),
);

$llgems=array(
1=> array (" pearl","pearls",10,16),
2=> array ("n opal","opals",25,31),
3=> array (" sapphire","sapphires",50,46),
4=> array (" topaz","topazes",75,61),
5=> array ("n amethyst","amethysts",100,76),
6=> array (" piece of jade","pieces of jade",250,86),
7=> array (" ruby","rubies",500,91),
8=> array ("n emerald","emeralds",750,96),
9=> array (" diamond","diamonds",1000,101),
);
// 0 = singular, 1=plural, 2=value,
// 3=it's this gem if d100 is under this number
// (and it isn't the previous one)

$lljewels=array(
1=> array ("ring","rings",1,4,10),
2=> array ("ring","rings",1,4,10),
3=> array ("brooch","brooches",2,4,10),
4=> array ("bracelet","bracelets",1,4,100),
5=> array ("set of earrings","sets of earrings",2,4,100),
6=> array ("pendant","pendants",2,6,100),
7=> array ("necklace","necklaces",3,6,100),
8=> array ("necklace","necklaces",3,6,100),
9=> array ("necklace","necklaces",3,6,100),
10=> array ("necklace","necklaces",3,6,100),
);
// 0: singular, 1: plural
// 2-4: value of 1d4 x 10gp is 1,4,10 eg.
// only used for LL/MF.

$ament=array ("null","Chaotic","Neutral","Lawful");
$saves=array ("null","Fighter","Magic-User","Cleric","Thief","Dwarf","Elf");
$whoard=array();
$lhoard=array();
$llavtr=array();
$wnenca=array();
$wnencb=array();
$lnenca=array();
$lnencb=array();
// if the number encountered is 2d4, for example,
// $wnenca will be 2 and $wnencb will be 4 (for wandering),
// $lnenca will be 2 and $lnencb will be 4 (for lair).
$hdice=array();
$hdiceadd=array();
$diceface=array("null",1,3,4,6,8,10,12);
$dicenum=7;
$attackdice=array();
$attacknum=array();
$thpsame=array("null",20,30,35,60,60,75,75,80);
$thpwand=array("null",20,40,50,60,70,80,85,90);
$minhd=array("null",0,1,2,2,2,2,3,4);
$maxhd=array("null",2,3,4,5,7,9,11,12);
$treasuretypes=array(
1=> array ("I",0.14),
2=> array ("II",1),
3=> array ("III",3.25),
4=> array ("IV",4.5),
5=> array ("V",35),
6=> array ("VI",119.4985),
7=> array ("VII",266.3525),
8=> array ("VIII",1125),
9=> array ("IX",2250),
10=> array ("X",12921.7),
11=> array ("XI",247.1),
12=> array ("XII",362.5),
13=> array ("XIII",46.25),
14=> array ("XIV",4012.8625),
15=> array ("XV",48354.625),
16=> array ("XVI",24074.675),
17=> array ("XVII",6746.5),
18=> array ("XVIII",3175.2875),
19=> array ("XIX",4215.1),
20=> array ("XX",1149.8),
21=> array ("XXI",1608.025),
22=> array ("XXII",12357.0625),
);
// the 2nd element is average value, with magic items
// being counted as being worth 1000gp each.

$monmor=array(
1=> array ("null",5,6,6,7,7,7,7,7,7,7,8,8,8,9,9,9,10,11,12,12),
2=> array ("null",5,6,7,7,7,7,7,7,8,8,8,8,9,9,9,9,10,11,12,12),
3=> array ("null",6,6,7,7,8,8,8,8,9,9,9,10,10,10,11,12,12,12,12,12),
4=> array ("null",6,6,7,8,8,8,8,9,9,9,9,10,10,10,11,12,12,12,12,12),
5=> array ("null",6,6,7,8,8,8,8,9,9,9,9,10,10,10,11,12,12,12,12,12),
6=> array ("null",7,7,7,8,8,8,9,9,9,9,10,10,10,10,11,12,12,12,12,12),
);
// $monmor[$x][1-20] determines the morale
// of a monster whose home level is level $x.

$monsp=array(
1=> array ("null",60,60,60,60,60,60,90,90,90,90,90,90,90,90,120,120,180,180,210,210),
2=> array ("null",60,60,60,60,60,90,90,90,90,90,120,120,120,120,120,180,180,210,210,210),
3=> array ("null",60,60,60,60,90,90,90,90,120,120,120,120,150,150,180,180,210,210,210,210),
4=> array ("null",60,60,60,60,90,90,90,90,120,120,120,150,150,150,180,210,240,240,240,300),
5=> array ("null",60,60,60,60,90,90,90,90,120,120,120,150,150,150,180,210,240,240,240,300),
6=> array ("null",60,60,60,90,90,90,90,90,120,120,150,150,180,180,210,240,240,240,300,300),
7=> array ("null",60,60,60,90,90,90,90,90,120,120,150,150,180,180,210,240,240,240,300,300),
8=> array ("null",60,60,90,90,120,120,120,120,120,120,180,180,180,210,210,240,240,240,300,300),
);
// $monsp does the same for speed.
// if the creature has two speeds, this array generates the
// higher one.

$cleric=array(
1=> array ("null","Cure Light Wounds","Detect Evil (Cleric version)","Detect Magic","Light","Protection From Evil","Purify Food and Drink","Remove Fear","Resist Cold"),
2=> array ("null","Bless","Find Traps","Know Alignment","Hold Person","Resist Fire","Silence 15' Radius","Snake Charm","Speak with Animal"),
3=> array ("null","Animal Growth","Animate Dead","Continual Light","Dispel Magic","Locate Object","Remove Curse","Striking"),
4=> array ("null","Create Food and Water","Cure Serious Wounds","Detect Lie","Lower Water","Neutralize Poison","Protection from Evil 10' Radius","Speak With Plants","Sticks to Snakes"),
5=> array ("null","Commune","Cure Critical Wounds","Dispel Evil","Flame Strike","Insect Plague","Quest","Raise Dead","True Seeing"),
6=> array ("null","Animate Objects","Blade Barrier","Conjure Animals","Find the Path","Heal","Part Water","Stone Tell","Word of Recall"),
7=> array ("null","Control Weather","Earthquake","Holy Word","Regenerate","Restoration","Resurrection","Symbol (Cleric version)","Wind Walk"),
);
// there are 7 levels, each with 8 spells.

$elfmu=array(
1=> array ("null","Charm Person","Detect Magic","Floating Disc","Hold Portal","Light","Magic Missile","Protection from Evil","Read Languages","Read Magic","Shield","Sleep","Ventriloquism"),
2=> array ("null","Arcane Lock","Continual Light","Detect Evil (Elf/Magic-User version)","Detect Invisible","ESP","Invisibility","Knock","Levitate","Locate Object","Mirror Image","Phantasmal Force","Web"),
3=> array ("null","Clairvoyance","Dispel Magic","Fire Ball","Fly","Haste","Hold Person","Infravision","Invisibility 10' Radius","Lightning Bolt","Protection from Evil 10' Radius","Protection from Normal Missiles","Water Breathing"),
4=> array ("null","Arcane Eye","Charm Monster","Confusion","Dimension Door","Hallucinatory Terrain","Massmorph","Plant Growth","Polymorph Others","Polymorph Self","Remove Curse","Wall of Fire","Wall of Ice"),
5=> array ("null","Animate Dead","Cloudkill","Conjure Elemental","Contact Other Plane","Feeblemind","Hold Monster","Magic Jar","Passwall","Telekinesis","Teleport","Transmute Rock to Mud","Wall of Stone"),
6=> array ("null","Anti-Magic Shell","Control Weather","Death Spell","Disintegrate","Geas","Invisible Stalker","Lower Water","Move Earth","Part Water","Project Image","Reincarnation","Stone to Flesh"),
7=> array ("null","Grasping Hand","Delayed Blast Fireball","Instant Summons","Duo-Dimension","Limited Wish","Mass Invisibility","Magic Sword","Phase Door","Power Word Stun","Reverse Gravity","Simulacrum","Statue"),
8=> array ("null","Antipathy/Sympathy","Clenched Fist","Clone","Glass Like Steel","Incendiary Cloud","Irresistible Dance","Mass Charm","Maze","Mind Blank","Polymorph Any Object","Symbol (Elf/Magic-User version)","Trap the Soul"),
9=> array ("null","Crushing Hand","Imprisonment","Meteor Swarm","Power Word Kill","Prismatic Sphere","Shape Change","Temporal Stasis","Time Stop","Wish"),
);
// there are 9 levels, each with 12 spells,
// except for level 9, which has only 9 spells.

$advantage=array(
1=> array ("baked bread","hobbits and humans"),
2=> array ("a forest","humans, fairies, leprechauns and elves"),
3=> array ("a city","humans"),
);
$advnum=3;
$rd=array();
$mwidth=10;
$shrine=array();
$language=array(
1=> "Common",
2=> "Dwarvish",
3=> "Elvish",
4=> "Orcish",
5=> "Hobbit",
);
$langnum=5;
if ($system=="ll") {
$language[5]="Halfling";
$language[6]="Goblin";
$language[7]="Gnome";
$language[8]="Kobold";
$language[9]="Gnoll";
$language[10]="Hobgoblin";
$language[11]="Chaotic";
$language[12]="Neutral";
$language[13]="Lawful";
$langnum=13;
}
$stats=array();
$crmag=array();
$crlang=array();
$crarmour=array();
$crsize=array();
$sizetext=array(
1=> array (3,"roughly fairy-sized","fairies",4),
2=> array (10,"roughly leprechaun-sized","leprechauns",3),
3=> array (15,"roughly hobbit-sized","hobbits",3),
4=> array (20,"roughly dwarf-sized","dwarves",2),
5=> array (30,"roughly human-sized","humans and elves",2),
6=> array (60,"gigantic","XXX",1),
);
$sizecats=6;
$grp=array();
$enc=array();
$wmtable=array();
$wmll=array();
$levmark=array();
$levgoal=array();
$table=array(
1=> array (1,"N/A","N/A","N/A"),
2=> array (2,"N/A","N/A","N/A"),
3=> array (3,1,1,3),
4=> array (6,1,1,6),
5=> array (9,1,3,3),
6=> array (12,1,6,2),
7=> array (18,1,6,3),
8=> array (24,6,2,2),
9=> array (27,3,3,3),
10=> array (36,1,6,6),
);
$standardm=array(
1=> array("Balrog",10,2,1,7,2,5,1,1,3),
2=> array("+Basilisk",.25,2,1,.25,.6667,.5,1,1,.1),
3=> array("Brownie",.25,.75,1,3,1,1,1,1,.1),
4=> array("Centaur",3,1,1,3,1,1,1.5,.5,1.5),
5=> array("+Chimera",4,1.2,.25,3,-3,5,1,.25,1.3333),
6=> array("Demon",4.5,2,.25,4.5,1.5,5,1,1,1.5),
7=> array("+Dragon",25,5,.5,50,3,5,1,1,50),
8=> array("Dwarf",2,1,1,2,1,.6667,1,1,.6667),
9=> array("Elf",1,1.5,1,.6667,1.5,2,1,1,1.1),
10=> array("Fairy",.25,1,1.5,.25,1.5,2,1,1,.1),
11=> array("Giant",5,.5,1,5,1,5,1,1,5),
12=> array("+Giant Spider",2,1,.5,1,2,4,1,1,1),
13=> array("Gnome",.6667,1.5,1.5,2,1,1,1,1,.6667),
14=> array("Goblin",.75,1,1,.75,1.5,.5,1,1,.75),
15=> array("Gorgon",1,1,.75,1.25,1.5,3,1,1,1),
16=> array("+Griffin",10,1,1,10,-3,5,1,1,1.5),
17=> array("Gremlin",.5,1,1.5,.5,1,2,1,.5,.3333),
18=> array("Half-Orc",1.5,1,1,1.5,1,1,1,1,1.25),
19=> array("+Harpy",1.5,.6667,1,1.5,-3,2,1,1,1),
20=> array("Hobbit",.5,1,1,2,1.5,1,1,.5,.5),
21=> array("Human",1,1,1,1,1,1,1,1,1),
22=> array("+Hydra",15,-9,1,1,-3,5,1,1,2),
23=> array("Lamia",2.5,1,.5,2,1,2,1,1,1),
24=> array("Leprechaun",.5,1,1.5,1,1.5,1,1,1.5,.3333),
25=> array("Living Skeleton",1,1,1,1,1,1,1,1,1),
26=> array("Living Statue",2,1,1,10,.3333,4,1,1,1),
27=> array("Lizard Man",1.5,.5,1,2,1.5,.5,1,1,1.1),
28=> array("Naga",2,3,1,3,2,1,.5,3,1),
29=> array("+Manticore",4,.75,.75,4,-3,5,1,1,1.3333),
30=> array("Minotaur",2.5,.75,1,2.5,.75,5,1,1,1.25),
31=> array("Ogre",2,1,1,2,1,1.5,1,1,1.5),
32=> array("Orc",1,1,1,1,1,1,1,1,1),
33=> array("Neanderthal",1.5,.75,1,2,.75,1,1,1,1),
34=> array("Satyr",.75,1,1,1,1.5,1,.75,1,.75),
35=> array("Shoggoth",20,-5,1,50,1,4,1,1,5),
36=> array("+Sphinx",1.5,2,1,1,-3,2,1,1,1),
37=> array("Wood Elf",.6667,1,1,.6667,2,2,1,1,.6667),
38=> array("Troll",3,1,1,3,1,4,1,1,2),
39=> array("+Unicorn",2,1,1.5,3,-3,3,1,1,1),
40=> array("+Giant Wolf",2.5,.75,1,2.5,-3,2,1,1,1.5),
41=> array("+Giant Worm",15,5,.5,25,-3,5,1,1,25),
42=> array("+Wyvern",3,3,.5,5,-3,4,1,1,1.5),
43=> array("Ghoul",3,.25,.5,3,1,4,1,.6667,1),
44=> array("Mummy",2,-3,-10,3,-3,1,1,1,1),
45=> array("Vampire",2.5,1.5,1.5,1,1,1,1,1,1),
46=> array("Werewolf",2.5,.5,.6667,3,-3,4,1,1,1),
47=> array("Zombie",2,-3,.25,3,-3,1,1,1,1),
48=> array("+Giant Slug",2,-3,.25,10,-3,.5,1,1,2),
49=> array ("Talking Cat",.5,1.3333,1,.5,1,1.3333,1.3333,1,.6667),
50=> array ("Talking Dog",1,.6667,1,1,1,1.3333,1,1,.6667),
51=> array ("Talking Mouse",.5,1,1,.6667,1.3333,1,1.5,1,.5),
52=> array ("Talking Owl",.6667,1.5,1,1,.5,1,1,1,.5),
53=> array ("Talking Bear",1.5,1,1,1.5,.5,1,.5,1,1),
54=> array ("Talking Fox",.5,1.3333,1.3333,.5,.6667,1.3333,1.3333,1,.6667),
55=> array ("Talking Crocodile",.5,1.3333,1.3333,.6666,1,1.3333,.5,1.3333,1),
56=> array ("Half-Demon",.5,1.5,.5,.6667,1,1.5,1,1.3333,1),
57=> array ("Dryad",.5,1,1,.5,1,1.3333,1,1.3333,1),
58=> array ("+Carnivorous Ape",3.3333,-5,1,4.5,2,1,1.5,-3,1.2),
59=> array ("+Giant Boar",2,-5,1,5.5,1,1,1.5,-3,1),
60=> array ("+Cave Bear",7,-5,1,6.6667,1.3333,1,1.5,-3,1.2),
61=> array ("Clockwork Warrior",1,-3,.5,4.5,1,1,1,-3,1),
62=> array ("+Wild Dog",1.5,-5,1,1.5,1.3333,1,1.2,-3,.6667),
63=> array ("+Living Sword",3,-3,1,3,2,-3,1.5,-3,.6667),
);
$standardn=63;
// standard monsters for T&T.
// 0 is name. If it starts with "+"
// the creature always uses 'tooth and claw'.
// 1-8 are attribute multipliers (or, if negative, maximum values)
// 9 is the height multiplier. This x 30 = the creature's size, where
// 30 is human-size.
// 10 becomes 'power'.
// 11 is a flag, set to 1 if this species is used in the dungeon,
// or if it's too powerful to be used.
$stplural=array();
$splus=array();
$mrtype=array();
$desc=array();
$htoh=array();
$spt=array();
$namefirst=array(
1 => "Abber",
2 => "Abomin",
3 => "Albin",
4 => "Arach",
5 => "Arg",
6 => "Arimas",
7 => "Ash",
8 => "Atlan",
9 => "Auton",
10 => "Baph",
11 => "Bar",
12 => "Basil",
13 => "Blu",
14 => "Bru",
15 => "Bucen",
16 => "Cac+",
17 => "Capr+",
18 => "Car",
19 => "Carn+",
20 => "Cary",
21 => "Cato",
22 => "Cer",
23 => "Cha",
24 => "Chi",
25 => "Chiro",
26 => "Col",
27 => "Cyn",
28 => "Degen",
29 => "Der",
30 => "Dich",
31 => "Dodec",
32 => "Dol",
33 => "Dr+",
34 => "Drac",
35 => "Fom",
36 => "Gor",
37 => "Gorg",
38 => "Gr+",
39 => "Har",
40 => "Hecat+",
41 => "Hecaton",
42 => "Hell+",
43 => "Hipp",
44 => "Hyper",
45 => "Ich",
46 => "Icht",
47 => "Jugger",
48 => "Mal",
49 => "Manti",
50 => "Megalo",
51 => "Min",
52 => "Mor",
53 => "Mus",
54 => "Myr",
55 => "Nyct",
56 => "Olym",
57 => "Olymp",
58 => "Per",
59 => "Ple",
60 => "Pyr+",
61 => "Quin",
62 => "Rhab",
63 => "Rhin",
64 => "Sagit",
65 => "Scor",
66 => "Sti",
67 => "Tant+",
68 => "Tetr+",
69 => "Tri",
70 => "Trag",
71 => "Trog",
72 => "Un",
73 => "Urs"
);
$firstnum=73;
$namesecond=array(
1 => "ban",
2 => "banian",
3 => "barian",
4 => "basti",
5 => "beria",
6 => "beros",
7 => "bian",
8 => "blepas",
9 => "borean",
10 => "can",
11 => "cephal",
12 => "cephalon",
13 => "ceros",
14 => "chios",
15 => "clope",
16 => "clops",
17 => "core",
18 => "corn",
19 => "cornean",
20 => "crit",
21 => "crota",
22 => "cus",
23 => "dosian",
24 => "dra",
25 => "dyte",
26 => "ean",
27 => "gog",
28 => "gon",
29 => "gryph",
30 => "lian",
31 => "lid",
32 => "liph",
33 => "lith",
34 => "lock",
35 => "mander",
36 => "mar",
37 => "massu",
38 => "median",
39 => "mera",
40 => "mia",
41 => "mian",
42 => "midon",
43 => "mur",
44 => "mure",
45 => "nasm",
46 => "naut",
47 => "neon",
48 => "niad",
49 => "nian",
50 => "nid",
51 => "nite",
52 => "nix",
53 => "path",
54 => "pax",
55 => "phalon",
56 => "phant",
57 => "pheros",
58 => "phin",
59 => "phon",
60 => "pian",
61 => "pion",
62 => "poid",
63 => "pusa",
64 => "rate",
65 => "raton",
66 => "ratos",
67 => "rax",
68 => "rena",
69 => "rete",
70 => "roid",
71 => "ron",
72 => "rone",
73 => "ronian",
74 => "ront",
75 => "ros",
76 => "rost",
77 => "saur",
78 => "seid",
79 => "sk",
80 => "soid",
81 => "ssus",
82 => "st",
83 => "stomos",
84 => "tanian",
85 => "tarian",
86 => "taur",
87 => "tauride",
88 => "taurine",
89 => "teon",
90 => "tep",
91 => "tesk",
92 => "tetra",
93 => "theon",
94 => "thid",
95 => "thoid",
96 => "thol",
97 => "tid",
98 => "toid",
99 => "tomian",
100 => "ton",
101 => "tor",
102 => "tos",
103 => "trice",
104 => "tyr",
105 => "vern",
106 => "vore",
);
$secondnum=106;
$vowels=array(
1=> "a",
2=> "e",
3=> "i",
4=> "o",
5=> "u",
6=> "y",
7=> "ae",
8=> "ai",
9=> "ao",
10=> "au",
11=> "ea",
12=> "ee",
13=> "ei",
14=> "eo",
15=> "eau",
16=> "ia",
17=> "ie",
18=> "io",
19=> "oa",
20=> "oe",
21=> "oi",
22=> "oo",
23=> "ou",
24=> "ua",
25=> "ue",
26=> "ui",
27=> "uo",
);
$vnum=27;

$namethird=array(
1=> "Shambling",
2=> "Whispering",
3=> "Slithering",
4=> "Shadow",
5=> "Bright",
6=> "Sun",
7=> "Light",
8=> "Gibbering",
9=> "Screaming",
10=> "Foul",
11=> "Shining",
12=> "Golden",
13=> "Bronze",
14=> "Hungry",
15=> "Merciful",
16=> "Compassionate",
17=> "Peaceful",
18=> "Beautiful",
19=> "Pitiful",
20=> "Twisted",
21=> "Nameless",
22=> "Hopeful",
23=> "Harmonious",
24=> "-With-Two-Voices",
25=> "Watchful",
26=> "Velvet",
27=> "Silk",
28=> "Harsh",
29=> "Ancient",
30=> "Imperial",
31=> "Lost",
32=> "-Who-Waits",
33=> "Conquering",
34=> "Silent",
35=> "-in-Yellow",
36=> "Greedy",
37=> "Mad",
38=> "Green",
39=> "Fat",
40=> "Barrow-",
41=> "Proud",
42=> "Love's",
43=> "Purple",
44=> "-in-the-Green",
45=> "-on-the-Hill",
46=> "-o'-the-Isles",
47=> "Floating",
48=> "-in-the-Dark",
49=> "Cave",
50=> "Thin",
51=> "Burrowing",
52=> "'s Mercy",
53=> "'s Ruin",
54=> "High",
55=> "-of-the-Ancients",
// entries from here on are only for MF/LL
56=> "Electric",
57=> "Gamma",
58=> "Radiation",
59=> "Brain",
60=> "Xeno",
61=> "Clone",
62=> "Waste",
63=> "Toxic",
64=> "Cybernetic",
65=> "Cyber-",
);
$thirdnum=55;
if ($system=="ll") {
$thirdnum=65;
}

$namefourth=array(
1=> "Mother",
2=> "Sister",
3=> "Companion",
4=> "Hag",
5=> "Protector",
6=> "Servant",
7=> "Heart",
8=> "Eye",
9=> "Knight",
10=> "King",
11=> "Champion",
12=> "Judge",
13=> "Sower",
14=> "Hand",
15=> "Finger",
16=> "Warrior",
17=> "Forgiver",
18=> "Sleeper",
19=> "Lady",
20=> "Gentleman",
21=> "Drinker",
22=> "Emperor",
23=> "Guide",
24=> "Bird",
25=> "Duke",
26=> "Duchess",
27=> "Hisser",
28=> "Peacock",
29=> "Dandy",
30=> "Conqueror",
31=> "Worm",
32=> "Folk",
// entries from here on are only for MF/LL
33=> "Dog",
34=> "Leech",
35=> "Scavenger",
36=> "Cyborg",
37=> "Android",
38=> "Commando",
39=> "Spawn",
);
$fourthnum=32;
if ($system=="ll") {
$fourthnum=39;
}

// have to make sure $firstnum<>$secondnum, and $thirdnum<>$fourthnum
// otherwise might get infinite loop, where it's trying to get one
// that's unused, but the only ones left are forbidden combinations.

$namecount=array();
$crname=array();
$crnick=array();
$xlow=array();
$xhigh=array();
$ylow=array();
$yhigh=array();
$mrdesc=array(
"null",
"only gets its full adds for the first Combat Round. After that, it gets half its adds. Its dice are treated normally.",
"always gets @@D dice and @@A adds, regardless of how wounded it is.",
"always gets @@D dice. Its adds are based on its current MR.",
"gets both dice and adds based on its current MR.",
);
if ($adds==1) {
$mrdesc[4]="gets its full adds in every Combat Round.";
$mrdesc[2]="gets @@D dice and @@A adds each Combat Round, regardless of how wounded it is or what round it is.";
}
$appani=array(
1=> "an amoeba",
2=> "an ant",
3=> "an ape",
4=> "an armadillo",
5=> "a bat",
6=> "a bee",
7=> "a bird of paradise",
8=> "a blowfly",
9=> "a butterfly",
10=> "a cat",
11=> "a scorpion",
12=> "a crocodile",
13=> "a crow",
14=> "a dog",
15=> "a elephant",
16=> "a crow",
17=> "a shark",
18=> "a horse",
19=> "a camel",
20=> "a zebra",
21=> "an iguana",
22=> "a jackal",
23=> "a kangaroo",
24=> "a mouse",
25=> "an owl",
26=> "a parrot",
27=> "a rhinoceros",
28=> "a scarab/dung beetle",
29=> "a seagull",
30=> "a snail",
31=> "a snake",
32=> "a spider",
33=> "a tiger",
34=> "a lion",
35=> "a jaguar",
36=> "a turtle",
37=> "a vulture",
38=> "a walrus",
39=> "a warthog",
40=> "a wolf",
41=> "a rabbit",
42=> "an octopus",
43=> "an angel",
44=> "a bear",
45=> "a deer",
46=> "an ox",
47=> "a skeleton",
48=> "a grasshopper",
49=> "a triceratops",
50=> "a tyrannosaurus rex",
);
$aniapp=50;

$apppla=array(
1=> "a rose",
2=> "a venus flytrap",
3=> "a water lily",
4=> "a leaf",
5=> "a sunflower",
6=> "a sakura/cherry blossom tree",
7=> "a mushroom",
8=> "a weeping willow",
9=> "a bunch of flowers",
10=> "a laurel wreath",
11=> "a tree (with green leaves)",
12=> "a tree (with autumn leaves)",
13=> "a tree (with no leaves)",
14=> "a palm tree",
15=> "a hedge",
16=> "a clump of seaweed",
17=> "a patch of mould",
18=> "a pile of leaves",
19=> "a dandelion",
20=> "a haystack",
21=> "a four-leaf clover",
22=> "a tumbleweed",
23=> "a wooden hut",
24=> "a piece of driftwood",
25=> "a plume of smoke",
);
$plaapp=25;

$apphum=array(
1=> "a dwarf",
2=> "an elf",
3=> "a hobbit",
4=> "a baby",
5=> "a child of around ten years old",
6=> "a beautiful woman",
7=> "a strong, handsome youth",
8=> "a wrinkled crone",
9=> "a wizened old man",
10=> "whoever is standing closest to it at any given time",
11=> "a person that could be either a boy or a young woman",
12=> "a person that could either be a feminine-looking young man, or a masculine-looking woman",
13=> "whoever the delver standing closest to it will respond best to (eg a parent, first love, or favourite teacher)",
);
$humapp=13;

if ($system=="ll") {
$apphum[3]="a halfling";
}

$appcha=array(
1=> "has the body of @@HU, but a head like @@AN.",
2=> "has the body of @@HU, but a head which looks like @@PL.",
3=> "has a body which looks like @@EI, but with the face of @@HU.",
4=> "looks like a wooden carving of @@EH.",
5=> "looks like a wooden puppet of @@EA.",
6=> "looks like a child's doll of @@EA.",
7=> "looks like @@AN, but can talk, use weapons etc.",
8=> "looks like @@EH, but insubstantial and ghostly.",
9=> "looks like the animated corpse of @@EA.",
10=> "looks like @@EA, but fiery and demonic.",
11=> "takes the form of @@HU, but may revert to its true form, which looks like @@EI.",
12=> "looks like the offspring of @@AN and @@A2.",
13=> "looks like @@PL which has grown into the shape of @@EA.",
14=> "looks like a statue^ of @@PL.",
15=> "looks like a statue of @@HU.",
16=> "looks like a statue^^ of @@AN.",
17=> "looks like a hedge, cut into the shape of @@AN.",
18=> "looks like @@HU above the waist, @@EI below.",
19=> "looks like the offspring of a human and @@AN.",
20=> "looks like the disembodied head of @@EA.",
21=> "is a robot, built to resemble @@EH.",
22=> "looks like @@HU on one side of its body, @@H2 on the other.",
23=> "looks like @@HU on one side of its body, @@AN on the other.",
24=> "looks like @@HU, wearing a mask of @@AN.",
25=> "looks like @@AN, wearing a mask of @@HU.",
26=> "looks like @@AN, wearing a mask of @@A2.",
27=> "looks like @@A2, wearing a mask of @@AN.",
);

// 26 and 27 are because, if there's a theme, only $a2 can be set.

// @@EA means either @@HU or @@AN.
// @@EH means either @@HU, @@AN, or @@PL.
// @@EI means either @@AN or @@PL.
// @@A2 same list as @@AN, but can't be the same choice.
// @@H2 same list as @@HU, but can't be the same choice.
$chaapp=27;

$sname=array("null","STR","INT","LK","CON","DEX","CHR","SPD","WIZ");
$attnum=7+$wiz;
if ($system=="ll") {
$sname[3]="WIL/WIS";
$sname[6]="CHA";
$attnum=6;
}
$shallow=array();
$deep=array();
$climates=array(
1=> "Desert-like",
2=> "Hot and dry",
3=> "Hot and damp",
4=> "Mild",
5=> "Cold",
6=> "Logical",
);
$climated=array(
"Desert-like"=> "During the early morning, the STR requirement for armour is doubled. From mid-morning to sunset, the STR requirement for armour is tripled. Shields aren't affected in either case. Delvers whose armour is now too heavy will have time to remove it or get to an area with a lower temperature.<br><br>At night, the temperature drops rapidly: every hour of in-game time, unless the delvers have made a fire, each delver must make a save on CON @@2. If they fail, they take damage equal to the amount they failed by (critical failure counts as a failure by at least 1).",
"Hot and dry"=> "The STR requirement for armour is doubled. Shields aren't affected. Delvers whose armour is now too heavy will have time to remove it or get to an area with a lower temperature.",
"Hot and damp"=> "The STR requirement for armour is multiplied by 3/2. Delvers whose armour is now too heavy will have time to remove it or get to an area with a lower temperature.<br><br>Every hour of in-game time, every delver with any wounds (not damage due to other sources such as cold) must make a save on CON @@1. If they fail, they've become sick (characters who are sick don't need to keep making the save). They immediately lose 1-3 CON, and will not recover CON in the usual way. If a sick delver moves to an area of mild temperature, they may make a save on their <i>maximum</i> CON at the same level every four hours of in-game time. If they succeed, they're no longer sick, and will heal normally.",
"Mild"=> "Delvers won't suffer any ill effects from the temperature.",
"Cold"=> "Every hour of in-game time, unless the delvers have made a fire, each delver must make a save on CON @@2. If they fail, they take damage equal to the amount they failed by (critical failure counts as a failure by at least 1).",
);

if ($system=="ll") {
$climated["Desert-like"]="During the early morning, characters must have a CON of at least 11 to be able to wear metal armour. From mid-morning to sunset, characters must have a CON of at least 11 to wear <i>any</i> armour, and CON of at least 14 to wear metal armour. Characters whose armour is now too heavy will have time to remove it or get to an area with a lower temperature before they pass out.<br><br>At night, the temperature drops rapidly: every hour of in-game time, unless the delvers have made a fire, each delver must roll 2d10. If the result is higher than their CON, they take damage equal to the difference. A successful save vs Poison or Death will halve the damage (rounded up).";
$climated["Hot and dry"]="Characters must have a CON of at least 11 to be able to wear metal armour. Characters whose armour is now too heavy will have time to remove it or get to an area with a lower temperature before they pass out.";
$climated["Hot and damp"]="Every hour of in-game time, every delver with any wounds (not damage due to other sources such as cold) must make a save vs Poison or Death. If they fail, they've become sick (characters who are sick don't need to keep making the save). They immediately lose 1-3 Hit Points, treat their STR as being 1d6 lower than its real value, and will not recover Hit Points in the usual way. If a sick delver moves to an area of mild temperature, they may make a save vs Poison or Death every four hours of in-game time. If they succeed, they're no longer sick (however they don't get their lost Hit Points back instantly - they have to wait for them to heal normally).";
$climated["Mild"]="The party won't suffer any ill effects from the temperature";
$climated["Cold"]="Every hour of in-game time, unless the delvers have made a fire, each delver must roll 2d10. If the result is higher than their CON, they take damage equal to the difference. A successful save vs Poison or Death will halve the damage (rounded up).";
}

$climatew=array(
"Hot and damp"=> "10 minutes",
"Hot and dry"=> "40 minutes",
"Cold"=> "40 minutes",
"Mild"=> "20 minutes",
"Desert-like"=> "40 minutes of in-game time at night or in the early morning, once every 80 minutes of in-game time otherwise",
);
$cnum=5;
if ($system=="tt") {
// 'logical' levels are only for Tunnels & Trolls.
$cnum=6;
if (rand(1,3)==1) {
$climatew["Logical"]="15 minutes";
} elseif (rand(1,2)==1) {
$climatew["Logical"]="30 minutes";
} else {
$climatew["Logical"]="hour";
}
$climated["Logical"]=$climated["Logical"]."all spells cast in this environment ";
if (rand(1,3)==1) {
$ec1=rand(1,6);
$ec2=rand(1,6)+rand(1,6);
$climated["Logical"]=$climated["Logical"]."need ".$ec1." extra INT and ".$ec2." extra DEX compared to their normal requirements. If a spell-caster tries to cast a spell but doesn't have the INT and/or DEX, they waste a Combat Round but don't pay any cost.";
} elseif (rand(1,2)==1) {
$ec=rand(1,6)+rand(1,6);
$climated["Logical"]=$climated["Logical"]."will cost an extra ".$ec." ".$sname[1+(7*$wiz)].".";
} else {
$ec=rand(1,5);
$climated["Logical"]=$climated["Logical"]."have a ".$ec." in 6 chance of failure. If a spell fails the spell-caster pays half the ".$sname[1+(7*$wiz)].", rounded down. Trying to cast a spell and failing still takes a whole Combat Round.";
}
$climated["Logical"]=$climated["Logical"]."<br><br>Warriors won't notice anything different. Wizards and Rogues will know that there'll be some problem with casting spells, but won't know what until they actually try to cast one. Creatures of the dungeon that can cast spells will know what the effects will be.";
}
$lclimate=array();
$ss=2;
$dshr=array();
$entrance=array (
1=> "@@A used by an evil cult as a means of sacrificing people.",
2=> "@@A easy to find guides, maps etc, since the locals make a lot of their income from equipping adventurers.",
3=> "under a @@T. The entrance has been exposed by accident.",
4=> "under a @@T. It's entered via a trapdoor in a cellar.",
5=> "under a @@T. It's entered via a secret door in a public building.",
6=> "inside the body of a giant @@B.",
7=> "entered via @@C lair.",
8=> "behind a waterfall.",
9=> "in an abandoned mine.",
10=> "accidentally discovered during extensions to a mine.",
11=> "in an extinct volcano.",
12=> "entered by a secret cave. The cave can only be entered via the water.",
13=> "on another plane of existence, and entered and exited by a magic portal.",
14=> "@@A widely advertised by the occupants of the dungeon, in order to attract adventurers to their doom.",
15=> "in a tomb.",
16=> "entered via a stairway inside a hollowed-out tree.",
);
$ennum=16;

$sett=array(
1=> "city",
2=> "town",
3=> "village",
4=> "castle",
5=> "temple",
);
$settnum=5;

$ruins=array(
1=> "airport",
2=> "military base",
3=> "bomb shelter",
4=> "factory",
5=> "holiday resort",
6=> "farm",
7=> "hospital",
8=> "mine",
9=> "missile base",
10=> "power plant",
11=> "shopping mall",
12=> "spaceport",
);
$ruinnum=12;



$map=array();
$stairs=array();
$exit=array();
$doors=array();
$doorsymbol=array("null","+","#","%");
$exitsave=array();
$stype=array(
1=> "non-printing",
2=> "wall",
3=> "tunnel",
4=> "wall",
5=> "non-printing",
6=> "wall",
7=> "corner",
8=> "2only",
9=> "corner",
10=> "wall",
11=> "tunnel",
12=> "2only",
13=> "centre",
14=> "2only",
15=> "tunnel",
16=> "wall",
17=> "corner",
18=> "2only",
19=> "corner",
20=> "wall",
21=> "non-printing",
22=> "wall",
23=> "tunnel",
24=> "wall",
25=> "non-printing",
);

$gods=array(
1=> array ("Thoth","ibis-headed","god","magic","@@Lfor the next 4 hours of in-game time all spells the delver casts have their cost reducted by an amount equal to the level of the save (to a minimum cost of 1). For example, if the delver makes a level 3 save, for 4 hours all spells cost them 3 less."),
2=> array ("Guan Yin","motherly","goddess","compassion","The save is based on how wounded the character is: divide the amount of CON they've lost by 10, and round down (minimum 0). If the save succeeds, and if the delver can refrain from killing any living thing for 24 hours of in-game time (robots don't count), they'll be healed back to their full CON. If the save fails the delver won't lose CON. Instead, they'll be <i>unable</i> to wound any living thing for 24 hours. They can still contribute to the delvers' Hit Point Total using hand-to-hand weapons (defending themselves but not attacking). However if the delvers win a round, the damage is reduced by the total amount that this delver contributed, to a minimum of zero."),
3=> array ("Ra","falcon-headed","god","the sun","@@Lfor the next 4 hours the delver is immune to the damaging effects of cold, and the increase in STR required for armour in the heat."),
4=> array ("Hestia","virginal","goddess","the home","@@Lthis area will be free from wandering monsters for the next 24 hours."),
5=> array ("Hermes","swift-footed","god","thieves","@@Lthe delver may count one future failed save of the same level or less as a success, if the save was made to hide, outrun someone, search an area or disarm a trap."),
6=> array ("Kali","fierce","goddess","destruction","@@Lin a future Combat Round where the delver is fighting hand-to-hand, they can invoke the blessing of destruction. For that round, their strike contributes to the delvers' Hit Point Total, but does its damage as a minimum, in the same way as a Take That You Fiend spell. Armour and shields still reduce the damage."),
7=> array ("Loki","sly","god","transformation","@@Lthe next creature encountered will perceive the delvers as members of their own species."),
8=> array ("Fortuna","veiled and blind","goddess","luck","@@Lthe delver may count one future failed LK save of the same level or less as a success."),
9=> array ("Xipe Totec","flayed and bloody","god","agriculture","@@Lthe delver is blessed with corn sufficient for a number of meals equal to the level they made the save at."),
10=> array ("Freya","golden-haired","goddess","wealth","@@Lthe delver is told the location of the nearest gold (other than that carried by the delvers, or in a vending machine), and what monsters and/or traps are guarding it. Note that this applies only to gold, not to treasure in general."),
11=> array ("Lug","royal","god","every skill","The save is made at a level equal to the character's level. If it succeeds, for one future Combat Round or saving roll, the delver may use any of INT, DEX, or STR in place of any other. If the delver gains a level before using this blessing, and if your game uses Talents, they gain two Talents instead of one and the blessing is 'used up.'"),
12=> array ("Diana","graceful","goddess","hunting","The save is made at the character's level. If it succeeds, the delver may count one future missed missile attack as a hit. If they fail, they don't lose CON. Instead, they are cursed to be hunted: the GM should roll for wandering monsters twice as often, until two groups of wandering monsters have been defeated."),
13=> array ("Prometheus","brave","god","fire","The save is made at a level equal to the character's level. If it succeeds, the character can cast the Wall of Fire spell once, with no cost, regardless of their Type and attributes."),
14=> array ("Sophia","winged","goddess","wisdom","@@Lthe delver may count one future failed INT save of the same level or less as a success."),
15=> array ("Baron Samedi","skull-faced","god","death and resurrection","This shrine can bring anyone back to life who's been dead for an hour or less. The level of the save depends on the delver or creature being resurrected. For Monster Rated monsters, look at their MR. For creatures or delvers with full attributes, look at the total of their INT, STR, and LK. In either case, divide by 10 and round down. If it succeeds, the subject is brought back to life, with 1 CON or 1 MR."),

16=> array ("Pan","goat-legged","god","nature","The save is based on how wounded the character is: divide the amount of CON they've lost by 10, and round down (minimum 0). If the save succeeds, the delver will heal twice as quickly as they would otherwise. This effect will last until they're back to their full CON, or until they wound any natural creature (robots, and creatures described as 'insubstantial and ghostly', 'fiery and demonic', or as looking like a wooden puppet or carving or a doll, don't count).<br><br>If the save fails, the delver doesn't lose CON. Instead, every exit from this area is covered with a wall of thorns, which will take four hours for one human to cut through. Dwarves, elves and hobbits will work twice as fast. Fairies and leprechauns will work half as fast. Any creature trying to walk through it will fall asleep for 1-6 days (like the Wall of Thorns spell, but without any chance of avoiding this effect). If the GM rolls wandering monsters while the thorns are present, they should randomise which exit they come from, and secretly roll a dice:<br><br>* 1-2 they start cutting through the thorns.<br>* 3-4 they try to walk through the thorns and fall asleep.<br>* 5-6 they leave."),
);
$gnum=16;
// if $godd==0, only slots 3 and 4 are used,
// and it's random whether a given deity is a god or goddess.

// slot 0 is singular, 1 is plural
// 2 is value, 3 is weight.
$misceqpt=array(
1=> array ("A day's worth of rations","days worth of rations",10,20),
2=> array ("A 5 foot/1.5 metre rope","ropes (each 5 feet/1.5 metres long)",.5,25),
3=> array ("A 10 foot/3 metre rope","ropes (each 10 feet/3 metres long)",1,50),
4=> array ("A pair of calf-high boots (wearable by any creature from leprechaun to human size)","pairs of calf-high boots (wearable by any creature from leprechaun to human size)",10,40),
5=> array ("A pair of calf-high boots (wearable by fairy-sized creatures)","pairs of calf-high boots (wearable by fairy-sized creatures)",10,4),
6=> array ("A blanket","blankets",2,20),
7=> array ("A copper flask (holds 1 pint/half a litre)","copper flasks (each holds 1 pint/half a litre)",5,2),
8=> array ("A compass","compasses",5,1),
9=> array ("A set of lock picks (anyone using these may add 5 to their roll when trying to pick a lock)","sets of lock picks (anyone using these may add 5 to their roll when trying to pick a lock)",35,35),
10=> array ("A tent (including poles), big enough for four humans","tents (including poles), each big enough for four humans",40,250),
11=> array ("A small hand-mirror","small hand-mirrors",5,1),
12=> array ("A drinking horn","drinking horns",4,15),
13=> array ("A piece of chalk","pieces of chalk",1,0),
14=> array ("A wooden dice","wooden dice",1,0),
15=> array ("A wooden cup","wooden cups",2,1),
16=> array ("A six-foot/2 metre long wooden pole","wooden poles, each 6 feet/2 metres long",7,40),
17=> array ("A metal spoon","metal spoons",2,0),
18=> array ("A metal fork","metal forks",2,0),
19=> array ("A metal knife (for eating with - it's no use in combat)","metal knives (for eating with - they're no use in combat)",2,0),
20=> array ("A chalk-board (8 by 8 inches/20 by 20 cm)","chalk-boards (8 by 8 inches/20 by 20 cm)",2,9),
);
$eqptnum=20;

// 0 is name, 1 is weight, 2 is value.
$music=array(
1=> array ("bagpipes",30,500),
2=> array ("small harp",100,100),
3=> array ("large harp",1000,1000),
4=> array ("drum",20,10),
5=> array ("flute",5,50),
6=> array ("sitar",50,500),
7=> array ("lute",50,300),
8=> array ("pan pipes",5,50),
);
$musnum=8;

$arm=array (
1=> array ("helmet",1,1,10,25),
2=> array ("helmet",2,1,15,35),
3=> array ("helmet",3,1,20,50),
4=> array ("shield",3,1,10,75),
5=> array ("shield",4,5,35,300),
6=> array ("shield",5,5,65,450),
7=> array ("shield",6,6,100,550),
8=> array ("breastplate",1,1,15,50),
9=> array ("full suit of armour",2,1,30,70),
10=> array ("breastplate",3,1,30,150),
11=> array ("breastplate",4,2,70,240),
12=> array ("breastplate",4,3,35,500),
13=> array ("full suit of armour",5,1,40,170),
14=> array ("breastplate",5,2,200,570),
15=> array ("full suit of armour",6,3,90,270),
16=> array ("breastplate",6,6,150,800),
17=> array ("full suit of armour",7,6,70,720),
18=> array ("full suit of armour",8,4,385,860),
19=> array ("breastplate",8,5,100,900),
20=> array ("full suit of armour",9,11,285,1160),
21=> array ("full suit of armour",11,10,480,950),
22=> array ("full suit of armour",14,12,600,1200),
);
$armnum=22;
// 0 is broad type, 1 is protection, 2 is STR required
// 3 is cost, 4 is weight

$handw=array(
1=> array ("sword",6,2,22,18,0,135,150,0,2),
2=> array ("sword",6,1,21,18,0,125,165,0,2),
3=> array ("sword",6,0,21,18,0,120,170,0,2),
4=> array ("sword",5,2,17,14,0,110,160,0,2),
5=> array ("sword",5,0,16,12,0,90,150,0,2),
6=> array ("sword",3,4,15,10,0,70,120,0,1),
7=> array ("sword",3,2,10,7,0,50,70,0,1),
8=> array ("sword",3,0,7,3,0,35,30,0,1),
9=> array ("sword",4,4,12,13,0,75,110,0,1),
10=> array ("sword",4,0,10,11,0,60,100,0,1),
11=> array ("sword",3,4,10,14,0,80,20,0,1),
12=> array ("axe",6,3,21,10,0,140,220,0,2),
13=> array ("hatchet",2,2,7,5,10,28,35,15,1),
14=> array ("mace",5,2,17,3,0,120,200,0,2),
15=> array ("hammer",5,1,16,3,0,85,300,0,1),
16=> array ("morning star",5,0,17,11,0,140,110,0,1),
17=> array ("mace",3,4,12,7,0,120,125,0,1),
18=> array ("club",3,0,5,2,0,15,50,0,1),
19=> array ("polearm",7,0,14,13,0,210,300,0,2),
20=> array ("polearm",6,5,15,12,0,250,190,0,2),
21=> array ("pike",6,0,16,12,0,160,100,0,2),
22=> array ("staff",2,0,2,8,0,10,50,0,1),
23=> array ("club",2,0,2,1,0,10,20,0,1),
24=> array ("trident",4,3,10,10,10,60,75,10,1),
25=> array ("dagger",2,5,7,10,0,30,25,0,1),
26=> array ("dagger",2,5,6,6,30,30,20,10,1),
27=> array ("dagger",2,4,2,4,0,25,10,0,1),
28=> array ("dagger",2,3,1,4,23,20,33,10,1),
29=> array ("dagger",2,1,1,4,10,18,16,10,1),
30=> array ("dagger",2,-2,1,1,8,5,10,10,1),
);
$handnum=30;

// put nets in later, as they have their own rules.

// 0 is broad type, 1 is dice, 2 is adds, 3 is STR required,
// 4 is DEX to use hand-to-hand, 5 is DEX to throw, 6 is cost,
// 7 is weight, 8 is range, 9 is 'handedness'.

$rangew=array(
1=> array ("javelin",2,0,5,7,"self",10,30,40,1),
2=> array ("sling staff",3,0,5,11,"stone",5,100,150,2),
3=> array ("sling",3,0,5,11,"stone",1,10,100,1),
4=> array ("throwing star",1,0,2,10,"self",30,10,10,1),
5=> array ("throwing knife",4,0,8,15,"self",180,125,30,1),
6=> array ("crossbow",8,0,15,10,"bolt",600,250,100,2),
7=> array ("crossbow",5,0,15,10,"bolt",250,180,100,2),
8=> array ("crossbow",4,0,12,10,"bolt",170,120,90,2),
9=> array ("bow",6,0,25,17,"arrow",200,70,100,2),
10=> array ("bow",4,3,15,15,"arrow",100,60,140,2),
11=> array ("bow",2,0,9,15,"arrow",50,30,60,2),
12=> array ("bullwhip",0,0,0,15,"self",30,45,5,1),
13=> array ("pistol",5,15,10,8,"self",1000,50,"any",1),
);
$rangenum=13;

// 0 is broad type, 1 is dice, 2 is adds, 3 is STR required,
// 4 is DEX required, 5 is ammunition - "self" means it's 'ammunition'
// in itself (eg javelins and throwing stars), anything else refers
// to the $ammo array. 6 is cost, 7 is weight, 8 is range, 9 is
// 'handedness'.

$ammo=array(
'stone'=> array ("100 sling stones",3,50),
'bolt'=> array ("10 crossbow bolts",5,10),
'arrow'=> array ("24 arrows",40,10),
);
// 0 is name to print, 1 is value, 2 is weight.

$poisons=array(
1=> array ("curare",100,"Curare doubles the effect of an edged weapon, after damage reduction for armour and/or shields"),
2=> array ("spider venom",150,"If the damage from a weapon coated in spider venom isn't reduced to zero by armour or shields, the victim will be unaffected in the next combat round, their Hit Point Total will be halved the round after that, and they will be totally paralysed the round after that"),
3=> array ("Hellfire Juice",500,"Any weapon coated in Hellfire Juice (even bashing weapons like clubs) will multiply their damage by 3/2, after damage reduction for armour and/or shields"),
4=> array ("dragon venom",1000,"Dragon venom multiplies the effect of an edged weapon by four, after damage reduction for armour and/or shields"),
);
$poisnum=4;
// 0 is name, 1 is cost, 2 is effect.

$jewel=array (
1 => array ("rose pink quartz",1),
2 => array ("smokey quartz",2),
3 => array ("green quartz",3),
4 => array ("citrine",4),
5 => array ("alexandrite",5),
6 => array ("jasper",6),
7 => array ("cat's eye",7),
8 => array ("agate",8),
9 => array ("peridot",9),
10 => array ("mother-of-pearl",10),
11 => array ("sardonyx",11),
12 => array ("carnelian",12),
13 => array ("amber",13),
14 => array ("chalcenody",14),
15 => array ("coral",15),
16 => array ("jet",16),
17 => array ("malachite",17),
18 => array ("lapis lazuli",18),
19 => array ("garnet",19),
20 => array ("black onyx",20),
21 => array ("topaz",20),
22 => array ("turquoise",21),
23 => array ("amethyst",21),
24 => array ("opal",22),
25 => array ("sea opal",22),
26 => array ("black opal",23),
27 => array ("aquamarine",23),
28 => array ("tiger's eye",24),
29 => array ("tanzanite",24),
30 => array ("jade",25),
31 => array ("black jade",35),
32 => array ("pearl",45),
33 => array ("ruby",55),
34 => array ("fire opal",65),
35 => array ("blue sapphire",75),
36 => array ("white sapphire",85),
37 => array ("diamond",95),
38 => array ("emerald",100),
);
$jnum=37;
// 0 is name, 1 is 'base value' (multiplied by 1-4)

$spells=array(
1=> array ("Detect Magic",1,0),
2=> array ("Lock Tight",1,1),
3=> array ("Knock Knock",1,2),
4=> array ("Will-o-the-wisp",1,1),
5=> array ("Oh There It Is",1,4),
6=> array ("Take That You Fiend",1,6),
7=> array ("Vorpal Blade",1,5),
8=> array ("Oh-Go-Away",1,5),
9=> array ("Omnipotent Eye",2,5),
10=> array ("Hidey Hole",2,10),
11=> array ("Cateyes",2,6),
12=> array ("Glue-You",2,8),
13=> array ("Little Feets",2,8),
14=> array ("Mirage",2,8),
15=> array ("Poor Baby",2,2),
16=> array ("Whammy",2,10),
17=> array ("Magic Fangs",2,1),
18=> array ("Curses Foiled",3,7),
19=> array ("Slush Yuck",3,15),
20=> array ("Rock-a-bye",3,11),
21=> array ("Dis-Spell",3,11),
22=> array ("Blasting Power",3,8),
23=> array ("Freeze Pleeze",3,8),
24=> array ("Fly Me",3,7),
25=> array ("Healing Feeling",3,14),
26=> array ("Too-Bad Toxin",4,7),
27=> array ("Wink-wing",4,14),
28=> array ("Smog",4,11),
29=> array ("Dum-Dum",4,8),
30=> array ("Double-double",4,18),
31=> array ("Protective Pentagram",4,12),
32=> array ("Upsidaisy",4,9),
33=> array ("Mind Pox",5,39),
34=> array ("Dear God",5,30),
35=> array ("ESP",5,20),
36=> array ("Second Sight",5,25),
37=> array ("Breaker Breaker",5,25),
38=> array ("Wall of Fire",6,26),
39=> array ("Wall of Ice",6,26),
40=> array ("Wall of Thorns",6,14),
41=> array ("Wall of Stone",6,20),
42=> array ("Wall of Iron",6,23),
43=> array ("Zappathingum",7,24),
44=> array ("Zapparmour",8,30),
45=> array ("Zombie Zonk",8,36),
46=> array ("Medusa",9,30),
47=> array ("Death Spell",9,40),
48=> array ("Hellbomb Bursts",10,36),
49=> array ("Bigger Is Better",11,33),
);
$spnum=49;
// 0 is name, 1 is level, 2 is cost
// (used for some potions)

$xspells=array(
1=> array ("Ariana's Spectral Aquarium",10,"This spell creates a floating globe of water, filled with twenty ghostly fish. The water is drinkable, and the ghostly fish can be 'eaten'. Each fish has a 1 in 18 chance of being poisonous (roll 2 dice - the fish is poisonous if the two dice add up to exactly 3). A poisonous fish does a number of dice damage equal to the level of the caster. Wearing a holy symbol will grant immunity to the poison. The ghost-fish have no taste or nutritional value, but they allow the eater to fly for 1d3 minutes, or become 1 foot tall for 1d6 minutes (eater's choice). Creatures with cat features will value the globe and ghost-fish at a total of 100gp per level of the caster."),
2=> array ("Bran's Melancholy Vista",20,"Supernatural shadows fill an area 333 yards/metres in diameter (in the open), or 1 level of a dungeon, for one hour. The effective distance of all light sources (even magical ones) will be cut in half. Even in direct sunlight trees and buildings will cast thick, shifting shadows and the light will be like twilight. Generally saving rolls to hide will be 2 levels lower, or saving rolls to notice someone will be 2 levels higher."),
3=> array ("Accalon's Vexatious Globes",10,"Three stones rise from the ground and circle the caster for up to 1 hour. One is blue, and allows the caster to add 3 to all saving rolls they make, except ranged weapon attacks. One is green, and acts as a shield, absorbing two damage. The third is black, and will absorb the first spell cast at the caster, after which it disappears. The stones can be attacked directly: they're about the size of a rabbit or rat, and have 10 hit points and the equivalent of 2 points of armour. The stones mean that the caster effectively takes up twice as much room as they would otherwise."),
4=> array ("Sigrid's Hermetical Cocoon",20,"The caster may trap any single creature, except for statted creatures whose level is higher than the caster, in a magical cocoon. The cocoon will resist all spells, but can be physically attacked. It has 100 hit points, and the equivalent of 2 points of armour. If the cocoon isn't destroyed within 6 hours, the GM should roll a dice to see how the victim emerges:<br>1 Dead<br>2 With 3 dice more CON or MR<br>3 With half the STR or MR.<br>4 With wings (roll again: 1-3 bat-like 4-6 bird-like). They can fly if they're carrying half their Weight Possible or less. If the victim already has wings, they emerge without them.<br>5 As a different person of the victim's kindred (level 1 if relevant), with a desire to serve the caster.<br>6 As a beautiful spray of colours which will last for 7 days, and have a hypnotic effect. All statted creatures who see it must make a save against INT at the caster's level, or watch the colours until they fade."),
5=> array ("Idril's Scintillant Cage",15,"In a circle designated by the caster, no more than 13 yards/metres in radius, spectral crystals grow from the ground and trap anyone within the circle. The effect lasts for 10 minutes. Creatures inside can see and breathe, but can't move. There's a 25% chance that a spell cast into or through the cage will reflect back at the caster."),
6=> array ("Sobekhotep's Audacious Deceit",15,"Roll one dice and multiply by 10 minutes. For that period, any silver object within 20 yards/metres that the caster sees will teleport into their backpack, pockets etc. For each robot or machine, roll 1 dice: on a 6, it contains a vital silver part and is destroyed by this spell. Normal weapons, armour and shields are not made of silver. While the spell is in effect, the caster must treat their CHR as 5 less than its real value when dealing with any creature with bird-like features."),
7=> array ("The Incomparable Banquet of King Ranjit",10,"This spell creates a delicious and huge banquet, more than enough to feed everyone in the room. For the purposes of trading, most creatures will treat the banquet as being worth 80gp. Creatures with hobbit-like features will treat it as worth 120gp. The food is high-quality and nourishing, but doesn't bewitch the eater. For example, someone who is attacked will stop eating in order to defend themselves or run away. If the party is being chased by Monster Rated creatures, there is normally a 2 in 6 chance they'll break off their pursuit to eat the banquet. Statted creatures will normally do the same if they fail a level 0 save on INT - level 1 for creatures with hobbit-like features. The caster may cast the spell in order to eat the banquet themselves. However it creates the kind of food that won't last long and can't easily be transported, such as large cakes, so it's unlikely to provide more than 1 meal per person."),
8=> array ("Sigrid's Indolent Cartography",10,"This spell creates a piece of parchment, with an entirely accurate map on it. The map will depict the current dungeon level, a single settlement, or an area of wilderness centred on the caster (depending on whether the spell is cast in a dungeon, settlement or wilderness). If the spell is used to create a map of wilderness, the area shown will be 56km/35 miles east-west by 80km/50 miles north-south. All maps will show the caster's current location, a key, and a scale. Dungeon maps will show all walls and tunnels, and any exits up or down. Illusory walls will be shown on the map as if they were real walls. The contents of the rooms, such as traps, monsters and treasure, won't be shown. Maps of settlements will include street and district names, and major landmarks. Wilderness maps will show the type of terrain, but no man-made features such as roads or towns. The location of dungeons may or may not be shown on wilderness maps: natural features such as the entrances to cave systems will be, artificial structures won't be."),
);
$xspnum=8;
$elweir=6;
// First $elweir are spells from 'Eldritch Weirdness', converted to T&T.
// 0 = name, 1 = cost, 2 = detailed description.
// these spells have no level (their cost is the same for any caster)

// next one: someone's Splendid Ectoplasm.

$ewspells=array();
// whether extra spells are mentioned anywhere
// (ie do I need to give the detailed description)

$diplo=array("null","at war","hostile","allied","strongly allied","wary");
$dipnum=5;
$dipused=array();
$dipex=array(
1=> "If the two species come into contact, they'll fight each other or run. If the delvers are perceived as being allied with one species by the other, they'll have a -10 penalty on their CHR rolls. If the delvers present evidence that they've attacked one of the species to the other, they'll have a +6 bonus on their CHR rolls",
2=> "If the two species come into contact, they'll often end up fighting each other. They certainly won't allow the other species to pass through their territory. If the delvers are perceived as being allied with one species by the other, they'll have a -6 penalty on their CHR rolls. If the delvers are being chased by one species, the other will usually shelter them, if only out of spite",
3=> "The two species are quite friendly. They'll at least listen to the other species' opinion and discuss with them if possible, when deciding what to do with the delvers. If the delvers are perceived as being hostile to one species, they'll have a -10 penalty on their CHR rolls when dealing with the other",
4=> "The two species will regard an attack on each other as an attack on them. They'll usually respect the decision of the other species in regard to how to treat the delvers",
5=> "The two species would like to destroy each other, but fear the results of open conflict. If the delvers are perceived as being allied with one species by the other, they'll have a -6 penalty on their CHR rolls. The creatures are likely to help the delvers with any plan which will weaken the other species, but only if they can do so in a way that allows them to deny involvement",
);
if ($system=="ll") {
for ($z=1;$z<=5;$z++) {
$dipex[$z]=str_replace("their CHR rolls","their Monster Reaction rolls",$dipex[$z]);
$dipex[$z]=str_replace("they'll have a -10 penalty on","they must add 5 to",$dipex[$z]);
$dipex[$z]=str_replace("they'll have a -6 penalty on","they must add 3 to",$dipex[$z]);
$dipex[$z]=str_replace("they'll have a +6 bonus on","they can take 3 from",$dipex[$z]);
}
}
$isdiplo=array();

$doing=array(
1=> array ("@sleeping",1,1000),
2=> array ("@having sex",2,1000),
3=> array ("@arguing about their relationship",2,2),
4=> array ("@arguing about politics",2,1000),
5=> array ("@arguing about religion",2,1000),
6=> array ("@arguing about money",2,1000),
7=> array ("@arguing",2,1000),
8=> array ("@gambling with dice",2,1000),
9=> array ("@gambling on a race between small animals (eg snails or rats)",2,1000),
10=> array ("@gambling on a fight between small animals (eg snails or rats)",2,1000),
11=> array ("@re-setting the dungeon: setting up treasure, removing adventurers' bodies and so on"),
12=> array ("@fighting",2,1000),
13=> array ("two of the creatures will be fighting, the others will be cheering them on",5,1000),
14=> array ("two of the creatures will be fighting, the others will be cheering them on and gambling on the result",5,1000),
15=> array ("two of the creatures will be fighting to the death while the others cheer them on",5,1000),
16=> array ("@alert and guarding the area",1,1000),
17=> array ("@trading",2,1000),
18=> array ("@getting drunk and fighting",5,1000),
19=> array ("@recovering from a fight (divide CON or MR by 2)",1,1000),
20=> array ("@exercising",1,1000),
21=> array ("@training for combat",1,1000),
22=> array ("@silently meditating",1,1000),
23=> array ("@about to sacrifice an animal",1,1000),
24=> array ("@about to sacrifice one of their number",5,1000),
25=> array ("@engaging in a solemn religious ritual",4,1000),
26=> array ("@engaging in a boisterous and ecstatic religious ritual",6,1000),
27=> array ("@waiting in ambush for the delvers",1,1000),
28=> array ("@washing",1,1000),
29=> array ("@listening to one of their number tell a story",3,1000),
30=> array ("@listening to one of their number recite a poem",3,1000),
31=> array ("@listening, bored and resentful, as one of their number lectures them",5,1000),
32=> array ("@listening, respectfully silent and attentive, as one of their number lectures them",5,1000),
33=> array ("@plotting against their rulers",2,5),
34=> array ("@playing sport",5,1000),
35=> array ("@lying as if dead, but will spring to life as soon as the delvers enter",1,1000),
36=> array ("@eating",1,1000),
37=> array ("@eating and getting drunk",1,1000),
38=> array ("@getting drunk",1,1000),
39=> array ("@playing <i>Filing & Photocopying</i>, the game of adventure in a strange world where technology is real and magic doesn't work",3,1000),
);
$donum=39;

if (rand(1,2)==1 AND $system=="tt") {
$doing[39][0]=$doing[39][0].". If the delvers end up playing the game, after their first session (which will take 2-12 hours) they will gain 2 INT, but lose 2 CHR";
}

if ($system=="ll") {
$doing[19][0]="@recovering from a fight (treat the HP given as the maximum. For current HP, divide by two and round up)";
}

$object=array(
1=> "Gem",
2=> "Cup",
3=> "Scroll",
4=> "Crown",
5=> "Wand",
6=> "Stone",
7=> "Scarab",
8=> "Mirror",
9=> "Necklace",
);
$objnum=9;

$oname=array(
1=> "Yashub-yahad",
2=> "Black Jenkin",
3=> "Beketmut",
4=> "Seostris",
5=> "Agathangelos",
6=> "Chariton",
7=> "Arah-Sammat",
8=> "Sharrat-sippar",
9=> "Ashmadu",
10=> "Baasha",
11=> "Eira",
12=> "Eydis",
13=> "Ingegard",
14=> "Hrothgar",
15=> "Aredhel",
16=> "Idril",
17=> "Mithrellas",
18=> "Tinuviel",
19=> "Aegnor",
20=> "Beleg",
21=> "Egalmoth",
22=> "Glorfindel",
23=> "Mablung",
24=> "Menegilda",
25=> "Bandobras",
26=> "White Buffalo",
27=> "Crow-Mother-Spirit",
28=> "Coyote-Chasing-Deer",
29=> "Feathered-Water-Snake",
30=> "Gorgol",
31=> "Aelwyd",
32=> "Banon",
33=> "Cadwyn",
34=> "Cerwen",
35=> "Delyth",
36=> "Caerwyn",
37=> "Conwy",
38=> "Corryn",
39=> "He-Who-Should-Not-Have-Been-Born",
);
$onames=39;

$ancients=array(

1=> array (

1=> array ("all-seeing ","m"),
2=> array ("analytical-predictive ","t"),
3=> array ("antedeluvian ","m"),
4=> array ("chromatic ","t"),
5=> array ("core ","t"),
6=> array ("cycloptic ","m"),
7=> array ("electrical ","t"),
8=> array ("electromagnetic ","t"),
9=> array ("endochronic ","t"),
10=> array ("fey ","m"),
11=> array ("forbidden ","m"),
12=> array ("gamma ","t"),
13=> array ("geomantic ","m"),
14=> array ("gravitational ","t"),
15=> array ("gravitomagnetic ","t"),
16=> array ("hydromantic ","m"),
17=> array ("dimensional ","t"),
18=> array ("infernal ","m"),
19=> array ("magnetic ","t"),
20=> array ("neutrino ","t"),
21=> array ("non-Euclidian ","t"),
22=> array ("phased ","t"),
23=> array ("quantum ","t"),
24=> array ("resonating ","t"),
25=> array ("stochastic ","t"),
26=> array ("temporal ","t"),
27=> array ("steam ","t"),

),

2=> array (

1=> array ("anti-matter ","t"),
2=> array ("bewitchment ","m"),
3=> array ("damnation ","m"),
4=> array ("dark matter ","t"),
5=> array ("displacement ","t"),
6=> array ("dragon ","m"),
7=> array ("elder ","m"),
8=> array ("flux ","t"),
9=> array ("hex ","m"),
10=> array ("homunculus ","m"),
11=> array ("immolation ","m"),
12=> array ("ion ","t"),
13=> array ("matter ","t"),
14=> array ("necro-","m"),
15=> array ("particle ","t"),
16=> array ("photon ","t"),
17=> array ("plasma ","t"),
18=> array ("polarity ","t"),
19=> array ("propulsion ","t"),
20=> array ("were-","m"),
21=> array ("summoning ","m"),
22=> array ("superstring ","t"),
23=> array ("teleportation ","t"),
24=> array ("transmutation ","t"),
25=> array ("vibrational ","t"),
26=> array ("warding-","m"),
27=> array ("warp-","t"),

),

3=> array(

1=> array ("beam","t"),
2=> array ("capacitator","t"),
3=> array ("cauldron","m"),
4=> array ("chamber","t"),
5=> array ("circuit","t"),
6=> array ("coil","t"),
7=> array ("compensator","t"),
8=> array ("crown","m"),
9=> array ("drive","t"),
10=> array ("emitter","t"),
11=> array ("engine","t"),
12=> array ("field","t"),
13=> array ("gem","m"),
14=> array ("generator","t"),
15=> array ("grid","t"),
16=> array ("gun","t"),
17=> array ("idol","m"),
18=> array ("matrix","t"),
19=> array ("modulator","t"),
20=> array ("projector","t"),
21=> array ("ray","t"),
22=> array ("regulator","t"),
23=> array ("rune","m"),
24=> array ("sensor","t"),
25=> array ("stone","m"),
26=> array ("throne","m"),
27=> array ("wand","m"),

),

);


$llclasses=array(
1=> "Fighters",
2=> "Magic-Users",
3=> "Clerics",
4=> "Thieves",
5=> "Dwarves",
6=> "Elves",
7=> "Halflings",
8=> "Mutant Humans",
9=> "Mutant Animals",
10=> "Mutant Plants",
11=> "Replicants",
);
$llclassnum=11;
$retainer=array();

// the following tables are all mutations, which are used for
// retainers and will be used for monsters.

// for all these arrays, 0 = name, 1 = level manifested
// (the latter is only used for monsters).

$phtemp=array();
$pltemp=array();

// these arrays have a value of 1 if the mutation
// in question has already been used for this mutant.


$bph1=array(
1=> "Aberrant Form - Enlarged Parts (legs and feet: +60' movement)",
2=> "Aberrant Form - Enlarged Parts (arms and hands: +2 damage)",
3=> "Aberrant Form - Extra Parts (heart and lungs: +1 CON)",
4=> "Aberrant Form - Natural Weapon (stinging tail: 1d6 damage)",
5=> "Dwarfism",
6=> "Echolocation",
7=> "Epidermal Photosynthesis",
8=> "Gigantism",
9=> "Night Vision",
10=> "Prehensile Tail",
11=> "Spiny Growth",
12=> "Thermal Vision",
13=> "Ultraviolet Vision",
);
// can't have both Dwarfism and Gigantism.

$bph2=array(
1=> "Energy Retaining Cell Structure",
2=> "Fragrance Development",
3=> "Increased Balance",
4=> "Increased Physical Attribute (Strength)",
5=> "Increased Physical Attribute (Dexterity)",
6=> "Increased Physical Attribute (Constitution)",
7=> "Increased Sense (Vision)",
8=> "Increased Sense (Hearing)",
9=> "Increased Sense (Smell)",
10=> "Increased Sense (Touch)",
11=> "Increased Sense (Taste)",
12=> "Natural Armour",
13=> "Optic Emissions (bright eyes)",
14=> "Shriek",
15=> "Toxic Weapon",
16=> "Unique Sense (detect radiation)",
17=> "Unique Sense (detect water)",
18=> "Unique Sense (detect gold - note that this doesn't apply to treasure in general)",
19=> "Unique Sense (detect living beings)",
);

$bph3=array(
1=> "Chameleon Epidermis",
2=> "Complete Wing Development",
3=> "Density Alteration (self)",
4=> "Dermal Poison Slime",
5=> "Dual Headed",
6=> "Energy Ray",
7=> "Metamorph",
8=> "Optic Emissions (gamma eyes)",
9=> "Parasitic Control",
10=> "Quickness",
11=> "Reflective Epidermis",
12=> "Regenerative Capability",
);
// Metamorph - randomly choose an animal from the list.

$bme2=array(
1=> "Ability Boost",
2=> "Acute Hyper Healing",
3=> "Combat Empathy",
4=> "Empathy",
5=> "Increased Willpower",
6=> "Intellectual Affinity",
7=> "Know Direction",
8=> "Mental Barrier",
9=> "Mental Phantasm",
10=> "Metaconcert",
11=> "Mind Thrust",
12=> "Neural Telepathy",
);

$bme3=array(
1=> "Accumulated Resistance",
2=> "Ancestral Form",
3=> "Body Adjustment",
4=> "Control Light Waves",
5=> "Control Weather",
6=> "Damage Turning",
7=> "Density Alteration (others)",
8=> "Disintegration",
9=> "Dual Cerebellum",
10=> "Flight, Psionic",
11=> "Force Screen",
12=> "Force Screen, Greater",
13=> "Killing Sphere",
14=> "Neural Telekinesis",
15=> "Plane Shift",
16=> "Posession",
17=> "Precognition",
18=> "Mind Reflection",
19=> "Quick Mind",
20=> "Teleport",
21=> "Temperature Control",
22=> "Vampiric Field",
);
// can't have Force Screen and ..Greater

$bpl1=array(
1=> "Natural Vegetal Weapons",
2=> "Projectile Thorns",
);

$bpl2=array(
1=> "Dermal Acid Sap",
2=> "Injected Poison Sap",
3=> "Prehensile Tendrils",
);

$bpl3=array(
1=> "Carnivore",
2=> "Chameleon Metamorph",
3=> "Grenade-like Fruit",
4=> "Poisonous Spores",
5=> "Radioactive Emissions",
6=> "Thermal Emissions",
);

$dph1=array(
1=> "Albinism",
2=> "Bizarre Appearance",
3=> "Obese",
4=> "Pituitary Deformation",
5=> "Simian Deformity",
);

$dph2=array(
1=> "Epidermal Susceptibility",
2=> "Frailty",
3=> "Increased Caloric Needs",
4=> "Poison Susceptibility",
5=> "Prey Scent",
);

$dph3=array(
1=> "Hemophilia",
2=> "Pain Insensitivity",
3=> "Pain Sensitivity",
4=> "Reduced Immune System",
5=> "Reduced Oxygen Efficiency",
6=> "Sensory Deficiency",
7=> "Slow Mutant",
8=> "Vision Impairment",
);
// can't have Pain Sensitivity and ..Insensitivity.

$dme3=array(
1=> "Atrophied Cerebellum",
2=> "Dual Cerebellum (defective)",
3=> "Mind Reflection (defective)",
4=> "Negative Empathy",
5=> "Phantasmal Damage",
6=> "Phobia",
7=> "Weak Will",
);
// Dual Cerebellum (defective) is incompatible with
// the 'working' version. Mind Reflection isn't.

$dpl3=array(
1=> "Nocturnal",
2=> "Thermal Sensitivity",
);


// determine the nature of the dungeon.
if (rand(1,2)==1 OR $system<>"ll") {
$thisent=rand(1,$ennum);
if (str_replace("@@A","XXX",$entrance[$thisent])==$entrance[$thisent]) {
$entstr=$entrance[$thisent];
} else {
do {
$othent=rand(1,$ennum);
} while (str_replace("@@A","XXX",$entrance[$othent])<>$entrance[$othent]);
$entstr=$entrance[$othent]." It's ".str_replace("@@A","",$entrance[$thisent]);
}
$entstr=str_replace("@@T",$sett[rand(1,$settnum)],$entstr);
if (str_replace("@@B","XXX",$entstr)<>$entstr) {
$z=$appani[rand(1,$aniapp)];
$z=str_replace("a ","",$z);
$z=str_replace("an ","",$z);
$entstr=str_replace("@@B",$z,$entstr);
}
if (str_replace("@@C","XXX",$entstr)<>$entstr) {
$entstr=str_replace("@@C",$appani[rand(1,$aniapp)],$entstr);
}
if (str_replace("temple","XXX",$entstr)<>$entstr) {
$type=rand(1,$gnum);
if ($godd==0) {
$gods[$type][2]="the god";
if (rand(1,2)==1) {
$gods[$type][2]=$gods[$type][2]."dess";
}
$x=$gods[$type][2]." of ".$gods[$type][3];
} else {
$x=$gods[$type][0];
}
$entstr=str_replace("temple","temple dedicated to ".$x,$entstr);
$dedi=$type;
$shrine[$type]=1;
$manygods=1;
}
} else {
$entstr="the ruins of an ancient ".$ruins[rand(1,$ruinnum)];
if (rand(1,3)==1) {
$entstr=$entstr.", whose inhabitants have been raiding a nearby ".$sett[rand(1,$settnum)];
}
$entstr=$entstr.".";
}
$entstr="The dungeon is ".$entstr;

// determine $questobject, and add it to $entstr
// (needs to be seperate as well, so
// can put it in a room of the dungeon).
if (rand(1,2)==1) {
$questobject="the ".$object[rand(1,$objnum)]." of ".$oname[rand(1,$onames)];
$entstr=$entstr." The heroes are seeking ".$questobject.".";
} else {
for ($z=1;$z<=27;$z++) {
for ($y=1;$y<=3;$y++) {
if ($ancients[$y][$z][1]=="t") {
$ancients[$y][$z][1]=1;
} else {
$ancients[$y][$z][1]=0;
}
}
}
do {
$ok=1;
$questobject="";
$tandm=0;
for ($z=1;$z<=3;$z++) {
$y=rand(1,27);
$questobject.=$ancients[$z][$y][0];
$tandm+=$ancients[$z][$y][1];
}
if ($tandm<1 OR $tandm>2) {
$ok=0;
}
} while ($ok==0);
$questobject="the ".ucwords($questobject);
$entstr=$entstr." The heroes are seeking a lost device of the Ancients - ".$questobject.".";
}



// $level is used for variables which affect individuals -
// for example "characters must make a level x saving roll on Luck..",

// $mr[$x] is the total Monster Rating for a group which
// will be roughly the same power as the party (hopefully), on
// $level $x, for T&T.

// $pow[$x] is the 'power' of species $x, for T&T.
// it's compared to $mr[the current level]
// to see how big the groups should be.
// It also determines the creature's size.

// $rn[$x] is the exact number of areas on level $x.
// $rn[0] is the total number of areas in the dungeon.

// $rb[$x][$y] is the broad type of encounter in
// room $y of level $x.
// $rd[$x][$y] is the string printed out to describe the same room.
// $tr[$x][$y] is the value of the treasure in the same room.
// $mo[$x][$y][0] is the type of creature in the same room.
// $mo[$x][$y][1] is the number of creatures in the same room.

// $shrine[$x] is whether the xth god has at least 1 shrine.
// $snum[$x] is how many shrines the xth god has in the dungeon.
// need both $shrine and $snum, because $shrine temporarily uses value
// 2, to indicate 'have rolled on this level, but doesn't increase
// likelihood until next level'.

// $traps[1-$trapnum] is the details of different traps.

// $mwidth is the maximum width that the dungeon can be
// (so it won't print off the page)

// for species $x, $stats[$x][0] is either
// 1 (for Monster Rated monsters), or
// 2 (for statted monsters).
// 1: $stats[$x][1] is the MR. $stats[2-8] aren't used.
// 2: $stats[$x][1-7 or 8] is the number for each stat.

// $crmag[$x][$y] is 1 if species $x knows spell $y.

// $splus is only used for statted monsters -
// it's the adds. $splus[$x][$y] is used with $stats[$x][$y].

// $crlang[$x][$y] is whether creature number $x speaks language $y.

// $crarmour[$x][1-4] defines whether the species ever
// wears armour, and if so what its characteristics are:

// $crarmour[$x][1] is protection. 0 means 'never wears armour'.
// [2] is STR required.
// [3] is weight.
// [4] is value.

// $crsize[$x] is a number from 1-6
// (matched to $sizetext[that number][1]),
// giving what size the creature is.
// $sizetext[$y][0] is a number, compared to a number generated by
// each creature based on its stats, to see what size it is.
// $sizetext[$y][1] is a description "this creature is roughly..."
// $sizetext[$y][2] is the plural "remember that...can use its armour"
// $sizetext[$y][3] is the DEX roll to hit it at point-blank range
// based on 5th edition.

// $mrtype are only used for Monster Rated monsters -
// it governs how their stats respond to losing MR.
// used in conjunction with $mrdesc

// $shallow[$x] and $deep[$x] give the range
// of levels where species $x can be found.

// $desc[$x] is the description of species $x: what it looks like,
// and any special combat abilities (except that in $mrtype[$x]).

// $htoh[$x] is set to 1 if species $x is a standard creature
// which won't have weapons or armour (ie one which begins with "+").

// $lclimate[$x] is the climate on level $x.

// $rv - room variance: by what % can the number of areas on a level
// vary from $r.

// $sp - on average, should be a different species for each $sp areas.

// $sn - how many species in the dungeon.

// $grp[$x][$y] is the average size of a
// group of members of species $x on level $y.

// $enc[$x][$y] is how many areas have species $x on level $y.

// $enc[$species][$level] is how many areas have species $species on level $level.

// $wmtable[$level][0] is the number of monsters
// who appear on level $level.
// $wmtable[$level][$species] is the number of 'slots' that
// monster $species has in the w.m. table for level $level.
// if creature $species's territory includes level $level
// (based on $deep[$species] and $shallow[$species]), then
// $enc[$species][$level]+$wmtable[$level][$species] must be >0.

// if creature $x's territory includes level $y (based on $deep[$x]
// and $shallow[$x]), then $enc[$x][$y]+$wmtable[$y][$x] must be >0.

// $table[$x][0] is the number of slots in the $xth possible table.
// $table[$x][1-3] are dice:
// 1 = not rolled
// 2 = "1-3" then "4-6"
// 3 = "1-2", "3-4", "5-6"
// 6 = increments normally.

// $ha - handicap. This is a percentage. An average group of monsters
// should be $ha% as effective as the group of delvers that the
// dungeon is designed for.
// not used for D&D.

// $ss - how many different temperature save strings there are.

// $exit[$x][0] gives the number of tunnels leading from/to level $x.

// $stype is an array for deciding what part of the square the
// computer is currently printing.

// $doors[$x][$y][$d][1-4] gives the type of exit (if any), from
// room $x, $y on level $d.
// 1 is an illusory wall,
// 2 is a locked door (STR + armour to break, or DEX to pick),
// 3 is a secret door (higher of INT or LK to find).
// 4 is a porticullus trap.

// $exitsave[$t][$d] gives the level of save
// necessary for exit type $t, on level $d.

// $dshr[$x] is where the shrine to god number $dedi is on level $x.
// it should usually not be used (because $dedi usually isn't).

$rv=25;
$sp=5;
if (!isset($ha) OR $ha<1) {
$ha=60;
}
$ra=$r*$rv/100;

for ($x=1;$x<=$l;$x++) {
$level[$x]=$s+$x-1;
$rn[$x]=rand(round($r-$ra),round($r+$ra));
$rn[0]+=$rn[$x];
$lclimate[$x]=rand(1,$cnum);

// these should only be if $system is "tt"
$z=31.5*$c;
$bonus=1.5*(($level[$x]*($level[$x]+1)/2)-1);
$z+=($bonus*$c);
$mr[$x]=$z*$ha/100;
//

}

for ($x=1;$x<=$gnum;$x++) {
if (str_replace("@@L","XXX",$gods[$x][4])<>$gods[$x][4]) {
$z=$s-1+rand(1,3)-rand(1,3);
if ($z==0) {
$z="";
} elseif ($z>0) {
$z=", plus ".$z;
} else {
$z=", minus ".-$z." (with a minimum of 1)";
}
$gods[$x][4]=str_replace("@@L","The save is made at a level equal to the dungeon level the shrine is on".$z.". If it succeeds, ",$gods[$x][4]);
}
}

for ($x=1;$x<=$ss;$x++) {
$z="at the level of the dungeon";
$a=rand(0,$s)-1;
if ($a<0) {
$z=$z." minus ".abs($a);
} elseif ($a>0) {
$z=$z." plus ".$a;
}
for ($y=1;$y<=$cnum;$y++) {
$climated[$climates[$y]]=str_replace("@@".$x,$z,$climated[$climates[$y]]);
}
}

$sn=max(6,round($rn[0]/$sp));

// generate names for each species.

// 'ambient temperature' ($spt array) done here as well.

for ($x=1;$x<=$sn;$x++) {
if (rand(1,10)==1) {
$spt[$x]=rand(1,$cnum);
}
do {
$nok=1;

$sofar=floor(($x-1)/$firstnum);
do {
$z=rand(1,$firstnum);
} while ($namecount[$z][1]>$sofar);
$namecount[$z][1]++;
$x1=$namefirst[$z];

if (str_replace("+","XXX",$x1)<>$x1) {
$x1=str_replace("+","",$x1);
$x2=$vowels[rand(1,$vnum)];
} else {
$x2="";
if (rand(1,2)==1) {
$x2=$vowels[rand(1,$vnum)];
}
}

$sofar=floor(($x-1)/$secondnum);
do {
$z=rand(1,$secondnum);
} while ($namecount[$z][2]>$sofar);
$namecount[$z][2]++;
$x3=$namesecond[$z];

$crname[$x]=$x1.$x2.$x3;
$crname[$x]=str_replace("uu","u",$crname[$x]);
$crname[$x]=str_replace("ii","i",$crname[$x]);
$crname[$x]=str_replace("yy","y",$crname[$x]);
$crname[$x]=str_replace("cc","c",$crname[$x]);
$crname[$x]=str_replace("tt","t",$crname[$x]);
if (strlen($crname[$x])<5) {
$nok=0;
} elseif (substr($crname[$x],0,2)=="Dr" AND substr($crname[$x],-3)=="gon") {
$nok=0;
} elseif (substr($crname[$x],0,2)=="Un" AND substr($crname[$x],-4)=="corn") {
$nok=0;
} else {
for ($y=1;$y<$x;$y++) {
if ($crname[$x]==$crname[$y]) {
$nok=0;
}
}
}
if ($nok==1) {
$sofar=floor(($x-1)/$thirdnum);
do {
$z=rand(1,$thirdnum);
} while ($namecount[$z][3]>$sofar);
$namecount[$z][3]++;
$x3=$namethird[$z];

$sofar=floor(($x-1)/$fourthnum);
do {
$z=rand(1,$fourthnum);
} while ($namecount[$z][4]>$sofar);
$namecount[$z][4]++;
$x4=$namefourth[$z];

if ($x3=="Imperial" AND $x4=="Emperor") {
$nok=0;
} elseif ($x3=="Conquering" AND $x4=="Conqueror") {
$nok=0;
} elseif ($x3=="Cyber-" AND $x4=="Cyborg") {
$nok=0;

} else {
$crnick[$x]=$x3." ".$x4;
if (str_replace("Barrow-","XXX",$crnick[$x])<>$crnick[$x] OR str_replace("Cyber-","XXX",$crnick[$x])<>$crnick[$x]) {
$crnick[$x]=str_replace(" ","",$crnick[$x]);
} elseif (str_replace("-","XXX",$crnick[$x])<>$crnick[$x]) {
$crnick[$x]=$x4.$x3;
} elseif (str_replace("'s","XXX",$crnick[$x])<>$crnick[$x] AND $x3<>"Love's") {
$crnick[$x]=$x4.$x3;
}
for ($y=1;$y<$x;$y++) {
if ($crnick[$x]==$crnick[$y]) {
$nok=0;
}
}
}
}
} while ($nok==0);
};


// define levels for each species.
for ($x=1;$x<=$sn;$x++) {
$y=rand(1,$l);
$z=rand(1,$l);
if (rand(1,3)==1) {
$y=1;
} elseif (rand(1,2)==1) {
$y=$l;
}
$shallow[$x]=min($y,$z);
$deep[$x]=max($y,$z);
}

// look at $deep and $shallow, to make sure that each
// level has at least one monster. alter if necessary.
for ($x=1;$x<=$l;$x++) {
$nearest=$l;
for ($y=1;$y<=$sn;$y++) {
if ($shallow[$y]<=$x AND $deep[$y]>=$x) {
$nearest=0;
} else {
$nearest=min($nearest,abs($shallow[$y]-$x),abs($deep[$y]-$x));
}
}
if ($nearest>0) {
do {
$y=rand(1,$sn);
} while (abs($shallow[$y]-$x)>$nearest AND abs($deep[$y]-$x)>$nearest);
$shallowdist=abs($shallow[$y]-$x);
$deepdist=abs($deep[$y]-$x);
if ($shallowdist<$deepdist) {
$shallow[$y]=$x;
} else {
$deep[$y]=$x;
}
}
}

// work out scores for standard monsters.
if ($smo==2) {
$smo=rand(0,1);
}
if ($smo==1) {
$standardused=0;
// $standardused is the number of standard monsters used.
for ($z=1;$z<=$standardn;$z++) {
$plu=$standardm[$z][0]."sVVV";
$plu=str_replace("ysVVV","ies",$plu);
$plu=str_replace("fsVVV","ves",$plu);
$plu=str_replace("xsVVV","xes",$plu);
$plu=str_replace("Mouses","Mice",$plu);
$plu=str_replace("MansVVV","Men",$plu);
$plu=str_replace("+","",$plu);
$stplural[$z]=str_replace("VVV","",$plu);
// attributes.
for ($y=1;$y<=8;$y++) {
$x=rand(1,6)+rand(1,6)+rand(1,6);
$mb=$standardm[$z][$y];
if ($mb>0) {
$standardm[$z][$y]=round($mb*$x);
} else {
$standardm[$z][$y]=min(-$mb,$x);
}
}

// now work out 'power', and put it in $standardm[$z][10].
$con=$standardm[$z][4];
$phys=$con;
for ($y=1;$y<=5+(2*$spd);$y=$y+2) {
$phys+=$standardm[$z][$y];
}
$standardm[$z][10]=3*$phys/(4+$spd);
$int=$standardm[$z][2];
$dex=$standardm[$z][5];
$sus=1+(7*$wiz);
$sfu=$standardm[$z][$sus];
if ($int>9 AND $dex>7 AND $sfu>5) {
$mag=($con+$int+$dex+$sfu)*3/4;
$standardm[$z][10]=max($mag,$standardm[$z][10]);
}
if ($standardm[$z][10]>$mr[$l]) {
$standardm[$z][11]=1;
} elseif ($standardm[$z][10]*10<$mr[$l]) {
$standardm[$z][11]=1;
} else {
$standardused++;
}
}
$standardused=min($standardused,$sn);
for ($z=1;$z<=$standardused;$z++) {
do {
$thisstandard=rand(1,$standardn);
} while ($standardm[$thisstandard][11]==1);
$standardm[$thisstandard][11]=1;
$standardsn[$z]=$thisstandard;
if (substr($standardm[$thisstandard][0],0,1)=="+") {
$htoh[$z]=1;
}
}
}

// define stats for each species.
// either generate randomly, or copy from $standardm.
for ($x=1;$x<=$sn;$x++) {
$stats[$x][0]=rand(1,2);
if ($stormr==1) {
$stats[$x][0]=2;
} elseif ($stormr==3) {
$stats[$x][0]=1;
}
if ($x<=$standardused) {
$stats[$x][0]=2;
}
if ($stats[$x][0]==2 AND $x>$standardused) {
$fullstat=1;
}
if ($stats[$x][0]==2) {
if ($x>$standardused) {
for ($y=1;$y<=$attnum;$y++) {
do {
$stats[$x][$y]=rand(1,5);
$splus[$x][$y]=rand(1,6)-rand(1,6);
} while ($stats[$x][$y]+$splus[$x][$y]<1);
// ie no chance of getting 0 or less.
}
$y=$level[rand($shallow[$x],$deep[$x])];
$y=rand(1,$y);
if ($y>1) {
for ($z=2;$z<=$y;$z++) {
// levelling gives one of the following bonuses:
// half new number to both STR and CON (1,4) - '0'
// new number to STR (1)
// half to INT (2)
// twice to LK (3)
// new number to CON (4)
// half to DEX (5)
// half to CHR (6)
// new number to SPD (7) (doesn't happen in rules)
// new number to WIZ (8)
$lbon=$z;
do {
$watt=rand(0,$attnum);
} while ($watt==7 AND $spd==0);
// ie if SPD doesn't contribute to combat adds,
// monsters won't 'level up' their Speed.

if ($watt==3) {
$lbon=$lbon*2;
} elseif ($watt<>1 AND $watt<>4 AND $watt<>8 AND $watt<>7) {
$lbon=$lbon/2;
// half rounded down in rules.
}
if ($watt==0) {
$splus[$x][1]+=$lbon;
$splus[$x][4]+=$lbon;
} else {
$splus[$x][$watt]+=$lbon;
}
}
}

for ($z=1;$z<=$attnum;$z++) {
$stats[$x][$z]=(3.5*$stats[$x][$z])+$splus[$x][$z];
if (rand(1,2)==1) {
$stats[$x][$z]=floor($stats[$x][$z]);
} else {
$stats[$x][$z]=ceil($stats[$x][$z]);
}
}

$con=$stats[$x][4];
$phys=$con;
for ($z=1;$z<=5+(2*$spd);$z=$z+2) {
$phys+=$stats[$x][$z];
}
$pow[$x]=3*$phys/(4+$spd);
$int=$stats[$x][2];
$dex=$stats[$x][5];
$sus=1+(7*$wiz);
$sfu=$stats[$x][$sus];
if ($int>9 AND $dex>7 AND $sfu>5) {
$mag=($con+$int+$dex+$sfu)*3/4;
$pow[$x]=max($mag,$pow[$x]);
}
$rsize=($stats[$x][1]+$con)*1.5;
} else {
for ($y=1;$y<=$attnum;$y++) {
$stats[$x][$y]=$standardm[$standardsn[$x]][$y];
}
$pow[$x]=$standardm[$standardsn[$x]][10];
$rsize=30*$standardm[$standardsn[$x]][9];
}
} else {
do {
$stats[$x][1]=5*rand(1,40);
} while ($stats[$x][1]>$mr[$shallow[$x]]);
$mrtype[$x]=$adds;
if (rand(1,5)==1) {
$mrtype[$x]=rand(1,4);
}
$pow[$x]=$stats[$x][1];
$rsize=$stats[$x][1];
}

// define $crsize array.
$leeway=round($rsize/2);
if ($x<=$standardused) {
$leeway=0;
}
$finalsize=$rsize;
for ($y=1;$y<=3;$y++) {
$finalsize=min($finalsize,rand($rsize-$leeway,$rsize+$leeway));
}
if ($finalsize<=$sizetext[1][0]) {
$crsize[$x]=1;
} elseif ($finalsize>=$sizetext[$sizecats][0]) {
$crsize[$x]=$sizecats;
} else {
$y=0;
do {
$y++;
} while ($y<$sizecats AND $finalsize>$sizetext[$y][0]);
$lowgap=abs($finalsize-$sizetext[$y-1][0]);
$highgap=abs($finalsize-$sizetext[$y][0]);
if (rand(1,2)==1) {
$lowgap+=.5;
} else {
$highgap+=.5;
}
if ($lowgap>$highgap) {
$crsize[$x]=$y;
} else {
$crsize[$x]=$y-1;
}
}

// define whether this species wears armour,
// and if so what its characteristics are.
$wearsarmour=1;
if ($toughskin>0) {
$wearsarmour=rand(0,1);
}
if (rand(1,3)==1) {
$wearsarmour=0;
}
if (rand(1,2)==1 AND $stats[$x][0]==1) {
$wearsarmour=0;
}
if ($wearsarmour==1) {
$protection=rand(5,10);
$weight=$protection*rand(33,100);
$streq=($protection*2)-min(rand(10,14),rand(10,14),rand(10,14));
$value=($protection*20)-70;
if ($protection>8) {
$value+=($protection-8)*60;
}
$leeway=$value*15/100;
$value=rand(round($value-$leeway),round($value+$leeway));
$z=(3*$finalsize)+15;
$streq=round($streq*$z/100);
$weight=round($weight*$z*$z/10000);
$streq=max(ceil($weight/100),$streq);
if ($stats[$x][0]==1 OR $stats[$x][1]>=$streq) {
$crarmour[$x][0]=1;
$crarmour[$x][1]=$protection;
$crarmour[$x][2]=$streq;
$crarmour[$x][3]=$weight;
$crarmour[$x][4]=$value;
}
}
}

// fill in $grp, start on $wmtable.
for ($x=1;$x<=$sn;$x++) {
for ($y=$shallow[$x];$y<=$deep[$x];$y++) {
$grp[$x][$y]=round($mr[$y]/$pow[$x]);
$grp[$x][$y]=max($grp[$x][$y],1);
$wmtable[$y][0]++;
$wmtable[$y][$x]=1;
}
}
$line="<div>&nbsp</div>";
$pic="<img src=\"http://www.apolitical.info/webgame/dungeon/";
print "Designed for a group of ".$c." delvers, of level ".$s.".";
print $line;

// print effects of temperature
print "<b>Effects of Temperature:</b>";
print $line;
for ($x=1;$x<=$cnum;$x++) {
$y=0;
for ($z=1;$z<=$l;$z++) {
if ($lclimate[$z]==$x) {
$y=1;
}
}
if ($y==0) {
for ($z=1;$z<=$sn;$z++) {
if ($spt[$z]==$x) {
$y=1;
}
}
}
if ($y==1) {
print "<i>".$climates[$x]."</i>: ".$climated[$climates[$x]]."<br><br>In ".$climates[$x]." areas, roll for wandering monsters every ".$climatew[$climates[$x]].".";
print $line;
}
}
print $line;



// work out theme.
if ($theme==2) {
$theme=rand(0,1);
}
if ($theme==1) {
do {
$z=rand(1,7);
} while ($z==2);
// 2 is just plants, so this is re-rolled.
if (rand(1,5)<3) {
do {
$stth=rand(1,$chaapp);
$stth1=rand(1,$chaapp);
} while ($stth==$stth1);
$z=0;
}
if ($z>3) {
$anth=$appani[rand(1,$aniapp)];
} else {
$anth="none";
}
if ($z%2==1) {
$huth=$apphum[rand(1,$humapp)];
} else {
$huth="none";
}
if ($z>5 OR ($z<4 AND $z>1)) {
$plth=$apppla[rand(1,$plaapp)];
} else {
$plth="none";
}
} else {
$anth="none";
$huth="none";
$plth="none";
}

// print creatures details.
print "<b>Creatures</b>:";
print $line;
print "There are ".$sn." types of creature in the dungeon.";
print $line;
for ($x=1;$x<=$sn;$x++) {
print "(".$x.") ".$crname[$x].", or ".$crnick[$x];
print $line;
// description.
if ($x<=$standardused) {
$y="is a type of ".$standardm[$standardsn[$x]][0].".";
$y=str_replace("+","",$y);
} else {
do {
if ($stth>0) {
if (rand(1,2)==1) {
$y=$appcha[$stth];
} else {
$y=$appcha[$stth1];
}
} else {
$y=$appcha[rand(1,$chaapp)];
}
$an=$appani[rand(1,$aniapp)];
if ($anth<>"none") {
$an=$anth;
}
$a2=$appani[rand(1,$aniapp)];
} while ($an==$a2 OR (($an=="an octopus" OR $a2=="an octopus") AND str_replace("disembodied","XXX",$y)<>$y));
$pl=$apppla[rand(1,$plaapp)];
if ($plth<>"none") {
$pl=$plth;
}
do {
$hu=$apphum[rand(1,$humapp)];
if ($huth<>"none") {
$hu=$huth;
}
$h2=$apphum[rand(1,$humapp)];
} while ($hu==$h2);
if (rand(1,2)==1) {
$ei=$appani[rand(1,$aniapp)];
if ($anth<>"none") {
$ei=$anth;
}
} else {
$ei=$apppla[rand(1,$plaapp)];
if ($plth<>"none") {
$ei=$plth;
}
}
if (rand(1,3)==1) {
$eh=$apppla[rand(1,$plaapp)];
if ($plth<>"none") {
$eh=$plth;
}
} elseif (rand(1,2)==1) {
$eh=$appani[rand(1,$aniapp)];
if ($anth<>"none") {
$eh=$anth;
}
} else {
$eh=$apphum[rand(1,$humapp)];
if ($huth<>"none") {
$eh=$huth;
}
}
if (rand(1,2)==1) {
$ea=$appani[rand(1,$aniapp)];
if ($anth<>"none") {
$ea=$anth;
}
} else {
$ea=$apphum[rand(1,$humapp)];
if ($huth<>"none") {
$ea=$huth;
}
}
$y=str_replace("@@AN",$an,$y);
$y=str_replace("@@A2",$a2,$y);
$y=str_replace("@@PL",$pl,$y);
$y=str_replace("@@HU",$hu,$y);
$y=str_replace("@@H2",$h2,$y);
$y=str_replace("@@EI",$ei,$y);
$y=str_replace("@@EH",$eh,$y);
$y=str_replace("@@EA",$ea,$y);
}
// generate special powers.
// $y becomes $desc[$x];

if ($system=="ll") {
$alent=rand(1,3);
print "Alignment: ".$ament[$alent]."<br>";
$homelevel=$level[rand($shallow[$x],$deep[$x])];
$saveclass=$saves[rand(1,6)];
if ($homelevel==1) {
$savelev=rand(0,2);
} elseif ($homelevel==2) {
$savelev=1;
if (rand(1,5)<4) {
$savelev=2;
}
} elseif ($homelevel==3) {
$savelev=3;
} elseif ($homelevel<6) {
$savelev=4;
if (rand(1,10)<4) {
$savelev=5;
}
} elseif ($homelevel<8) {
$savelev=5;
if (rand(1,5)<3) {
$savelev=6;
}
} else {
$savelev=7;
if (rand(1,4)<5) {
$savelev=8;
}
$savelev+=floor($homelevel/2)-4;
}
$hilev=19;
$lband=3;
if ($saveclass=="Magic-User") {
$lband=5;
} elseif ($saveclass=="Cleric" OR $saveclass=="Thief") {
$hilev=17;
$lband=4;
} elseif ($saveclass=="Dwarf") {
$hilev=12;
} elseif ($saveclass=="Elf") {
$hilev=10;
}
$savelev=min($savelev,$hilev);
$leeway=min(2,$savelev,$hilev-$savelev);
$savelev=rand($savelev-$leeway,$savelev+$leeway);
print "Save As: ";
if ($savelev==0) {
print "0-level Human";
} else {
$savelev=(floor($savelev/$lband)*$lband)+1;
print "Level ".$savelev." ".$saveclass;
}
print "<br>Hoard Class: ";
$whoard[$x]=0;
if (rand(1,2)==1 AND $homelevel<8) {
$whoard[$x]=rand(1,7);
}
if ($homelevel<6) {
$lowchance=30;
$medchance=45;
$highchance=0;
} elseif ($homelevel<8) {
$lowchance=5;
$medchance=70;
$highchance=10;
} else {
$lowchance=0;
$medchance=25;
$highchance=60;
}
$dhun=rand(1,100);
if ($dhun<=$lowchance) {
$lair="low";
} elseif ($dhun<=$lowchance+$medchance) {
$lair="medium";
} elseif ($dhun<=$lowchance+$medchance+highchance) {
$lair="high";
} else {
$lair="none";
}
if ($lair=="none") {
$lhoard[$x]=0;
} else {
do {
$ok=0;
$a=rand(8,22);
$tval=$treasuretypes[$a][1];
if ($lair=="low" AND $tval<1000) {
$ok=1;
} elseif ($lair=="medium" AND $tval>999 AND $tval<10000) {
$ok=1;
} elseif ($lair=="high" AND $tval>9999) {
$ok=1;
}
} while ($ok==0);
$lhoard[$x]=$a;
}
if ($treasuretypes[$lhoard[$x]][1]<$treasuretypes[$whoard[$x]][1]) {
$lhoard[$x]=$whoard[$x];
}
if ($lhoard[$x]==0) {
print "none";
} elseif ($whoard[$x]<>$lhoard[$x] AND $whoard[$x]>0) {
print $treasuretypes[$whoard[$x]][0]." (".$treasuretypes[$lhoard[$x]][0].")";
} else {
print $treasuretypes[$lhoard[$x]][0];
}

if ($lhoard[$x]<8) {
$totalhpw=$thpsame[$homelevel];
$totalhpl=0;
} else {
$totalhpw=$thpwand[$homelevel];
if ($homelevel<6) {
$totalhpl=rand(70,120);
} else {
$totalhpl=($homelevel*10)+70;
}
}
if ($homelevel>8) {
$totalhpw+=5*($homelevel-8);
}
if ($totalhpl>0) {
$totalhpl=max($totalhpl,$totalhpw);
}
$totalhpw=$totalhpw*$c/4.5;
$totalhpl=$totalhpl*$c/4.5;
if ($homelevel<9) {
$lowhd=$minhd[$homelevel];
$highhd=$maxhd[$homelevel];
} else {
$lowhd=$minhd[8]+$homelevel-8;
$highhd=$maxhd[8]+$homelevel-8;
}

// generate the following variables:
// $tempa: Hit Dice (0 = 1d4)
// $tempb: add to (or subtract from) Hit Dice (-1 to +2)

// $tempc: number encountered - number of dice.
// $tempd: number encountered - type of dice.

// $tempcl, $tempdl: as above, but for lair.
// only needed if $totalhpl>$totalhpw.

// generate number encountered, then decide Hit Dice
// based on which one comes closest to $totalhpw
// (and to $totalhpl if $totalhpl>$totalhpw)

$maxdice=3;
$maxface=5;
// $maxface means the highest element of $diceface array.
// $maxface of 5 means highest dice is d8.

do {
$ok=1;
$tempc=rand(1,$maxdice);
if (rand(1,2)==1) {
$tempc=1;
}
$tempd=$diceface[rand(1,$maxface)];
$wgrp=$tempc*(($tempd/2)+.5);
if ($totalhpl>$totalhpw) {
$tempcl=rand(1,$maxdice);
if (rand(1,2)==1) {
$tempcl=1;
}
$tempdl=$diceface[rand(1,$maxface)];
$lgrp=$tempcl*(($tempdl/2)+.5);
if ($lgrp<$wgrp) {
$ok=0;
}
}
} while ($ok==0);

$tempa=0;
$besthd=0;
do {
$temphp=4.5*$tempa;
$nexthp=4.5*($tempa+1);

$tempgrp=$temphp*$wgrp;
$nextgrp=$nexthp*$wgrp;

$faroff=abs($tempgrp-$totalhpw);
$nextoff=abs($nextgrp-$totalhpw);

if ($totalhpl>$totalhpw) {
$tempgrp=$temphp*$lgrp;
$nextgrp=$nexthp*$lgrp;

$faroff+=abs($tempgrp-$totalhpl);
$nextoff+=abs($nextgrp-$totalhpl);
}

if ($faroff>$nextoff) {
$tempa++;
} else {
$besthd=1;
}
if ($tempa<$lowhd AND rand(1,3)>1) {
$besthd=0;
} elseif ($tempa>$highhd AND rand(1,2)==1) {
$besthd=1;
}
} while ($besthd==0);

$tempb=rand(-1,2);
if (rand(1,3)>1) {
$tempb=0;
}

print "<br>Hit Dice: ";
if ($tempa==0) {
print "1d4";
} else {
print $tempa;
}
if ($tempb>0) {
print " + ".$tempb;
} elseif ($tempb<0) {
print " - ".abs($tempb);
}
if ($tempa==0) {
print " Hit Points";
}
print "<br>Number Encountered: ";
if ($tempd==1) {
print $tempc;
} else {
print $tempc."d".$tempd;
}
if ($totalhpl>$totalhpw) {
print " (";
if ($tempdl==1) {
print $tempcl;
} else {
print $tempcl."d".$tempdl;
}
print ")";
}
$hdice[$x]=$tempa;
$hdiceadd[$x]=$tempb;
$wnenca[$x]=$tempc;
$wnencb[$x]=$tempd;
if ($totalhpl>$totalhpw) {
$lnenca[$x]=$tempcl;
$lnencb[$x]=$tempdl;
} else {
$lnenca[$x]=$tempc;
$lnencb[$x]=$tempd;
// ie the same as for wandering.
}
print "<br>Morale: ".$monmor[min(6,$homelevel)][rand(1,20)];
print "<br>Armour Class: ";
if ($homelevel<7) {
$ac=6.5-floor($homelevel/2);
if (rand(1,2)==1) {
$ac=floor($ac);
} else {
$ac=ceil($ac);
}
} else {
$ac=7-floor($homelevel/2);
}
print rand($ac-2,$ac+2);

$damr=3;
if ($homelevel==1) {
$avdam=3;
$damr=2;
} elseif ($homelevel<8) {
$avdam=$homelevel+2.5;
} else {
$avdam=11.5+(($homelevel-8)*1.5);
}
$avdam=rand($avdam-$damr,$avdam+$damr);
$dlee=30;
$dlow=max(1,floor($avdam*(100-$dlee)/100));
$dhigh=ceil($avdam*(100+$dlee)/100);
$mostatt=4;
$mostdice=3;
while ($dlow>$mostatt*$mostdice*(($diceface[$dicenum]/2)+.5)) {
if (rand(1,2)==1) {
$mostatt++;
} else {
$mostdice++;
}
}
for ($aa=1;$aa<=$mostatt;$aa++) {
$attacknum[$aa]=0;
}
$exdam=0;
while ($exdam<$dlow OR $exdam>$dhigh) {
$aa=rand(1,$mostatt);
$cv=$attacknum[$aa]*(($attackdice[$aa]/2)+.5);
$nn=rand(0,$mostdice);
$nd=$diceface[rand(2,$dicenum)];
$nv=$nn*(($nd/2)+.5);
if (($nv<$cv AND $exdam>$dhigh) OR ($nv>$cv AND $exdam<$dlow)) {
$attacknum[$aa]=$nn;
$attackdice[$aa]=$nd;
$exdam=$exdam-$cv+$nv;
}
};
print "<br>Attacks: ";
$an=0;
for ($aa=1;$aa<=$mostatt;$aa++) {
if ($attacknum[$aa]>0) {
$an++;
}
}
print $an;
print "<br>Damage: ";
$fa=0;
for ($aa=1;$aa<=$mostatt;$aa++) {
if ($attacknum[$aa]>0 AND $attackdice[$aa]>0) {
if ($fa==1) {
print ", ";
}
print $attacknum[$aa]."d".$attackdice[$aa];
$fa=1;
}
}
print "<br>Movement: ";
$temsp=$monsp[min($homelevel,8)][rand(1,20)];
$movetype=0;
// 0: normal, 1: flying (show two speeds),
// 2: teleports (show two speeds).
if (rand(1,2)==1) {
if ($temsp>=150) {
$movetype=1;
}
if (rand(1,25)==1) {
$movetype=2;
}
}
if ($movetype==1) {
if ($temsp==300) {
$grspd=150;
} elseif ($tempsp>210) {
$grspd=90+(rand(0,1)*30);
} else {
$grspd=max(rand(1,4)*30,rand(1,4)*30);
}
print $grspd."' (".($grspd/3)."')";
print "<br>Flying: ";
}
print $temsp."' (".($temsp/3)."')";

if ($movetype==2) {
print $line;
print "This creature teleports, like a blink dog (see p.66 of Labyrinth Lord)";
}

if (rand(1,5)<3) {
// monstrous abilities.
print $line;
if (rand(1,7)==1) {
print "This creature's attack is a breath weapon. It can thus attack at a distance. It doesn't roll to hit. Rather, the target must save vs Breath Attacks or take the damage.";
} elseif (rand(1,6)==1) {
if ($homelevel<3) {
print "This creature's touch rusts metal, like a Rust Monster (see p92 of Labyrinth Lord).";
} else {
print "This creature regains ".($homelevel-2)." hit point";
if ($homelevel>3) {
print "s";
}
print " per round, up to its full strength.";
}
} elseif (rand(1,5)==1) {
print "A character hit by this creature must save vs Poison";
$poislev=$homelevel+rand(1,3)-rand(1,3);
$poislev=min(20,max(1,$poislev));
if (rand(1,2)==1) {
print ", or ";
if ($poislev>5) {
print "die.";
} elseif ($poislev>2) {
print "lose 1d3 HP this round, and every subsequent round until either they die, or a <i>Cure Disease</i> spell is cast on them.";
} else {
print "take an extra 1d6 damage.";
}
} else {
print ", as for a class ";
print $poislev;
print " poison (see p50 of Mutant Future)";
}
} elseif (rand(1,4)==1) {
print "A character hit by this creature must save vs Petrify or Paralyze or become paralysed ";
$parlev=$homelevel+rand(1,3)-rand(1,3);
if ($parlev<3) {
print "for ".(min(rand(1,3),rand(1,3)))."d".((rand(1,3)*2)+2)." rounds, or ";
}
print "until cured by means such as a <i>Cure Light Wounds</i> spell.";
} elseif (rand(1,3)==1) {
print "A character hit by this creature has a ";
$dralev=$homelevel+rand(1,3)-rand(1,3);
$dralev=$dralev*10;
$dralev=max(10,$dralev);
$dralev=min(90,$dralev);
print $dralev;
print "% chance of suffering an energy drain (see p62 of Labyrinth Lord) ";
if (rand(1,2)==1) {
print "as well as";
} else {
print "instead of";
}
print " taking the listed damage from the attack.";
} elseif (rand(1,2)==1) {
print "This creature's attacks aren't physical, but mental. Treat it's WIL/WIS as ";
print (($homelevel*2)+6+rand(1,3)-rand(1,3));
print " (see p47 of Mutant Future).";
} else {
print "Wounds caused by this creature can cause lycanthropy (see p85 of Labyrinth Lord).";
}
}
print $line;
if (str_replace("Gamma","XXX",$crnick[$x])<>$crnick[$x] OR str_replace("Radiation","XXX",$crnick[$x])<>$crnick[$x] OR (str_replace("Shining","XXX",$crnick[$x])<>$crnick[$x] AND rand(1,2)==1)OR rand(1,8)==1) {
print "This creature glows with radioactivity. Anyone who spends ".(rand(1,4)*6)." hours in its presence must save as if they've been exposed to Class ";
$rl=$homelevel+rand(1,3)-rand(1,3);
$rl=max(1,min(10,$rl));
print $rl." radiation (see p51 of Mutant Future). After that, they";
if (rand(1,3)==1) {
print " must make the save save for every 12 hours of exposure";
} elseif (rand(1,2)==1) {
print "'re immune to radiation from the specific individual (but are still vulnerable to other members of the species)";
} else {
print "'re immune to radiation from this species";
}
print ". The creature itself is immune to radiation.";
print $line;
}
// do the same thing for 'Waste' and 'Toxic' with disease
// (look for 'flesh-eating bacteria' in MF).

$undead=0;
if (str_replace("demon","XXX",$y)<>$y) {
$undead=1;
if (rand(1,2)==1) {
print "This creature is undead. If a Cleric tries to turn one, the DM should use the row marked 'Infernal' instead of its Hit Dice.";
print $line;
} elseif (rand(1,2)==1) {
print "This creature is undead (it's not 'Infernal')";
print $line;
}
} elseif (str_replace("disembodied","XXX",$y)<>$y OR str_replace("skeleton","XXX",$y)<>$y OR str_replace("ghost","XXX",$y)<>$y OR str_replace("corpse","XXX",$y)<>$y OR str_replace("doll","XXX",$y)<>$y) {
if (rand(1,2)==1) {
print "This creature is undead.";
$undead=1;
print $line;
}
}
if (rand(1,6)==1) {
print "This creature can turn the undead";
if ($undead==1) {
print " (other than members of its own species)";
}
print " as a Cleric of level ";
$clericl=max(1,$tempa);
if ($clericl==1 OR rand(1,2)==1) {
print $clericl;
} else {
print rand(1,$clericl);
}
print ".".$line;
}
if (rand(1,6)==1) {
print "This creature has the special abilities of a Thief of level ";
$thiefl=max(1,$tempa);
if ($thiefl==1 OR rand(1,2)==1) {
print $thiefl;
} else {
print rand(1,$thiefl);
}
print ".".$line;
}
if (rand(1,4)==1) {
print "Because of its large size, this creature treats Halflings as if their AC was 2 lower than its real value (see p11 of Labyrinth Lord).";
print $line;
}
if (rand(1,6)==1) {
do {
$manyspell=rand(1,(2*$homelevel));
$highlevel=rand(1,min($homelevel,9));
$mv=$manyspell*$highlevel;
} while (abs($mv-$homelevel)>2);
$y=$y."<br><br>Once a day they can cast ";
if ($manyspell>1) {
$y=$y."the following spells:<br>";
}
for ($a=1;$a<=$manyspell;$a++) {
if (rand(1,2)==1) {
$y=$y.$cleric[rand(1,min($highlevel,7))][rand(1,8)]."<br>";
} else {
$splevel=rand(1,$highlevel);
$spchoice=rand(1,12);
if ($splevel==9) {
$spchoice=rand(1,9);
}
$y=$y.$elfmu[$splevel][$spchoice]."<br>";
}
}
$y=$y."Treat its Hit Dice as its level if this is relevant to spell-casting.";
}
$lang=rand(1,4);
} elseif ($system=="tt") {

// this one must be first in the list in order
// for 'while in this form' to make sense.
if (str_replace("revert","XXX",$y)<>$y AND $stats[$x][0]==2 AND rand(1,2)==1) {
do {
$att1=$sname[rand(1,$attnum)];
$att2=$sname[rand(1,$attnum)];
$att3=$sname[rand(1,$attnum)];
} while ($att1==$att2 OR $att2==$att3 OR $att3==$att1 OR $att1=="CON" OR $att2=="CON" OR $att3=="CON");
$y=$y." While in its true form, its ".$att1." ";
if (rand(1,2)==1) {
$y=$y."is doubled, but its ".$att2." and ".$att3." are";
} else {
$y=$y."is multiplied by 3/2, but its ".$att2." is";
}
$y=$y." halved (round down for both).";
}

// this one likewise.
if (str_replace("statue","XXX",$y)<>$y) {
if (rand(1,3)==1) {
if (str_replace("statue^","XXX",$y)<>$y) {
if (str_replace("statue^^","XXX",$y)<>$y) {
$z=str_replace("a ","",$an);
$z=str_replace("an ","",$z);
$y=$y." In death, its corpse will look like that of a normal ".$z.".";
} else {
$z=str_replace("a ","",$pl);
$z=str_replace("an ","",$z);
$y=$y." If it dies, its corpse will look like a normal ".$z.".";
}
} else {
$y=$y." In death, it will look like a normal corpse rather than a statue.";
}
} elseif (rand(1,2)==1) {
$y=$y." If it dies, its corpse will be indistinguishable from an actual statue. It will be worth ";
$y=$y.($level[rand($shallow[$x],$deep[$x])]*100*rand(1,6));
$y=$y." gold pieces, and weigh the same as ";
$y=$y.(rand(75,350)*10);
$y=$y." coins.";
} else {
$y=$y." If it dies, its corpse will wither until all that's left is a single ";
$a=rand(1,$jnum);
$b=rand(1,4);
$base=$jewel[$a][1];
if ($base<25) {
$y=$y."semi-";
}
$y=$y."precious stone (".$jewel[$a][0].", weighing the same as ";
if ($b==1) {
$y=$y."a coin";
} else {
$y=$y.$b." coins";
}
$y=$y." and worth ".($b*$base)." gold pieces).";
}
}
}

// for any system.
$y=str_replace("^","",$y);
$y=str_replace("the disembodied head of a skeleton","a disembodied skull",$y);
$y=str_replace("a child's doll of a human child","a child's doll",$y);

if ($system=="tt") {
$a=rand(1,10);
if ($a==1) {
do {
$z=$sname[rand(1,$attnum)];
} while ($z=="CON" OR ($spd==0 AND $z=="SPD"));
$y=$y."<br><br>Half the damage that this creature does (rounded down) comes off ".$z." instead of CON.";
if ($z=="STR") {
$y=$y." If this brings a delver's STR below the amount they need to wear their armour, they'll collapse on the floor and be unable to act, but not suffer any damage. The creature will ignore them until and unless all other delvers have been dealt with. If it means they can't use their shield, they'll get no benefit from the shield and their shield arm will be useless, but again they won't suffer any damage.";
}
if ($z=="STR" or $z=="DEX") {
$y=$y." If a delver can no longer use their weapon, they'll drop it.";
}
} elseif ($a==2) {
$y=$y."<br><br>For any Combat Round where one of these creatures does any damage, and at least one of their opponents is wearing armour (shields don't count), roll 1 dice.<br><br>1-2 Treat the damage as normal.<br>3-4 Armoured opponents take no damage, but their armour permanently absorbs 1 less damage. If it now absorbs no damage, it will fall off.<br>5-6 Armoured opponents take no damage.";
} elseif ($a==3) {
$y=$y."<br><br>If this creature does any damage to an opponent who isn't wearing any armour (and the damage isn't reduced to zero by a shield) that opponent takes an extra ".max(2,$level[rand($shallow[$x],$deep[$x])])." points of damage.";
} elseif ($a==4) {
$y=$y."<br><br>If this creature does hand-to-hand damage to a single character who knows any spells, and the damage isn't reduced to zero by armour and shields, that character has a ".(rand(1,5))." in 6 chance of forgetting a single randomly-chosen spell instead of taking the damage. Rogues can forget any spell. Wizards can forget any spell of level 2 or above (if they don't know any, they'll take the damage instead). The character will be able to re-learn the spell.";
}
$armour=0;
if (str_replace("robot","XXX",$y)<>$y) {
$armour+=rand(1,3);
}
if (str_replace("turtle","XXX",$y)<>$y) {
$armour+=rand(1,3);
}
if (str_replace("statue","XXX",$y)<>$y) {
$armour+=rand(1,3);
}
if (str_replace("scarab","XXX",$y)<>$y) {
$armour+=rand(1,3);
}
if (str_replace("rhino","XXX",$y)<>$y) {
$armour+=rand(1,3);
}
if (str_replace("triceratops","XXX",$y)<>$y) {
$armour+=rand(1,3);
}
if (str_replace("doll","XXX",$y)<>$y) {
$armour=0;
}
$z=$level[rand($shallow[$x],$deep[$x])];
$a=rand(1,6);
$toughskin=0;
if ($armour>0 AND $z>$a) {
$toughskin=$armour+$z-$a;
$y=$y."<br><br>Its tough skin acts as armour, stopping ".($armour+$z-$a)." points of damage.";
}

if (str_replace("animated corpse","XXX",$y)<>$y OR str_replace("disembodied","XXX",$y)<>$y) {
$z=$level[rand($shallow[$x],$deep[$x])];
$z=rand(0,$z);
$y=$y."<br><br>On first meeting the creature, or a group of the creatures, all delvers must make a level ".$z." save on ";
if ($wiz==1) {
$y=$y."WIZ";
} else {
$y=$y."INT";
}
$y=$y.". Any delvers who fail will have to subtract the amount they failed by from any saving rolls, or rolls to generate a Hit Point Total, that they make when dealing with the species. Each time a delver who failed meets a different member of this species (or group of them), they may make the save again, and take the better result.";
}

$wooden=0;
if (str_replace("wood","XXX",$y)<>$y) {
$wooden=1;
}

if (str_replace("tree","XXX",$y)<>$y AND str_replace("statue","XXX",$y)==$y AND str_replace("ghost","XXX",$y)==$y AND str_replace("robot","XXX",$y)==$y) {
$wooden=1;
}

if ($wooden==1 AND rand(1,2)==1) {
$z=$level[rand($shallow[$x],$deep[$x])];
$z=rand(0,$z);
$y=$y."<br><br>If this creature";
if (str_replace("true form","XXX",$y)<>$y) {
$y=$y." reverts to its true form, and in that form it";
}
$y=$y." loses a Combat Round against a delver with a bladed or pointed weapon and survives, there's a ";

// 'a head' rather than 'head', because of 'disembodied head'.
if (str_replace("waist","XXX",$y)==$y AND str_replace("a head","XXX",$y)==$y) {
$y=$y."50%";
$a="their wooden";
} else {
$y=$y."1 in 3";
$a="the wooden part of their";
}
$y=$y." chance that the weapon will get stuck in ".$a." body. If it does, a delver can try and pull it out. This takes the delver the whole round. The delver must make a level ".$z." save against the higher of STR or DEX. If they fail by more than 5, or roll a critical failure, the weapon breaks. If they succeed by more than 5, the creature takes damage as if they'd been hit again with the weapon (this doesn't count towards the party's Hit Point Total). If they succeed by more than 10, the creature splits in two and dies.";
}

if (str_replace("robot","XXX",$y)<>$y OR str_replace("ghost","XXX",$y)<>$y OR str_replace("animated corpse","XXX",$y)<>$y OR str_replace("demon","XXX",$y)<>$y OR str_replace("statue","XXX",$y)<>$y) {
$poison=$level[rand($shallow[$x],$deep[$x])];
$z=rand(1,6)+rand(1,6);
if ($poison>$z) {
$y=$y."<br><br>This creature is completely immune to poison.";
} elseif (($poison*2)>$z) {
$y=$y."<br><br>Every time this creature is wounded by a poisoned weapon, they have a 50% chance of suffering no ill effects from the poison.";
}
}

$rcommand=0;
if ((str_replace("robot","XXX",$y)<>$y AND rand(1,3)==1) OR (str_replace("puppet","XXX",$y)<>$y AND rand(1,2)==1)) {
$y=$y."<br><br>Delvers can attempt to command these creatures if they share a language with them. They must ";
$rcommand=1;
if ($stats[$x][0]==1) {
$z=$level[rand($shallow[$x],$deep[$x])];
$z=rand(0,$z);
$y=$y."make a level ".$z." save on CHR. The delver subtracts two from their roll for each of the creatures present. If they make the roll,";
} else {
$y=$y."roll two dice, with doubles adding and rolling over, and add their CHR. The creatures do the same with their INT. If the delver's total is higher than any single creature's total,";
}
$y=$y." the creatures will obey the delver without question for an hour. Otherwise, all creatures present will be 'immune' to further attempts for two hours.";
$y=$y." A failed attempt, or a successful attempt which 'runs out', won't affect normal diplomacy with the creatures. However the delvers' treatment of them while they're under command can have a negative effect.";
}

if (str_replace("robot","XXX",$y)<>$y) {
if (rand(1,6)==1) {
$y=$y."<br><br>These creatures regard vending machines as gods. They'll stop anyone trying to break into them, at the risk of their own lives. ";
if ($rcommand==1) {;
$y=$y." This applies even if they're under the command of the delver trying to break in - although once the delver stops they'll still obey them. ";
}
$y=$y."They'll also want to put at least some money into the machines every time they pass one. If they're with a group of delvers who refuse, for the next 24 hours the creature will treat the delvers as if their CHR was 2 points lower than its real value. This penalty is added each time the delvers refuse to 'make an offering to the god' - even if the delvers pass the same machine several times.";
} elseif (rand(1,5)==1) {
$y=$y."<br><br>These creatures regard vending machines as hateful oppressors. They'll always try to break into them when they see one. They'll attack anyone on sight who tries to put money into one, or even mentions having done so.";
if ($rcommand==1) {
$y=$y." This applies even if they're under the command of the delver trying to put money in - although once the delver stops they'll still obey them.";
}
}
}

if ((str_replace("scorpion","XXX",$y)<>$y AND str_replace("disembodied","XXX",$y)==$y) OR (str_replace("snake","XXX",$y)<>"$y" AND rand(1,2)==1)) {
$poison=$level[rand($shallow[$x],$deep[$x])];
$z=rand(1,6)+rand(1,6);
if ($poison>$z*2) {
$y=$y."<br><br>This creature's weapons are poisoned. If it wins a Combat Round, it does double damage <i>after</i> the damage is reduced by armour and shields.";
} elseif ($poison>$z*1.5) {
$y=$y."<br><br>This creature's weapons are poisoned. If it wins a Combat Round, it does 1.5 times normal damage <i>after</i> the damage is reduced by armour and shields.";
} elseif ($poison>$z) {
$y=$y."<br><br>This creature's weapons contain a mild poison. If it wins a Combat Round, and a delver doesn't reduce its damage to zero with armour and shield, they become sick. While sick, they don't recover any attributes from normal healing. Every four hours they may make a level ".$z." save on CON. If they succeed, they're no longer sick.";
}
}
}

$y="This creature ".$y;
print $y;
print $line;
$desc[$x]=$y;
if ($system=="tt") {
print "They are ".$sizetext[$crsize[$x]][1];
if ($adds==4) {
print " (in 5th edition rules, a level ".$sizetext[$crsize[$x]][3]." DEX save to hit at point-blank range)";
}
print ".";
print $line;
$ww=0;
if ($stats[$x][0]==1) {
print "Monster Rating ".$stats[$x][1]." (".(floor($stats[$x][1]/10)+1)." dice + ".(floor($stats[$x][1]/2))." adds)";
print $line;
if ($mrtype[$x]<>$adds) {
$y=$mrdesc[$mrtype[$x]];
$y=str_replace("@@D",floor($stats[$x][1]/10)+1,$y);
$y=str_replace("@@A",floor($stats[$x][1]/2),$y);
print "This creature ".$y;
print $line;
}
} else {
$ca=0;
$ma=0;
$ap=0;

$ct=0;
$mt=0;
// $ct and $mt aren't implemented yet -
// combat and missile adds when transformed
// (ie only for creatures with a 'true form')

print "<table cellspacing=0 cellpadding=0>";
for ($y=1;$y<=$attnum;$y++) {
$score=$stats[$x][$y];
if ($y%2==1 AND ($y<7 OR $spd==1)) {
$z=0;
if ($score>12) {
$z=$score-12;
} elseif ($score<9) {
$z=$score-9;
}
$ca+=$z;
$ma+=$z;
if ($y==5) {
$ma+=$z;
}
}
if ($y<5 AND $y<>3) {
$ap+=$score;
}
print "<tr><td align=\"right\">".$sname[$y].":</td><td width=20></td><td align=\"right\">".$score."</td></tr>";
}
print "<tr><td align=\"right\"><i>Combat Adds</i>:</td><td width=20></td><td align=\"right\">".$ca."</td></tr>";
print "<tr><td align=\"right\"><i>Missile Adds</i>:</td><td width=20></td><td align=\"right\">".$ma."</td></tr>";
print "</table>";
print $line;
$int=$stats[$x][2];
$dex=$stats[$x][5];
$mag=min(floor(($int-8)/2),$dex-7);
if ($mag>0) {
$sfu=$stats[$x][1+($wiz*7)];
$a=min(rand(2,7),rand(2,4)*$mag);
$reducea=0;
for ($b=1;$b<=$a;$b++) {
do {
$spok=1;
$d=rand(1,$spnum+$xspnum);
if ($crmag[$x][$d]==1) {
$spok=0;
} elseif ($d<=$spnum) {
if ($spells[$d][1]>$mag OR $spells[$d][2]>=$sfu) {
$spok=0;
}
} elseif ($xspells[$d-$spnum][1]>=$sfu) {
$spok=0;
}
$moveon=rand(1,10);
} while ($spok==0 AND $moveon<10);
if ($spok==1) {
$crmag[$x][$d]=1;
if ($d>$spnum) {
$ewspell++;
$ewspells[$d-$spnum]=1;
}
} else {
$reducea++;
}
}
$d=0;
$a=$a-$reducea;
if ($a>0) {
print "They can cast ";
for ($b=1;$b<=($spnum+$xspnum);$b++) {
if ($crmag[$x][$b]==1) {
$d++;
if ($b<=$spnum) {
print $spells[$b][0];
} else {
print $xspells[$b-$spnum][0];
print " (see 'Magic of Odand' below)";
}
if ($d<$a-1) {
print ", ";
} elseif ($d==$a-1) {
print " and ";
}
}
}
print ".".$line;
}
}
print "Defeating one of these creatures is worth ".$ap." AP.";
print $line;
print "They use ";
$hidam=max(3.5,round($stats[$x][1]/10)*3.5);
$a=0;
$fw=0;
do {
$a++;
$hw=rand(1,$handnum);
if ($stats[$x][1]>=$handw[$hw][3] AND $stats[$x][5]>=$handw[$hw][4] AND $stats[$x][5]>=$handw[$hw][5]) {
$newdam=(3.5*$handw[$hw][1])+$handw[$hw][2];
if ($newdam>$hidam) {
$hidam=$newdam;
$fw=$hw;
}
}
} while (($fw==0 AND $a<10) OR $a<5);
if ($fw>0 AND $htoh[$x]<>1 AND str_replace("disembodied","XXX",$desc[$x])==$desc[$x]) {
if ($handw[$fw][0]=="staff") {
print "staves";
} else {
print $handw[$fw][0]."s";
}
print " (".$handw[$fw][1]." dice ";
if ($handw[$fw][2]>=0) {
print "+ ";
} else {
print "- ";
}
print abs($handw[$fw][2]).", used ".$handw[$fw][9]."-handed, min. STR ".$handw[$fw][3]." DEX ".$handw[$fw][4];
if ($handw[$fw][8]>0) {
if ($handw[$fw][4]==$handw[$fw][5]) {
print " (hand-to-hand or thrown)";
} else {
print " hand-to-hand, ".$handw[$fw][5]." to throw";
}
print ", range ".$handw[$fw][8]." yards/metres";
}
print ", weight ".$handw[$fw][7].", value ".$handw[$fw][6]."gp)";
$ww=$handw[$fw][7];
} else {
if (str_replace("disembodied","XXX",$desc[$x])<>$desc[$x]) {
print "their teeth";
} elseif (str_replace("Sword","XXX",$desc[$x])<>$desc[$x]) {
print "themselves as weapons";
} else {
print "'tooth and claw'";
}
print " (".max(1,round($stats[$x][1]/10))." dice)";
}
print ".<br>".$line;

// ranged weapon. only pick one for this.

$rw=rand(1,$rangenum);
if ($stats[$x][1]>=$rangew[$rw][3] AND $stats[$x][5]>=$rangew[$rw][4] AND str_replace("disembodied","XXX",$desc[$x])==$desc[$x] AND $htoh[$x]<>1) {
$rww=$rangew[$rw][7];
$am=$rangew[$rw][5];
if ($am<>"self") {
$rww+=$ammo[$am][2];
}
if ($stats[$x][1]*100>=$ww+$rww) {
$ww+=$rww;
$wname=$rangew[$rw][0];
print "They'll also carry a ".$wname." (";
if ($wname<>"bullwhip") {
print $rangew[$rw][1]." dice + ".$rangew[$rw][2].", ";
}
print "used ".$rangew[$rw][9]."-handed, min. STR ".$rangew[$rw][3]." DEX ".$rangew[$rw][4].", range ".$rangew[$rw][8]." yards/metres, weight ".$rangew[$rw][7]." value ".$rangew[$rw][6]."gp)";
if ($wname=="bullwhip") {
print "<br><br>Wizards can't use bullwhips. Bullwhips do no damage. Instead, the creature wielding it can try and wrap it around an opponent's weapon and pull the weapon out of their hands (it's no use against an opponent fighting with fists, claws etc). To do this, they make a DEX saving roll as if they were using a missile weapon. However, if the victim has a shield, the difficulty of the roll is increased by the damage reduction of the shield (armour doesn't have any effect).<br><br>If the attacker makes the save, they compare their STR to the STR of their opponent. If the target weapon is 1-handed, and the attacker's STR is at least half that of the defender, the defender's weapon is yanked out of their hand. If the target weapon is 2-handed, the bullwhip wielder's STR must be at least equal to the opponent's STR. In either case, if the attacker's STR isn't high enough the attack has no effect.";
} elseif ($wname=="pistol") {
print "<br><br>Pistols are mechanical contrivances of the gnomes. They fire anything that's put in them (stones, bits of metal etc). Their range is effectively limitless: if you can see it you can shoot at it. However, if the range is more than 50 yards/metres the shooter rolls on LK rather than DEX, and uses LK adds rather than DEX adds to modify damage. If the shooter's roll to hit is a critical failure, they should roll 2 dice:<br>2-3: The weapon starts to fire late, and will do so until it's unloaded and re-loaded. If this is done in combat, it will take an entire Combat Round. Until then, add 1 to the level of all saving rolls to hit.<br>4-6: The pistol is jammed. It must be unloaded and re-loaded before it can be used again. This will take the whole of the next Combat Round.<br>7-8: It gives a flash and a bang, but doesn't shoot. The shooter should make a level 1 saving roll on INT. If they make it, treat as '2-3' above. If they fail, they instinctively look down the barrel to see what the problem is - the weapon then goes off, and the shooter takes full damage, not reduced by armour or shields.<br>9-10: The weapon doesn't shoot - this Combat Round is wasted.<br>11: The pistol jams, and will be unusable until it's repaired (the gnomes are the only ones who know anything about these devices).<br>12: The pistol explodes, and the weapon's user takes the full dice and adds of the weapon in damage (reduced by armour but not shields).";
}
if ($am<>"self") {
print ", and ".$ammo[$am][0]." (weight ".$ammo[$am][2]." total value ".$ammo[$am][1]."gp)";
}
print $line;
}
}
}
if ($stats[$x][0]==2) {
$int=$stats[$x][2];
if ($int>12) {
$lang=min($langnum,$int-12);
} else {
$lang=1;
}
} else {
$lang=min(rand(1,3),rand(1,3));
}
}

$langdone=0;

// robots often speak dwarvish.
if (str_replace("robot","XXX",$desc[$x])<>$desc[$x] AND rand(1,2)==1) {
$crlang[$x][2]=1;
$langdone++;
}

// if it looks like a hobbit, it often speaks hobbit.
// (or halfling, in LL's case)
// ditto for dwarf, elf.
if (str_replace("dwarf","XXX",$desc[$x])<>$desc[$x] AND rand(1,2)==1 AND $crlang[$x][2]<1) {
$langdone++;
$langdone=$langdone-$crlang[$x][2];
$crlang[$x][2]=1;
}
if (str_replace("hobbit","XXX",$desc[$x])<>$desc[$x] AND rand(1,2)==1) {
$crlang[$x][5]=1;
$langdone++;
}
if (str_replace("halfling","XXX",$desc[$x])<>$desc[$x] AND rand(1,2)==1) {
$crlang[$x][5]=1;
$langdone++;
}
if (str_replace("elf","XXX",$desc[$x])<>$desc[$x] AND rand(1,2)==1) {
$crlang[$x][3]=1;
$langdone++;
}

// warthogs = orcs
if (str_replace("warthog","XXX",$desc[$x])<>$desc[$x] AND rand(1,2)==1 AND $crlang[$x][6]<1) {
$crlang[$x][4]=1;
$langdone++;
}

// alignment language (Labyrinth Lord only)
if ($system=="ll" and rand(1,2)==1) {
$crlang[$x][10+$alent]=1;
$langdone++;
}

$lang=max($lang,$langdone);
for ($z=1;$z<=$lang-$langdone;$z++) {
do {
$a=rand(1,$langnum);
} while ($crlang[$x][$a]==1);
$crlang[$x][$a]=1;
}
print "These creatures speak and understand ";
$a=0;
for ($z=1;$z<=$langnum;$z++) {
if ($crlang[$x][$z]==1) {
$a++;
print $language[$z];
if ($lang>2 AND $a<$lang) {
print ", ";
}
if ($a==$lang-1) {
print " and ";
}
}
}
print ".";
print $line;

if ($crarmour[$x][0]>0 AND $htoh[$x]<>1 AND $system=="tt") {
$ghostprint=0;
if (str_replace("ghost","XXX",$desc[$x])<>$desc[$x]) {
$ghostprint=rand(1,3);
}
if ($stats[$x][0]==1 OR ($stats[$x][1]>=$crarmour[$x][2] AND $stats[$x][1]*100>=$crarmour[$x][3]+$ww)) {
print "These creatures wear ";
if (str_replace("disembodied","XXX",$desc[$x])<>$desc[$x]) {
print "a helmet";
} else {
print "armour";
}
print " which absorbs ".$crarmour[$x][1]." damage";
if ($toughskin>0) {
print " (a total of ".($toughskin+$crarmour[$x][1])." with their tough skin)";
}
if ($ghostprint==1) {
print ".";
} else {
print ", weighs the same as ".$crarmour[$x][3]." coins, and is worth ".$crarmour[$x][4]." gold.";
if ($crsize[$x]<3 OR str_replace("disembodied","XXX",$desc[$x])==$desc[$x]) {
print " It requires ".$crarmour[$x][2]." STR for a non-Monster-Rated creature to wear.";
}
}
}
print $line;
if ($ghostprint==1) {
print "If this creature is 'killed', its armour will fade away with it.";
} elseif ($ghostprint==2) {
print "If this creature is 'killed', its armour will retain some traces of magic. Any statted creature who tries to wear its armour must make a level ";
$tlev=$level[rand($shallow[$x],$deep[$x])];
print rand(0,$tlev)." save on ";
if ($wiz==1) {
print "WIZ";
} else {
print "CHR";
}
print ". If they fail, they take the difference in damage - half, rounded down, coming off LK - and can't put the armour on. If they succeed, they can wear the armour safely from then on. ";
} elseif ($ghostprint==3) {
print "If this creature is 'killed', its armour will become substantial and may be worn. ";
}
if (str_replace("demon","XXX",$desc[$x])<>$desc[$x]) {
if (rand(1,3)==1) {
print "If this creature is 'killed', its armour will forever retain some of the foul odour of the abyss. Anyone who wears it will have ".(3+$level[rand(1,$l)])." less CHR while they wear it, and afterwards until they've bathed. ";
} elseif (rand(1,2)==1) {
print "If this creature is 'killed', its armour will forever retain some of the heat of the inferno. Any statted creature who tries to wear its armour must make a level ";
$tlev=$level[rand($shallow[$x],$deep[$x])];
print rand(0,$tlev)." save on ";
if ($wiz==1) {
print "WIZ";
} else {
print "CON";
}
print ". If they fail, they take the difference in damage - half, rounded down, coming off CHR - and can't put the armour on. If they succeed, they can wear the armour safely from then on. ";
}
}
if ($ghostprint<>1) {
if (str_replace("disembodied","XXX",$desc[$x])==$desc[$x]) {
if ($sizetext[$crsize[$x]][2]<>"XXX") {
print ucfirst($sizetext[$crsize[$x]][2]).", and c";
} else {
print "C";
}
print "reatures described as '".$sizetext[$crsize[$x]][1]."', can wear these creatures' armour.";
} elseif ($crsize[$x]<3) {
if ($sizetext[$crsize[$x]+4][2]<>"XXX") {
print ucfirst($sizetext[$crsize[$x]+4][2]).", and c";
} else {
print "C";
}
print "reatures described as '".$sizetext[$crsize[$x]+4][1]."', can wear these creatures' helms.";
} else {
print "These creatures' helmets are too large for anyone to wear (but the delvers can still sell them, for example to wizards, bored nobles looking for novelty cooking pots, and people who find the phrase 'these creatures' helmets are too large for anyone' hilarious).";
}
}
print $line;
}
if ($spt[$x]>0) {
print "This creature alters the air wherever it goes. It will always be <i>".$climates[$spt[$x]]."</i> in the presence of this creature.";
print $line;
print "If two creatures who alter the air meet, compare their ";
if ($system=="ll") {
print "Hit Dice (use current Hit Points to break ties)";
} else {
print "CHR ";
if ($wiz==1) {
print "or WIZ, whichever's higher ";
}
print "for statted creatures, or MR divided by ".(7+$wiz)." for Monster-Rated creatures";
}
print ". The one with the highest number will affect the air.";
print $line;
print "Changing the air in this way doesn't alter how often the GM should roll for wandering monsters.";
print $line;
}
}
print $line;
if ($system=="tt" and $fullstat==1) {
print "<b>Using Dungeon Species In Other Adventures</b>";
print $line;
print "If you want to give the statted creatures of the dungeon individual attributes (for example to use them as player characters), use the following multipliers:";
print $line;
print "<table border=4 cellspacing=4 cellpadding=4>";
print "<tr><td>Species</td>";
for ($y=1;$y<=$attnum;$y++) {
print "<td>".$sname[$y]."</td>";
}
print "</td></tr>";
for ($z=1;$z<=$sn;$z++) {
if ($stats[$z][0]==2) {
print "<tr><td>".$crname[$z]."</td>";
for ($y=1;$y<=$attnum;$y++) {
print "<td>x ";
$a=max(1,round($stats[$z][$y]/2.625));
if ($a%4==0) {
print ($a/4);
} elseif ($a%2==0) {
print ($a/2)."/2";
} else {
print $a."/4";
}
print "</td>";
}
print "</tr>";
}
}
print "</table>";
print $line;
print $line;
}
print "<b>Mission</b>";
print $line;
print $entstr;
print $line;
print $line;
print "<b>Diplomacy:</b>";
print $line;
if ($system=="tt") {
print "When a delver is negotiating with one of the creatures in the dungeon, unless the GM decides otherwise they should make a CHR check, at the level listed below.";
print $line;
print "Success means that the creatures will allow the delvers to move through their territory.<br>";
print "Beating the target number by at least 6 means that the creatures will actively aid the delvers - for example, they may share their food.<br>";
print "Beating the target number by at least 12 means that the creatures will go to some risk for the delvers - for example, one of them might act as a guide.<br>";
print "Failure means that the creatures will tell the delvers to return the way they came at once, and fight them if they don't.<br>";
print "Missing the target number by at least 6 means that the creatures will attack, without giving the delvers the opportunity to leave.";
} elseif ($system=="ll") {
print "When one of the party is negotiating with one of the creatures in the dungeon, unless the GM decides otherwise they should roll on the Monster Reaction Table (p52 of Labyrinth Lord, or p45 of Mutant Future). The roll is modified based on the party member's Charisma. There are also modifiers listed below for each species in the dungeon.<br><br>The creatures in the dungeon won't treat mutants differently. Don't use the 'Charisma and Racial Modifier Table' on p11 of Mutant Future.";
print $line;
print "A result of 'Friendly, helpful' means that the monsters will actively help the party. For example, they might share their food. If the result is zero or less (obviously only possible with adjustments to the roll), the monsters will go to some risk for them. For example, one of them might act as a guide.<br>";
print "A result of 'Indifferent, uninterested' means that the monsters will allow the party to move through their territory. If they want, the party can continue negotiating with them, making a new roll. They don't get any bonuses for any gifts they originally gave, but can give more.<br>";
print "A result of 'Neutral, uncertain' means that the monsters will allow the party to move through their territory as above. The difference is that with this result, and the two below, the monsters won't be interested in further negotiation.<br>";
print "A result of 'Unfriendly, may attack' means that the monsters will tell the party to return the way they came at once, and fight them if they don't.<br>";
print "A result of 'Hostile, attacks' means that the monsters will attack the party, without giving them a chance to leave.";
print $line;
print "If the party successfully negotiates with a group of monsters, they should get the same XP they would have gotten for defeating them. However, if the party gave any gifts to the monsters, the XP value of the gifts is subtracted from this. If this results in the encounter having a negative XP value, raise it to zero.";

// find average hoard values for monster groups on each level.
for ($z=1;$z<=$l;$z++) {
$a=0;
$b=0;
for ($y=1;$y<=$sn;$y++) {
if ($shallow[$y]<=$z AND $deep[$y]>=$z) {
$a++;
$b+=$treasuretypes[$lhoard[$y]][1];
}
}
$llavtr[$z]=$b/$a;
}
}
print $line;
print "If the delver lacks a common language with the creatures, as well as the penalties listed below they'll find it difficult or impossible to exchange any complex information.";
print $line;
for ($z=1;$z<=$sn;$z++) {
print "(".$z.") ".$crname[$z].", or ".$crnick[$z];
if ($z<=$standardused) {
print " (".$stplural[$standardsn[$z]].")";
}
print $line;
$host=$level[rand($shallow[$z],$deep[$z])];
if ($system=="tt") {
print "CHR save at level ".$host.".<br>";
print "Add 1 to the delver's roll for each ";
$avtr=$level[rand($shallow[$z],$deep[$z])]*rand(70,100)*$c;
// this should be the average treasure
// value of one group of monsters.
} elseif ($system=="ll") {
$host=$host-4;
if (rand(1,2)==1) {
$host=rand(-2,2);
}
if ($host>0) {
print "Add ".$host." to the Monster Reaction roll, but take 1 from the roll for each ";
} elseif ($host<0) {
print "Take ".-$host." from the Monster Reaction roll, and another 1 for each ";
} else {
print "Take 1 from the Monster Reaction roll for each ";
}
// LL/MF gift value goes here.
$avtr=$llavtr[rand($shallow[$z],$deep[$z])];
$avtr=$avtr*rand(80,120)/100;
$avtr=max(100,$avtr);
}
$avtr=$avtr/5;
$avtr=round($avtr/10)*10;
print $avtr."gp worth of gifts the adventurers give.<br>";
if ($system=="tt") {
if (rand(1,2)==1 AND $stats[$z][0]==2) {
print "If the delver's ";
do {
$a=$sname[rand(1,$attnum)];
} while ($a=="CHR");
print $a." is higher than the creatures', the delver can add ".rand(5,10)." to their roll.<br>";
}
print "If the delvers lack a common language with the creatures, they should take ".(rand(1,6)+rand(1,6))." from their roll.";
} elseif ($system=="ll") {
print "They'll treat magic items ";
if (rand(1,2)==1) {
print "and technological artifacts as if they had a value of ".(rand(80,120)*10)."gp.<br>";
} else {
print "as if they had a value of ".(rand(80,120)*10)."gp, and technological artifacts as if they had a value of ".(rand(80,120)*10)."gp.<br>";
}
print "If the party member lacks a common language with the monsters, they should add ".(rand(1,6)+rand(1,6))." to their roll.";
}
print $line;
}
print "For the purposes of trading and giving gifts, the creatures of the dungeon will treat ".$questobject." as if it had a value of ";
if ($system=="tt") {
print ($level[$l]*1000);
} elseif ($system=="ll") {
print round ($llavtr[$l]/10)*10;
}
print " gp.";
print $line;
print $line;

// inter-species relationships.
$anylev=0;
for ($z=1;$z<$sn;$z++) {
for ($y=$z+1;$y<=$sn;$y++) {
if (rand(1,$sn)==1 AND $shallow[$z]<=$deep[$y] AND $shallow[$y]<=$deep[$z]) {
$rel=rand(1,$dipnum);
$anylang=0;
for ($x=1;$x<=$langnum;$x++) {
if ($crlang[$z][$x]*$crlang[$y][$x]==1) {
$anylang=1;
}
}
if ($anylang==1 OR $rel<3) {
$anylev++;
if ($anylev==1) {
print "<b>Inter-Species Diplomacy</b>";
print $line;
}
$cr=$crname[$z];
$a="the ".$cr;
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
$a=$a."e";
}
$cr=$crname[$y];
$a=$a."s and ".$crname[$y];
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
$a=$a."e";
}
$a=$a."s (species ".$z." and ".$y.") are ";
$dipused[$rel]=1;
$a=$a.$diplo[$rel].".";
print ucfirst($a);
$isdiplo[$anylev]=$a;
print $line;
}
}
}
}

for ($y=1;$y<=$dipnum;$y++) {
if ($dipused[$y]==1) {
print ucfirst($diplo[$y]).": ".$dipex[$y].".".$line;
}
}
print $line;

// generate dungeon map

$oddeven=0;
// $oddeven is 0 if there's an even number of inter-level
// tunnels, or odd if there's an odd number.

for ($d=1;$d<=$l;$d++) {
$xlow[$d]=99;
$xhigh[$d]=101;
$ylow[$d]=99;
$yhigh[$d]=101;
$togo=$rn[$d]-1;
$map[100][100][$d]=1;
// 1: encounter area
// 2: connecting tunnels, internal to the level
// 3: connecting tunnels (the ones that fade out on map)
// 4: not part of the dungeon

for ($r=2;$r<=$rn[$d];$r++) {
do {
$dwidth=$xhigh[$d]-$xlow[$d]-1;
do {
if ($dwidth==$mwidth-1) {
if (rand(1,2)==1) {
$x=rand($xlow[$d],$xhigh[$d]-1);
} else {
$x=rand($xlow[$d]+1,$xhigh[$d]);
}
} elseif ($dwidth==$mwidth) {
$x=rand($xlow[$d]+1,$xhigh[$d]-1);
} else {
$x=rand($xlow[$d],$xhigh[$d]);
}
$y=rand($ylow[$d],$yhigh[$d]);
} while ($map[$x][$y][$d]>0);
$neigh=0;
for ($var=1;$var<=2;$var++) {
for ($cha=-1;$cha<=1;$cha++) {
$xcomp=$x;
$ycomp=$y;
if ($var==1) {
$xcomp+=$cha;
} else {
$ycomp+=$cha;
}
if ($map[$xcomp][$ycomp][$d]==1) {
$neigh++;
}
}
}
} while ($neigh==0);
if ($neigh==1) {
$map[$x][$y][$d]=1;
if ($x==$xhigh[$d]) {
$xhigh[$d]++;
} elseif ($x==$xlow[$d]) {
$xlow[$d]--;
}
if ($y==$yhigh[$d]) {
$yhigh[$d]++;
} elseif ($y==$ylow[$d]) {
$ylow[$d]--;
}
// no maximum 'depth', because mwidth is for printing.
} else {
$map[$x][$y][$d]=4;
$r--;
}
}
for ($x=$xlow[$d]+1;$x<$xhigh[$d];$x++) {
for ($y=$ylow[$d]+1;$y<$yhigh[$d];$y++) {
if ($map[$x][$y][$d]<>1) {
$map[$x][$y][$d]=4;
if (rand(1,3)>1) {
$map[$x][$y][$d]=2;
$connect=0;
if ($map[$x][$y+1][$d]==1) {
$connect++;
}
if ($map[$x+1][$y][$d]==1) {
$connect++;
}
if ($map[$x][$y-1][$d]==1) {
$connect++;
}
if ($map[$x-1][$y][$d]==1) {
$connect++;
}
if ($connect==0) {
$map[$x][$y][$d]=4;
} elseif ($connect==1) {
$map[$x][$y][$d]=3;
$exit[$d][0]++;
$oddeven=1-$oddeven;
}
}
}
}
}
}

// if there's no inter-level tunnel on the first level, make one.
if ($exit[1][0]==0) {
$exit[1][0]=1;
for ($xx=$xlow[1];$xx<=$xhigh[1];$xx++) {
$map[$xx][$ylow[1]][1]=4;
$map[$xx][$yhigh[1]][1]=4;
}
for ($yy=$ylow[1];$yy<=$yhigh[1];$yy++) {
$map[$xlow[1]][$yy][1]=4;
$map[$xhigh[1]][$yy][1]=4;
}
$oddeven=1-$oddeven;
$dwidth=$xhigh[1]-$xlow[1]-1;
$xlowone=$xlow[1];
$xhighone=$xhigh[1];
if ($dwidth==$mwidth-1) {
if (rand(1,2)==1) {
$xlowone++;
} else {
$xhighone--;
}
} elseif ($dwidth==$mwidth) {
$xlowone++;
$xhighone--;
}
do {
$neigh=0;
$x=rand($xlowone,$xhighone);
$y=rand($ylow[1],$yhigh[1]);
if ($map[$x][$y][1]<1 OR $map[$x][$y][1]>3) {
for ($var=1;$var<=2;$var++) {
for ($cha=-1;$cha<=1;$cha++) {
$xcomp=$x;
$ycomp=$y;
if ($var==1) {
$xcomp+=$cha;
} else {
$ycomp+=$cha;
}
if ($map[$xcomp][$ycomp][1]==1) {
$neigh++;
}
}
}
}
} while ($neigh<>1);
if ($x==$xhigh[1]) {
$xhigh[1]++;
} elseif ($x==$xlow[1]) {
$xlow[1]--;
}
if ($y==$yhigh[1]) {
$yhigh[1]++;
} elseif ($y==$ylow[1]) {
$ylow[1]--;
}
$map[$x][$y][1]=3;
}

// make one or more of the tunnels on level 1 into 'entrances/exits'.
$difent=rand(1,round($exit[1][0]/2));
for ($z=1;$z<=$difent;$z++) {
do {
$y=rand(1,$exit[1][0]);
} while ($exit[1][$y]<>"");
if ($z==1) {
$exit[1][$y]="This is the entrance the delvers will find or be shown.";
} else {
$exit[1][$y]="This is another entrance to / exit from the dungeon.";
}
$oddeven=1-$oddeven;
}

// if there's an odd number of 'spare' inter-level tunnels,
// make another one.
if ($oddeven==1) {
$d=rand(1,$l);
for ($xx=$xlow[$d];$xx<=$xhigh[$d];$xx++) {
$map[$xx][$ylow[$d]][$d]=4;
$map[$xx][$yhigh[$d]][$d]=4;
}
for ($yy=$ylow[$d];$yy<=$yhigh[$d];$yy++) {
$map[$xlow[$d]][$yy][$d]=4;
$map[$xhigh[$d]][$yy][$d]=4;
}
$dwidth=$xhigh[$d]-$xlow[$d]-1;
$xlowdee=$xlow[$d];
$xhighdee=$xhigh[$d];
if ($dwidth==$mwidth-1) {
if (rand(1,2)==1) {
$xlowdee++;
} else {
$xhighdee--;
}
} elseif ($dwidth==$mwidth) {
$xlowdee++;
$xhighdee--;
}
do {
$neigh=0;
$x=rand($xlowdee,$xhighdee);
$y=rand($ylow[$d],$yhigh[$d]);
if ($map[$x][$y][$d]<1 OR $map[$x][$y][$d]>3) {
for ($var=1;$var<=2;$var++) {
for ($cha=-1;$cha<=1;$cha++) {
$xcomp=$x;
$ycomp=$y;
if ($var==1) {
$xcomp+=$cha;
} else {
$ycomp+=$cha;
}
if ($map[$xcomp][$ycomp][$d]==1) {
$neigh++;
}
}
}
}
} while ($neigh<>1);
if ($x==$xhigh[$d]) {
$xhigh[$d]++;
} elseif ($x==$xlow[$d]) {
$xlow[$d]--;
}
if ($y==$yhigh[$d]) {
$yhigh[$d]++;
} elseif ($y==$ylow[$d]) {
$ylow[$d]--;
}
$map[$x][$y][$d]=3;
$exit[$d][0]++;
}

$traveltime=rand(2,11)*5;
// here rather than when printing map, because it's necessary
// for some of the traps - to say when monsters arrive,
// and for inter-level tunnels.

for ($d=1;$d<=$l;$d++) {
if ($exit[$d][0]>0) {
for ($t=1;$t<=$exit[$d][0];$t++) {
if ($exit[$d][$t]=="") {
do {
$ok=1;
$d2=rand(1,$l);
if ($exit[$d2][0]==0) {
$ok=0;
} elseif ($d2==$d AND rand(1,6)>1) {
$ok=0;
} else {
$t2=rand(1,$exit[$d2][0]);
if ($exit[$d2][$t2]<>"") {
$ok=0;
} elseif ($d==$d2 AND $t==$t2) {
$ok=0;
}
}
} while ($ok==0);
if ($d>$d2) {
$p1="upwards ";
$p2="downwards ";
} elseif ($d2>$d) {
$p1="downwards ";
$p2="upwards ";
} else {
$p1="";
$p2="";
}
// climate in the tunnel.
if (rand(1,3)==1 OR $d==$d2) {
$tclim=$lclimate[$d];
} elseif (rand(1,2)==1) {
$tclim=$lclimate[$d2];
} else {
$tclim=$lclimate[rand(1,$l)];
}
$tcl=" It's <i>".$climates[$tclim]."</i>. The journey will take ";
$e1=$tcl;
$e2=$tcl;
// travel time.
$z=$traveltime/5;
if ($d==$d2) {
$a=rand(1,(2*$z)-1)*5;
} else {
$z=rand(1,$z)*abs($d-$d2);
$a=rand(1,(2*$z)-1)*5;
$b=rand(1,(2*$z)-1)*5;
$up=max($a,$b);
$down=min($a,$b);
// find difference, if any, between $up and $down.
// express as a % in terms of $down.
// this is to see if the tunnel 'slopes subtly'.
// done here because $up and $down become strings.
$ttgap=$up-$down;
$ttgap=$ttgap/$down*100;
$uphours=floor($up/60);
$downhours=floor($down/60);
$upminutes=$up-(60*$uphours);
$downminutes=$down-(60*$downhours);
if ($uphours==0) {
$up=$up." minutes";
} else {
$up=$uphours." hour";
if ($uphours>1) {
$up=$up."s";
}
if ($upminutes>0) {
$up=$up." and ".$upminutes." minutes";
}
}
if ($downhours==0) {
$down=$down." minutes";
} else {
$down=$downhours." hour";
if ($downhours>1) {
$down=$down."s";
}
if ($downminutes>0) {
$down=$down." and ".$downminutes." minutes";
}
}
}
if ($d==$d2 OR $up==$down) {
$ttt=$up.".";
} else {
$ttt=$up." going up or ".$down." going down. ";
}

// width
$ttt=$ttt." It's wide enough for ".max(2,rand(1,6))." humans to walk side by side. ";
if ($system=="ll") {
$ttt=str_replace("humans","characters",$ttt);
}

// wandering monsters.
$donmon=0;
if (rand(1,3)==1) {
$ttt=$ttt."This tunnel is never used. There's no need to roll for wandering monsters while in here.";
$donmon=1;
} elseif (rand(1,2)==1 AND $d<>$d2) {
// is there any species that lives on both levels?
// if so, choose such a species.
// group size is anything in range defined by
// $grp of both levels.

for ($z=1;$z<=$sn;$z++) {
if ($shallow[$z]<=$d AND $deep[$z]>=$d AND $shallow[$z]<=$d2 AND $deep[$z]>=$d2) {
$donmon=1;
}
}
if ($donmon==1) {
do {
$z=rand(1,$sn);
} while ($shallow[$z]>$d OR $deep[$z]<$d OR $shallow[$z]>$d2 OR $deep[$z]<$d2);
$a=$grp[$z][$d];
$b=$grp[$z][$d2];
$mn=rand(min($a,$b),max($a,$b));
$cr=$crname[$z];
$ttt=$ttt."If a wandering monster check shows that monsters are present, don't roll on a wandering monster table. Instead, the delvers will meet ";
if ($system=="tt") {
if ($mn==1) {
$ttt=$ttt."a";
$f=substr($cr,0,1);
if ($f=="A" OR $f=="E" OR $f=="I" OR $f=="O" OR $f=="U") {
$ttt=$ttt."n";
}
} elseif ($mn==2) {
$ttt=$ttt."1-3";
} else {
if ($mn==3) {
$dice=1;
$adds=0;
} else {
$dice=floor($mn/3.5);
$adds=round($mn-(3.5*$dice));
}
$lowposs=$dice+$adds;
$highposs=(6*$dice)+$adds;
$ttt=$ttt.$lowposs."-".$highposs;
if ($highposs<>($lowposs*6)) {
$ttt=$ttt." (roll ";
if ($dice==1) {
$ttt=$ttt."a";
} else {
$ttt=$ttt.$dice;
}
$ttt=$ttt." dice";
if ($adds>0) {
$ttt=$ttt." and add ".$adds;
}
$ttt=$ttt.")";
}
}
$ttt=$ttt." ".$cr;
if ($mn>1) {
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
$ttt=$ttt."e";
}
$ttt=$ttt."s";
}
} else {
if ($wnencb[$z]==1) {
if ($wnenca[$z]==1) {
$ttt=$ttt."a";
$f=substr($cr,0,1);
if ($f=="A" OR $f=="E" OR $f=="I" OR $f=="O" OR $f=="U") {
$ttt=$ttt."n";
}
} else {
$ttt=$ttt.$wnenca[$z];
}
} else {
$ttt=$ttt.$wnenca[$z]."d".$wnencb[$z];
}
$ttt=$ttt." ".$cr;
if ($wnenca[$z]>1 OR $wnencb[$z]>1) {
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
$ttt=$ttt."e";
}
$ttt=$ttt."s";
}
}
$ttt=$ttt." (species ".$z.").";
}
}
if ($donmon==0) {
if ($d<>$d2) {
$ttt=$ttt."While in this tunnel, use the wandering monster table for level ";
if (rand(1,2)==1) {
$ttt=$ttt.$d2.".";
} else {
$ttt=$ttt.$d.".";
}
} else {
$ttt=$ttt."Roll for wandering monsters as normal in this tunnel.";
}
}

// who can tell if changing levels?
if ($d<>$d2) {
$diff=rand($level[$d],$level[$d2]);
$diff=rand(round($diff/2),$diff);
$slev=($level[$d]+$level[$d2])/2;
if (rand(1,2)==1) {
$slev=ceil($slev);
} else {
$slev=floor($slev);
}
$slev=8+rand(1,2*$slev);
if (rand(1,12)==1) {
if ($system=="tt") {
$ttt=$ttt." This tunnel is enchanted so that delvers other than dwarves won't notice it's going up or down unless they make a level ".$diff." save on ";
if ($wiz==1) {
$ttt=$ttt."WIZ.";
} else {
$ttt=$ttt."INT.";
}
} elseif ($system=="ll") {
$ttt=$ttt." This tunnel is enchanted so that the party might not notice that it's going up or down. The GM should secretly ";
if (rand(1,2)==1) {
$ttt=$ttt." make a Save vs Spells, using the highest save in the party. If the save fail";
} else {
$ttt=$ttt." roll on the Mental Attack Table (Mutant Future, p55), with the Attacker's Will being ".$slev." and the Defender's Will being the highest value in the party. If the attack succeed";
}
$ttt=$ttt."s, non-Dwarf members of the party won't notice the tunnel sloping. The GM should roll 1d6 for each Dwarf in the party, if any. They will notice on a 1 or 2.";
}
} elseif (rand(1,11)==1) {
if ($system=="tt") {
$ttt=$ttt." This tunnel is enchanted so that delvers other than dwarves won't notice it's going up or down - and dwarves will only notice if they make a level ".$diff." save on ";
if ($wiz==1) {
$ttt=$ttt."WIZ.";
} else {
$ttt=$ttt."INT.";
}
} elseif ($system=="ll") {
$ttt=$ttt." This tunnel is enchanted so that non-Dwarf members of the party won't notice it's going up or down. Dwarves will only notice if ";
if (rand(1,2)==1) {
$ttt=$ttt."the GM rolls a 1 or 2 on 1d6";
} elseif (rand(1,2)==1) {
$ttt=$ttt."they make a Save vs Spells (the GM should secretly roll for them)";
} else {
$ttt=$ttt."they successfully defend against a Mental Attack, counting the Attacker's WIL/WIS as ".$slev." (the GM should secretly roll on the Mental Attack Table on p55 of Mutant Future)";
}
$ttt=$ttt.". If there's more than one Dwarf in the party, roll for each one.";
}
} elseif (rand(1,3)==1) {
if (rand(1,30)>$ttgap) {
if (rand(1,30)>$ttgap) {
if ($system=="tt") {
$ttt=$ttt." This tunnel slopes so subtly that delvers other than dwarves won't notice it's going up or down - and dwarves will only notice if they make a level ".$diff." save on INT.";
} elseif ($system=="ll") {
$ttt=$ttt." This tunnel slopes so subtly that party members other than Dwarves won't notice it's going up or down - and Dwarves will only notice on a 1 or 2 on 1d6.";
}
} else {
if ($system=="tt") {
$ttt=$ttt." This tunnel slopes so subtly that delvers other than dwarves won't notice it's going up or down unless they make a level ".$diff." save on INT.";
} elseif ($system=="ll") {
$ttt=$ttt." This tunnel slopes so subtly that party members other than Dwarves only have a 2 in 6 chance of noticing that it's going up or down (Dwarves will notice 100% of the time).";
}
}
}
}
}
$e1=$e1.$ttt;
$e2=$e2.$ttt;

// warning for tunnels between distant levels.
if (abs($d-$d2)>rand(1,3)) {
do {
$z=rand(1,$sn);
} while ($shallow[$z]>min($d,$d2) OR $deep[$z]<min($d,$d2));
do {
$y=rand(1,$langnum);
} while ($crlang[$z][$y]<>1);
$warn=" There's a warning painted on the wall of the area leading to the tunnel, in ".$language[$y].".";
if ($d>$d2) {
$e2=$e2.$warn;
} else {
$e1=$e1.$warn;
}
}

if ($d<10) {
$x=$d;
} else {
$x=chr(55+$d);
}
if ($d2<10) {
$x2=$d2;
} else {
$x2=chr(55+$d2);
}
$exit[$d][$t]="This tunnel goes ".$p1."to ".$x2.chr($t2+96).".".$e1;
$exit[$d2][$t2]="This tunnel goes ".$p2."to ".$x.chr($t+96).".".$e2;
}
}
}
}

// fill in $stairs array.
// It's text, which is printed at the end of room descriptions.

for ($z=1;$z<$l;$z++) {
$st=rand(1,round(min($rn[$z],$rn[$z+1])/2));
for ($y=1;$y<=$st;$y++) {
do {
$r1=rand(1,$rn[$z]);
$x=$stairs[$z][$r1];
} while (str_replace("down","XXX",$x)<>$x);
do {
$r2=rand(1,$rn[$z+1]);
$x=$stairs[$z+1][$r2];
} while (str_replace("up","XXX",$x)<>$x);
if (rand(1,2)==1) {
$a="narrow and winding spiral staircase";
} else {
$a="narrow set of stairs";
}
$oldroom=0;
$newroom=0;
if ($z>1) {
for ($x=1;$x<$z;$x++) {
$oldroom+=$rn[$x];
$newroom+=$rn[$x];
}
}
$newroom+=$rn[$z];
$oldroom+=$r1;
$newroom+=$r2;
if ($oldroom>99) {
$b=floor($oldroom/10);
$oldroom=chr($b+55).($oldroom-(10*$b));
}
if ($newroom>99) {
$b=floor($newroom/10);
$newroom=chr($b+55).($newroom-(10*$b));
}
$ext="";
if (rand(1,6)==1) {
$ext=" These stairs are slightly askew in the fourth dimension. They'll only be found if ";
if ($system=="tt") {
$ext=$ext."a character with a";
if (rand(1,3)==1 AND $wiz==1) {
$ext=$ext." WIZ";
} elseif (rand(1,2)==1) {
$ext=$ext."n INT";
} else {
$ext=$ext." LK";
}
$ext=$ext." of at least ".(rand(6,14)+(2*$z))." searches the room.";
} elseif ($system=="ll") {
if (rand(1,3)==1) {
$ext=$ext."a cleric or magic-user (not an elf) searches the room.";
} elseif (rand(1,2)==1) {
$ext=$ext."a character with a WIL/WIS of at least ".rand(8,16)." searches the room.";
} else {
$ext=$ext."the character who searches the room makes a save vs Spells.";
}
}
}
$tt=rand(1,4)*5;

$stairs[$z][$r1]=$stairs[$z][$r1]."<br><br>A ".$a." leads down to room ".$newroom.". The journey takes ".$tt." minutes. For wandering monsters, count the stairs as part of level ".($z+1).".";
if ($system=="tt") {
$stairs[$z][$r1]=$stairs[$z][$r1]." If 'gigantic' wandering monsters are generated, they'll be at the bottom rather than on the stairs.";
}
$stairs[$z][$r1]=$stairs[$z][$r1].$ext;

$stairs[$z+1][$r2]=$stairs[$z+1][$r2]. "<br><br>A ".$a." leads up to room ".$oldroom.". The journey takes ".($tt*7/5)." minutes. For wandering monsters, count the stairs as part of level ".($z+1).".";
if ($system=="tt") {
$stairs[$z+1][$r2]=$stairs[$z+1][$r2]." If 'gigantic' wandering monsters are generated, they'll be at the top rather than on the stairs.";
}
$stairs[$z+1][$r2]=$stairs[$z+1][$r2].$ext;
}
}




// fill $rb ie rooms,
// and generate monsters (can't be done room-by-room, because
// of requirement that as many monsters as possible appear).

// 1 monsters.
// 2 trap - but this has 50% chance of becoming 6 (empty).
// 3 a shrine.
// 4 a pool.
// 5 trap and shrine.
// 6 empty: but 1 in 5 chance of becoming 7, 8, or 11
// 7 magic shop.
// 8 vending machine. 50% chance of becoming 9.
// 9 trap and vending machine.
// 10 monsters and shrine.
// 11 likely to get turned around.

// for T&T, chance of treasure:
// 1 4 in 6, larger treasure.
// 2 3 in 6, larger treasure.
// 3 3 in 6, smaller treasure.
// 4 2 in 6, smaller treasure.
// 5 roll as for 2 AND 3.
// 6 1 in 6, smaller treasure.
// 7 no treasure.
// 8 1 in 6, smaller treasure.
// 9 roll as for 2.
// 10 roll as for 1 AND 3.
// 11 as for 6.

// for LL:
// 30% chance empty (15% chance treasure)
// 30% chance monster (50% treasure)
// 15% trap (30% treasure)
// 25% unique (variable treasure)
// (from p123 of Labyrinth Lord)


for ($x=1;$x<=$l;$x++) {
if (isset($dedi)) {
$dshr[$x]=rand(1,$rn[$x]);
}
$monstrooms=0;
for ($y=1;$y<=$rn[$x];$y++) {
$smt=$level[$x]*rand(8,12)*$c;
$lgt=$level[$x]*rand(70,100)*$c;
if ($system=="tt") {
do {
$z=rand(1,2);
if ($z==2 AND rand(1,3)==1) {
$z=rand(3,5);
}
if (isset($dedi) AND $y==$dshr[$x]) {
$z=3+(rand(0,1)*2);
}
if ($z==2 AND rand(1,2)==1) {
$z=6;
}
if ($z==6 AND rand(1,6)==1) {
$z=rand(7,9);
if ($z==9) {
$z=11;
}
}
if ($z==8 AND rand(1,2)==1) {
$z=9;
}
if ($z==5 AND rand(1,2)==1) {
$z=10;
}
} while (($z==3 OR $z==5 OR $z==10) AND $godd==2);
} elseif ($system=="ll") {
$rdu=rand(1,15);
// in final version this should be rand(1,20).
// 16-20 represent 'special' results (put this possiblity
// in once convert at least one 'special').

if ($rdu<7) {
$z=6;
if (rand(1,20)<4) {
$tr[$x][$y]=1;
}
} elseif ($rdu<13) {
$z=1;
$monstrooms++;
if (rand(1,2)==1) {
$tr[$x][$y]=1;
}
} elseif ($rud<16) {
$z=2;
if (rand(1,10)<4) {
$tr[$x][$y]=1;
}
} else {
// special. currently not implemented.
}
}
$rb[$x][$y]=$z;

if ($system=="tt") {
if (($z==1 OR $z==10) AND rand(1,3)>1) {
$tr[$x][$y]=$lgt;
$monstrooms++;
}
if (($z==2 OR $z==5 OR $z==9) AND rand(1,2)==1) {
$tr[$x][$y]=$lgt;
}
if (($z==3 OR $z==5 OR $z==10) AND rand(1,2)==1) {
$tr[$x][$y]+=$smt;
}
if ($z==4 AND rand(1,3)==1) {
$tr[$x][$y]=$smt;
}
if (($z==6 OR $z==8 OR $z==11) AND rand(1,6)==1) {
$tr[$x][$y]=$smt;
}
if ($tr[$x][$y]>=$eyeval AND rand(1,10)==1) {
$tr[$x][$y]-=$eyeval;
$eye[$x][$y]=1;
$anyeye=1;
}
}
}

if ($system=="tt") {
// define $levmark[$x] and $levgoal[$x]
if ($wmtable[$x][0]>35) {
$levmark[$x]=10;
$levgoal[$x]=36;
} elseif ($wmtable[$x][0]==1) {
$levmark[$x]=1;
$levgoal[$x]=1;
} else {
$z=0;
while ($table[$z][0]<$wmtable[$x][0]) {
$z++;
}
$ichange=$table[$z][0]-$wmtable[$x][0];
$xchange=$wmtable[$x][0]-$table[$z-1][0];
if (rand(1,2)==1) {
$ichange+=.5;
} else {
$xchange+=.5;
}
// this is to break ties.
if ($xchange<$ichange) {
$levmark[$x]=$z-1;
$levgoal[$x]=$table[$z-1][0];
} else {
$levmark[$x]=$z;
$levgoal[$x]=$table[$z][0];
}
}

// adjust wandering monster table so that it
// has a number of slots exactly equal to $levgoal.
while ($wmtable[$x][0]<>$levgoal[$x]) {
do {
$z=rand(1,$sn);
} while ($wmtable[$x][$z]<1);
if ($levgoal[$x]>$wmtable[$x][0]) {
$wmtable[$x][0]++;
$wmtable[$x][$z]++;
} else {
$wmtable[$x][0]--;
$wmtable[$x][$z]--;
}
}

}

if ($monstrooms>0 AND $system=="tt") {
// define $levmt - it can be 1,2, or 3.
// 1: there aren't enough areas for all the monsters -
// every monster type can appear only in 1 room, or
// in no rooms if they're on the w.m. table.

// 2: every monster that makes its home on this level is
// in the wandering monster table -
// areas can be assigned randomly.

// 3: any other situation -
// monsters are assigned randomly, but it's then checked.

$notapp=0;
for ($z=1;$z<=$sn;$z++) {
if ($wmtable[$x][$z]==0 AND $shallow[$z]<=$x AND $deep[$z]>=$x) {
$notapp++;
}
}
if ($notapp==0) {
$levmt=2;
} elseif ($notapp>$monstrooms) {
$levmt=1;
} else {
$levmt=3;
}
}

if ($monstrooms>0) {
for ($z=1;$z<=$rn[$x];$z++) {
if ($rb[$x][$z]==1 OR $rb[$x][$z]==10) {
if ($system=="tt") {
do {
$ok=0;
$a=rand(1,$sn);
if ($shallow[$a]<=$x AND $deep[$a]>=$x) {
$ok=1;
if ($levmt==1 AND ($wmtable[$x][$a]>0 OR $enc[$a][$x]>0)) {
$ok=0;
}
}
} while ($ok==0);
$enc[$a][$x]++;
$mo[$z][$x][0]=$a;
$base=$grp[$a][$x];
$mo[$z][$x][1]=rand(round($base*4/5),round($base*6/5));
} elseif ($system=="ll") {
do {
$a=rand(1,$sn);
} while ($shallow[$a]>$x OR $deep[$a]<$x);
$mo[$z][$x][0]=$a;
for ($zz=1;$zz<=$lnenca[$a];$zz++) {
$mo[$z][$x][1]+=rand(1,$lnencb[$a]);
}
}
}
}
if ($levmt==3) {
// will only happen if $system is "tt"
do {
$ok=1;
for ($z=1;$z<=$sn;$z++) {
if ($shallow[$z]<=$x AND $deep[$z]>=$x AND $wmtable[$x][$z]==0 AND $enc[$z][$x]==0) {
$ok=0;
}
}
if ($ok==0) {
do {
$a=rand(1,$sn);
} while ($shallow[$a]>$x OR $deep[$a]<$x OR $wmtable[$x][$a]>0 OR $enc[$a][$x]>0);
do {
$b=rand(1,$rn[$x]);
$d=$mo[$b][$x][0];
} while (($rb[$x][$b]<>1 AND $rb[$x][$b]<>10) OR ($wmtable[$x][$d]==0 AND $enc[$d][$x]<2));
$enc[$d][$x]--;
$enc[$a][$x]++;
$mo[$b][$x][0]=$a;
$base=$grp[$a][$x];
$mo[$b][$x][1]=rand(round($base*4/5),round($base*6/5));
}
} while ($ok=0);
}
}
}

if (!isset($manygods)) {
$manygods=0;
}

// place quest object.

$questlevel=$l;
if ($l>1) {
while (rand(1,2)==1) {
$questlevel--;
}
$questlevel=max(2,$questlevel);
}
$questroom=rand(1,$rn[$questlevel]);

for ($x=1;$x<=$l;$x++) {
for ($y=1;$y<=$rn[$x];$y++) {
do {
$rwidth=rand(2,12);
$rdepth=rand(2,12);
if (rand(1,2)==1) {
$rwidth==$rdepth;
}
} while ($rwidth*$rdepth<9);
$rheight=rand(3,12);
// $rwidth, $rdepth & $rheight can be
// increased if the room has monsters.
// for room type 11, $rwidth must equal $rdepth.

// 1 monsters.
// 2 trap.
// 3 a shrine.
// 4 a pool.
// 5 trap and shrine.
// 6 empty.
// 7 magic shop.
// 8 vending machine.
// 9 trap and vending machine.
// 10 monsters and shrine.
// 11 likely to get turned around.

if ($rb[$x][$y]==4) {
$rd[$x][$y]="There's a natural pool here. For as long as the delvers stay here the GM should roll for wandering monsters twice as often as usual. But any results of creatures that are robots, 'fiery and demonic', or 'insubstantial and ghostly' should count as no wandering monster. Any robot, or 'fiery and demonic' creature who enters the pool will take ".rand(1,3)." dice worth of damage (reduced by tough skin, but not by armour or shields) each Combat Round.";
} elseif ($rb[$x][$y]==3 OR $rb[$x][$y]==5 OR $rb[$x][$y]==10) {
$anyshrine=1;
if (isset($dedi) AND $y==$dshr[$x]) {
$type=$dedi;
} else {
if ($manygods==0) {
$target=0;
} elseif ($manygods==$gnum) {
$target=1;
} else {
$target=min(1,rand(0,$manygods));
}
do {
$type=rand(1,$gnum);
} while ($shrine[$type]<>$target AND ($shrine[$type]<>2 OR $target<>0));
}
$snum[$type]++;
$a="There's a shrine to ";
if ($godd==0 AND $shrine[$type]==0) {
$gods[$type][2]="the god";
if (rand(1,2)==1) {
$gods[$type][2]=$gods[$type][2]."dess";
}
}
if ($godd==0) {
$a=$a.$gods[$type][2]." of ".$gods[$type][3];
} else {
$a=$a.$gods[$type][0];
}
if ($shrine[$type]<>1) {
$shrine[$type]=2;
}
$rd[$x][$y]=$a." here.";
} elseif ($rb[$x][$y]==11) {
$rwidth=rand(3,12);
$rdepth=$rwidth;
$a="There are no direct threats here. However, malicious spirits that live here might use their magic to disorient the delvers. If the delvers have a compass they'll be safe. If not, the delver with the highest ";
$att=rand(1,3+$wiz);
if ($att==1) {
$a=$a."INT";
} elseif ($att==2) {
$a=$a."CHR";
} elseif ($att==3) {
$a=$a."LK";
} else {
$a=$a."WIZ";
}
$a=$a." should make a level ".rand(max(1,floor($level[$x]/2)),$level[$x])." saving roll. If they fail, the delvers will lose their sense of direction while in this room. When they leave, regardless of which direction they say they want to go in, they'll actually head in a random direction (movement up or down staircases is excepted). Once they reach another room or intersection their sense of direction will return to normal.<br><br>This could result in the delvers believing that the corridor they came down has disappeared behind them.";
$rd[$x][$y]=$a;
}
if ($rb[$x][$y]==5 OR $rb[$x][$y]==10) {
$rd[$x][$y]=$rd[$x][$y]."<br><br>";
}
if ($rb[$x][$y]==2 OR $rb[$x][$y]==5 OR $rb[$x][$y]==9) {
if ($system=="tt") {
do {
$ok=1;
$z=$traps[rand(1,$trapnum)];
if ($x==$l AND str_replace("@@L","XXX",$z)<>$z) {
$ok=0;
}
} while ($ok==0);
if ($spd==1) {
$z=str_replace("@@DS","SPD",$z);
} else {
$z=str_replace("@@DS","DEX",$z);
}
if ($adds==4) {
$z=str_replace("'gigantic' target","'gigantic' target (in 5th edition rules, a level 1 DEX save to hit at point-blank range)",$z);
}
$fd="any delver";
if (rand(1,2)==1) {
$fd=$fd." bigger than a fairy";
}
$z=str_replace("@@FD",$fd,$z);
$a=rand(1,$rn[$x+1]);
$bb=0;
for ($aa=1;$aa<=$x;$aa++) {
$bb+=$rn[$aa];
}
if ($a+$bb>99) {
$rstring=floor(($a+$bb)/10);
$a=chr($rstring+55).($a+$bb-(10*$rstring));
} else {
$a+=$bb;
}
$z=str_replace("@@L",$a,$z);
for ($a=1;$a<=6;$a++) {
$aa=max(0,$level[$x]+rand(1,3)-rand(1,3));
if ($a==6) {
$aa=max(2,$aa);
}
$z=str_replace("@@".$a,$aa,$z);
}
$z=str_replace("@@D",rand(1,4)." dice worth of ",$z);
$z=str_replace("@@TT",$traveltime,$z);
$z=str_replace("@@MD",rand(10,20)+(5*$x),$z);
} elseif ($system=="ll") {
if (rand(1,6)>($level[$x]-2)) {
$z=$lltraps[rand(1,$lltrapnum)];
} else {
$z=$mftraps[rand(1,$mftrapnum)];
}
$dummyx=$level[$x]+rand(1,3)-rand(1,3);
$dummyx=max(1,$dummyx);
$dummyx=$dummyx*10;
$z=str_replace("@XX",$dummyx,$z);
$z=str_replace("@YY",rand(2,5),$z);
$z=str_replace("@UU",rand(1,10),$z);
}
$rd[$x][$y]=$rd[$x][$y].$z;
$z=rand(1,$sn);
if ($shallow[$z]<=$x AND $deep[$z]>=$x) {
$rd[$x][$y]=$rd[$x][$y]."<br><br>Any ".$crname[$z]." (species ".$z;
if ($z<=$standardused) {
$rd[$x][$y]=$rd[$x][$y].": ".$stplural[$standardsn[$z]];
}
$rd[$x][$y]=$rd[$x][$y].") can tell the delvers about this trap.";
}
} elseif ($rb[$x][$y]==6) {
$z=rand(1,4);
if ($z==1) {
$b="Roll periodically for wandering monsters as normal.";
} elseif ($z==2) {
$b="It's rarely used. Roll for wandering monsters only half as often as usual.";
} elseif ($z==3) {
$b="However it's often used. Roll for wandering monsters twice as often as usual.";
} else {
do {
$a=rand(1,$sn);
} while ($wmtable[$x][$a]<1);
$cr=$crname[$a];
$b="It's most often used by the ".$cr;
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
$b=$b."e";
}
$b=$b."s (species ".$a;
if ($a<=$standardused) {
$b=$b.": ".$stplural[$standardsn[$a]];
}
$b=$b."). Roll for wandering monsters as usual. However, if the result is an encounter with any other creatures, there's a 50% chance that the delvers will meet";
if ($grp[$a][$x]==1) {
$b=$b." a";
$f=substr($cr,0,1);
if ($f=="A" OR $f=="E" OR $f=="I" OR $f=="O" OR $f=="U") {
$b=$b."n";
}
}
$b=$b." ".$cr;
if ($grp[$a][$x]>1) {
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
$b=$b."e";
}
$b=$b."s";
}
$b=$b." instead.";
}
$rd[$x][$y]="There are no dangers in this room. ".$b;
} elseif ($rb[$x][$y]==7) {
if ($magshop>0) {
$rd[$x][$y]="If the delvers haven't been to the mysterious shop yet, they'll find it here - refer to the description for <b>".$magshop."</b> for details. If they have already been, this area will be empty (roll for wandering monsters as usual).";
} else {
$z="The first time that the delvers visit this area, they'll find themselves unexpectedly in a shop, tended by what appears to be an elderly ";
if (rand(1,3)==1) {
$z=$z."human";
} elseif (rand(1,2)==1) {
$z=$z."dwarf";
} else {
$z=$z."hobbit";
}
$z=$z." ";
if (rand(1,2)==1) {
$z=$z."woman";
} else {
$z=$z."male";
}
$z=$z.". If the delvers are threatening, the shop and shopkeeper will instantly disappear.<br><br>The shop will have literally everything that it is possible for delvers to buy in your game world. For ridiculous items, for example a large sailing ship, the shopkeeper might 'think they have one left', and 'have to have a look out the back', but the item will always be found. All items will be sold at standard prices. If your campaign has different prices for different areas, use the prices for a very large city. The first time a delver tries to haggle, if any do, they should make a level ";
$z=$z.rand(1,$level[$l]);
$z=$z." save on CHR. If they make it by 10 or more, all items will be sold at 20% off standard price. If they make it by less, items will be sold at 10% off standard price. If they fail by 10 or more, items will be sold at standard price plus 20%. If they fail by a lesser amount, the markup on standard price will be 10%. This single save will apply to all items bought by all delvers.<br><br>Don't roll for wandering monsters while the delvers are in the shop. Nor should any time pass in the outside world.<br><br>If the delvers ask, the shopkeeper will allow them to rest here overnight, on couches out the back. However when they wake up, they'll find shop and shopkeeper gone and themselves back in the dungeon.<br><br>Once the delvers leave, if they return to this area they won't find no trace of shop or shopkeeper.<br><br>Once the delvers leave the dungeon, if they bought anything from the shop, roll one dice (once for all items, not once for each item). On a 1 or 2, the items are perfectly normal. On a 3 or 4, the items turn out to be worthless - swords are really sticks, a delver who thought they were wearing armour has leaves stuck to their clothing with mud, and so on (any benefit they got from the items in the dungeon doesn't cancel though). The delvers will also find any money they spent back in their coin-purse. On a 5 or 6, the items are worthless as for 3 or 4, but the delvers don't get their money back. If they return to the area where the shop was, they'll find the money there.<br><br>The following refers to the area when the shop isn't there:";
$rd[$x][$y]=$z;
for ($z=1;$z<$x;$z++) {
$magshop+=$rn[$z];
}
$magshop+=$y;
if ($magshop>99) {
$rstring=floor(($magshop)/10);
$a=chr($rstring+55).($magshop-(10*$rstring));
}
}
} elseif ($rb[$x][$y]==1 OR $rb[$x][$y]==10) {
$b=$mo[$y][$x][1];
do {
$a=rand(1,$donum);
if ($rb[$x][$y]==10 AND rand(1,3)>1) {
$a=rand(22,26);
}
} while ($doing[$a][1]>$b OR $doing[$a][2]<$b);
$cr=$crname[$mo[$y][$x][0]];
$cn=$mo[$y][$x][1];
if ($cn==1) {
$f=substr($cr,0,1);
if ($f=="A" OR $f=="E" OR $f=="I" OR $f=="O" OR $f=="U") {
$cr="There's an ".$cr;
} else {
$cr="There's a ".$cr;
}
} else {
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
$cr=$cr."e";
}
$cr="There are ".$cn." ".$cr."s";
}
$do=$doing[$a][0].".";
if ($cn>1) {
$do=str_replace("@","they'll be ",$do);
} else {
$do=str_replace("@","it'll be ",$do);
}
$rd[$x][$y]=$rd[$x][$y].$cr." (species ".$mo[$y][$x][0];
if ($mo[$y][$x][0]<=$standardused) {
$rd[$x][$y]=$rd[$x][$y].": ".$stplural[$standardsn[$mo[$y][$x][0]]];
}
$rd[$x][$y]=$rd[$x][$y].") here";
if ($system=="ll") {
$rd[$x][$y]=$rd[$x][$y]." (HP ";
for ($rnu=1;$rnu<=$cn;$rnu++) {
$hp=$hdiceadd[$mo[$y][$x][0]];
if ($hdice[$mo[$y][$x][0]]==0) {
$hp=rand(1,4);
} else {
for ($anu=1;$anu<=$hdice[$mo[$y][$x][0]];$anu++) {
$hp+=rand(1,8);
}
}
$hp=max(1,$hp);
$rd[$x][$y]=$rd[$x][$y].$hp;
if ($rnu<$cn) {
$rd[$x][$y]=$rd[$x][$y].", ";
}
}
$rd[$x][$y]=$rd[$x][$y].")";
}
$rd[$x][$y]=$rd[$x][$y].". When the delvers first enter this area, ".$do;
$crt=$spt[$mo[$y][$x][0]];
if ($crt>0 AND $crt<>$lclimate[$x]) {
$rd[$x][$y]=$rd[$x][$y]."<br><br>Remember that these creatures' presence makes the area <i>".$climates[$crt]."</i>.";
}

if (rand(1,10)==1) {
$paradox=rand(4,6);
while (rand(1,2)==1) {
$paradox=$paradox+(rand(0,1)*2)-1;
}
$rd[$x][$y]=$rd[$x][$y]."<br><br>This area is slightly unstuck in time. Its paradox limit is ".(max(2,$paradox)).". Please refer to the notes at the start of the adventure (under 'Unstuck in Time').";
$unstuck=1;
}

// alter $rwidth and $rdepth if necessary.
$spsz=$sizetext[$crsize[$mo[$y][$x][0]]][0];
$crspace=$spsz*$mo[$y][$x][1]/7.5;
while ($rwidth*$rdepth<$crspace) {
if (rand(1,3)>1) {
$rwidth++;
$rdepth++;
} elseif (rand(1,2)==1) {
$rdepth++;
} else {
$rwidth++;
}
};
$rheight=max($rheight,$spsz/15);
}
if ($rb[$x][$y]==9) {
$rd[$x][$y]=$rd[$x][$y]."<br><br>";
}
if ($rb[$x][$y]==8 OR $rb[$x][$y]==9) {
$z="There's a hireling vending machine here, belonging to the Koka Kobold Company. It dispenses robotic servants if fed enough coins.";
$cost=$level[$x]*rand(8,12);
$mcha=rand(1,6)+rand(1,6)+rand(1,6)+$level[$x];
$tou=$level[$x]*rand(8,12);
$car=$level[$x]*rand(8,12)*rand(8,12)*rand(8,12);
$vlang=$language[rand(2,$langnum)];
$z=$z." It will only speak, or allow a delver to give it coins, if they have enough CHR to command the servants (";
if (rand(1,2)==1) {
$z=$z.$mcha." or more).";
} else {
$leeway=floor($mcha/3);
$without=$mcha+rand(1,$leeway);
$with=$mcha-rand(1,$leeway);
$z=$z."at least ".$without." CHR for delvers who don't speak ".$vlang.", at least ".$with." for those that do. A book of phrases will be of no use in this situation).";
}
$z=$z."<br><br>The servants are ".$sizetext[rand(2,$sizecats-1)][1].", and look like a robotic version of ".$appani[rand(1,$aniapp)].". They have MRs of ".$tou.", and can carry the weight of up to ".$car." coins. They'll obey any command (subject to the note on CHR above). They can't speak.<br><br>The machine itself will answer questions about cost provided they're in ".$vlang.". If the delvers ask how tough the servants are or how much they can carry, it'll respond with bland advertising phrases (for example 'our servants are so tough they'll take a beating and keep on going').";
if (rand(1,2)==1) {
$mdex=rand(1,6)+rand(1,6)+rand(1,6)+$level[x];
$z=$z." A DEX of at least ".$mdex." is required to actually feed the coins into the machine's mouth once someone with enough CHR has approached it. This is because once that happens it will talk almost incessantly, repeating advertising slogans if it isn't asked anything. One delver can talk to the machine while another feeds it coins, if one delver has enough CHR but not DEX and another delver has the opposite problem.";
}
$z=$z." The servants cost ".$cost."gp each. The machine will take any coins, but won't give change.";
if (rand(1,2)==1) {
$z=$z."<br><br>The machine is frequently out of order. Whoever is paying the machine should make a level ".rand(1,$level[x])." save on ";
if (rand(1,2)==1) {
$z=$z."INT";
} else {
$z=$z."LK";
}
$z=$z.". If they fail, they'll pay half the cost (rounded down) before realising that the machine is out of order. If they make it by 5 or more, the hireling will appear when they've only paid half the cost (rounded down).";
}
if (rand(1,2)==1) {
$z=$z."<br><br>Trying to break into the machine will be futile.";
} else {
$z=$z."<br><br>If a delver tries to break into the machine, they should make a level ".rand(1,$level[$x])." save on STR. The attempt, whether it succeeds or not, will take ".(rand(1,4)*5)." minutes. If they succeed, the machine will cough up coins: roll ".rand(1,rand(1,$level[$x]))." dice for the value in gold pieces. Then roll again: 1-2 gold coins, 3-4 silver coins (10 for each gp worth) 5-6 copper coins (100 for each gp worth). A critical failure will mean that there are no more coins in the machine, except for any that the delvers have put in themselves. Whether they succeed or not, the GM should roll for wandering monsters for each attempt (as well as, not instead of, the usual roll for wandering monsters). Any monsters that result will arrive in ".$traveltime." minutes (from the start of the attempt, not from the end). The delvers can use coins gained this way to pay for a hireling, or pay and then try and get their coins back.";
}
$rd[$x][$y]=$rd[$x][$y].$z;
}

$z="";
if ($tr[$x][$y]>0 OR $eye[$x][$y]==1) {
$z="<br><br>Treasure in this area";
// where is the treasure (unfinished -
// for most rooms, could be hidden or on display)
$a=$rb[$x][$y];
if ($a==3 OR $a==5) {
$z=$z." (in front of the shrine)";
}
$z=$z.":".$line;
if ($a==8 OR $a==9) {
$z=$z."This list doesn't count any coins in the vending machine.".$line;
}
}

if ($eye[$x][$y]==1) {
$whicheye=rand(1,$eyenum);
$z=$z."* An Eye of ".$eyedesc[$whicheye][0].". ".$eyedesc[$whicheye][1]." weight 200 value ".$eyeval."gp<br>";
}

if ($tr[$x][$y]>0) {
if ($system=="ll") {

$copper=0;
$silver=0;
$electrum=0;
$gold=0;
$platinum=0;
$gems=0;
$jewelry=0;

// clear magic item and artifacts arrays.
for ($a=0;$a<=11;$a++) {
$magicitems[$a]=0;
$artifacts[$a]=0;
$bditems[$a]=0;
}

$anyt=0;

if ($rb[$x][$y]==1 OR $rb[$x][$y]==10) {
$ttype=$lhoard[$mo[$y][$x][0]];
if ($ttype>7) {
$tloops=1;
} else {
$tloops=$mo[$y][$x][1];
}
for ($a=1;$a<=$tloops;$a++) {
if (rand(1,100)<=$guarded[$ttype][2]) {
$anyt=1;
$newcopper=0;
for ($b=1;$b<=$guarded[$ttype][0];$b++) {
$newcopper+=rand(1,$guarded[$ttype][1]);
}
if ($ttype>7) {
$newcopper=$newcopper*1000;
}
$copper+=$newcopper;
}

if (rand(1,100)<=$guarded[$ttype][5]) {
$anyt=1;
$newsilver=0;
for ($b=1;$b<=$guarded[$ttype][3];$b++) {
$newsilver+=rand(1,$guarded[$ttype][4]);
}
if ($ttype>7) {
$newsilver=$newsilver*1000;
} elseif ($ttype==2) {
$newsilver++;
}
$silver+=$newsilver;
}

if (rand(1,100)<=$guarded[$ttype][8]) {
$anyt=1;
$newelectrum=0;
for ($b=1;$b<=$guarded[$ttype][6];$b++) {
$newelectrum+=rand(1,$guarded[$ttype][7]);
}
if ($ttype==15) {
$newelectrum=$newelectrum*10;
}
if ($ttype>7) {
$newelectrum=$newelectrum*1000;
} elseif ($ttype==3) {
$newelectrum++;
}
$electrum+=$newelectrum;
}

if (rand(1,100)<=$guarded[$ttype][11]) {
$anyt=1;
$newgold=0;
for ($b=1;$b<=$guarded[$ttype][9];$b++) {
$newgold+=rand(1,$guarded[$ttype][10]);
}
if ($ttype==15 OR $ttype==16) {
$newgold=$newgold*10;
}
if ($ttype>7) {
$newgold=$newgold*1000;
}
$gold+=$newgold;
}

if (rand(1,100)<=$guarded[$ttype][14]) {
$anyt=1;
$newplatinum=0;
for ($b=1;$b<=$guarded[$ttype][12];$b++) {
$newplatinum+=rand(1,$guarded[$ttype][13]);
}
if ($ttype>7) {
$newplatinum=$newplatinum*100;
// note that this is x100, not x1000.
}
$platinum+=$newplatinum;
}

if (rand(1,100)<=$guarded[$ttype][17]) {
$anyt=1;
$newgems=0;
for ($b=1;$b<=$guarded[$ttype][15];$b++) {
$newgems+=rand(1,$guarded[$ttype][16]);
}
if ($ttype==10) {
$newgems=$newgems+4;
} elseif ($ttype==15) {
$newgems=$newgems*10;
}
$gems+=$newgems;
}

if (rand(1,100)<=$guarded[$ttype][20]) {
$anyt=1;
$newjewelry=0;
for ($b=1;$b<=$guarded[$ttype][18];$b++) {
$newjewelry+=rand(1,$guarded[$ttype][19]);
}
if ($ttype==15) {
$newjewelry=$newjewelry*10;
}
$jewelry+=$newjewelry;
}

// finally, do $bditems (magic items or artifacts)
if (rand(1,100)<=$mitem[$ttype][0]) {
$anyt=1;
for ($b=1;$b<=5;$b++) {
if ($mitem[$ttype][$b]<0) {
for ($mia=1;$mia<=abs($mitem[$ttype][$b]);$mia++) {
$bditems[$b]+=rand(1,4);
}
} else {
$bditems[$b]+=$mitem[$ttype][$b];
}
}
}
}
} else {
// unguarded treasure - level $x.
// it treats levels over 9 by doing level 9,
// then remainder.

$anyt=1;
// because silver pieces are always present.

$tloops=ceil($x/9);
$lastloop=$x%9;
if ($lastloop==0) {
$lastloop=9;
}

for ($a=1;$a<=$tloops;$a++) {
$tlev=9;
if ($a==$tloops) {
$tlev=$lastloop;
}

for ($b=1;$b<=$unguarded[$tlev][0];$b++) {
$silver+=rand(1,$unguarded[$tlev][1])*$unguarded[$tlev][2];
}

if (rand(1,100)<=$unguarded[$tlev][6]) {
for ($b=1;$b<=$unguarded[$tlev][3];$b++) {
$gold+=rand(1,$unguarded[$tlev][4])*$unguarded[$tlev][5];
}
}

if (rand(1,100)<=$unguarded[$tlev][9]) {
for ($b=1;$b<=$unguarded[$tlev][7];$b++) {
$gems+=rand(1,$unguarded[$tlev][8]);
}
}

if (rand(1,100)<=$unguarded[$tlev][12]) {
for ($b=1;$b<=$unguarded[$tlev][10];$b++) {
$jewelry+=rand(1,$unguarded[$tlev][11]);
}
}

if (rand(1,100)<=$unguarded[$tlev][13]) {
$bditems[1]++;
}
}
}
$tr[$x][$y]=0;
if ($anyt==1) {
if ($copper>0) {
$z=$z."* ".$copper." copper pieces.<br>";
$tr[$x][$y]+=$copper/100;
};
if ($silver>0) {
$z=$z."* ".$silver." silver pieces.</br>";
$tr[$x][$y]+=$silver/10;
}
if ($electrum>0) {
$z=$z."* ".$electrum." electrum pieces.</br>";
$tr[$x][$y]+=$electrum/2;
}
if ($gold>0) {
$z=$z."* ".$gold." gold pieces.</br>";
$tr[$x][$y]+=$gold;
}
if ($platinum>0) {
$z=$z."* ".$platinum." platinum pieces.</br>";
$tr[$x][$y]+=$platinum*10;
}
if ($gems>0) {
$a=rand(1,100);
$whichgem=0;
do {
$whichgem++;
} while ($a>=$llgems[$whichgem][3]);
if ($gems==1) {
$z=$z."* A".$llgems[$whichgem][0]." worth ".$llgems[$whichgem][2]."gp.<br>";
} else {
$z=$z."* ".$gems." ".$llgems[$whichgem][1]." worth ".$llgems[$whichgem][2]."gp each.<br>";
}
$tr[$x][$y]+=$gems*$llgems[$whichgem][2];
}
if ($jewelry>0) {
$whichj=rand(1,10);
$jval=0;
for ($a=1;$a<=$lljewels[$a][2];$a++) {
$jval+=rand(1,$lljewels[$a][3])*$lljewels[$a][4];
}
if ($jewelry==1) {
$z=$z."* A ".$lljewels[$a][0]." worth ".$jval."gp.<br>";
} else {
$z=$z."* ".$jewelry." ".$lljewels[$a][1]." worth ".$jval."gp each.<br>";
}
$tr[$x][$y]+=$jewelry*$jval;
}

// turn $bditems into $llitems and $mfitems.
for ($a=1;$a<=5;$a++) {
for ($b=1;$b<=$bditems[$a];$b++) {
$wb=rand(1,2);
// 1 is LL, 2 is MF.

if ($a==4) {
$wit=($wb*6)-3;
// ie 3 for LL, 9 for MF.
} elseif ($a==5) {
$wit=($wb*9)-8;
// ie 1 for LL, 10 for MF.
} else {
do {
$ok=1;
$iv=rand(1,100);
$wit=0;
$lok=0;
do {
$wit++;
if ($wb==1 AND $llitems[$wit][1]>$iv) {
$lok=1;
} elseif ($wb==2 AND $mfitems[$wit][1]>$iv) {
$lok=1;
}
} while ($lok==0);
if ($a==2 AND $wb==1 AND ($wit==6 OR $wit==7)) {
$ok=0;
}
if ($a==2 AND $wb==2 AND ($wit<5 OR $wit==7 OR $wit==8)) {
$ok=0;
}
if ($a==3 AND $wb==1 AND $wit<6) {
$ok=0;
}
if ($a==3 AND $wb==2 AND $wit>5) {
$ok=0;
}
} while ($ok==0);
}
if ($wb==1) {
$magicitems[$wit]++;
} else {
$artifacts[$wit]++;
}
}
}

// print magic items and artifacts.
for ($a=1;$a<=8;$a++) {
for ($b=1;$b<=$magicitems[$a];$b++) {
$v=rand(1,100);
$thisitem="* ".$llitemsd[$b][$v][0];

// miscellaneous extra stuff goes here
// (number of charges etc)

$thisitem=$thisitem." - see p".$llitemsd[$b][$v][1]." of Labyrinth Lord.<br>";
$z=$z.$thisitem;
}
}
for ($a=1;$a<=11;$a++) {
if ($artifacts[$a]>0) {
for ($b=1;$b<=$artifacts[$a];$b++) {
$v=rand(1,100);
$z=$z."* ".$mfitemsd[$a][$v];
$z=$z." (Condition Grade ";
$cp=rand(1,10);
if ($cp>6) {
$z=$z.($cp-5);
} elseif ($cp>3) {
$z=$z.ceil($cp/3);
} else {
$z=$z."0";
}
$z=$z.")<br>";
}
}
}

} else {
if ($eye[$x][$y]==0) {
$z="";
}
}
} else {
$trleft=$tr[$x][$y];

$ok=1;
for ($a=1;$a<=$eqptnum;$a++) {
$misceqpt[$a][4]="ok";
}
for ($a=1;$a<=$musnum;$a++) {
$music[$a][3]="ok";
}
for ($a=1;$a<=$jnum;$a++) {
$jewel[$a][2]="ok";
}
for ($a=1;$a<=$poisnum;$a++) {
$poisons[$a][3]="ok";
}

$blackbread=1;
if (rand(1,6)==1) {
$blackbread=0;
}

$pipeweed=1;
if (rand(1,6)==1) {
$pipeweed=0;
}

$foldship=0;
$holyitem=0;

// putting these loops to 'refresh' item lists here
// means that the same item can't be in more than
// one place in a room's treasure list, but it can
// be found in more than one room.

$leeway=15;
$hmul=100+$leeway;
$lmul=100-$leeway;
// maximum % difference to stats from book.
// (not applied to jewels, magic, miscellaneous eqpt)

do {
if (rand(1,11)==1) {
if ($pipeweed==0) {
if ($trleft<20) {
$ok=0;
} else {
$trleft-=20;
$pipeweed=1;
$z=$z."* A pouch of pipe-weed. If a hobbit has matches or a tinder-box, they can smoke it (you can assume that all hobbits carry a pipe). It will last for an hour of in-game time. During that time, the pleasant odour and soothing effect mean that the hobbit can treat their INT and CHR as being 3 higher than their real value. The hobbit will also be immune to effects which cause fear or anger (for example the spell <i>Oh-Go-Away</i> won't work on them). The pipe-weed will also mask any other strong smell (but the smell will still be there once the pipe-weed is gone). The downside of it is that its strong smell will make it impossible for the hobbit to hide. Weight 0 value 20.<br>";
}
}
} elseif (rand(1,10)==1) {
// poison.
$rpo=rand(1,$poisnum);
if ($poisons[$rpo][3]<>"used") {
if ($trleft<$poisons[$rpo][1]) {
$ok=0;
} else {
$poisons[$rpo][3]="used";
$pnum=rand(1,min(rand(1,6),floor($trleft/$poisons[$rpo][1])));
$trleft-=$poisons[$rpo][1]*$pnum;
if ($pnum==1) {
$z=$z."* Poison: a vial of ".$poisons[$rpo][0];
} else {
$z=$z."* Poison: ".$pnum." vials of ".$poisons[$rpo][0];
}
$z=$z.". ".$poisons[$rpo][2].". weight 1 value ".$poisons[$rpo][1];
if ($pnum>1) {
$z=$z." per vial.";
}
$z=$z."<br>";
}
}
} elseif (rand(1,9)==1) {
if ($blackbread==0) {
if ($trleft<8) {
$ok=0;
} else {
$tfleft-=8;
$blackbread=1;
$z=$z."* A loaf of Dwarven black bread. Any dwarf who finds this food must make a level ".rand(1,$level[$x])." save on INT. If they fail they'll eat the bread, and lose ".max(2,rand(1,6*$level[$x]))." points of ";
if ($spd==1 AND rand(1,2)==1) {
$z=$z."SPD";
} else {
$z=$z."CON";
}
$z=$z.". They'll recover the lost points over 24 hours. If a delver is reduced to 0 or less as a result of eating the loaf, they won't die - rather, they'll fall unconscious until 24 hours after they've eaten the bread. The loaf counts as 1 day's food, and so anyone can choose to eat it. weight 20 value 8<br>";
}
}
} elseif (rand(1,8)==1) {
if (rand(1,6)==1) {
if ($trleft<50) {
$ok=0;
} else {
$tfleft-=50;
do {
$inlang=$language[rand(2,$langnum)];
if (rand(1,2)==1) {
$inlang="Common";
}
$learnlang=$language[rand(1,$langnum)];
} while ($inlang==$learnlang);
if (rand(1,3)==1) {
$z=$z."* A book on herbalism, written in ".$inlang.". Anyone who can read ".$inlang." and has an INT of at least ".(rand(8,12)+(rand(1,3)*$level[rand(1,$l)]))." can find a suitable wilderness area and study it. This will take a month of in-game time. Afterwards, they'll have a general knowledge of herbs. From then on, if they have access to wild herbs they pay half-price for all poisons, because they can gather some of the ingredients themselves.<br>";
} else {
$z=$z."* A book of ".$learnlang." phrases, written in ".$inlang.". Anyone who reads ".$inlang." and has an INT of at least ".(rand(8,12)+(rand(1,3)*$level[rand(1,$l)]))." can communicate in ".$learnlang.", on a very basic level, using this book. Delvers who use this book to communicate with creatures in the dungeon will get half the penalty (rounded down) for lacking a common language (weight 5 value 50).<br>";
}
}
}
} elseif (rand(1,7)==1) {
// miscellaneous magic items.

if ($trleft>999 AND rand(1,6)==1 AND $foldship==0) {
$trleft-=1000;
$foldship=1;
$z=$z."* A fold-up ship. This magic item fits in a backpack, but unfolds to become a seaworthy ship, with room for 10 people to sleep below decks, and folds up again. When folded it looks a bit like a folded fan. weight 50 value 1000<br>";
} elseif ($trleft>199 AND rand(1,3)==1 AND $holyitem==0) {
if (rand(1,2)==1) {
if ($trleft>199) {
$z=$z."* A vial of holy water. If it's splashed on a creature who's 'fiery and demonic', 'insubstantial and ghostly', or looks like 'an animated corpse', the creature will lose all armour (including that from tough skin) if it has any, or lose half its CON or MR if not. The delver must be at pointblank range (5 yards/metres or less) to use the holy water, but doesn't have to make a roll to hit. They can also use a 1-handed weapon in the same Combat Round, if they have a free hand - their Hit Point Total for the round will be halved (round up). There's enough water for one use. weight 10 value 200.<br>";
$trleft-=200;
$holyitem=1;
} else {
$ok=0;
}
} else {
$protection=rand(5,10);
$value=$protection*10;
if ($trleft>=$value) {
$z=$z."* A holy symbol. A delver who wears one of these symbols will have ".$protection." extra points of armour against wounds caused by creatures whose description includes any of the following words or phrases: 'fiery and demonic', 'insubstantial and ghostly', 'animated corpse', 'skull' or 'skeleton'. However these creatures will be able to sense the presence of this symbol, which means that the delver won't be able to hide from them. If any delver is wearing one, everyone in the group will treat their CHR as 5 less than its real value when dealing with such creatures. weight 10 value ".$value."<br>";
$trleft-=$value;
$holyitem=1;
} else {
$ok=0;
}
}
} else {
if ($trleft<125) {
$ok=0;
} elseif (rand(1,3)==1) {
$potype=rand(1,3);
$value=150*($potype+1);
if ($trleft<$value) {
$ok=0;
} else {
$trleft-=$value;
$z=$z."* A potion. Any statted character who drinks it ";
if ($potype==2) {
$z=$z." permanently gains an ability which has the same effect as the spell";
do {
$spok=1;
$splike=rand(1,$spnum+$xspnum);
if ($splike<=$spnum) {
if ($level[$x]<$spells[$splike][1] OR $spells[$splike][2]==0) {
$spok=0;
} else {
$spname=$spells[$splike][0];
$spcost=$spells[$splike][2];
}
} else {
$ewspell++;
$ewspells[$splike-$spnum]=1;
$spname=$xspells[$splike-$spnum][0];
$spcost=$xspells[$splike-$spnum][1];
}
} while ($spok==0);
$z=$z." <i>".$spname."</i>";
if ($splike>$spnum) {
$z=$z." (see 'Magic of Odand' above)";
}
$z=$z.". The character will temporarily lose ".$spcost." points of ";
do {
$pattr=$sname[rand(1,$attnum)];
} while (($wiz==0 AND $pattr=="STR") OR $pattr=="WIZ");
$z=$z.$pattr." each time they use this ability";
} else {
$z=$z."makes all rolls as if their ";
do {
$att1=$sname[rand(1,$attnum)];
} while ($att1=="CON");
$z=$z.$att1." was double its real value";
if ($potype==1) {
do {
$att2=$sname[rand(1,$attnum)];
} while ($att2=="CON" OR $att1==$att2);
$z=$z.", but must also treat their ".$att2." as if it was half its real value (rounded down),";
}
$ptime=rand(1,6);
$z=$z." for ";
if ($ptime>1) {
$z=$z.$ptime." hours";
} else {
$z=$z."an hour";
}
$z=$z." of in-game time";
}
$z=$z.". There's enough of the potion for one drink.";
if (rand(1,3)==1) {
$z=$z." There's no way to tell what the potion will do before it's drunk.";
} elseif (rand(1,2)==1) {
$lev1=$level[rand(1,$l)];
$lev2=round($lev1/2);
$plev=max(2,rand($lev2,$lev1));
$z=$z." Any Wizard or Rogue of at least level ".$plev." will be able to tell what the potion's effect will be. Any Wizard or Rogue of at least level ".($plev+rand(1,3))." will be able to tell ";
if ($potype==2) {
$z=$z."how much, and what attribute, the ability will cost.";
} else {
$z=$z."how long the effect will last.";
}
} else {
$z=$z." Any character with an ";
$attr=rand(1,2+$wiz);
if ($z==1) {
$z=$z."INT";
} elseif ($z==2) {
$z=$z."LK";
} else {
$z=$z."WIZ";
}
$z=$z." of at least ";
$lev=rand(1,$level[$l]);
$sreq=10;
if ($lev>1) {
for ($levn=2;$levn<=$lev;$levn++) {
$sreq+=$levn;
}
}
$z=$z.$sreq." will be able to tell what the potion's effect will be. If they have at least ".($sreq+rand(1,6)+rand(1,6))." they'll be able to tell ";
if ($potype==2) {
$z=$z."how much, and what attribute, the ability will cost.";
} else {
$z=$z."how long the effect will last.";
}
}
$z=$z." Weight.".(5*rand(1,20))." value ".$value."gp<br>";
}
} else {
$lev=max(1,floor($trleft/500)+1);
if ($lev>1) {
$lev=max(rand(1,$lev),rand(1,$lev));
}
do {
$spok=1;
$a=rand(1,$spnum+$xspnum);
$cost=max(125,500*($lev-1));
if ($a<=$spnum) {
$spdes="level ".$lev." spell <i>".$spells[$a][0]."</i>";
if ($spells[$a][1]<>$lev) {
$spok=0;
}
} else {
$spdes="spell <i>".$xspells[$a-$spnum][0]."</i> (see 'Magic of Odand' above)";
$ewspell++;
$ewspells[$a-$spnum]=1;
}
} while ($spok==0);
do {
$b=2;
$perm=rand(0,2);
// $perm:
// 0: scroll which is destroyed once read.
// 1: permanent scroll (x2 value)
// 2: runestone:
// $rstype:
// 1 Wizards only.
// 2 Wizards or Rogues.
// 3 anyone.
// $attype:
// 1 needs INT and DEX.
// 2 needs one attribute only.
// 3 needs no attributes (Odand spells always like this)
if ($perm==1) {
$b=4;
} if ($perm==2) {
do {
$rstype=rand(1,3);
$attype=rand(1,3);
if (str_replace("Odand","XXX",$spdes)<>$spdes) {
$attype=3;
}
} while ($attype==1 AND $rstype<>3);
$b=$rstype+$attype+1;
}
$newcost=round($cost*$b/2);
} while ($newcost>$trleft);
$int=8+($lev*2);
$dex=7+$lev;
$trleft-=$newcost;
$z=$z."* A ";
if ($perm==2) {
$z=$z."runestone. The ".$spdes." is locked into the stone.<br>Any ";
$a=0;
$b=0;
if (rand(1,2)==1) {
$z=$z."delver";
$a=1;
} else {
$z=$z."Rogue or Wizard";
}
if (rand(1,3)==1) {
$z=$z." with ";
if ($wiz==1 AND rand(1,3)==1) {
$z=$z."WIZ";
} elseif (rand(1,2)==1) {
$z=$z."INT";
} else {
$z=$z."CHR";
}
$z=$z." of at least ".rand(1,6)*$lev;
} elseif (rand(1,2)==1) {
$z=$z." of at least level ".(max(2,rand(1,round($lev*3/2))));
} else {
$b=1;
}
$z=$z." will be able to tell what spell is locked in the stone.<br>If a ";
if ($rstype==1) {
$z=$z."Wizard";
} elseif ($rstype==2) {
$z=$z."Rogue or Wizard";
} else {
$z=$z."delver (even a Warrior)";
}
if ($attype==1) {
$z=$z." with INT of at least ".$int." and DEX of at least ".$dex;
} elseif ($attype==2) {
if (rand(1,3)==1) {
$z=$z." with INT of at least ".$int;
} elseif (rand(1,2)==1) {
$z=$z." with DEX of at least ".$dex;
} else {
$z=$z." with CHR of at least ".rand($dex,$int);
}
}
$z=$z." holds the stone and concentrates,";
if ($a*$b==1) {
$z=$z." and if they know what spell is locked inside (including if someone who knows tells them),";
}
$z=$z." they can cast the spell without having to learn it. The spell still costs the holder the normal amount of ";
if ($wiz==1) {
$z=$z."WIZ";
} else {
$z=$z."STR";
}
if ($a*$b==0 AND str_replace("Odand","XXX",$spdes)==$spdes) {
$z=$z.".<br>The delver holding the stone can simply guess spells until they hit the right one, but for each wrong guess they'll temporarily lose ".rand(1,3)." ";
$watt=rand(1,2+$wiz);
if ($watt==1) {
$z=$z."CON";
} elseif ($watt==2) {
$z=$z."STR";
} else {
$z=$z."WIZ";
}
}
} else {
$z=$z."scroll, which contains instructions on how to cast the ".$spdes.". Any Rogue ";
if ($lev>1 OR str_replace("Odand","XXX",$spdes)<>$spdes) {
$z=$z."or Wizard ";
}
if (str_replace("Odand","XXX",$spdes)==$spdes) {
$z=$z."with INT of at least ".$int;
}
$z=$z."can read and learn the spell";
if ($lev==1 AND str_replace("Odand","XXX",$spdes)==$spdes) {
$z=$z." (Wizards will already know it)";
}
if (str_replace("Odand","XXX",$spdes)==$spdes) {
$z=$z.". The spell requires an INT of at least ".$int." and DEX of at least ".($lev+7)." to cast";
}
if ($perm==0) {
$z=$z.". Once one person has learned the spell, the scroll will ";
if (rand(1,3)==1) {
$z=$z." disappear";
} elseif (rand(1,2)==1) {
$z=$z." burst into flame";
} else {
$z=$z." crumble into dust";
}
$z=$z.". If ";
if (str_replace("Odand","XXX",$spdes)==$spdes) {
$z=$z."someone reads the scroll who can't learn the spell, either because they're a Warrior or because of their INT";
} else {
$z=$z."a Warrior reads the scroll";
}
$z=$z.", this won't destroy it. If someone reads the scroll who could learn the spell, but already knows it, this won't destroy the scroll either - and in this case, the reader will learn that the scroll is one which 'self-destructs'";
}
}
$z=$z.". weight 20 value ".$newcost."gp<br>";
}
}
} elseif (rand(1,6)==1) {
// ranged weapons, or ammunition for them.
$rw=rand(1,$rangenum);
$am=$rangew[$rw][5];
if ($am<>"self" AND rand(1,2)==1) {
$value=$ammo[$am][1];
if ($value>$trleft) {
$ok=0;
} else {
$trleft-=$value;
$z=$z."* ".$ammo[$am][0]." (weight ".$ammo[$am][2]." total value ".$value."gp)<br>";
}
} else {
$value=$rangew[$rw][6];
$value=round(rand($value*$lmul,$value*$hmul)/100);
$rmany=floor($trleft/$value);
if ($rmany==0) {
$ok=0;
} else {
$rmany=rand(1,min(rand(1,6),$rmany));
$trleft-=$rmany*$value;
$z=$z."* ";
$wname=$rangew[$rw][0];
if ($rmany==1) {
$z=$z."A ".$wname;
} else {
$z=$z.$rmany." ".$wname."s";
}
$z=$z." (";
$weight=$rangew[$rw][7];
$weight=round(rand($weight*$lmul,$weight*$hmul)/100);
$range=$rangew[$rw][8];
if ($range<>"any") {
$range=round(rand($range*$lmul,$range*$hmul)/100);
}
$dex=$rangew[$rw][4];
$dex=round(rand($dex*$lmul,$dex*$hmul)/100);
$str=$rangew[$rw][3];
$str=round(rand($str*$lmul,$str*$hmul)/100);
if ($wname<>"bullwhip") {
$damage=(7*$rangew[$rw][1])+(2*$rangew[$rw][2]);
$damage=round(rand($damage*$lmul,$damage*$hmul)/100);
$damage=$damage/2;
if (round($damage)==$damage AND $damage<7) {
$dd=2;
$da=$damage-7;
} else {
$dd=1;
if (round($damage)==$damage) {
$dd=2;
}
do {
$dd+=2;
} while ($dd*3.5<=$damage);
$dd-=2;
$da=$damage-(3.5*$dd);
}
$z=$z.$dd." dice ";
if ($da>=0) {
$z=$z."+ ";
} else {
$z=$z."- ";
}
$z=$z.abs($da).", ";
}
$z=$z."used ".$rangew[$rw][9]."-handed, min. STR ".$str." DEX ".$dex.", range ".$range." yards/metres, weight ".$weight." value ".$value."gp";
if ($rmany>1) {
$z=$z." each";
}
$z=$z.")<br>";
if ($wname=="bullwhip") {
$z=$z."Wizards can't use bullwhips. Bullwhips do no damage. Instead, the character wielding it can try and wrap it around an opponent's weapon and pull the weapon out of their hands (it's no use against an opponent fighting with fists, claws etc). To do this, they make a DEX saving roll as if they were using a missile weapon. However, if the victim has a shield, the difficulty of the roll is increased by the damage reduction of the shield (armour doesn't have any effect).<br>If the attacker makes the save, they compare their STR to the STR of their opponent. If the target weapon is 1-handed, and the attacker's STR is at least half that of the defender, the defender's weapon is yanked out of their hand. If the target weapon is 2-handed, the bullwhip wielder's STR must be equal to the opponent's STR. In either case, if the attacker's STR isn't high enough the attack has no effect.<br>";
} elseif ($wname=="pistol") {
$z=$z."Pistols are mechanical contrivances of the gnomes. They fire anything that's put in them (stones, bits of metal etc). Their range is effectively limitless: if you can see it you can shoot at it. However, if the range is more than 50 yards/metres the shooter rolls on LK rather than DEX, and uses LK adds rather than DEX adds to modify damage. If the shooter's roll to hit is a critical failure, they should roll 2 dice:<br>2-3: The weapon starts to fire late, and will do so until it's unloaded and re-loaded. If this is done in combat, it will take an entire Combat Round. Until then, add 1 to the level of all saving rolls to hit.<br>4-6: The pistol is jammed. It must be unloaded and re-loaded before it can be used again. This will take the whole of the next Combat Round.<br>7-8: It gives a flash and a bang, but doesn't shoot. The shooter should make a level 1 saving roll on INT. If they make it, treat as '2-3' above. If they fail, they instinctively look down the barrel to see what the problem is - the weapon then goes off, and the shooter takes full damage, not reduced by armour or shields.<br>9-10: The weapon doesn't shoot - this Combat Round is wasted.<br>11: The pistol jams, and will be unusable until it's repaired (the gnomes are the only ones who know anything about these devices).<br>12: The pistol explodes, and the weapon's user takes the full dice and adds of the weapon in damage (reduced by armour but not shields).<br>";
}
}
}
} elseif (rand(1,5)==1) {
// jewel
$a=rand(1,$jnum);
if ($jewel[$a][2]<>"used") {
$jsize=rand(1,4);
$base=$jewel[$a][1];
$value=$jsize*$base;
if ($value>$trleft) {
$ok=0;
} else {
$jmany=rand(1,min(rand(1,6),floor($trleft/$value)));
$z=$z."* ";
if ($base<25) {
$z=$z."Semi-";
}
$z=$z."Precious Stone";
if ($jmany>1) {
$z=$z."s (".$jmany.")";
}
$z=$z.": ".$jewel[$a][0].". weight ".$jsize." value ".$value." gp";
if ($jmany>1) {
$z=$z." (each)";
}
$z=$z."<br>";
$jewel[$a][2]="used";
$trleft-=($value*$jmany);
}
}
} elseif (rand(1,4)==1) {
// musical instrument
$mm=0;
$a=rand(1,$musnum);
$value=$music[$a][2];
if ($music[$a][3]<>"used") {
// if (rand(1,6)==1) {
// $value=$value*5;
// $mm=1;
// }
if ($value>$trleft) {
$ok=0;
} else {
$mmany=1;
if ($mm==0) {
$mmax=floor($trleft/$value);
if ($mmax==1) {
$mmany=1;
} else {
$mmany=rand(1,min(rand(1,6),$mmax));
}
}
if ($music[$a][0]=="pan pipes") {
$z=$z."* ";
if ($mmany==1) {
$z=$z."P";
} else {
$z=$z.$mmany." sets of p";
}
$z=$z."an pipes";
} elseif ($music[$a][0]=="bagpipes") {
$z=$z."* ";
if ($mmany==1) {
$z=$z."B";
} else {
$z=$z.$mmany." set of b";
}
$z=$z."agpipes";
} else {
if ($mmany==1) {
$z=$z."* A ".$music[$a][0];
} else {
$z=$z."* ".$mmany." ".$music[$a][0]."s";
}
}
$z=$z.". weight ".$music[$a][1]." value ".$value."gp";
if ($mmany>1) {
$z=$z." (each)";
} elseif ($mm==1) {
$z=$z." MAGIC: NOT DONE";
}
$z=$z."<br>";
$music[$a][3]="used";
$trleft-=($mmany*$value);
}
}
} elseif (rand(1,3)==1) {
// armour or shields
// note that $armnum =
// total number of different pieces of armour
// whereas $arnum =
// how many identical pieces in the list of
// treasure.
$a=rand(1,$armnum);
$atype=$arm[$a][0];
$protection=$arm[$a][1];
$streq=$arm[$a][2];
$value=$arm[$a][3];
$weight=$arm[$a][4];

$protection=round(rand($protection*$lmul,$protection*$hmul)/100);
$streq=round(rand($streq*$lmul,$streq*$hmul)/100);
$value=round(rand($value*$lmul,$value*$hmul)/100);
$weight=round(rand($weight*$lmul,$weight*$hmul)/100);

// body type, and hence adjustments to weight.
if ($atype<>"shield") {
$btype=rand(1,$sizecats);
$weight=round($weight*$sizetext[$btype][0]/30);
}

// STR required is at least $weight/100.
$streq=max($streq,ceil($weight/100));

if ($value>$trleft) {
$ok=0;
} else {
$arnum=rand(1,min(rand(1,6),floor($trleft/$value)));
$trleft-=($value*$arnum);
$z=$z."* ";
if ($arnum==1) {
$z=$z."A ".$atype;
} elseif ($atype=="full suit of armour") {
$z=$z.$arnum." full suits of armour";
} else {
$z=$z.$arnum." ".$atype."s";
}
if ($atype=="full suit of armour") {
$minmetal=rand(3,7);
} elseif ($atype=="breastplate") {
$minmetal=rand(2,4);
} elseif ($atype=="helmet") {
$minmetal=rand(1,2);
} else {
$minmetal=rand(3,5);
}
if ($protection>=$minmetal) {
$z=$z." (metal)";
} else {
$z=$z." (non-metal)";
}
$z=$z.": Hits Taken ".$protection." min STR ".$streq." weight ".$weight." value ".$value."gp";
if ($arnum>1) {
$z=$z." each";
}
$z=$z."<br>";
if ($atype<>"shield") {
$z=$z."This armour can be worn by ";
if ($sizetext[$btype][2]<>"XXX") {
$z=$z.$sizetext[$btype][2].", and ";
}
$z=$z.$sizetext[$btype][1]." creatures.<br>";
}
}
} elseif (rand(1,2)==1) {
// hand-to-hand weapon, including
// those that can be used hand-to-hand
// or thrown.

$a=rand(1,$handnum);

$wt=$handw[$a][0];
$wp=$wt."s";
if ($wp=="staffs") {
$wp="staves";
}
$damage=$handw[$a][2]+(3.5*$handw[$a][1]);
$streq=$handw[$a][3];
$dreq=$handw[$a][4];
$dthrow=$handw[$a][5];
$value=$handw[$a][6];
$weight=$handw[$a][7];
$range=$handw[$a][8];
$handed=$handw[$a][9];

$damage=$damage*2;
$damage=round(rand($damage*$lmul,$damage*$hmul)/100);
$damage=$damage/2;
$streq=round(rand($streq*$lmul,$streq*$hmul)/100);
$dreq=round(rand($dreq*$lmul,$dreq*$hmul)/100);
$dthrow=round(rand($dthrow*$lmul,$dthrow*$hmul)/100);
$value=round(rand($value*$lmul,$value*$hmul)/100);
$weight=round(rand($weight*$lmul,$weight*$hmul)/100);
// range isn't adjusted.

if (round($damage)==$damage AND $damage<7) {
$dd=2;
$da=$damage-7;
} else {
$dd=1;
if (round($damage)==$damage) {
$dd=2;
}
do {
$dd+=2;
} while ($dd*3.5<=$damage);
$dd-=2;
$da=$damage-(3.5*$dd);
}
if ($dthrow>0 AND $dthrow<=$dreq) {
if (rand(1,2)==1) {
$dthrow=$dreq+1;
} else {
$dreq=$dthrow-1;
}
}

if ($value>$trleft) {
$ok=0;
} else {
$swnum=rand(1,min(rand(1,6),floor($trleft/$value)));
$trleft-=($value*$swnum);
$chaos=0;
if (rand(1,5)==1) {
$chaos=rand(1,2);
}
if ($swnum==1) {
$z=$z."* A ".$wt;
} else {
$z=$z."* ".$swnum." identical ".$wp;
}
$z=$z.": ";
if ($chaos==0) {
$z=$z.$dd." dice ";
if ($da>=0) {
$z=$z."+ ".$da.", ";
} else {
$z=$z."- ".abs($da).", ";
}
}
$z=$z."used ".$handed."-handed, ";
$z=$z."min. STR ".$streq." DEX ".$dreq;
if ($dthrow>0) {
if ($dthrow==$dreq) {
$z=$z." to use hand-to-hand or to throw";
} else {
$z=$z." to use hand-to-hand, ".$dthrow." to throw. Range ".$range." yards/metres";
}
}
$z=$z.". weight ".$weight.", value ".$value."gp";
if ($swnum>1) {
$z=$z." each";
}
if ($chaos>0) {
$z=$z."<br>";
if ($swnum==1) {
$z=$z."This ".$wt." is";
} else {
$z=$z."These ".$wp." are";
}
if (rand(1,2)==1) {
$z=$z." touched by Chaos. Each Combat Round ";
if ($swnum==1) {
$z=$z."it's";
} else {
$z=$z."one of them is";
}
$z=$z." used, roll 1 dice";
if ($chaos==1 OR $dd==1) {
$z=$z.". On a 1-3, the ".$wt." generates a Hit Point Total of ".($dd+$da).". On a 4-6, it generates ".(($dd*6)+$da).".";
} else {
if ($da==0) {
$z=$z." and multiply by ".$dd;
} else {
$z=$z.", multiply by ".$dd.", then ";
if ($da>0) {
$z=$z."add ".$da;
} else {
$z=$z."subtract ".abs($da);
}
}
$z=$z.". The result is the amount the ".$wt." contributes to the Hit Point Total that round";
if ($range>0) {
$z=$z.", or the damage if it's thrown";
}
}
} else {
$z=$z." touched by Law. Don't roll for its contribution to the Hit Point Total";
if ($range>0) {
$z=$z.", or for damage if it's thrown";
}
$z=$z.". The result will always be ".(round(3.5*$dd)+$da);
}
$z=$z.". If a weapon touched by Law and one touched by Chaos ever touch each other, both weapons are instantly destroyed.";
}
$z=$z."<br>";
if (rand(1,6)==1 AND $dd>2 AND rand(13,27)>$damage) {
if ($swnum==1) {
$z=$z."This ".$wt." is";
} else {
$z=$z."These ".$wp." are";
}
$z=$z." so easy to use that Wizards can use them even though they do more than 2 dice damage. ";
if ($range>0) {
$z=$z."Wizards can only use them hand-to-hand. ";
}
$z=$z."However, if a Wizard does so and is on the losing side of a Combat Round, there's a ".rand(2,5)." in 6 chance that ";
if (rand(1,3)==1) {
$z=$z." the ".$wt." will break.";
} elseif (rand(1,2)==1) {
$z=$z." the Wizard will injure themselves, taking ".rand(1,3)." dice worth of damage. Shields don't reduce this damage, and armour that isn't a full suit doesn't either.";
} else {
$z=$z." the Wizard will strain something, and be unable to cast any spells for ".(rand(1,6)+rand(1,6))." hours of in-game time.";
}
$z=$z."<br>";
}
}
} else {
// miscellaneous equipment
$aa=rand(1,$eqptnum);

// normal sized boots more
// common than fairy ones:
if ($aa==5 AND rand(1,3)>1) {
$aa=4;
}

if ($misceqpt[$aa][4]<>"used") {
if ($misceqpt[$aa][2]>$trleft) {
$ok=0;
} else {
$eqnum=rand(1,min(rand(1,6),floor($trleft/$misceqpt[$aa][2])));
$trleft-=($misceqpt[$aa][2]*$eqnum);
$z=$z."* ";
if ($eqnum==1) {
$z=$z.$misceqpt[$aa][0];
} else {
$z=$z.$eqnum." ".$misceqpt[$aa][1];
}
if ($eqnum>1 AND str_replace("rations","XXX",$misceqpt[$aa][1])<>$misceqpt[$aa][1]) {
$z=$z.". total weight ".($misceqpt[$aa][3]*$eqnum)." total value ".($misceqpt[$aa][2]*$eqnum)." gp";
} else {
$z=$z.". weight ".$misceqpt[$aa][3];
if ($aa==7) {
$z=$z." (15 when full) ";
}
$z=$z." value ".$misceqpt[$aa][2]." gp";
if ($eqnum>1) {
$z=$z." (each)";
}
}
$z=$z."<br>";
$misceqpt[$aa][4]="used";
}
}
}
if (rand(1,3)>1) {
$ok=1;
}
} while ($ok==1);

// turn remaining value into coins:
// gold
$gp=0;
if (rand(1,3)==1) {
$gp=floor($trleft);
} elseif (rand(1,2)==1) {
$gp=max(rand(1,floor($trleft)-1),rand(1,floor($trleft)-1));
}
if ($gp>0) {
$trleft-=$gp;
$z=$z."* ".$gp." gold coin";
if ($gp>1) {
$z=$z."s";
}
$z=$z."<br>";
}

// silver
if ($trleft>0) {
$trleft=$trleft*10;
$sv=0;
if (rand(1,3)==1) {
$sv=$trleft;
} elseif (rand(1,2)==1) {
$sv=max(rand(1,$trleft-1),rand(1,$trleft-1));
}
if ($sv>0) {
$trleft-=$sv;
$z=$z."* ".$sv." silver coin";
if ($sv>1) {
$z=$z."s";
}
$z=$z." (value ".($sv/10)." gp)<br>";
}
}

// copper
if ($trleft>0) {
$trleft=$trleft*10;
$z=$z."* ".$trleft." copper coins (value ".($trleft/100)." gp)<br>";
}
}
}

if ($tr[$x][$y]>0 OR $eye[$x][$y]==1) {
$z=$z."<br>(total value ".($tr[$x][$y]+($eyeval*$eye[$x][$y]))."gp)";
$rd[$x][$y]=$rd[$x][$y].$z;
}

if ($x==$questlevel AND $y==$questroom) {
$rd[$x][$y]=$rd[$x][$y]."<br><br>The most important thing in this room, from the delvers' point of view, is <b>".$questobject."</b>";
if ($system=="tt") {
$rd[$x][$y]=$rd[$x][$y]." (weight ".rand(5,50).")";
}
$rd[$x][$y]=$rd[$x][$y].".";
}
// maybe put some kind of protection -
// spell, invisible, supernaturally heavy etc.


$z="<br><br>";
if ($system=="tt") {
$attr="LK";
if (rand(1,2)==1) {
$attr="INT";
}
$hlev=max(rand(0,$level[$x]),rand(0,$level[$x]));
if (rand(1,3)==1) {
$z=$z."This area has nowhere to hide";
if (rand(1,2)==1) {
$z=$z.", except for fairies, who stay hidden from a casual search if they make a successful level ".$hlev." save on ".$attr;
}
$z=$z.".";
} else {
if (rand(1,2)==1) {
$z=$z."This area is easy to hide in. Any delver can hide well enough that a casual search won't find them. A thorough search won't find a delver who makes a successful level ".$hlev." save on ".$attr.". Hobbits add 5 to their roll. Fairies don't have to make this save.";
} else {
$z=$z."This area is hard to hide in. A thorough search will find any delver. A casual search won't find a delver who makes a successful level ".$hlev." save on ".$attr.". Hobbits add 5 to their roll. Fairies automatically stay hidden from a casual search, and can make this save to stay hidden from a thorough search.";
}
}
} elseif ($system=="ll") {
if (rand(1,3)==1) {
$z=$z."This area has nowhere to hide.";
} elseif (rand(1,2)==1) {
$z=$z."Thieves can try and hide in this area, using their normal chance to Hide in Shadows. ";
if (rand(1,6)==1) {
$z=$z." Halflings have a 90% chance of hiding successfully. ";
} else {
$z=$z." Halflings hide on a 1 or 2 on 1d6. ";
}
$z=$z." No one else will be able to hide in this area.";
} else {
if (rand(1,2)==1) {
$z=$z."Thieves and Halflings can hide in this area. They succeed without having to roll. Anyone else can attempt to hide, rolling as if they were a Thief of their level trying to Hide in Shadows.";
} else {
$z=$z."Thieves can hide in this area. They succeed without having to roll. Anyone else can attempt to hide, rolling as if they were a Thief of their level trying to Hide in Shadows. Halflings, however, have at least a ";
if (rand(1,6)==1) {
$z=$z."90";
} else {
$z=$z."33";
}
$z=$z."% chance to hide regardless of their level.";
}
}
}
$rd[$x][$y]="This area is ".$rwidth." yards/metres east-west by ".$rdepth." yards/metres north-south, and ".$rheight." yards/metres high.<br><br>".$rd[$x][$y].$z;
}
for ($y=1;$y<=$gnum;$y++) {
if ($shrine[$y]==2) {
$shrine[$y]=1;
$manygods++;
}
}
}

if ($system=="ll") {
print "<b>Retainers</b>";
print $line;
// if (rand(1,3)==1) {
// $noretainers=1;
// print "The dungeon has such a bad reputation that no retainers can be hired. Retainers from a previous adventure must make an extra morale check, or they too will refuse to go in.";
// } else {
$anyr=0;
while ($anyr==0) {
for ($z=1;$z<=$llclassnum;$z++) {
if (rand(1,3)==1) {
$retainer[$z]=1;
$anyr++;
}
}
}
if ($anyr<3) {
print "The only retainers that can be hired are ";
} else {
print "The following retainers can be hired: ";
}
$sofar=0;
for ($z=1;$z<=$llclassnum;$z++) {
if ($retainer[$z]==1) {
$sofar++;
if ($anyr>1 AND $sofar==$anyr) {
print " and ";
}
print $llclasses[$z];
if ($sofar<$anyr) {
print ", ";
}
}
}
print ".";
print $line;
for ($z=8;$z<=11;$z++) {
if ($retainer[$z]==1) {
$duc=0;
print $llclasses[$z]." from this area will ";
if ($z==9) {
print "look like ".$appani[rand(1,$aniapp)].", and ";
} elseif ($z==10) {
print "look like ".$apppla[rand(1,$plaapp)].", and ";
}
print "have the following mutations:";
print $line;

// 1st level beneficial.
$m1=3;
if ($z==11) {
$m1=1;
}
for ($a=1;$a<=$m1;$a++) {
do {
$ok=1;
if (rand(1,2)==1 AND $z==10) {
$b=rand(1,2);
if ($pltemp[$b]==1) {
$ok=0;
} else {
print $bpl1[$b]."<br>";
$pltemp[$b]=1;
}
} else {
$b=rand(1,13);
if ($phtemp[$b]==1) {
$ok=0;
} else {
// Gigantism & Dwarfism incompatible
if ($b==5 AND $phtemp[8]==1) {
$ok=0;
} elseif ($b==8 AND $phtemp[5]==1) {
$ok=0;
} else {
print $bph1[$b]."<br>";
$phtemp[$b]=1;
}
}
}
} while ($ok==0);
}
for ($a=1;$a<=13;$a++) {
$phtemp[$a]=0;
$pltemp[$a]=0;
}

// 2nd level beneficial.
if ($m1==3) {
$m1=2;
}
for ($a=1;$a<=$m1;$a++) {
do {
$ok=1;
if (rand(1,3)==1 AND $z==10) {
$b=rand(1,3);
if ($pltemp[$b]==1) {
$ok=0;
} else {
print $bpl2[$b]."<br>";
$pltemp[$b]=1;
}
} elseif (rand(1,2)==1) {
$b=rand(1,19);
if ($phtemp[$b]==1) {
$ok=0;
} else {
print $bph2[$b]."<br>";
$phtemp[$b]=1;
}
} else {
$b=rand(1,12);
if ($metemp[$b]==1) {
$ok=0;
} else {
print $bme2[$b]."<br>";
$metemp[$b]=1;
}
}
} while ($ok==0);
}

for ($a=1;$a<=12;$a++) {
$phtemp[$a]=0;
$pltemp[$a]=0;
$metemp[$a]=0;
}
// not used for level 3, but needs to
// be cleared for next retainer type.

if ($z<11) {
// 3rd level beneficial.
if (rand(1,3)==1 AND $z==10) {
print $bpl3[rand(1,6)];
} elseif (rand(1,2)==1) {
$b=rand(1,12);
print $bph3[$b];
if ($b==7) {
print " (takes the form of ".$appani[rand(1,$aniapp)].")";
}
} else {
$b=rand(1,22);
if ($b==9) {
$duc=1;
}
print $bme3[$b];
}
print "<br>";

// drawbacks
if (rand(1,2)==1) {
// 1 x level 1, 1 x level 3.
print $dph1[rand(1,5)]."<br>";
if (rand(1,3)==1 AND $z==10) {
print $dpl3[rand(1,2)]."<br>";
} elseif (rand(1,2)==1) {
print $dph3[rand(1,8)]."<br>";
} else {
// Dual Cerebellum is incompatible
// with Dual Cerebellum (defective).
do {
$b=rand(1,7);
} while ($duc==1 AND $b==2);
print $dme3[$b]."<br>";
}
} else {
// 2 x level 2 (only physical)
do {
$a=rand(1,5);
$b=rand(1,5);
} while ($a==$b);
print $dph2[$a]."<br>";
print $dph2[$b]."<br>";
}
}
print $line;
}
}
$morale=rand(-2,2);
if ($morale>0) {
print "Retainers' morale will be ".$morale." higher than normal.";
print $line;
} elseif ($morale<0) {
print "Retainers' morale will be ".-$morale." lower than normal.";
print $line;
}
print "Each retainer will expect to get ";
if (rand(1,4)==1) {
print "a fifth";
} elseif (rand(1,3)==1) {
print "a quarter";
} elseif (rand(1,2)==1) {
print "a third";
} else {
print "half";
}
print " as much treasure as a PC.";
// }
print $line;
print $line;
print "<b>Technology Rolls</b>";
print $line;
print "As well as the modifier for Intelligence, you're recommended to give Thieves a +10% modifier, and Elves -10%.";
print $line;
print $line;
}

if ($anyshrine==1) {
print "<b>Shrines</b>";
print $line;
print "When a delver prays at a shrine that they haven't prayed at before, they should make a saving roll on CHR at the level given below. If they fail, the god smites them and they lose CON equal to the number they missed by (some gods might have other results of failure listed). If they succeed, they gain the benefit listed below.";
print $line;
for ($z=1;$z<=$gnum;$z++) {
if ($shrine[$z]==1) {
print "<i>";
if ($godd==1) {
print $gods[$z][0]."</i>, the ".$gods[$z][1]." ".$gods[$z][2]." of ".$gods[$z][3];
} else {
print ucfirst($gods[$z][2])." of ".$gods[$z][3]."</i>";
}
print ": ".$gods[$z][4];
print $line;
if ($godd==1) {
print $gods[$z][0];
} else {
print ucfirst($gods[$z][2]);
}
print " ";
$genpun=0;
$pu=rand(1,3);
if ($pu==1) {
print "won't punish any delver who takes offerings from their shrine";
if (rand(1,2)==1) {
print ", or destroys it.";
} else {
print ". However, if a delver destroys the shrine, they ";
$pu=rand(4,5);
}
}
if ($pu==2 OR $pu==4) {
if ($pu==2) {
print "might punish delvers who take offerings from their shrine";
if (rand(1,2)==1) {
$pu=5;
} else {
print ", or destroy it";
}
} else {
print " might be punished";
}
print ". The delver or delvers responsible should make a save on ";
if ($wiz==1 AND rand(1,2)==1) {
print "WIZ";
} else {
print "CHR";
}
print " at the level of the dungeon ";
$a=$s-1+rand(1,3)-rand(1,3);
if ($a>0) {
print " plus ".$a;
} elseif ($a<0) {
print " minus ".-$a." (with a minimum of 1)";
}
print ". They're punished if they fail.";
if ($pu==5) {
print " If a delver destroys the shrine, they ";
}
}
if ($pu==3) {
print "will punish any delver who takes offerings from their shrine, or destroys the shrine.";
}
if ($pu==5) {
print " will definitely be punished.";
}
print " ";
if ($pu>1) {
if ($godd==1) {
print $gods[$z][0]."'";
if (substr($gods[$z][0],-1)<>"s") {
print "s";
}
} else {
print ucfirst($gods[$z][2])."'s";
}
print " punishment will be that the delver will ";
if (rand(1,2)==1) {
$attl=rand(1,$attnum);
print "lose points from their ".$sname[$attl].", equal to the dungeon level x 2";
if ($s==1) {
print ".";
} else {
print ", plus ".((2*$s)-2).".";
}
print " This loss affects the delver's maximum score in the attribute, as well as their current score. That is, it won't heal.";
} else {
do {
$attl=rand(1,$attnum);
} while ($attl==4);
print "halve their ".$sname[$attl]." (rounded down) for ".(rand(1,6)*$level[rand(1,$l)])." hours of in-game time. This loss affects the delver's maximum score in the attribute, as well as their current score. At the end of this time, the maximum score will instantly return to normal. However, the current score will only recover at the normal rate (see 'Recovering Lost Attribute Points' below).";
}
}
print $line;
if (rand(1,2)==1 OR ($godd==1 AND $gods[$z][0]=="Pan")) {
$anygodm++;
$godinst=$music[rand(1,$musnum)][0];
if ($godd==1 AND $gods[$z][0]=="Pan") {
$godinst="pan pipes";
}
$godinst=str_replace("small ","",$godinst);
$godinst=str_replace("large ","",$godinst);
if ($godd==1) {
$gods[$z][5]=$gods[$z][0];
} else {
$gods[$z][5]=$gods[$z][2]." of ".$gods[$z][3];
}
$gods[$z][5]=$gods[$z][5]." loves the sound of the ".$godinst.".";
print ucfirst($gods[$z][5])." A delver who plays one near their shrine should make a level ".$level[rand(1,$l)]." saving roll on DEX. If they make it, the next delver to pray at the shrine takes ".rand(5,12)." from the difficulty of the roll. If a delver tries to please them with music and fails, no delver can get a bonus in this way for the next 12 hours of in-game time.";
print $line;
}
}
}

// chance of 'divine rivalry'.
$dr=0;
for ($z=1;$z<=3;$z++) {
if ($dr==0) {
$goda=rand(1,$gnum);
$godb=rand(1,$gnum);
if ($goda<>$godb AND $snum[$goda]>1 AND $snum[$godb]>0) {
$dr=1;
}
}
}

if ($dr==1) {
print "<b>War In Heaven:</b>";
print $line;
print "If any delver has prayed at ";
if ($snum[$goda]==2) {
print "both";
} else {
$z=rand(2,$snum[$goda]);
if ($z<$snum[$goda]) {
print $z." or more";
} else {
print "all ".$z;
}
}
print " shrines to ";
if ($godd==1) {
print $gods[$goda][0];
} else {
print $gods[$goda][2]." of ".$gods[$goda][3];
}
print ", and been successful at ";
if ($snum[$goda]==2) {
print "both";
} else {
if ($z==$snum[$goda]) {
print "at least ".ceil($z/2);
} else {
print "more of them than they've failed at";
}
}
print ", then ";
if ($godd==1) {
print $gods[$goda][0];
} else {
print $gods[$goda][2];
}
print " will appear, and charge the delver to destroy ";
if ($snum[$godb]==1) {
print "the shrine to ";
} else {
if ($snum[$godb]==2) {
print "both";
} else {
print "all ".$snum[$godb];
}
print " shrines to ";
}
if ($godd==1) {
print $gods[$godb][0];
} else {
print $gods[$godb][2]." of ".$gods[$godb][3];
}
print ". If the delver refuses, ";
if ($godd==1) {
print $gods[$goda][0];
} else {
print $gods[$goda][2];
}
print " will refuse to hear their prayers for 1-6 weeks of in-game time. If they accept but leave the dungeon before they've completed their task, ";
if ($godd==1) {
print $gods[$goda][0];
} else {
print $gods[$goda][2];
}
print " will ignore them for 2-12 weeks. If they succeed, they'll be blessed with ";
print $snum[$godb]*rand(200,300);
print " Adventure Points. ";
if ($godd==1) {
print $gods[$goda][0];
} else {
print ucfirst($gods[$goda][2]);
}
print " will tell the delver which level";
if ($snum[$godb]==1) {
print " the shrine is";
} else {
print "s the shrines are";
}
print " on, but not any more detailed directions.";
print $line;
}
print $line;
}
if ($system=="tt") {
print "<b>Poison</b>";
print $line;
print "A vial of poison has enough poison to coat a dagger, throwing star or throwing knife 6 times, or any larger weapon 3 times, or 72 arrows or crossbow bolts. When a hand-to-hand weapon is coated, the poison will last until the weapon does damage which isn't reduced to zero by armour or shields, or until 3 Combat Rounds have passed, whichever comes first.";
print $line;
print $line;
print "<b>Notes on Treasure</b>";
print $line;
print "Statted monsters might be guarding treasure which includes weapons, armour and shields which they can use, and which is better than their own equipment, potions which would help them, or other items which would be useful in combat. In this case, the GM should make a level 1 saving roll on INT for the monsters. If they succeed, they'll use the treasure if it comes to combat.";
print $line;
print "Scrolls are written in a magical language, which all Rogues and Wizards will be able to read. If statted creatures are guarding a scroll, and have enough INT to learn the spell:";
print "<ul><li>if the scroll is one that disappears once its spell is learned, they've been unable to read it.";
print "<li>Otherwise, they've read the scroll and know the spell.</ul>";
print $line;
print $line;
print "<b>Recovering Lost Attribute Points</b>";
print $line;
$spf="STR";
if ($wiz==1) {
$spf="WIZ";
}
print "Unless the GM rules otherwise, characters will recover 1 point of lost ".$spf." every 10 minutes, as long as the ".$spf." was lost casting spells. ".$spf." lost for any other reason, and any other reduced attribute (eg CON reduced from combat), recovers at 1 point per day.";
print $line;
print $line;
}
if ($anyeye==1) {
print "<b>Eyes</b>";
print $line;
print "Eyes are devices built by the Ancients. They look like oversized gems, with a switch on one side which activates the device, and a stylised eye on the other, as shown. <img src=\"http://www.apolitical.info/webgame/dungeon/eye.jpg\" align=\"left\">";
print $line;
print "Each Eye shoots a beam. The beams from different types of Eyes have different effects. However the Eyes themselves, and the beams, look identical.";
print $line;
print "Each Eye has 3-18 'charges'. The GM should roll 3";
if ($system=="tt") {
print " dice";
} elseif ($system=="ll") {
print "d6";
}
print " and keep track of the number of charges left. If an Eye has no charges left it can still be used. However the GM should roll a ";
if ($system=="tt") {
print "dice";
} elseif ($system=="ll") {
print "d6";
}
print ":<br>1-4 The Eye works as normal.";
print "<br>5 The Eye closes, never to work again (such an Eye will also be un-sellable).";
print "<br>6 The Eye explodes, doing 4";
if ($system=="tt") {
print " dice";
} elseif ($system=="ll") {
print "d6";
}
print " worth of damage to the character holding it, and 2";
if ($system=="tt") {
print " dice";
} elseif ($system=="ll") {
print "d6";
}
print " to any character within 3 yards/metres (";
if ($system=="tt") {
print "reduced by armour as normal";
} else {
print "save vs Breath Attacks for half damage";
}
print ").".$line;
print "It takes two hands to hold an Eye. Trying to hit a target with the beam is treated as a normal missile attack. Its range is effectively infinite - if you can see it, the beam will reach.";
print $line;
print "Most Eyes have an effect which lasts for a variable time. There's no way to tell how long the effect of an Eye will last. If a character is hit by an Eye, they're immune to that type of Eye until the effect wears off. If they're hit by an Eye while immune, roll again for how long the effect will last, and take whichever lasts longer, the new roll or the existing roll. But don't apply the effect again.";
print $line;
print $line;
}
if ($unstuck==1) {
print "<b>Unstuck In Time</b>";
print $line;
print "If a room is marked as being 'unstuck in time', this means several things:";
print $line;
print "For as long as the delvers stay here, no time will pass in the outside world. This means that there'll be no wandering monsters.";
print $line;
print "If the delvers leave and come back, things will be 'reset' to exactly as when the delvers first arrived. If they killed a creature it will be alive with no memory of meeting the delvers, if they carried off treasure they'll still have it, but identical treasure will be in the room. The delvers can only get experience for defeating a given creature once.";
print $line;
print "This means that the delvers might end up with multiple copies of the same treasure, or with multiple copies of the same creature accompanying them. Each area will have a 'paradox limit'. This is the maximum number of copies of the same creature or object that can exist in the same place at the same time.";
print $line;
print "Once this limit is exceeded, the GM should roll a dice:";
print "<br>1-2 the multiple items are treated as normal from now on, and don't count towards the paradox limit.";
print "<br>3-4 all 'copies' disappear, leaving only one.";
print "<br>5-6 all copies, including the original, explode, doing 1-3 damage each to anyone within two metres/yards (damage reduced as normal).";
print $line;
print "The GM should roll on this table seperately for each set of copies - however, treat up to 100 coins as 1 object.";
print $line;
print "The GM should also roll on this table if the delvers leave the dungeon with multiple copies of any object or creature.";
print $line;
print $line;
}
if ($system=="tt") {
print "<b>Chases</b>";
print $line;
print "It's likely that at some point the characters will have to run away from some of the creatures in the dungeon, or that creatures will run away from them.";
print $line;
print "If the characters are running away from, or chasing, a statted creature, both character and creature should roll 2 dice and add their SPD (doubles add and re-roll). The highest total is the faster.";
print $line;
print "If characters have lost at least half their CON, or are carrying half or more of their Weight Possible, they roll as normal but halve their final result. This applies to both delvers and non-player characters. If characters are both heavily wounded and carrying a heavy load, the result is still only halved rather than quartered.";
print $line;
print "If the characters are running away from, or chasing, a Monster Rated creature, the character should make a SR on SPD. The level of the save is the Monster Rating divided by 30, rounded up.";
print $line;
print "If characters have lost at least half their CON, or are carrying half or more of their Weight Possible, add 2 to the level of the save. Again, if a character meets both conditions, only 2 levels are added to their save, not 4. However if the Monster Rated creature has lost at least half its MR, take 2 from the level of the save.";
print $line;
print $line;
}
if ($system=="tt") {
print "<b>Searching and Hiding</b>";
print $line;
$z=rand(2,7);
print "Searching a single area will take ".($z*5)." minutes of in-game time for a thorough search. Before rolling, delvers can choose to take less time, taking 5 from their dice roll for";
if ($z>1) {
print " each";
}
print " five minutes saved.";
if ($z>1) {
print " Five minutes is the minimum time for a search.";
}
print " Delvers can search as many times as they want (remember to roll for wandering monsters).";
print $line;
print "If there's more than one hidden feature in the room, the delver should only roll once. However, this roll is compared to the relevant level and attribute for each feature.";
print $line;
print "If the delvers hide, they might have to make saving rolls (as given in the descriptions for the individual areas). If more than one creature is searching for them, the delvers subtract 2 from their roll for each 'extra' searcher.";
print $line;
print "The GM should bear in mind that the delvers might be able to cast the spell <i>Oh There It Is</i> instead of searching, and that some creatures in the dungeon might also know the spell.";
} elseif ($system=="ll") {
print "<b>Secret Doors and Illusory Walls</b>";
}
print $line;
print "If creatures are in an area with a secret door or illusory wall, or if the area is 'frequently used' by them, assume that all members of that species know about the feature. Otherwise creatures won't know about the feature.";
print $line;
print $line;
if ($ewspell>0) {
print "<b>Magic of Odand</b>";
print $line;
if ($ewspell==1) {
print "This spell comes from the parallel world of Odand. It has no level. It costs";
} else {
print "These spells come from the parallel world of Odand. They have no level. They cost";
}
print " the same regardless of the caster's level, can't be bought from the Wizard's Guild, and have no minimum INT or DEX to learn or cast. However, they can't be cast by one who has their hands bound.";
print $line;
$fromew=0;
$fromme=0;
for ($a=1;$a<=$xspnum;$a++) {
if ($ewspells[$a]==1) {
if ($a<=$elweir) {
$fromew=1;
} else {
$fromme=1;
}
print "<i>".$xspells[$a][0]." (".$xspells[$a][1]." ";
if ($wiz==1) {
print "WIZ";
} else {
print "STR";
}
print " to cast)</i> ".$xspells[$a][2];
print $line;
}
}
if ($fromew==1) {
if ($fromme==1) {
print "Partly a";
} else {
print "A";
}
print "dapted, with permission, from <a href=\"http://www.lulu.com/content/2791099\" target=\"_blank\">Eldritch Weirdness</a> by Matthew J. Finch (originally written for Dungeons & Dragons).";
}
print $line;
print $line;
};
// print levels
// details of messages on walls are generated here, because
// messages depend on what shrines are in the dungeon.
print "<b><big>Maps</big></b>";
print $line;

if ($system=="tt") {
print "Travelling from one area or intersection to an adjacent one will take ".$traveltime." minutes of in-game time. Travelling between levels will take a varying amount of time, given below. The delvers will move at half speed if any delver is carrying half or more of their Weight Possible, or has lost half or more of their CON. A delver who's both heavily wounded and carrying a heavy load will still move at half-speed, not quarter-speed.";
} elseif ($system=="ll") {
print "If a character has a Turn Movement of 60', they can travel from one area or intersection to an adjacent one in ".$traveltime." minutes of in-game time. Travelling between levels will take a varying amount of time, given below. Characters with a different movement will take more or less time, as per the Movement and Encumbrance Table on p44 of Labyrinth Lord or p36 of Mutant Future.";
}
print $line;
print "Note that the map isn't to scale. Corridors would be much longer if they were in scale to the rooms, and the rooms are actually different sizes.";
print $line;
$rs=0;
$rm=0;
for ($d=1;$d<=$l;$d++) {
$ex=0;
print "<b><big>Level ".$d."</big></b>";
print $line;
print "This level is <i>".$climates[$lclimate[$d]]."</i>.</div>";
print $line;
if (rand(1,2)==1 AND $system=="tt") {
$ad=rand(1,$advnum);
print "It smells subtly like ".$advantage[$ad][0].". This means that ".$advantage[$ad][1]." will feel more at home. Every hour of in-game time, they can re-roll one saving roll or roll in combat that they make. Dwarves, on the other hand, will feel like there's something wrong. If a dwarf succeeds on a saving roll, their next roll will be 1 level more difficult. This includes rolls to hit with ranged weapons.";
print $line;
}
$wide=max(2,rand(1,6));
print "The corridors on this level are wide enough for ".$wide." ";
if ($system=="ll") {
print "characters to walk side-by-side.";
} else {
print "humans to walk side-by-side.";
if ($d==1) {
print " For this purpose, count dwarves and hobbits as 3/4 of a human, and leprechauns as 1/2. Fairies count as 0 if they're flying, 1/3 otherwise. When fighting, every delver counts as 1 except for fairies, who count as 0 if flying or 1/2 if not. Gigantic creatures count as 2 humans whether fighting or not.";
}
}
print $line;
if ($d>1 AND $system=="tt") {
print "When the delvers first enter this level, they should each be given ".($level[$d]*100)." AP.";
print $line;
}
print "Roll for wandering monsters every ".$climatew[$climates[$lclimate[$d]]];
if ($climates[$lclimate[$d]]<>"Desert-like") {
print " of in-game time";
}
// create and print wandering monster table for this level.
if ($system=="tt") {
print ". Note that this includes when the delvers are dealing with creatures.";
print $line;
$mark=$levmark[$d];
$goal=$levgoal[$d];
$b=0;
if ($goal==1) {
print "On a five or six, the delvers encounter ";
} elseif ($goal==2) {
print "On a five, the delvers encounter ";
} else {
print "On a five or six, roll";
for ($z=1;$z<=3;$z++) {
if ($table[$mark][$z]>1) {
$b++;
}
}
if ($b==1) {
print " again";
} else {
print " ".$b." dice";
}
print " on the following table:";
print $line;
print "<table border=4 cellspacing=4 cellpadding=4><tr><td>";
if ($b>1) {
print "1st ";
}
print "roll</td>";
if ($b>1) {
print "<td>2nd roll</td>";
if ($b==3) {
print "<td>3rd roll</td>";
}
}
print "<td>result</td></tr>";
}
$curr=0;
for ($z=1;$z<=$sn;$z++) {
for ($a=1;$a<=$wmtable[$d][$z];$a++) {
$curr++;
if ($goal==2 AND $curr==2) {
print "<br><br>On a six, they encounter ";
} elseif ($goal>2) {
print "<tr>";
for ($colu=1;$colu<=3;$colu++) {
if ($table[$mark][$colu]<>1) {
print "<td>";
$period=1;
if ($colu<3) {
for ($oco=3;$oco>$colu;$oco--) {
$period=$period*$table[$mark][$oco];
}
}
$incr=6/$table[$mark][$colu];

$rotat=floor(($curr-1)/$period)+1;
$rotat=($rotat-1)*$incr+1;
while ($rotat>6) {
$rotat-=6;
}
print $rotat;
if ($incr>1) {
print "-".($rotat+$incr-1);
}
print "</td>";
}
}
print "<td>";
}
if ($a>1) {
print "as above";
} else {
$cr=$crname[$z];
if ($grp[$z][$d]==1) {
print "A";
$f=substr($cr,0,1);
if ($f=="A" OR $f=="E" OR $f=="I" OR $f=="O" OR $f=="U") {
print "n";
}
print " ".$cr;
} else {
if ($grp[$z][$d]==2) {
print "1-3";
} else {
if ($grp[$z][$d]==3) {
$dice=1;
$adds=0;
} else {
$dice=floor($grp[$z][$d]/3.5);
$adds=round($grp[$z][$d]-(3.5*$dice));
}
$lowposs=$dice+$adds;
$highposs=(6*$dice)+$adds;
print $lowposs."-".$highposs;
if ($highposs<>($lowposs*6)) {
print " (roll ";
if ($dice==1) {
print "a";
} else {
print $dice;
}
print " dice";
if ($adds>0) {
print " and add ".$adds;
}
print ")";
}
}
print " ";
print $cr;
if (substr($cr,-1)=="s" OR substr($cr,-1)=="x") {
print "e";
}
print "s";
}
print " (species ".$z;
if ($z<=$standardused) {
print ": ".$stplural[$standardsn[$z]];
}
print ")";
$crt=$spt[$z];
if ($crt>0 AND $crt<>$lclimate[$d]) {
print " Remember that these creatures' presence makes the area <i>".$climates[$crt]."</i>.";
}
}
if ($goal>2) {
print "</td></tr>";
}
}
}
if ($goal>2) {
print "</table>";
}
} elseif ($system=="ll") {
print ", using a d6. ";
// find how many species live on this level ($nml).
$nml=0;
for ($z=1;$z<=$sn;$z++) {
if ($shallow[$z]<=$d AND $deep[$z]>=$d) {
$nml++;
$wmll[$z]=1;
} else {
$wmll[$z]=0;
// this is probably unnecessary, but leave it anyway.
}
}

// find a number and size of dice which will give a
// range of results ($resnum) equal to or greater than $nml.
// $z=number, $diceface[$a]=size.
$z=1;
$a=1;
$resnum=1;
while ($resnum<$nml) {
if (rand(1,2)==1 AND $a<$dicenum) {
$a++;
$z=1;
} else {
$z++;
}
$resnum=($z*$diceface[$a])-$z+1;
if ($resnum>$nml AND rand(1,2)==1) {
if (rand(1,2)==1) {
$z=max(1,$z-1);
} else {
$a=max(1,$a-1);
}
$resnum=($z*$diceface[$a])-$z+1;
}
}
if ($nml==1) {
print "On a five or six, run the following encounter: ";
} else {
print "On a five or six, roll ".$z."d".$diceface[$a]." on the following table:";
}
while ($resnum>$nml) {
$resnum--;
do {
$b=rand(1,$sn);
} while ($wmll[$b]==0);
$wmll[$b]++;
}

print $line;
print "<table border=4 cellspacing=4 cellpadding=4><tr><td>";
if ($nml>1) {
print "result</td><td>";
}
print "Creature/s encountered</td><td>Hoard Class<br>(per creature)</td></tr>";
for ($cc=1;$cc<=$nml;$cc++) {
print "<tr><td>";
do {
$b=rand(1,$sn);
} while ($wmll[$b]==0);
if ($nml>1) {
print $z;
if ($wmll[$b]>1) {
print "-".($z+$wmll[$b]-1);
}
print "</td><td>";
$z=$z+$wmll[$b];
$wmll[$b]=0;
}
if ($wnencb[$b]==1) {
if ($wnenca[$b]==1) {
print "A";
$f=substr($crname[$b],0,1);
if ($f=="A" OR $f=="E" OR $f=="I" OR $f=="O" OR $f=="U") {
print "n";
}
} else {
print $wnenca[$b];
}
} else {
print $wnenca[$b]."d".$wnencb[$b];
}
print " ".$crname[$b];
if ($wnenca[$b]>1 OR $wnencb[$b]>1) {
if (substr($crname[$b],-1)=="s" OR substr($crname[$b],-1)=="x") {
print "e";
}
print "s";
}
print " (species ".$b.")";
if ($spt[$b]>0 AND $spt[$b]<>$lclimate[$d]) {
print " Remember that these creatures' presence makes the area <i>".$climates[$spt[$b]]."</i>.";
}
print "</td><td>";
if ($whoard[$b]==0) {
print "none";
} else {
print $treasuretypes[$whoard[$b]][0];
}
print "</td></tr>";
}
print "</table>";
}
print $line;
// generate $doors for level.
for ($x=$xlow[$d]+1;$x<$xhigh[$d];$x++) {
for ($y=$ylow[$d]+1;$y<$yhigh[$d];$y++) {
$roomexit=0;
if (rand(1,20)==1) {
$roomexit=-1;
if (rand(1,2)==1) {
$roomexit=rand(1,3);
}
}
for ($wexit=1;$wexit<5;$wexit++) {
if ($roomexit>0) {
$doors[$x][$y][$d][$wexit]=$roomexit;
} elseif ($roomexit==-1 OR rand(1,10)==1) {
$a=rand(1,3);
$doors[$x][$y][$d][$wexit]=$a;
}
}
}
}
// print the level.
print "<table cellspacing=0 cellpadding=0>";
for ($y=$yhigh[$d]-1;$y>$ylow[$d];$y--) {
for ($row=1;$row<=5;$row++) {
print "<tr>";
for ($x=$xlow[$d]+1;$x<$xhigh[$d];$x++) {
for ($col=1;$col<=5;$col++) {
print "<td width=\"20\" height=\"20\">";
$where=$col+(5*$row)-5;
$square=$stype[$where];
if ($map[$x][$y][$d]==3 AND ($square=="corner" OR $square=="wall")) {
$any=0;
if ($row<3) {
$halign="u";
if ($map[$x][$y+1][$d]==1) {
$any=1;
$ali="v";
}
} else {
$halign="d";
if ($map[$x][$y-1][$d]==1) {
$any=1;
$ali="v";
}
}
if ($col<3) {
$valign="l";
if ($map[$x-1][$y][$d]==1) {
$any=1;
$ali="h";
}
} else {
$valign="r";
if ($map[$x+1][$y][$d]==1) {
$any=1;
$ali="h";
}
}
if ($any==1) {
if ($square=="corner") {
print $pic.$where."-f-".$ali.".jpg\">";
} else {
if ($ali=="h") {
if ($row>1 AND $row<5) {
print $pic."w-h-".$halign.".jpg\">";
}
} else {
if ($col>1 AND $col<5) {
print $pic."w-v-".$valign.".jpg\">";
}
}
}
}
} elseif ($square=="centre") {
if ($map[$x][$y][$d]==1) {
$rm++;
$rstring=$rm;
if ($rm>99) {
$rstring=floor($rm/10);
$rstring=chr($rstring+55).($rm-(10*$rstring));
}
print "<div align=\"center\">".$rstring."</div>";;
} elseif ($map[$x][$y][$d]==3) {
$ex++;
if ($d<10) {
print $d;
} else {
print chr(55+$d);
}
print chr($ex+96);
}
} elseif ($square=="corner") {
if ($map[$x][$y][$d]==1) {
print $pic.$where."-e.jpg\">";
} elseif ($map[$x][$y][$d]==2) {
print $pic;
if ($col<3) {
$xcheck=-1;
} else {
$xcheck=1;
}
if ($row<3) {
$ycheck=1;
} else {
$ycheck=-1;
}
if ($map[$x][$y+$ycheck][$d]==1 AND $map[$x+$xcheck][$y][$d]==1) {
print $where."-t";
} elseif ($map[$x+$xcheck][$y][$d]==1) {
print "w-h-";
if ($row<3) {
print "u";
} else {
print "d";
}
} elseif ($map[$x][$y+$ycheck][$d]==1) {
print "w-v-";
if ($col<3) {
print "l";
} else {
print "r";
}
} else {
print $where."-o";
}
print ".jpg\">";
}
} elseif ($square=="tunnel") {
if ($map[$x][$y][$d]==1) {
$blocked=0;
if ($where==3) {
if ($y==$yhigh[$d]-1 OR $map[$x][$y+1][$d]==4) {
$blocked=1;
}
} elseif ($where==11) {
if ($x==$xlow[$d]+1 OR $map[$x-1][$y][$d]==4) {
$blocked=1;
}
} elseif ($where==15) {
if ($x==$xhigh[$d]-1 OR $map[$x+1][$y][$d]==4) {
$blocked=1;
}
} else {
if ($y==$ylow[$d]+1 OR $map[$x][$y-1][$d]==4) {
$blocked=1;
}
}
if ($blocked==1) {
print $pic.$where."-b.jpg\">";
} else {
if ($where==3) {
$which=1;
} elseif ($where==11) {
$which=2;
} elseif ($where==15) {
$which=3;
} else {
$which=4;
}
$what=$doors[$x][$y][$d][$which];
if ($what>0) {
print "<div align=\"";
if ($which==2) {
print "right";
} elseif ($which==3) {
print "left";
} else {
print "center";
}
print "\">".$doorsymbol[$what]."</div>";
$exitsave[$what][$d]=1;
if ($what==1) {
$exitsave[0][$d]=1;
}
}
}
}
} elseif ($square=="wall") {
if ($map[$x][$y][$d]<3) {
$blocked="b";
if (abs($col-3)==2) {
if ($row<3) {
$z="h-u";
} else {
$z="h-d";
}
} else {
if ($col<3) {
$z="v-l";
} else {
$z="v-r";
}
}
if ($col==1) {
if ($x>$xlow[$d]+1 AND ($map[$x-1][$y][$d]==1 OR ($map[$x][$y][$d]==1 AND $map[$x-1][$y][$d]<>4))) {
$blocked="t";
}
} elseif ($col==5) {
if ($x<$xhigh[$d]-1 AND ($map[$x+1][$y][$d]==1 OR ($map[$x][$y][$d]==1 AND $map[$x+1][$y][$d]<>4))) {
$blocked="t";
}
} elseif ($row==5) {
if ($y>$ylow[$d]+1 AND ($map[$x][$y-1][$d]==1 OR ($map[$x][$y][$d]==1 AND $map[$x][$y-1][$d]<>4))) {
$blocked="t";
}
} else {
if ($y<$yhigh[$d]-1 AND ($map[$x][$y+1][$d]==1 OR ($map[$x][$y][$d]==1 AND $map[$x][$y+1][$d]<>4))) {
$blocked="t";
}
}
}
if ($map[$x][$y][$d]==1) {
print $pic.$where."-".$blocked;
if ($blocked=="t") {
if ($where==2 OR $where==4) {
$which=1;
} elseif ($where==6 OR $where==16) {
$which=2;
} elseif ($where==10 OR $where==20) {
$which=3;
} else {
$which=4;
}
if ($doors[$x][$y][$d][$which]>0) {
print "s";
}
}
print ".jpg\">";
} elseif ($map[$x][$y][$d]==2) {
if ($blocked=="t") {
print $pic."w-".$z.".jpg\">";
}
}
} elseif ($square=="2only" and $map[$x][$y][$d]==2) {
$ali="h";
if ($row==3) {
$ali="v";
}
$check=-1;
if ($col>$row) {
$check=1;
}
if ($ali=="h") {
$neigh=$map[$x][$y+$check][$d];
} else {
$neigh=$map[$x+$check][$y][$d];
}
if ($neigh<>1) {
print $pic."w-".$ali."-";
if ($where==8) {
$z="u";
} elseif ($where==12) {
$z="l";
} elseif ($where==14) {
$z="r";
} else {
$z="d";
}
print $z.".jpg\">";
}
}
print "</td>";
}
}
print "</tr>";
}
}
print "</table>";
print $line;
if ($exit[$d][0]>0) {
for ($t=1;$t<=$exit[$d][0];$t++) {
print "<b>";
if ($d<10) {
print $d;
} else {
print chr($d+55);
}
print chr($t+96)."</b> ".$exit[$d][$t]."</br>";
}
}
$anyexits=0;
for ($z=0;$z<=3;$z++) {
if ($exitsave[$z][$d]==1) {
$compare=$d-1;
while ($compare>0 AND $exitsave[$z][$compare]<1) {
$compare--;
}
$exitsave[$z][$d]=max($exitsave[$z][$compare],rand($level[d]-2,$level[$d]+2));
$howhard=max(0,$exitsave[$z][$d]);
if ($z>0) {
print "<b>".$doorsymbol[$z]."</b> ";
if ($z==1) {
print "Illusory wall. Anyone who searches the room will find this illusion";
if ($system=="ll") {
print ". However, even when it's noticed as an illusion, it's very hard to walk through it. Anyone with a WIL/WIS of less than ";
print min(16,6+(2*$howhard));
print " will be unable to do so.";
} else {
print ", regardless of their roll. However, even when it's noticed as an illusion, it's very hard to walk through it. Anyone with a";
if ($wiz==1) {
print " WIZ";
} else {
print "n INT";
}
print " of less than ".(10+(2*$howhard))." (or a Monster Rating of less than ".(max(30,30*$howhard)).") will be unable to do it. For the purposes of Dis-spell, treat the illusion as level ".($exitsave[0][$d]+3).".";
}
} elseif ($z==2) {
print "Locked door.";
if ($system=="tt") {
print " Any delver can try and break this down. They should make a level ".$howhard." save on STR. If they're wearing armour (shields don't count), they should increase their roll by the amount of damage their armour stops. If they make it, the door breaks. If they fail, they take damage equal to the difference, not reduced by armour or shields. Each attempt should be treated as if 20 minutes had passed for the purposes of rolling for wandering monsters. If wandering monsters are attracted by the noise, they'll normally wait on the other side.<br>The delvers might also try to pick the lock. This will be impossible without a set of lockpicks. It will take 45 minutes of work, and require a level ".$howhard." save on DEX. If a delver fails, they can try again as many times as they want (but be sure to roll for wandering monsters).";
}
} elseif ($z==3) {
print "Secret door.";
if ($system=="tt") {
print " Any delver searching the room will find this door, if they make a level ".$howhard." save on the higher of their LK and INT.";
}
}
print "<br>";
}
}
}
print $line;
for ($z=1;$z<=$rn[$d];$z++) {
$rstring=$rs+$z;
if ($rstring>99) {
$rstring=floor(($rs+$z)/10);
$rstring=chr($rstring+55).($rs+$z-(10*$rstring));
}
print "<b>".$rstring.":</b> ".$rd[$d][$z];
if (rand(1,6)==1) {
do {
$cr=rand(1,$sn);
} while ($shallow[$cr]>$d OR $deep[$cr]<$d);
do {
$lang=rand(1,$langnum);
} while ($crlang[$cr][$lang]<1);
print $line;
print "There's a message on the wall, written in ".$language[$lang].". ";
$ok=0;
do {
$ok=1;
$mty=rand(1,5);
// 1 - contents of room on the same level.
// 2 - punishment or lack thereof for stealing
// from or destroying shrines.
// 3 - information about alliances/rivalries.
// 4 - teach spells.
// 5 - musical instruments/gods.
if ($mty==1 AND $rn[$x]==1) {
$ok=0;
} elseif ($mty==2 AND $anyshrine<1) {
$ok=0;
} elseif ($mty==5 AND $anygodm<1) {
$ok=0;
} elseif ($mty==3 AND $anylev==0) {
$ok=0;
} elseif ($mty==4 AND $system=="ll") {
$ok=0;
}
} while ($ok==0);
if ($mty==1) {
$rms=0;
if ($d>1) {
for ($a=1;$a<$d;$a++) {
$rms+=$rn[$d];
}
}
do {
$a=rand(1,$rn[$d]);
} while ($a==$y);
$targ=$rms+$a;
if ($targ>99) {
$a=floor($targ/10);
$targ=chr($a+55).($targ-(10*$a));
}
print "It gives a description of the contents of room ".$targ.". It also gives the quickest route there (or routes if there's more than one), but no information about anything along the way.";
} elseif ($mty==2) {
print "It gives a description of the punishment (or lack of) for stealing from or destroying the shrines of ";
do {
$a=rand(1,$gnum);
} while ($shrine[$a]<1);
if ($godd==0) {
print $gods[$a][2]." of ".$gods[$a][3];
} else {
print $gods[$a][0];
}
print ". The delvers will learn what attribute will be effected, and whether it'll be permanent, but not the number of points lost. Similarly, if saving rolls are involved the delvers won't learn the level of the save, but will learn the attribute.";
} elseif ($mty==3) {
print "Anyone who reads it will learn that ".$isdiplo[rand(1,$anylev)];
} elseif ($mty==4) {
// because 'Magic of Odand' has already been printed,
// the only Odand spells that can appear here are
// ones that already 'exist' (ie a monster can cast
// it, or a scroll with it is in the dungeon).
$wlev=rand(1,$level[$x]);
do {
$spok=1;
do {
$spok2=1;
$spe=rand(1,$spnum+$xspnum);
if ($spe>$spnum AND $ewspells[$spe-$spnum]==0) {
$spok2=0;
}
} while ($spok2==0);
if ($spe<=$spnum) {
if ($spells[$spe][1]<>$wlev) {
$spok=0;
} else {
$spdes="level ".$wlev." spell <i>".$spells[$spe][0]."</i>";
}
} else {
$spdes="spell <i>".$xspells[$spe-$spnum][0]."</i> (see 'Magic of Odand' above)";
}
} while ($spok==0);
print "Anyone who reads it will see that it's dangerous magic. If they keep reading, they should make a level ".(rand(round($wlev/2),round($wlev*3/2)))." save on ";
if (rand(1,3)==1) {
print "CHR";
} elseif (rand(1,2)==1 AND $wiz==1) {
print "WIZ";
} else {
print "INT";
}
print ". If they fail, they take damage equal to the amount they failed by (a critical failure counts as a failure by at least 1). If they succeed, and they're a Rogue ";
if ($wlev>1 OR str_replace("Odand","XXX",$spdes)<>$spdes) {
print "or Wizard ";
}
print "who doesn't already know the ".$spdes.", they now know it. This doesn't necessarily mean they're able to cast it: the normal requirements";
if (str_replace("Odand","XXX",$spdes)==$spdes) {
print " for INT and DEX";
}
print " still apply. If a Warrior succeeds, or a Wizard or Rogue who already knows the spell, they gain ".(rand(round($wlev/2),round($wlev*3/2)))." dice worth of CON up to their maximum - any 'wasted' points turn into 10 AP each. Once anyone succeeds in reading the message, it'll disappear. Delvers who fail can try again as often as they want. Reading the message will take ".(rand(1,6)*5)." minutes.";
} else {
do {
$a=rand(1,$gnum);
} while ($gods[$a][5]=="");
print "It will tell any who read it that ".$gods[$a][5];
}
}
print $stairs[$d][$z];
print $line;
}
$rs+=$rn[$d];
print $line;
}
?>
<div>&nbsp</div>
<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></div>
<div>&nbsp</div>
<div align="center">
<!-- Project Wonderful Ad Box Code -->
<div id="pw_adbox_1077_2_0"></div>
<!-- End Project Wonderful Ad Box Code -->
</html>
</body>