No posts here the last 3 years, so I want to open again this topic.
It's because I woundering why the 'character change to hit' sould be a comparison of the armor classes.
I already disassembled, or better investigated, this part of the code in the 80s. But since my notices were lost
over the years, I did it again. And it was a lot of fun
.
Unfortunately the 'character-chance-to-hit' code is very long with many subs. Therefore I will just mention the addresses. But the code can be found on your C64
.
start: $58D1
1. load AC of monster from table $7DA8 (only the 5 right bits) in ZP (zero page) $4A
(example: AC 7 => 03h =>$4A; AC L0 => 14h => $4A)
2. check if weapon with a bonus is equiped (jsr $5A6E); the weapon bonus can be found in table $A377 (MSB); if yes, e.g. mthr sword (+1), subtract the weapon bonus from $4A and store the result in $4A
(example: AC 7 => 02h; AC L0 => 13h)
3. substract class bonus (located in table $82B5 + class index) from $4A and store the result in $4A
(example: warrior with class bonus 2; AC 7 => 00h; AC L0 => 11h)
4. substract party bonus, which is stored in ZP $40, from $4A and store the result in $4A
(example: bard song 2 => group bonus +1; AC 7 => 00h; AC L0 => 0Ah)
5. add party malus (stored in ZP $DF) to $4A and store the resut in $4A
(example: not tested yet; maybe if party is affected by the spells FRFO, FEAR or CURS)
6. check if AC of monster ($4A) > 15h; if yes, set it to 15h; if not => next step
7. store this value in ZP $3B
(example: AC 7 => 00h; AC L0 => 0Ah)
8. create a random number by using jsr $18CE twice and add 03h to this random number; result is between 3 and 17 (decimal).
(example: 09h)
9. add character bonus (stored in table $82FA + character no) to the random number
(example: character is affected by BASK, which adds 04h; 09h + 04h => 0Dh)
10. compare this value (0Dh) with the AC of the monster; in our example, both, AC 7 (00h) and AC L0 (0Ah) are lower than 0Dh => hit; without BASK => 09h => only AC 7 is a hit and AC L0 is missed.
Just a short summary:
hit: if monster AC - item bonus - class bonus - group bonus + group malus < random no (3-17 dec) + character bonus
It's very interesting that there is no level bonus for the 'chance to hit'.