jtauber / u4a2

disassembly, analysis, and commentary on the code for Ultima IV for the Apple ][
https://u4a2.com
9 stars 1 forks source link

Hit Chance #1

Open Fenyx4 opened 3 years ago

Fenyx4 commented 3 years ago

I've been working on a mod using the decompiled DOS version of U4 and I'm vert curious if how it computes hit chance in the dos version is a bug.

In the DOS version as dex goes from 0-39 it starts at ~50% and goes to ~65% and then when it hits 40 it jumps to 100%. This feels weird to me. As each point of dex isn't making a noticeable change and then BAM you hit every time.

I was wondering if you had insight into how this worked in the Apple version.

Thanks!

Fenyx4 commented 3 years ago

Hiya. Just wanted to let you know that someone helped me out on this. I would still love a second opinion but it isn't as urgent as it was.

sean-gugler commented 3 years ago

@Fenyx4 Both Apple II and Commodore 64 editions calculate the player's chance to hit a foe as (DEX * 2 + 128) / 255. There is no way to reach 100% even though there is code logic to treat 8-bit overflow as 100% chance, because that happens at DEX >= 64 but game rules limit DEX to 50 maximum.

Enemy chance to hit a player is simply Armour / 255, according to a look-up table for armour type ($60, $80, $90, $a0, $b0, $c0, $d0, $f8).

@jtauber I've done extensive analysis of the C64 version over the past six months. I was about to embark on porting all the known C64 fixes to Apple II, when I discovered your efforts here. You both might be very interested in the "documented" branch in my fork. In particular, the following files can tell you lots more about the hidden rules and data tables of the game.

u4remastered\src\patchedgame\main.s
u4remastered\src\regenerator\15b.disasm
u4remastered\Ultima IV internals.txt

Though of course, if you're having fun figuring it out for yourself, by all means enjoy the journey! I sure did.

Major props to MagerValp for documenting so much before me, and to the Regenerator tool which has been invaluable for reconstructing assembly from both C64 and A2 binary programs.

Fenyx4 commented 3 years ago

Thank you @sean-gugler ! Great to have confirmation on that. I did end up adding an option to give the DOS version the Apple II/C64 hit chance logic.

It would be awesome to get an Apple II version with all the Remastered fixes! I just listed out all the fixes I've got in the Randomizer; https://github.com/Fenyx4/U4DosRandomizer/blob/master/FIXES.md

It'd be awesome to get everyone working on Ultima 4 together and chat. Do you use Discord? Or maybe we could spin up a GitHub repo just for U4 modders and use discussions.

sean-gugler commented 3 years ago

@Fenyx4 I'm brand new to Discord, just joined for a private event a couple weeks ago. Ping me if a venue for general discussion gets spun up; I'm not hard to find on gmail. Cheers!

cambragol commented 3 years ago

I must second how awesome a Remastered Apple II version would be. That's the only version for me! (Though C64 and Dos version get very respectful nods.)

jtauber commented 3 years ago

I'm not a huge Discord user but I'm totally up for joining an Ultima Hacking server if someone sets it up!

cambragol commented 3 years ago

Never used Discord, but a Github repo with Discussions sounds easy enough.

sean-gugler commented 3 years ago

@Fenyx4 @cambragol I've just published a Remastered edition for Apple II. All issues I'm aware of have been fixed. https://github.com/sean-gugler/u4remasteredA2/releases/

Coming soon:

cambragol commented 3 years ago

Wow! This is amazing news! The holiest of holy Ultima IVs has just become...holier!

Downloading and testing out now.