Ten things Pool of Radiance never told you

The secret paladin and ranger you can't pick, the training hall that crashes if you're half a gold piece short, the 25,000 gold bow that's really a heavy crossbow, and seven more Pool of Radiance secrets, each with its line of code.

25 min read Pool of Radiancegame bugsAD&D

The original game in our emulator, started with the word, just after Alt-X in a fight: "The Gods intervene!", and every monster gone at once

If you're in a fight in Pool of Radiance and you press Alt-X, you can get the message "The Gods intervene!", and every monster on the battlefield drops dead at once. It isn't a mod or a trainer. It's part of the original game as SSI shipped it, a back door the developers left in, and you can only reach it if you know a certain word. I'll get to that.

Another thing: on my real Tandy 1000 EX, a magic-user named Svengali with 25 darts locked the game up solid. That's a bug SSI shipped too, and it's number one on this list.

In the last article, we decompiled Pool of Radiance into Turbo Pascal: source code which, when compiled, reproduces the original game byte for byte. Then I sat down and played the game on the Tandy Color Computer 3 port we built from that source.

During that play-through, I kept asking Claude questions about the rules. Why did that happen? What does this item do? Can I charm that monster? Claude would go through the source code, down to the line, and tell me. One thing I really liked is that the answers said so when something was read in the code but not tested in the game. I'll do the same here. Where we could, we set the situation up in an emulator running the original program and watched it happen, and I'll say where we couldn't. Many of the setups needed something changed by hand first, such as some experience, some gold, an item, a spell or the monster in a fight, and I say so where it matters.

There's one more thing we did for this article. Pool of Radiance is first edition Advanced Dungeons and Dragons on a computer, so we also put the code next to the rules it was built from, and where the game and the book disagree, I'll say so. The rules come from secondary sources that summarise the books, never from the books themselves, so I say "as it's usually read" where the sources do.

So here are ten things Pool of Radiance never told you: how you see each one in the game, the few lines of Pascal that make it happen, and what it means for you as a player. There's a video that covers the same ground; this written version has the code, the tables and the links into the repository.

Every episode in the playlist

10. The classes you can't pick

Character creation in the emulator: the class menus offer clerics, fighters, magic-users, thieves and their mixes, with no paladin and no ranger

When you roll a character in Pool of Radiance, the class menu offers clerics, fighters, magic-users, thieves and the multi-class combinations. No paladin, no ranger. But the game's tables have both: in the class name table, class 3 is the paladin and class 4 is the ranger.1

The paladin's rows are filled in like a real AD&D class: lawful good only, a Charisma of at least 17, a ten-sided hit die, and the fighter's to-hit and saving throw rows. The ranger gets two eight-sided hit dice at first level, as AD&D's ranger is usually described. Both even have a starting age, but only in the human column.

The paladin and ranger rows, decoded from the game's data, and the starting age table with only the human column filled

However, neither class goes past the first level. From level two on, their experience rows hold the special value that means no further level, just like the druid and the monk.

In practice the paladin is a fighter in name only, and a weaker one. Of the powers an AD&D paladin is usually described with, it has none: it can't lay on hands, turn undead, get a warhorse, cast spells, or shrug off disease. The fighter's perks, like exceptional strength, the constitution bonus and extra attacks, check for the fighter class by number, so the paladin doesn't get them either. It can't even fall from grace, because nothing in the game ever changes an alignment.

The ranger is even worse off. Every item records which classes may use it. 87 of the 128 item types allow the paladin; not one allows the ranger. We edited a character into a ranger in the emulator, took off the flail and tried to ready it again, and the game said "Wrong Class".

Staged in the emulator: Thrender Grone edited into a level 1 ranger, the flail no longer readied, WRONG CLASS

The adventure scripts still know about rangers. In more than twenty places, before a fight, a script asks whether there's a ranger in the party:

Pascal
while Member <> nil do
begin
  if (Member^.ClassCombo = 4) or (Member^.ClassCombo = 10) then
  begin
    Found := 1;
    Mark := 1;
  end;
  Member := Member^.Next;
end;

If there is one, the party is a little harder to surprise. Nobody playing the game as shipped could ever trigger it.

9. Alignment does nothing you'd notice

In first edition AD&D, as it's usually played, alignment is a big deal. It shapes who can become a paladin, which magic items can be used, and how your character is supposed to act. In Pool of Radiance it's one byte in the character record, set when you create the character, and nothing in the game can ever change it.

We searched the game engine and all 29 event scripts. The engine reads the byte in seven lines of code, and the scripts read it with four commands, in two of the scripts.2 Together they change five things:

  • character creation, where each class has its own list of alignments;
  • Protection from Evil and Protection from Good;
  • three magic swords locked to one alignment;
  • a blessing in a temple;
  • a vote before the final fight.
The engine's reads of the alignment, the script scan's four hits, and the five things they change

As the game codes it, Protection from Evil gives an evil attacker minus two to hit the protected character, and that character plus two on saving throws:

Pascal
if (SelectedCharacter^.Alignment = AlignLawfulEvil) or (SelectedCharacter^.Alignment = AlignNeutralEvil) or
   (SelectedCharacter^.Alignment = AlignChaoticEvil) then
begin
  Inc(SaveRoll, ProtectionShift);
  Dec(AttackRoll, ProtectionShift);
end;

But this runs while the attack is being set up, before the roll. Then the roll itself writes over the value:

Pascal
function RollToHit(Attacker, Target: PCharacter; Needed: Byte): Boolean;
...
  AttackRoll := RollDice(1, 20);

So, as far as we can tell from the code, only the plus two on saving throws does anything.3 We haven't tested it in play. Monsters do have an alignment, and 86 of the 172 monster records are evil. But the final boss, Tyranthraxus, is stored as lawful good, so Protection from Evil has no effect on him at all.

The tower's record, MON5CHA block 66: alignment 0, Lawful Good, and the name as the record itself misspells it, TYRANITHRAXUS (the game's dialogue says TYRANTHRAXUS)

The swords are a Long Sword +2 in the knight's tomb in Valhingen Graveyard, for lawful good characters only, and two Long Swords +3 behind the Bane altar in Valjevo Castle, for lawful evil characters only. Anyone else who readies one takes damage, 15 for the +2 and 5 for the +3s, and the sword won't ready. Random treasure can never make one.

The temple is the Temple of Bane in Valjevo Castle. Accept the priest's blessing and every member who isn't evil "doubles up in agony", for two ten-sided dice plus two, with no saving throw. Then the priest unmasks the party and the fight starts. An all-evil party simply gets blessed. The script looks the answer up in a nine-byte table indexed by alignment, which is also why our first disassembly of it lost its way.4

The Temple of Bane's script, re-synced: the table at A4E4, one byte per alignment, and the damage that follows

Finally, before the last fight, evil characters under computer control switch sides and join the boss on their own, except Genheeris, who the script names as an exception. Characters you control vote by menu, whatever their alignment.

That's the whole list. No experience penalty, no reactions, no shop, no healer's temple, no trainer that cares. For building a party, alignment is close to useless. Pick what you like.

8. Half a gold piece short

When a character has earned enough experience, you take them to a training hall to go up a level. In the rules, training costs your level times 1,500 gold pieces a week, for one to four weeks, with a tutor of your class.5 Pool of Radiance charges a flat 1,000 gold, and it's instant.

But the hall has a bug. To check the 1,000 gold, the game rounds your purse to the nearest gold piece, adding half a gold piece before it divides, so 999 gold and a single electrum piece counts as 1,000. Then it pays one kind of coin at a time, from copper up to platinum:6

Pascal
while Amount > 0 do
begin
  Coins := Amount div CoinCopperValues[Ord(Kind)] + 1;
  if Coins > Money[Ord(Kind)] then
    Coins := Money[Ord(Kind)];
  Dec(Amount, Coins * CoinCopperValues[Ord(Kind)]);
  Dec(Money[Ord(Kind)], Coins);
  Kind := Succ(Kind);

It takes the electrum and all 999 gold and is still 100 copper short, so it keeps going past platinum, into gems and jewelry, and reads their "coin values" from beyond the end of its five-entry table: the bytes of the word "Cleric" that happen to follow it, and then a zero.

We set up a purse like that in the emulator, with no gems or jewelry, and the game quit with "Runtime error 200 at 0078:4347." The training never happened.

Staged: Thrender Grone with 999 gold and 1 electrum is congratulated, then the emulator's DOS output reads Runtime error 200

With one piece of jewelry in that staged purse, the game took the jewel as if it were worth six and a half million copper and gave back the change: 6,514 platinum, 4 gold, 1 electrum, 5 silver and 8 copper. The fighter reached level two, and the weight of all those coins cut its movement from 6 to 3.

Staged, with one piece of jewelry: level 2, platinum 6,514, encumbrance 7,032, movement 3

7. Wood beats silver, and forty-four weapons

You'd think any holy symbol would ward off a vampire, but in Pool of Radiance it's not about whose symbol it is, it's about what it's made of. The general store in New Phlan sells a Wooden Holy Symbol of Tyr for 1 gold piece, an Iron Holy Symbol of Tempus, and a Silver Holy Symbol of Sune for 50.

In the code, when a vampire picks a target, it looks at that character's readied items for a holy symbol whose third name is Wooden, or a mirror of any kind. If it finds one, it can't attack that character at all:7

Pascal
if Item^.Readied then
  for NameIndex := 1 to 3 do
    if ((Item^.NameNum[NameIndex] = HolySymbolNameNum) and (Item^.NameNum[3] = WoodenNameNum)) or
      (Item^.NameNum[NameIndex] = MirrorNameNum) then
      HookVetoFlag := 1;

So the Silver Holy Symbol of Sune won't help you. Neither will the Woods Holy Symbol, worth 500 gold, that you can find in the Temple of Bane: Woods is a different word from Wooden.

The vampire's check beside the item names: the Wooden Holy Symbol of Tyr passes, the Woods Holy Symbol does not

The Monster Manual, as it's usually read, has a vampire keep its distance from a lawful good holy symbol, garlic or a mirror.8 There's no garlic in the game, and the game's vampire doesn't keep its distance: it can't attack you at all. By the code, a mirror also turns a medusa's or a basilisk's gaze back on the monster. We never got as far as a vampire or a medusa in the emulator, so this part is from the code only.

Now for the silver shop in New Phlan. Its most expensive item is the Fine Composite Long Bow, at 25,000 gold. Its item type is 45, which is the heavy crossbow's row in the item table, the same type as a heavy crossbow worth 20.9 Every weapon takes its damage, reach and shots from its type's row, so the bow has less reach than the 100 gold Composite Long Bow and no magic. Its one perk is that the row adds your Strength to hit and damage, which no ordinary bow does. And like every heavy crossbow in this game, it fires arrows.

The silver shop's bow and the Heavy Crossbow share item type 45; the Composite Long Bow reaches further

The shop also has Silver Plate Mail for 4,000 gold and Silver Chain Mail for 750. They are plain plate mail, worth 400, and plain chain mail, worth 75. The only places the code looks for the word silver are the weapon or arrow you strike with.

The good deal in that shop is the silver arrows, 20 for 20 gold. When you split a stack with Halve, both halves keep the whole stack's value, and a shop pays half the value for a single item.10 In a staged run in the emulator (the gold given and the party moved to the shop by hand), a stack of 10 sold for 5 gold, and a single arrow sold for 10. Do the sums for all twenty, and the 20 gold bundle sells for 200. Halve is only offered while a character carries fewer than 16 items, so it takes some juggling.

Staged: the 20 Silver Arrows halved down to one, and the shop's offer of 10 gold for it

And by the code, the best deal in the game might be the sling: 1 gold piece, one hand, a reach of 20 squares to the short bow's 15, and no ammunition needed. The attack chooser accepts its flags with nothing to fire:

Pascal
if (Aim <> nil) or (Flags = $A) then
  ChooseAttackItem := 1;

It's also the only launcher a thief can use.

Next door to the silver shop is the arms and armor shop, and its list has 44 kinds of weapon. Seventeen are polearms: the awl pike, bardiche, bec de corbin, bill-guisarme, fauchard, fauchard-fork, glaive, glaive-guisarme, guisarme, guisarme-voulge, halberd, lucern hammer, military fork, partisan, ranseur, spetum and voulge, all from the first edition Players Handbook. (The shop's data also holds a battle axe, but its list never shows it.)

Staged: the arms shop's list, page 1 of 3, with its polearms lit

The weapons table in the Players Handbook gives each weapon a weight, damage against small or medium foes and against large ones, a length, the space it needs, a speed factor, and a row of adjustments to hit against each armor class from 0 to 10. Footnotes add more: some polearms do double damage when set against a charge, some can pull a rider off a horse, and some, like the ranseur, can disarm.11 That's the reason there are so many of them: each one trades something for something else.

Pool of Radiance kept the names, the weights and the damage dice, and dropped the rest. The game's item table has, for each type, the hands it takes, the damage against normal and large foes, the number of attacks, the range, the classes that can use it, and some flags.12 There is no length, no speed and no armor table, and every polearm only reaches the square next to you, like a long sword.

Take the ranseur and the voulge. In the book they differ in space (1 foot against 2), speed factor (8 against 10) and most of their armor adjustments, and the ranseur can disarm. In the game, their two rows are identical, byte for byte. The voulge just weighs 125 to the ranseur's 50, and costs 2 gold to its 4.

So the choice comes down to the dice. On average damage, the 30 gold two-handed sword matches or beats all 17 polearms, against normal foes and large ones (the halberd ties it against normal foes). Seven polearms (bec de corbin, fauchard, fauchard-fork, military fork, glaive, partisan, awl pike) do no more on average than the one-handed long sword, which costs 15 gold, so with any of them you give up your shield for nothing.

Average damage against normal and large foes: the two-handed sword on top, seven polearms in red no better than a long sword

Two polearms are worse than they look. Every weapon's row has a flags byte, and the value 4 in it is what adds your Strength to hit and damage. The other 15 polearms have it. The bill-guisarme's flags are $01 and the guisarme-voulge's are $00:

Pascal
if (ItemTable[ItemType].Flags and WeaponFlagStrength) <> 0 then
begin
  Who^.HitAdjust := Who^.HitAdjust + StrengthAttackAdjustment(Who);
  Who^.WeaponDamageBonus[1] := Who^.WeaponDamageBonus[1] + StrengthDamageAdjustment(Who);
end;

With no weapon at all, the game adds your Strength anyway, so a strong fighter does better with bare hands than with either of these two. By the code, the value 1 makes the bill-guisarme add the magic bonus of the arrows you're carrying instead, which we didn't test.

We tried it in a staged run in the emulator (the gold given and the party moved to the shop door by hand): Bakshi, whose Strength is 18/90, bought the three guisarmes. With the guisarme readied his sheet shows THAC0 18 and damage 2d4+4. With the bill-guisarme or the guisarme-voulge, THAC0 20 and damage 2d4. With nothing readied, THAC0 18 and 1d2+4.

Staged: Bakshi's sheet with the bill-guisarme readied, THAC0 20 and damage 2d4

So, as a player: ready the cheap wooden symbol and a mirror, skip the 25,000 gold bow, split your stacks before you sell, and give your fighters a two-handed sword, or a long sword and a shield.

6. The goblin bribe

In the slums, I came across goblins, parleyed with them, and paid them 100 gold to leave. They left. Then my CoCo 3 build of the game crashed.

That one was our problem, and the most likely reason is kind of funny. Paying runs a script command that scales your money with a Pascal Real, a floating point number. It's the only floating point arithmetic in the entire game, and our CoCo port didn't support it yet.13

Pascal
Mode := OperandValue(1);
Percent := OperandValue(2);
Factor := (100 - Percent) / 100;
Chance := OperandValue(2);

But look at what the slums script actually does:14

Output
B39F PRINTCLR  'TYPE IN THE NUMBER OF GP YOU OFFER.'
B3BD INNUM     2, [6E81]
B3C3 CMP       [6E81], [9808]
B3CA IF>=
B3CB GOTO      [B40F]
B3CF PRINTCLR  "'WHAT A BUNCH OF CHEAPSKATES,' THE LEADER COMPLAINS. 'LET 'EM HAVE IT BOYS!'"
B40B GOTO      [B157]
B40F PRINTCLR  'THEY PAW THROUGH YOUR COINS AND LEAVE.'
B42F ROB       1, 50, 0

It asks how much you're offering and compares that with a number it worked out earlier from your party. Too little, and you get "What a bunch of cheapskates" and a fight. Enough, and they paw through your coins and leave. But then it never uses your number again. Instead it runs a command we call ROB, at 50 percent, on the whole party.

So every party member loses half of every kind of coin, regardless of what you typed in. Each item has a 50 in 100 chance of going too, until the robbers run into something heavy. From the first item heavier than 24 on, that item included, the chance is zero for the rest of that member's pack.

We played it through in the emulator, with nothing set by hand. Every member's silver went from 36 to 18 and their platinum from 2 to 1 (Phineas, who had 1, lost it). The 100 gold we typed was never used. One character lost a stack of 4 darts, and nothing after anyone's first heavy item went.

The bribe played through: every member's coins before and after, and how the pack rolls work (the pack's rolls are drawn as an example)

If you surrender instead, the same command runs at 100 percent.

5. Charm Person, and the boss nothing touches

Cast Charm Person on an orc and, unless it makes its saving throw, it fights on your side. Cast it on an ogre and the game says the ogre "is unaffected". We set both up in the emulator: the orc was charmed, and the ogre was unaffected.

Before the saving throw, the spell checks two things: the target must be human or humanoid, and it must fill one square on the combat map.15

Pascal
if (Target^.CreatureType > CharmableType) or (Target^.CombatSize > CharmableSize) then
  ShowCharacterMessage(Target, 'is unaffected', MessageColor, TimedMessage)

The ogre takes up more than one square. But the Ogre Leader is stored as type 0, size 1, so, on paper, you can charm the boss but not his followers. Across the game's monster files there are 103 monster names, and 59 of them pass this check in every record. The one Bugbear record is refused, because its size byte has its top bit set and the spell compares the whole byte.

The two records: OGRE (type 1, size 2) unaffected, OGRE LEADER (type 0, size 1) can be charmed

The first edition Player's Handbook lists gnolls among the creatures you can charm. The game refuses them, because they take up two squares. And in the book a charm wears off: the victim gets a new saving throw at intervals set by its intelligence, from every three months for the dimmest to every day for the brightest.16 In the game the charm's duration in the spell table is zero, and the clock skips anything with a duration of zero, so it never ends by time. As far as we can tell, it lasts until something removes it, such as Dispel Magic, or death.

The book's rule, paraphrased, beside the game's refusal of the gnoll and the spell's zero duration

Then there's the final boss. The Tyranthraxus you fight in the tower is the huge record, type 3 and size 4, so Charm Person won't work on him. Neither will much else. His record has a fifteen percent chance to cancel a spell, and the code lowers that chance by five points for each level the caster is below eleven. But it stores the result in a single byte:17

Pascal
Level := SpellCasterLevel(CastingSpell);
Threshold := Chance - 5 * (11 - Level);
if (HookAffectId = 0) and ((DamageKind and KindMagic) = 0) then
  Exit;
if RollDice(1, 100) <= Threshold then
  CancelPendingHook(0);

For any caster below level eight the result goes below zero and wraps around, from 221 at level one to 246 at level six, against a roll of one to a hundred. Your party's casters stop at level six, and scrolls of their spells are cast at level six too. So by the code, Magic Missile, Fireball, and any spell they cast that lays an effect on him should fail every time. Items that cast a spell of their own, like the Wand of Magic Missiles, count as level twelve, where the roll cancels them one time in five. Your weapons still work. We haven't tested that one in play.

RollMagicResistance and the worked table for caster levels 1 to 6: -35 to -10, stored as 221 to 246

4. The cave that is four caves

If you walk around the mountain wilderness for long enough, about one step in 420, you'll find a small dark cave, and the game asks whether you'll enter.

The second time you go in, you may not recognise it as the same cave. It's one map with four separate lairs: wild boars, an ankheg, thri-kreen and giant snakes. The script drops you into one of the four at random, one chance in four each, so it's four caves in one. And the fights reset every time you go in, so the lairs are always full again.

The cave's map, one map with four lairs, beside the view inside one of the four arrival cells (staged: the party set in the cave's square)

The map is drawn from our reading of the area's script, so it's as good as that reading.18

3. The jewelry that vanished

In the last article, I appraised some jewelry worth over 7,000 gold. I didn't want to sell it yet, but later it was gone. Here's why.

The appraise routine takes the jewel out of your purse as soon as you pick it, before you decide anything. Then it offers Sell or Keep. Only the K key keeps it; by the code, any other key sells it, Escape and Enter included. And Keep isn't even offered if you're too loaded to carry one more item.19

A sale pays the full value in platinum. If you can't carry the coins, the game says "Money will be put in Pool." When you leave, the shop asks whether you want to go back and get your money. If you say no, the next shop or temple you enter wipes the pool as you walk in. That's most likely where my 7,000 gold went.

We set it up in the emulator, giving a character a piece of jewelry first. An overloaded sale paid 1,579 platinum: the character carried 1,462, 117 went to the pool, and walking back into the shop left the pool at zero.

Staged, a jewel given first: the overloaded sale in the emulator, 1,579 platinum, 1,462 carried, 117 into the pool

There's a smaller bug in the same routine. If the character carries no items at all and keeps a gem, the new item ends up only in a local variable instead of reaching the character:

Pascal
Last := SelectedCharacter^.Items;
if Last = nil then
  Last := NewItem

So it's lost. We set it up in the emulator, with a gem given and the item list emptied by hand: the gem left the purse, and the item list stayed empty.

Three tips, then:

  • take the pool before you leave a shop;
  • appraise with a light character who carries at least one item;
  • sell straight from Appraise, since a gem you keep sells later for only half its value.

2. STING

Remember the gods from the start? Here's the word. Start the game with START STING and you skip the title screens and the code wheel. The copy protection is gone, with one word. It's right there in the main program, the second line:20

Pascal
begin
  StartGame;
  if ParamStr(1) <> 'STING' then
  begin
    ShowTitleScreen;
    CheckCodeWheel;
START STING: the DOS prompt (drawn for the video) and, in the emulator, the game loading with the title screens and the code wheel skipped

STING also turns on the developers' keys. From the character menu, press J, and the game answers "I Understand, master...". From then on, you can train for free, at any hall, whether or not you have the experience. In the emulator, a new level one fighter with 100 gold and no experience trained to level two and still had the 100 gold afterwards. Without STING, the same character isn't even offered Train.

Free training under STING: a new fighter trains to level 2 with no experience, and keeps the 100 gold

In combat, Alt-X calls the gods, and every monster on the field dies. Ctrl-D switches on a debug mode we haven't fully figured out. And even without STING, Alt-X in combat answers "That doesn't work." I don't know whether anyone outside SSI knew about STING back then, but it's certainly in the code.

1. The darts freeze

I was playing on my real Tandy 1000 EX, in a battle, and I hit Quick for my magic-user so the computer would take her turn. The game froze. The panel on the right kept redrawing, about three times a second, and nothing else happened. I had to restart the machine, and I couldn't make it happen again.

The phone video from the Tandy 1000 EX: SVENGALI, HITPOINTS 6, AC 2, 25 DARTS, the panel redrawing

I sent the phone video to Claude and asked whether this was a bug in the original. It was, and the video, plus the code, was enough to work out the path the game took. On a Quick turn, the computer looks at your readied weapon. If it can only be thrown, and an enemy is right next to you, it asks for a melee weapon instead and hands the turn back to try again:21

Pascal
if IsRangedWeapon(Who) then
  if not RangedWeaponCanMelee(Who) then
    if CollectEnemiesInRange(Who, 1) > 0 then
    begin
      UseBestItem(Who);
      Done := 1;
      goto Attack;
    end;

However, darts are flagged in the item table in a way that lets the weapon chooser count them as a melee pick. So if there's nothing better than darts, it picks them again. Nothing has changed, the panel is redrawn, and the turn comes back to the same spot.

There's a safety limit of 20 passes, but its counter starts again from zero every time the turn is handed back. And nothing in the loop that hands it back reads the keyboard:

Pascal
while Done = 0 do
begin
  if ChooseCombatTarget(Who, $FF, 1, 0) and (Who^.Combat^.Initiative > 0) then
    Done := AiTurn(Who)
  else
    Done := EndOrGuardTurn(Who);
end;

So it never ends. It takes three things at once: darts and nothing better, an enemy next to you, and the target the computer remembers out of reach. That's probably why I couldn't repeat it.

The loop: QuickTurn calls AiTurn, AiTurn's pass counter goes back to 0 on every call, the limit of 20 is never reached

Our first tries in the emulator didn't hang, because the recorded fight never took that path. So we forced it: we gave the first four characters darts and cleared their remembered target. The trace showed the same two routines taking turns, with no key read, until we stopped it after 301 passes, just like on the Tandy.

The fix has two parts. If darts are still readied after the swap, the character throws them. And after 50 passes, the turn just ends; a normal turn takes one or two. Here's the second part:22

Output
+  Passes := 0;
   while Done = 0 do
   begin
-    if ChooseCombatTarget(Who, $FF, 1, 0) and (Who^.Combat^.Initiative > 0) then
+    Inc(Passes);
+    if Passes > QuickTurnPassLimit then
+      Done := EndOrGuardTurn(Who)
+    else if ChooseCombatTarget(Who, $FF, 1, 0) and (Who^.Combat^.Initiative > 0) then
       Done := AiTurn(Who)

The fix lives in its own fixes folder, which every port applies to a copy of the source. The source itself stays the original, bugs and all, and still byte-identical.

src/ stays the original; fixes/ is applied to a copy for the DOS port, the C translation and the CoCo 3

So if you ever see a magic-user on Quick throw darts at someone standing right next to her, that's the fix doing its job.

Staged, on our build of the source plus the fixes, in the emulator: Darkstar moved to the front, on Quick, next to a kobold, throws darts instead of hanging

What it means, and what's next

For decades, nobody could see why these happened: bad luck, a curse, a cranky training hall. Now they're code you can read. And that code turns out to be a careful reading of the AD&D rules, with a few slips you can now point your finger at.

These questions came from playing the CoCo 3 port, and that's next: how we got a 1988 PC game running on a 1986 Tandy Color Computer 3. After that comes a whole series on how the engine works, with more quirks in every episode. And if you want to go looking for the next one yourself, the source, the fixes folder and the map tools are all in the repository.

Notes and sources

  1. ClassNames, src/POOLVARS.PAS line 1136; the race menu RaceClassChoices (line 2852) offers neither class; the item class bits ClassItemBits (line 939). The ranger check is CheckPartyHasRangerCommand, src/OVL03.PAS, lines 1124 to 1148. ↩︎

  2. grep -n "\.Alignment" src/*.PAS lists the engine's reads; the scripts read it only through the script variable $6BD8 (GetCharacterVar, src/OVL07.PAS line 394), and nothing writes it after creation (SetCharacterVar has no case for it). The script scan followed the control flow of every block of the eight ECL files, with a scanner built on tools/maps/ecldis.py (whose straight-line listing loses its way on data) plus a raw search of the bytes; the scanner is a research note, not in the repository. ↩︎

  3. ShiftAttackToSaveVsEvil, src/OVL12.PAS lines 485 to 492, runs in the attack set-up hooks (kind $B, src/OVL24.PAS lines 267 to 275, called at src/OVL13.PAS line 850); RollToHit rolls afresh at src/OVL24.PAS line 414, and the hooks it runs after the roll (kinds $A and $10) do not include the protection affects. The saving throw hooks (kind $C) do. ↩︎

  4. ECL5 block 6, from A4ED: the nine bytes at A4E4 are 1 for every alignment except the three evil ones; GETTABLE [A4E4], [6BD8] at A545, then DAMAGE 160, 2, 10, 2 at A579. ↩︎

  5. The Dungeon Masters Guide, p. 86, as summarised by Methods and Madness, AD&D DMG cover to cover, pages 84 to 100, and Murphy's Victim, Training in AD&D. ↩︎

  6. CharacterMoneyValueInGold, src/OVL19.PAS line 1221; PayGold, src/OVL16.PAS lines 2130 to 2160; the coin table CoinCopperValues, src/POOLVARS.PAS line 1132, is followed in memory by the class names. ↩︎

  7. VetoTargetWithMirrorOrWoodenHolySymbol, src/OVL12.PAS, line 2216; the mirror against a gaze is GazeStonesTarget (line 1499). ↩︎

  8. Secondary summaries of the Monster Manual's vampire entry, for example Vile Monsters, Vampire. ↩︎

  9. The item rows come from the ITEMS file (python3 tools/re/items.py dump poolrad/ITEMS, with tools/re/items.py); damage, reach and shots are read from the type's row (ApplyWeaponBonuses, src/RES12.PAS line 274). ↩︎

  10. HalveItem, src/OVL19.PAS lines 657 to 668, copies the whole record; SellItem, lines 838 to 844, pays half the value, and for a stack the count times that divided by 20. The sling's line is ChooseAttackItem, src/RES12.PAS line 1808. ↩︎

  11. The Players Handbook weapons table and its footnotes, as reproduced by 1eonline.info. ↩︎

  12. The ITEMS rows (python3 tools/re/items.py dump poolrad/ITEMS) and the arms shop's records (ITEM3.DAX block 53); the row layout is TItemRow, src/POOLVARS.PAS line 558. Strength is added by ApplyWeaponBonuses, src/RES12.PAS lines 285 to 289, and for an empty hand by RecalcCombatValues, lines 721 to 725. ↩︎

  13. LoseMoneyAndItemsCommand, src/OVL03.PAS, line 1432; grep -n ": Real" src/*.PAS gives three lines, this one and the two of ScaleMoney in src/OVL07.PAS. Item loss is LoseItems, src/OVL07.PAS lines 1000 to 1027. ↩︎

  14. python3 tools/maps/ecldis.py ECL2 20, with tools/maps/ecldis.py. ROB is ECL command 40, the routine above. Surrender is ROB 1, 100, 100 at B479. ↩︎

  15. CastCharmPerson, src/OVL22.PAS, line 702. The monster counts come from reading every record of the eight MON*CHA.DAX files with tools/re/dax.py. The zero-duration rule is in src/OVL20.PAS at line 162. ↩︎

  16. The Player's Handbook, pp. 55 to 56 and 65, as summarised by Delta's D&D Hotspot, Spells through the ages: Charm Person. ↩︎

  17. RollMagicResistance, src/OVL12.PAS lines 1924 to 1935, called with 15 by the affect on the tower's record (MON5SPC block 66); SpellCasterLevel, src/RES12.PAS lines 1550 to 1559, gives 6 to an item casting a cleric or magic-user spell, and 12 to the item-only spells (spell class 2, such as the Wand of Magic Missiles). ↩︎

  18. tools/maps/areas/wilderness_cave.py, read from GEO6 and ECL6 block 25. ↩︎

  19. AppraiseGems, src/OVL21.PAS, line 762: the purse is debited at line 821, Keep is if (Key = 'K') and not MustSell at line 845, the lost gem is lines 858 to 860. The pool is wiped by FillChar(PooledMoney, SizeOf(PooledMoney), 0) in src/OVL06.PAS (line 200) and src/OVL04.PAS (line 465); a shop buys items at half value in src/OVL19.PAS, line 808. ↩︎

  20. src/POOL.PAS, line 59. The J key is src/OVL16.PAS lines 305 to 309, Alt-X is GodsIntervene in src/OVL13.PAS (line 2102), "That doesn't work" is src/OVL08.PAS lines 257 to 263, and Ctrl-D is src/RES04.PAS lines 69 to 72. ↩︎

  21. AiTurn, src/OVL09.PAS, lines 586 to 592; QuickTurn's loop is lines 112 to 118, AiTurnLimit = 20 is line 36 and its counter is reset at line 524. Darts are row 9 of the ITEMS table, with flags $10 and no attack flag (python3 tools/re/items.py dump poolrad/ITEMS). ↩︎

  22. fixes/quick-combat-hang.patch and fixes/README.md. ↩︎

Related