tetracorp / dungeons-of-avalon

Exploring the Dungeons of Avalon; an analysis of a 1991 Commodore Amiga game.
https://tetracorp.github.io/dungeons-of-avalon
5 stars 0 forks source link

Stat contribution to AC and WC. #1

Closed abilena closed 1 year ago

abilena commented 4 years ago

Hi!

Great job on the decompilation!

I always thought that there was a door in the Tower of Roa (DOA2) which needed the NPC thief to unlock which got you stuck if you did not know how to add the NPC to your group. I'll verify that one.

It seems that the Armour Class value is based on Math.floor((Luck + Character Level) / 32) plus Item bonuses. Accordingly the Weapon Class value seems to be based on Math.floor(Strength / 16) plus Item bonuses. (I am unsure whether the Character Level is added to this value too). If you're interested I can provide a List of all Items with AC/WC bonuses.

Since HP and MP seem to be individual stats which are not based on IQ, DX, WI, LU, ST and KO I wonder if you found any references in the code that could hint to what they are used for anyway. (Luck seems to add to Armor and Strength to Attack Chance, but apart from that?).

Regards, Abilena

tetracorp commented 4 years ago

I believe I can confirm your observation about the NPC thief.

There is a unique door on level 2 which appears just as you come up a set of stairs from level 1. It has a value of 0x1c (28), which isn't used for any other door in the game. At first I assumed it was some special item or condition, but I couldn't find any special handling code. This means it's literally a door which requires a level 28 thief to lockpick, which should be impossible as the game has a level cap.

However, the NPCs Flint and Rahven are level 32. You can't see NPC stats, but I checked their stats in memory. As Rahven is a thief, this makes him the only character who can pick that lock and open that door.

(If you're interested, Flint is a human pirate (NPC-only class) with 168 HP, all stats at 160, with a WC/AC of 14 and 16, and carries Ara's Armour, Metal Shield, Bee-Ring, Battle Helmet, and Arc's Sword. Rahven is an elf thief with 96 HP, all stats at 160, a WC/WC of 12 and 14, and carries Armour, Buckler, Bee-Ring, Sefer's Helmet, and Bolas.)

I've made some findings regarding stats, which appear in comments around line 3,472 or address ;02e82 onward in the source.

As far as I can tell, a minimum amount of ST or DX is required to wield certain items. However, every item in the game has zero for its ST/DX prerequisites. I haven't found any other use for DX, so it's possible this stat does nothing.

The values displayed for AC and WC seem to be reversed from their obvious meanings, so that AC is attack, and WC is defense. You can see this by unequipping a weapon and watching AC decrease. The German name for AC is Angriffstärke, "attack strength". Internally, the stat shown as AC is byte 64, and WC is byte 65.

Therefore it's AC (perhaps "attack class") which is ((((KO + Level)/16) + ST)/16)+???, where ??? is probably item bonuses. (I incorrectly state in a comment that RS is added, but that's wrong.) You're basically adding one-sixteenth of your Strength and 1/256 of your KO and level, which is bizarre numbers considering that you'd need level 16 and 240 KO just to get one point out of that. Of course, using integer logical shift right instructions, all divisions are floored, as you note.

WC (perhaps we should call this "worn class") is ((LU + Level)/32)+???, where again ??? is probably item bonuses. There's also a certain status effect (bit 4) which reduces WC by two. My notes here suggest this is caused by a "banshee" trap; three appear in DoA1's first dungeon, and none appear in DoA2.

ST and DX appear to serve to meet prerequisites for certain items, such as weapons. However, the requirements for all items in the game is zero. As far as I have discovered, this means DX does nothing.

WI is supposedly necessary to gain a new spell level, but it's acutally limited by caster level (see around line 4,904 or address ;0413a). You gain access to a new level of spells every 2 character levels after the first, just like AD&D (i.e. 1, 3, 5, 7, 9, 11, 13, 15 and 17), which is probably why the game caps at level 16; at level 17 you would gain ninth level spells, and they didn't add any of those to the game. It's possible WI does nothing at all.