News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Poll

Patching Mysidian Tower Orbs Behavior: http://www.romhacking.net/forum/index.php?topic=29704.msg388989#msg388989

Leave it, flawed as it is; the remakes retained this behavior after all
3 (13.6%)
Keep the random single-character bonus, but remove the 4th character from the RNG
4 (18.2%)
Grant the bonus to all characters, giving them a much-earned buff at this point in the game.
15 (68.2%)

Total Members Voted: 22

Author Topic: Final Fantasy II Restored  (Read 54870 times)

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #280 on: March 25, 2020, 09:03:47 am »
What, other than Wall, have you tested so far that we can cross it off our bug list?
At this point I think I've got everything except Tsunami and friends tested. I'll update the patch once I've got those tested. I was having second thoughts about whether the current behaviour of Haste/Slow was really a bug or not, but I think I'm going to stick with 0 net successes not negating the opposing spell's effect. I also noticed a few more bugs:
  • Casting Basuna on a target with only the Critical HP ailment results in displaying the message for Fear. (This is a consequence of the other bug where Basuna mistakenly clears the Critical HP flag.)
  • If Esuna/Basuna fail to clear the highest present ailment, they display the Ineffective message even if they did clear other ailments.
  • Sap does not reduce target's MP with 0 successes but still displays its success message.
It's not exactly a bug, but I also converted the code for displaying the message for the highest-cured Ailment into a loop, so Esuna/Basuna now display messages for each Ailment they cured.

Should I revert the reversal of messages for Dispel and Barrier on my ChaosRush translation, then, if you've fixed the code to make it play nice with current translations?
Yup, there's no need to re-order the strings anymore, so those can be reverted. While you're there, though, Chaos Rush's battle message for curing Amnesia is just "Cured of", which is not particularly helpful. Maybe we could use something like "Memory returned" instead?

It also occurs to me that while the actual behavior of Ultima in remakes is still an enigma, there's some fairly easy math that could be used to make the final spell fairly balanced. 1 point of guaranteed damage per level in a skill. Consider 16 spells (Ultima included) and 8 weapon types, all with 16 levels. That's 24 x 16 = 384. Make the base damage of Ultima something like 100 (or 116 for the sake of nice round numbers), and you end up with 500 damage per hit, with 16 hits on a Level 16 Ultima giving ~8000 damage. Might be an easier scaling spell that way rather than having it do obscene damage and then forcing a 9999 cap.
On the other hand, unless you've hacked your skill levels, massively abused the target/cancel bug, or spent probably hundreds of hours grinding, how high are your endgame skill levels realistically going to be?

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #281 on: March 25, 2020, 12:09:31 pm »
Updated first post, will try to help with testing everything in the spell package when work settles down, and I will try to fix the Amnesia message in the Chaos translation.

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #282 on: March 25, 2020, 08:16:09 pm »
Taking a closer look at Cyclone/Quake/Tsunami, it's a little hard to tell what the intended behaviour actually was. The original code
  • calculates the number of hits as spell level + successes
  • tries (but fails) to set the number of hits to 0 if the target is a member of a family included in the spell's data byte 3
  • calculates the target's number of resist successes (but does nothing with them)
  • calculates damage based on number of hits and spell power
  • doubles the damage if the target is a member of a family included in the spell's data byte 4
  • inflicts the damage
Since the spell's data byte 4 pretty obviously means families that are weak to the spell, I'm assuming byte 3 should mean families that resist the spell, but more on that in a moment. This code is unusual in that the target appears to be intended to resist the total number of hits, not just the successes, suggesting that full resistance should result in 0 hits, which logically and in agreement with physical attacks ought to mean a miss or 0 damage. However, because of the way the damage calculation loop works (LDY $hits/calculate damage for current hit and add to total damage/DEY/BNE @loop), calling it with 0 hits calculates 256 hits, resulting in extremely high (as in 2000 per target) damage, which is pretty much the opposite of what resistance should mean :P. On the other hand, only monsters have families and the party's only access to these spells is via 2 breakable items, so maybe being strong against some families and OP against others isn't a mistake? It would possibly make Earth Drums and Wind Flutes worth their inventory space.

So, we've got some choices here:
  • we can leave these spells with their current unresistable behaviour
  • we can let resistance work against the total number of hits instead of just successes, but fix it so that 0 hits gives full immunity (probably with the Ineffective message, but 0 damage would work too) instead of OP damage
  • as above for normal spell resistance, but make the spell's data byte 3 mean OP damage against the corresponding family
In any case, families included in the spell's data byte 4 should still take double damage.

Thoughts?

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #283 on: March 25, 2020, 08:22:11 pm »
I can try to test them out in Anniversary. Quake comes from Gaia Drum, Cyclone comes from Wind Flute, and what gives Tsunami? Also, what families should resist what?

I'd like to try and make them behave as close to intended behavior as possible. The second one sounds like the most in-line with what the code was trying to do, just from how you've explained it.

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #284 on: March 25, 2020, 09:52:53 pm »
I can try to test them out in Anniversary. Quake comes from Gaia Drum, Cyclone comes from Wind Flute, and what gives Tsunami? Also, what families should resist what?
Wind Flute casts Cyclone 13, Earth Drum casts Quake 10, and the party has no access to Tsunami (except if you can confuse a monster that casts it, I guess).

Cyclone deals double damage to Magic Beast and ??? damage to Earth;
Quake deals double damage to Earth and ??? damage to Magic Beast;
Tsunami deals double damage to Aquatic and ??? damage to Magic Beast.

I'd like to try and make them behave as close to intended behavior as possible. The second one sounds like the most in-line with what the code was trying to do, just from how you've explained it.
Yeah, probably, although of the three options, the first one seems like the most in-line with the rest of the game. There is code for calculating unresistable amounts, but it's only used by healing spells, not attack spells. This would be the only set of spells where resist attempts are able to reduce hits from the spell level. No other damage spell is able to miss or inflict 0 damage, and 256 hits is just plain ridiculous. So, they're weird any way. They're also fairly uncommon, so it probably doesn't matter too much which way they're adjusted.

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #285 on: March 25, 2020, 09:55:59 pm »
I'll play around with it in Anniversary and get back to you.

EDIT: So I've noticed that "Magic Beasts" sometimes seem to be synonymous with "Flying" types. So Hornets and Queen Bees are considered whatever this family is. Quake 10 missed on all 5 of them in a group, while doing massive damage to Leg Eaters and Vampire Thorns, who are considered Earth. I will assume this to mean that Quake should be completely null against Flying/Magic Beasts/whatever that bit is on monster family. I will continue testing on the same enemy formation with Cyclone this time, but it seems clear to me that the behavior as intended is the ??? should be immunity. And indeed, Wind Flute missed 7 Leg Eaters / Vampire Thorns.

I think that settles it in terms of how we should fix it. Also, I really apologize that my contributions have slowed down. I feel guilty that it seems like you've tackled this huge part of the project while I'm trying to find time. The current crisis has complicated work, but I'm doing my best to clear my table, so to speak, so I can focus on this project once more. This project wouldn't even be possible without your awesome contributions, abw. :thumbsup:
« Last Edit: March 25, 2020, 10:21:13 pm by redmagejoe »

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #286 on: March 26, 2020, 08:04:29 am »
So I've noticed that "Magic Beasts" sometimes seem to be synonymous with "Flying" types.
Yeah, I noticed that too, but it includes a decent number of non-fliers and some things that are also Earth family, so I wasn't quite sure what to make of it.

I think that settles it in terms of how we should fix it.
Okay, spell data byte 3 now grants immunity to the corresponding family. For non-immune families, I've made the number of hits be calculated the same as other non-elemental damage spells, i.e. spell level + resistable successes, and have kept double damage to the families in spell data byte 4. I've uploaded the latest files; the spell fixes currently weigh in at 81 bytes shorter than the original!

Also, I really apologize that my contributions have slowed down. I feel guilty that it seems like you've tackled this huge part of the project while I'm trying to find time. The current crisis has complicated work, but I'm doing my best to clear my table, so to speak, so I can focus on this project once more. This project wouldn't even be possible without your awesome contributions, abw. :thumbsup:
No worries - I've actually got more free time now that I don't have to commute back and forth every day, so that helps ;). I was already familiar with the spell code thanks to going through and documenting it, so the testing has actually taken longer than the coding :P.

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #287 on: March 26, 2020, 12:06:47 pm »
Quote
Bug Fix To-Do List:
  • WIP Life only writes the low byte of HP to be restored on success, which may result in leaving the target dead due to 16-bit math error.
  • WIP Sap only acts on the least significant byte rather than the whole of a target's MP. Investigate and correct.
  • WIP Osmose drains MP even if the target has none. Needs to check source MP before awarding it.
  • WIP Protect and Berserk bonus may overflow before being added to Defense or Attack, resulting in low or no effect.
  • WIP Wall can be exploited by casting it on monsters to ensure that Toad, Break, Death, and Warp work on them. Wall's effects should likely be checked before any routines handling animation or other effects take place. Investigate.
  • WIP Cyclone/Quake/Tsunami should be resisted by certain monster families, but the branching code checks the wrong processor flag (C instead of Z), which means family resistance is broken but that bug is cancelled out by another bug where after calculating the target's number of successful resists, the result is never used, which means resistance for these spells is just totally broken.
  • WIP Imbibe decreases the target's evasion % by 1, but there is no check for underflow, so you could end up going from 0 to 255 % evasion; having 255 evasion probably breaks other logic elsewhere.
  • WIP Basuna always clears the Critical HP flag
  • WIP Basuna always cures Poison, even with 0 successes
  • WIP Slow and Fear are slightly too powerful, only failing with negative net successes instead of also failing with 0 net successes
  • WIP Fear calculates spell power * net successes, but does not check the high byte of the product
  • WIP Status-curing items don't set the variable containing the target's previous ailments when calling the code for determining which battle message to display, resulting in an incorrect message being displayed (e.g. if you suffer from both Amnesia and Curse, curing Curse in battle with a Cross will display the message for curing Amnesia.

I'm assuming that these are all good to go and mark off our list?

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #288 on: March 26, 2020, 07:02:02 pm »
I'm assuming that these are all good to go and mark off our list?
Yes indeed, and these ones too:
  • WIP Casting Basuna on a target with only the Critical HP ailment results in displaying the message for Fear. (This is a consequence of the other bug where Basuna mistakenly clears the Critical HP flag.)
  • WIP If Esuna/Basuna fail to clear the highest present ailment, they display the Ineffective message even if they did clear other ailments.
  • WIP Sap does not reduce target's MP with 0 successes but still displays its success message.

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #289 on: March 26, 2020, 07:13:58 pm »
It's so amazing to see the list trimmed down so much. I grew anxious when the list started growing that it would only grow faster than it shrunk. I can't wait to get the beta patch distributed for playtesting before long. Do you think once we've finished all the bug fixes (which will be a separate patch made first and asked to have playtesting done on it), and need to start making space for enhancements, it would be of benefit to make a new disASM of that version? Just trying to think down the road, but I should probably try to focus on what's right in front of us.

EDIT: Did some quick testing and found a crash that results from, after some narrowing down work, pairing the Spell Handlers Rewrite with the Weapons Effect Fix. It only seems to occur when I have Maria cast Berserk. I'm assuming this is due to the fact that the Weapons Effect fix addresses Berserk (Yoichi's Bow), but it's using the pre-rewrite pointers? If my speculation is correct, I'm sure that Drain's new address will need to be taken into consideration as well, since I believe those were the only 2 spell handlers from weapons that were touched.
« Last Edit: March 26, 2020, 07:26:05 pm by redmagejoe »

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #290 on: March 26, 2020, 10:00:38 pm »
Presumably that'll be caused by the call to $BF9A in the weapon special effects patch, since $BF9A is now a bunch of 00 in the spell handlers rewrite patch :P. Since I've got the ASM files for both patches, gluing them together is easy (another reason why coding in text files is better than direct hex editing!); I only ran a quick test, but this ought to fix the problem.

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #291 on: March 26, 2020, 10:03:37 pm »
Awesome. Is this a rewritten Weapons Effects + Spell Handlers Rewrite, or a stopgap? Obviously we're going to bundle everything together eventually so it doesn't matter too much, but I want to make sure I've got load order taken into account. In other words, does that IPS replace both Spell Handlers and Weapon Effects?

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #292 on: March 26, 2020, 10:49:13 pm »
That's a replacement for both patches. I guess you could call it a rewrite, but really all I did was copy the Weapon Special Effects ASM, switch the syntax from Asar to ca65, and then paste it into the full assembly containing the Spell Handlers Rewrite changes.

I've updated the Weapons Effects + Spell Handlers Rewrite patch (same link as above) to include the rest of the previous bugfixes, merging them all together into a single patch that should be compatible with the Chaos Rush translation patch. I've also included fixes for the following:
  • The logic for determining whether a monster will run or not calculates (total party HP - total monster HP) >> 5, but then ignores the high byte of the result and the possible carry from adding the monster's fear level.
As a consequence of the fear calculation fix, monsters are now probably running too often; a party with a total of around 6500 HP is quite capable of scaring away single monsters in the final room of the game.

  • Combat engine gives credit for actions from both player characters and enemies before they've happened. Causes party to receive Magic Defense and Evasion credit even if the enemy is killed before it acts. Change counter increment behavior to happen after actions take place. May require significant rewriting of combat routine. Target/cancel exploit should be addressed through a solution.
By the time commands are executed, there doesn't appear to be anything left in RAM to indicate whether the command came from a spell or an item, so as a consequence only giving credit to commands that actually execute, items that cast spells will give credit for casting those spells, but only if the character already knows the spell being cast. I think I'm okay with that, as a mage gaining experience with a spell by observing an item that casts that spell still sounds reasonably logical.

In other news, I came across some more bugs:
  • If a character is killed before their turn happens, their battle command and target are not cleared, which means that if the character gets revived before their turn comes up (even in a later round!), they will still try to execute their battle command.
  • Monsters that are killed by poison/venom have their current HP set to 0 and KO Ailment bit set, but are not actually removed from battle; they remain valid targets (you can even cast Life on them to bring them back!) and need to attacked again in order to remove them from battle.
  • When Leon rejoins, his starting stats don't match his calculated stats; the first time his stats are recalculated, he loses 8 primary hand damage, gains 1% primary hand accuracy, gains 10 secondary hand damage, loses 7% secondary hand accuracy, and loses 15% evasion.
And here's another formatting error in the Chaos Rush translation: when meeting up with Leon in Palamecia, the last letter of Maria's first line of dialogue ("Stop! Both of you! Why") gets chopped off ("Stop! Both of you! Wh") if her name is 6 characters long.

Thinking a little more about the running total of HP/MP loss, out-of-battle MP use should be included too.
« Last Edit: March 30, 2020, 11:11:12 pm by abw »

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #293 on: March 31, 2020, 09:57:01 am »
Other than merging all our current fixes, was anything else changed, or any addresses moved around? I think I was trying to avoid merging everything until towards the end when it was clear we wouldn't need to move too much any more, but I guess we're getting close to that point. Also I knew about that dead character battle command thing early on, and yet somehow I neglected to mention it or add it to the list this entire time... No idea how the hell I let that happen.

I'll go ahead and update the first post to start using the combined patch and rename it simply to "Final Fantasy Restored (Bug Fixes Only) Beta" since that seems like the path we're taking this close to the finish line. I'll also add those bugs to the list. If possible it would be nice if we could fine-tune the fleeing of enemies if it is, indeed, too frequent compared to usual.

And did you actually manage to fix the target cancel exploit? I'm genuinely curious what approach you took to make that happen. Comparing our versions side by side and I see some places where I did some pretty rough fixes early on that it looks like you improved on, though the entire 0x1687A to 0x16A4B block looks like it's been significantly redone so I couldn't follow what all changed there.

At 0x16C51, there's 3 $05 which if I recall were the chance to lose stats that needed to be changed to $0B for the RNG change. Does that still hold or did you find a way to redo the RNG that can use the original values? Wow, there's a lot of mess in some of my early work I'm seeing now side-by-side, like leftover bytes and such. :-[

I'll make a note to fix that issue in the Chaos Rush translation in short order.
« Last Edit: March 31, 2020, 11:03:44 am by redmagejoe »

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Restored
« Reply #294 on: March 31, 2020, 11:24:45 pm »
Other than merging all our current fixes, was anything else changed, or any addresses moved around? I think I was trying to avoid merging everything until towards the end when it was clear we wouldn't need to move too much any more, but I guess we're getting close to that point.
Oh, plenty of stuff got moved around - trying to maintain the original addresses of every pointer target was just too annoying. That said, there are about 90 new NOPs scattered throughout the rewritten code in order to keep certain things at the addresses expected by the Chaos Rush translation patch.

Also I knew about that dead character battle command thing early on, and yet somehow I neglected to mention it or add it to the list this entire time... No idea how the hell I let that happen.
:D

I'll go ahead and update the first post to start using the combined patch and rename it simply to "Final Fantasy Restored (Bug Fixes Only) Beta" since that seems like the path we're taking this close to the finish line. I'll also add those bugs to the list. If possible it would be nice if we could fine-tune the fleeing of enemies if it is, indeed, too frequent compared to usual.
Yeah, that'll require some more play-testing to find the right balance. The funny part about scaring endgame monsters away is that the monsters aren't wrong: by that point, most lone monsters can easily be killed in less than a round, very possibly before they have a chance to act :P.

And did you actually manage to fix the target cancel exploit? I'm genuinely curious what approach you took to make that happen. Comparing our versions side by side and I see some places where I did some pretty rough fixes early on that it looks like you improved on, though the entire 0x1687A to 0x16A4B block looks like it's been significantly redone so I couldn't follow what all changed there.
Yes, although after some further investigation, it looks like there are some variables still set that are related to determining whether a used item is consumed or not, so we could use those to distinguish between spells cast from the Item command and spells cast from the Magic command. However, that led to the discovery of another bug:

- There is an approximately 1% chance (1/256 with the original unbalanced RNG) for "non-breakable" items to be destroyed anyway when used in battle. It sure sucks to lose the Masmune that way :(

As for the fix itself, it was basically just moving the counter increments from the code for entering commands to the code for executing commands, with a little bit of extra work to reconstruct some information that was no longer as easily accessible during command execution, such as which of the current character's spell slots needed to have its use counter incremented.

At 0x16C51, there's 3 $05 which if I recall were the chance to lose stats that needed to be changed to $0B for the RNG change. Does that still hold or did you find a way to redo the RNG that can use the original values? Wow, there's a lot of mess in some of my early work I'm seeing now side-by-side, like leftover bytes and such. :-[
I left those as $05 for the time being on the assumption that the 1/6 chance to lose a stat was the original intent; changing it to 1/12 to match the actual behaviour is easy enough, but that might be more suited to a rebalance patch than a strictly bugfix patch. On that note, how strongly do you feel that equipment stat bonuses not stacking is actually a bug?

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #295 on: April 01, 2020, 12:07:10 am »
On that note, how strongly do you feel that equipment stat bonuses not stacking is actually a bug?

I'm using the Anniversary version as a basis to say that it was a bug.



I've got a bit more time to focus on this project at the moment, so I'm going to start looking at the following for now since it seems like it should be a relatively easy fix.

Quote
  • Stat refresh needed after Mysidian Tower Orbs
« Last Edit: April 04, 2020, 04:18:57 pm by redmagejoe »