Author Topic: Single status immunity blocks Breath?!  (Read 1831 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Single status immunity blocks Breath?!
« on: November 29, 2015, 01:10:14 PM »
Is this true?
More generally speaking, if you have a spell that inflicts multiple status ailments, and attempt to cast it on a target that is immune to any one (but not all) of those ailments, will the spell fail every time?

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #1 on: November 29, 2015, 01:32:39 PM »
That's been my experience.
Let's dance!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #2 on: November 29, 2015, 01:44:12 PM »
Delving into Grimoire's notes here, it appears as though that is how the routine is written...
Well, that's ridiculous.
I definitely need to change that.

Kea

  • Vargas
  • *
  • Posts: 92
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #3 on: November 29, 2015, 02:42:22 PM »
Yep, that's how it is in every version. That's how Twist Headbands are the thing to wear vs. Malboros.

The same thing happens with physical attacks that inflict multiple status ailments.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #4 on: November 29, 2015, 04:38:55 PM »
The same thing happens with physical attacks that inflict multiple status ailments.
Oh, for cryin' out loud...

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #5 on: November 29, 2015, 06:37:04 PM »
There are several things which should be rewritten for FFIV and this is definitely one of them. Oddly enough until the DS version this is how all versions of FFIV behaved.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #6 on: November 29, 2015, 09:07:05 PM »
I have an idea how it can be fixed, and I think you noted that there are 19 bytes in that routine that are completely unneeded, right? That should be plenty.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #7 on: November 29, 2015, 09:48:29 PM »
I had spoken a little too soon on that. That is used for Golbez's Hold spell so that it never ends... but if you put his sequence to occur right after it in the first place it shouldn't really matter.

You can also get rid of the "creature type" check which it looks for if Death status is being applied (Really guys? Just use the innate immunity system you put into each enemy!)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #8 on: November 29, 2015, 11:12:20 PM »
Aww, bummer, well then maybe a universal fix isn't in the cards, but it's definitely getting changed in TfW.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #9 on: December 02, 2015, 12:05:03 PM »
I think I worked this out!

So, the original assembly does this:
Code: [Select]
$03/D54F AD 2B 27    LDA $272B  [$7E:272B]   ;Load target's status immunity 1
$03/D552 2D A3 28    AND $28A3  [$7E:28A3]   ;AND immunity 1 with status to inflict 1
$03/D555 D0 06       BNE $06    [$D55D]      ;If any immunity matches any status to inflict, fail any further operations
$03/D557 AD 2C 27    LDA $272C  [$7E:272C]   ;Load target's status immunity 2
$03/D55A 2D A4 28    AND $28A4  [$7E:28A4]   ;AND immunity 2 with status to inflict 2
$03/D55D D0 53       BNE $53    [$D5B2]      ;fail pending any matches
$03/D55F AD 03 27    LDA $2703  [$7E:2703]   ;Load target's status byte 1
$03/D562 05 AE       ORA $AE    [$00:00AE]   ;add in all applicable statuses to inflict
$03/D564 8D 03 27    STA $2703  [$7E:2703]   ;store in target's status byte 1
$03/D567 AD 04 27    LDA $2704  [$7E:2704]   
$03/D56A 05 AD       ORA $AD    [$00:00AD]   
$03/D56C 8D 04 27    STA $2704  [$7E:2704]   ;perform same operation with status 2

Obviously, the problem with this is that any immunity to any applicable status will fail the whole routine.

So I replaced that chunk of code with this (which is the same exact length thanks to some extreme variable storing on the part of the original developers):
Code: [Select]
$03/D54F AD 2B 27    LDA $272B  [$00:272B]   ;Load Target's Status Immunity Byte 1
$03/D552 49 FF       EOR #$FF                ;Perform Exclusive OR (this turns "on" all bits that are "off" and turns "off" all bits that are "on"), thus turning "status Immunity" into "status vulnerability"
$03/D554 25 AE       AND $AE    [$00:06AE]   ;AND status vulnerability 1 with status to inflict 1 (leaving only the vulnerable statuses to inflict)
$03/D556 85 AE       STA $AE    [$00:06AE]   ;Store the result into status to inflict 1
$03/D558 AD 2C 27    LDA $272C  [$00:272C]   ;
$03/D55B 49 FF       EOR #$FF                ;
$03/D55D 25 AD       AND $AD    [$00:06AD]   ;
$03/D55F 85 AD       STA $AD    [$00:06AD]   ;Perform the same operation with status immunity 2 and status to inflict 2
$03/D561 A5 AC       LDA $AC    [$00:06AC]   ;Load target's current status 1 (already stored here earlier in the routine)
$03/D563 05 AE       ORA $AE    [$00:06AE]   ;add in all applicable statuses to inflict (1)
$03/D565 8D 03 27    STA $2703  [$00:2703]   ;Store in target's current status 1
$03/D568 A5 AB       LDA $AB    [$00:06AB]   ;
$03/D56A 05 AD       ORA $AD    [$00:06AD]   ;
$03/D56C 8D 04 27    STA $2704  [$00:2704]   ;Perform same operation with status 2

And there you have it! I tested it out, having a monster use Breath on a party that had two completely vulnerable, one with Blind immunity and one with Mute immunity. All statuses applied to all targets with the exception of those that they were immune to.

Looking at the code, i can see one possible drawback to this fix - this will force the game to consider any execution of this routine "successful," thus it will always dispel Berserk status (which the original one does upon any successful hit), even if it doesn't inflict any new statuses. But I think I can live with that.

Thoughts?

Kea

  • Vargas
  • *
  • Posts: 92
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #10 on: December 02, 2015, 05:56:35 PM »
Would it not also play the spell's animation, regardless of whether any statuses were applied?

When I recoded it for FF4 Advance I had enough space to make the routine return 0 if the target was immune to all of the statuses, but you may not have enough room to do that.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #11 on: December 02, 2015, 06:25:18 PM »
Yeah, the spell animation does still play, but I'm pretty sure that's how it happens in some later FF games, too.

I could probably rewrite the entire routine to make it fail if the target is immune to all of the applicable statuses, but I'm not sure it would be worth all the trouble.

Pinkpuff

  • Flan Princess
  • *
  • Posts: 923
  • Find a Megalixir in Unprecedented Crisis!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #12 on: December 03, 2015, 05:18:50 AM »
This seems like a decent candidate for an independent bugfix/improvement patch.
Let's dance!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,682
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #13 on: December 03, 2015, 07:54:44 AM »
This seems like a decent candidate for an independent bugfix/improvement patch.

Fully agreed! Fantastic work Chillyfeez! As for it still playing the animation, I'm not really sure of a way around that. Wouldn't the failing of the spell just show "miss!" and wouldn't that be enough of an indication?

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,234
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Single status immunity blocks Breath?!
« Reply #14 on: December 03, 2015, 08:15:40 AM »
This seems like a decent candidate for an independent bugfix/improvement patch.

Fully agreed! Fantastic work Chillyfeez! As for it still playing the animation, I'm not really sure of a way around that. Wouldn't the failing of the spell just show "miss!" and wouldn't that be enough of an indication?

No, Kea's right on the mark here.
I'm not sure what causes it, but with the original assembly, when the routine fails (due to any applicable immunity), the animation just doesn't play on the target.
With my modified routine, the animation plays, but no a status is applied if the target is immune to all of the right ones.
Neither one shows "miss!" I think that's reserved for physical attacks that result in zero damage.