øA slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=printpage;topic=1891.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index39b8.html slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1891.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index39b8.html.z x þGg^ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ À$ B OK text/html ISO-8859-1 gzip 0|Ö B ÿÿÿÿÿÿÿÿ Tue, 10 Mar 2020 08:12:05 GMT 0ó° °® 0® P® €§² ð® ýGg^ ÿÿÿÿÿÿÿÿoX B
Print Page - Immune and 99% Evade, Glitch or Design? - Documentation Within
Board of Slick
Library of the Ancients => Final Fantasy IV Research & Development => Topic started by: Grimoire LD on October 09, 2013, 12:01:40 AM
Title: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 09, 2013, 12:01:40 AM
This has always boggled my mind when I first heard about it. What was the expected design of the Immune bit? Was it really supposed to give a character 99% Physical Evade or was it just a code mess that only occurred by chance and a mistaken byte exchange.
Well now, I think I have the answer to that...
$03/9A00 A0 29 00 LDY #$0029 A:0023 X:0003 Y:0023 P:envMxdIZC - Load 29 into A. $03/9A03 18 CLC A:0023 X:0003 Y:0029 P:envMxdIzC - Clear Carry Flag. $03/9A04 A5 AA LDA $AA [$00:00AA] A:0023 X:0003 Y:0029 P:envMxdIzc - Load the Value in AA into A. $03/9A06 6D 6C 39 ADC $396C [$7E:396C] A:0094 X:0003 Y:0029 P:eNvMxdIzc - Add the value from 7E369C into A. $03/9A09 20 2A 9E JSR $9E2A [$03:9E2A] A:0094 X:0003 Y:0029 P:eNvMxdIzc - Jump to Subroutine. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $03/9E2A C9 63 CMP #$63 A:0094 X:0003 Y:0029 P:eNvMxdIzc - Is it 63? $03/9E2C 90 02 BCC $02 [$9E30] A:0094 X:0003 Y:0029 P:envMxdIzC - If less than 63, branch to 9E30. $03/9E2E A9 63 LDA #$63 A:0094 X:0003 Y:0029 P:envMxdIzC - Load 63 into A. $03/9E30 60 RTS A:0063 X:0003 Y:0029 P:envMxdIzC - Return ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $03/9A0C 91 80 STA ($80),y[$7E:2129] A:0063 X:0003 Y:0029 P:envMxdIzC - Store A in Evasion.
AA - Is the temporary storing place of Character's evasion. For some reason when an Immune bit item is put on it, it jumps to 94.
When we dig a little deeper...
$03/9987 B5 AD LDA $AD,x [$00:00AD] A:0000 X:0000 Y:0029 P:envMxdIZC - Load AD (+x) into A. (AD Becomes 80 through the Immune Bit) $03/9989 30 06 BMI $06 [$9991] A:0080 X:0000 Y:0029 P:eNvMxdIzC -If it is 80 or above branch to 039991. ----------------------
------------------ $03/9991 05 AA ORA $AA [$00:00AA] A:0080 X:0000 Y:0029 P:eNvMxdIzC - Add it to AA $03/9993 85 AA STA $AA [$00:00AA] A:0080 X:0000 Y:0029 P:eNvMxdIzC - Store it in AA.
So now the question becomes... how did AD acquire that 80?
Well we have to go back to the beginning of this process which begins at 039965 it appears...
$03/99657B TDCA:0000X:0005Y:0030P:envMxdIZC - Transfer Direct Page $03/9966AA TAXA:0000X:0005Y:0030P:envMxdIZC - Transfer A to X. $03/996786 A9STX $A9 [$00:00A9]A:0000X:0000Y:0030P:envMxdIZC - Store A in A9. $03/9969A0 08 00LDY #$0008A:0000X:0000Y:0030P:envMxdIZC - Load 0008 into Y -----------------------------------------------------------(Looping Point)--------------------------------------------------------- $03/996CB1 82LDA ($82),y[$7E:27F6]A:0000X:0000Y:0008P:envMxdIzC - Load Value from 7E27F6 into A. $03/996E95 ADSTA $AD,x [$00:00AD]A:0080X:0000Y:0008P:eNvMxdIzC - Store A in AD. $03/997098 TYAA:0080X:0000Y:0008P:eNvMxdIzC - Transfer Y to A $03/997118 CLCA:0008X:0000Y:0008P:envMxdIzC - Clear Carry Flag. $03/997269 0BADC #$0BA:0008X:0000Y:0008P:envMxdIzc - Add 0B to A. $03/9974A8 TAYA:0013X:0000Y:0008P:envMxdIzc - Transfer A to Y. $03/9975E8 INXA:0013X:0000Y:0013P:envMxdIzc - +1 to X. $03/9976E0 03 00CPX #$0003A:0013X:0001Y:0013P:envMxdIzc - Has it cycled three times? $03/9979D0 F1BNE $F1 [$996C]A:0013X:0001Y:0013P:eNvMxdIzc - Then loop back to 03996C ---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------- $03/997BAD 6D 39LDA $396D [$7E:396D]A:0029X:0003Y:0029P:envMxdIZC - Load 7E396D into A. $03/997E85 B0STA $B0 [$00:00B0]A:0000X:0003Y:0029P:envMxdIZC - Store A in B0. $03/9980AD 6E 39LDA $396E [$7E:396E]A:0000X:0003Y:0029P:envMxdIZC - Load A from 7E396E. $03/998385 B1STA $B1 [$00:00B1]A:0000X:0003Y:0029P:envMxdIZC - Store A in B1. $03/99857B TDCA:0000X:0003Y:0029P:envMxdIZC - Transfer Direct Page. $03/9986AA TAXA:0000X:0003Y:0029P:envMxdIZC - Transfer A to X. ---------------------------------------------------------(Looping Point)---------------------------------------------------------------- $03/9987B5 ADLDA $AD,x [$00:00AD]A:0000X:0000Y:0029P:envMxdIZC - Load A from AD +X. $03/998930 06BMI $06 [$9991]A:0080X:0000Y:0029P:eNvMxdIzC - If minus branch to 039991. ------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------- $03/999105 AAORA $AA [$00:00AA]A:0080X:0000Y:0029P:eNvMxdIzC - Add 80 to AA $03/999385 AASTA $AA [$00:00AA]A:0080X:0000Y:0029P:eNvMxdIzC - Store A in AA. $03/9995E8 INXA:0080X:0000Y:0029P:eNvMxdIzC - +1 to X $03/9996E0 05 00CPX #$0005A:0080X:0001Y:0029P:envMxdIzC - Is X 5? $03/9999D0 ECBNE $EC [$9987]A:0080X:0001Y:0029P:eNvMxdIzc - If not loop back to 039987.
7E27F6 is the key. Now this is a section of RAM that is woefully under-explored, but 27F6 must deal with the character slot. The Glass Helm in particular (and likely any immune bit) copies an 80 to there. What 7E2780 and beyond appears to be copies of the character equipment that the characters currently have equipped.
And the final verdict...
It's intended. As idiotic of a decision as it is, the programming doesn't lie, it Specifically looks for an item that is equipped (hence why it searches three times through the character's equipment, interestingly Shields are not included in this search and indeed when they have the Immune bit they are not effected by the 99% evade) for a negative value byte in Elemental Resistance to take it through a special piece of code that...
$03/9987 B5 AD LDA $AD,x [$00:00AD] A:0000 X:0000 Y:0029 P:envMxdIZC - Load A from AD +X. $03/9989 30 06 BMI $06 [$9991] A:0080 X:0000 Y:0029 P:eNvMxdIzC - If minus branch to 039991. ------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------- $03/9991 05 AA ORA $AA [$00:00AA] A:0080 X:0000 Y:0029 P:eNvMxdIzC - Add A to AA $03/9993 85 AA STA $AA [$00:00AA] A:0080 X:0000 Y:0029 P:eNvMxdIzC - Store A in AA. $03/9995 E8 INX A:0080 X:0000 Y:0029 P:eNvMxdIzC - +1 to X $03/9996 E0 05 00 CPX #$0005 A:0080 X:0001 Y:0029 P:envMxdIzC - Is X 5? $03/9999 D0 EC BNE $EC [$9987] A:0080 X:0001 Y:0029 P:eNvMxdIzc - If not loop back to 039987.
Looks for AA (Evasion) and places it in AA. The only thing I can possibly think of what it may have done was supposed to give the player 99% magic evasion, but that's just as equally dumb. Something here was supposed to give the player 99 of something. Whatever it was, it couldn't have been balanced, that's for certain.
To fix this you change...
$03/9987 B5 AD LDA $AD,x [$00:00AD] A:0000 X:0000 Y:0029 P:envMxdIZC - Load A from AD +X. $03/9989 30 06 BMI $06 [$9991] A:0080 X:0000 Y:0029 P:eNvMxdIzC - If minus branch to 039991.
To...
$03/9987 B5 AD LDA $AD,x [$00:00AD] A:0000 X:0000 Y:0029 P:envMxdIZC - Load A from AD +X. $03/9989 EA NOP A:0080 X:0000 Y:0029 P:eNvMxdIzC - NULL $03/998A EA NOP A:0080 X:0000 Y:0029 P:eNvMxdIzC - NULL
And that's all it takes. This does not cause any issues as far as I could make out and fixes the 99% problem in its entirety. A more clever hacker could utilize this in a more efficient fashion, actually redirecting the 80 rather than downright avoiding it.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 09, 2013, 01:11:32 AM
- What's at 03/998B thru 03/9990, for comparison? - What is 7E/396C? - How is $AA originally built up from your various pieces' of equipment Evade values? Is there capping done then, and if so, is it done with 03/9A00?
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 09, 2013, 01:38:52 AM
A fair point, I wasn't exactly thorough, lets find out...
$03/998B 05 A9 ORA $A9 [$00:00A9] A:0000 X:0000 Y:0029 P:envMxdIZC - Add the value in A9 into A. (If applicable) $03/998D 85 A9 STA $A9 [$00:00A9] A:0000 X:0000 Y:0029 P:envMxdIZC - Store A9 into A. $03/998F 80 04 BRA $04 [$9995] A:0000 X:0000 Y:0029 P:envMxdIZC - Branch to 039995 ----------------------
------------------- $03/9995 E8 INX A:0000 X:0000 Y:0029 P:envMxdIZC +1 to X ....
7E396D and E both seem to be blank outside of battle and during this routine, Inside of battle they still appear to be blank, so I can't say the only hint given is the Tower of Babil docs which says two bytes away is...
3965-396C Copy of Attacker's main stats (STR, AGI, ???, VIT, WIS, WILL, ???, ???)
It seems to only be read once, but it is read whenever you equip or dequip (or not even change) equipment. And at that time it looks as if the value had already loaded what will be the evasion likely from one of its main sources, before equipping this new item. Where that happens on its own I've had difficulty locating. There does not appear to be any capping done though, which I suppose means in theory that it could overflow, but I may just not have found a "CMP FF, BCC XX" because it would be inapplicable.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 09, 2013, 02:16:46 AM
what's $A9? is that ever added to anything? when's it first read after this?
at first, i was thinking that they wanted to have "Immune" guarantee the maximum Evasion value of 99 (because they knew that setting $AA to 128+ would later get Evasion capped to 99). now for this, they could've skipped the "ORA $AA", and still accomplished what they wanted.
and i figured the bottom 7 bits of $AD,X were just a normal integer. however, the $A9 code is suggesting they aren't, because it's being treated like a bitfield as well.. except i don't anticipate it ensuring 99 of anything, because $A9 will be under 128.
at this point, i'd say the bottom 7 bits of $AD,X are a list of unknown properties, and the top bit is a switch to control what variable(s) these properties will be applied to.
however, the whole idea of adding a bitfield to an integer, which is what 03/9A00 does, seems wrong. FF6 does mix and match the two a little (by having a 16-bit value where bits 0-7 are a character's normal HP or MP, then bits 8-9 are flags that select a certain percentage bonus to give to the stat), but FF6 actually has code to interpret this rather than just add things willy nilly.
this makes me think that the FF4 makers didn't want to use $AA in 03/9A00, but some other variable, though that's with the caveat that i know nothing whatsoever about this game. :P i wonder if you'll find some "complementary" code, where they read some other variable and treat it like a bitfield to do certain things, except the variable was never set in the first place (or maybe it was set as an integer). then two things would be resolved in a nice, tidy basket. if only.
that's a bit of speculation. anyway, i'm with you that something seems suspect here.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 09, 2013, 10:40:50 AM
what's $A9? is that ever added to anything? when's it first read after this?
at first, i was thinking that they wanted to have "Immune" guarantee the maximum Evasion value of 99 (because they knew that setting $AA to 128+ would later get Evasion capped to 99). now for this, they could've skipped the "ORA $AA", and still accomplished what they wanted.
and i figured the bottom 7 bits of $AD,X were just a normal integer. however, the $A9 code is suggesting they aren't, because it's being treated like a bitfield as well.. except i don't anticipate it ensuring 99 of anything, because $A9 will be under 128.
at this point, i'd say the bottom 7 bits of $AD,X are a list of unknown properties, and the top bit is a switch to control what variable(s) these properties will be applied to.
however, the whole idea of adding a bitfield to an integer, which is what 03/9A00 does, seems wrong. FF6 does mix and match the two a little (by having a 16-bit value where bits 0-7 are a character's normal HP or MP, then bits 8-9 are flags that select a certain percentage bonus to give to the stat), but FF6 actually has code to interpret this rather than just add things willy nilly.
this makes me think that the FF4 makers didn't want to use $AA in 03/9A00, but some other variable, though that's with the caveat that i know nothing whatsoever about this game. :P i wonder if you'll find some "complementary" code, where they read some other variable and treat it like a bitfield to do certain things, except the variable was never set in the first place (or maybe it was set as an integer). then two things would be resolved in a nice, tidy basket. if only.
that's a bit of speculation. anyway, i'm with you that something seems suspect here.
A9 looks to, oddly be enough, Critical Hit Bonus and before that is A8 in Critical Hit Chance. Which are also stored in character data, so I could easily verify that. What a strange order...
A8 - Critical Hit Chance (A set value held by character to character. Equipping a weapon of any sort doubles the value and equipping a Bow and Arrow triples the value. Noticeably when you have two weapons equipped the game will reset the Critical Hit chance to default)
A9 - Critical Hit Bonus - (A set value held by character to character. Equipping a weapon will add half of the weapon's attack power to the possible highest damage of a Critical Hit.)
AA - ??
That is what it reads by default, but in this routine they may be different...
In the Routine A8 and A9 are set as 00's with only AA being used as a temporary Evasion store-point.
The other 7 bits of AD are Elemental Resistance, Fire, Ice, Bolt, Holy, Dark, Air, Absorb and the game carries them as normal until it reaches the Branch if Minus portion, once it sees that it isn't 80 it leaves that value behind. Though I do have to wonder why it is then saved to A9... instead of AA. Maybe it is an off-by-one error? It wouldn't be the first time that Square had this happen (In this very game!)
25 elemental defense (if immunity bit wasn't set)***
Why it has to jump through loops to put the value into 7E2125, I'm not really sure. More interestingly is what happens to the value in AA...
$03/99A3 A5 AA LDA $AA [$00:00AA] A:0001 X:0005 Y:0026 P:envMxdIzC $03/99A5 91 80 STA ($80),y[$7E:2126] A:0000 X:0005 Y:0026 P:envMxdIZC
26 elemental defense (if immunity bit was set)***
AA is not only a Temporary Evasion Store but is also where the Immunity Byte value is stored. I think I'm starting to see the picture here... maybe Square did screw up and a haphazard programmer used both AA as an Elemental Immune and Evade byte.
The real issue is that the Elemental Immunity byte is never zeroed out. as the other values in the routine appear to be before going onto their next function.
This may be the issue. By default in the routine A9 seems to be Zero at this point anyhow. It is a possibility that this is supposed to be STZ AA, which would clear the problematic Immunity=Evade Byte.
I was not thorough enough before. Those bytes I said to null are necessary for applying Elemental Immunity. I think now the object is to find where these are fed into Evasion.
It is all to do with AA's dual purposes which causes this noticeable problem.
Read one byte of Equipment (Evasion), store it in AA, move on to the next piece of equipment. (Shields are not read here for some reason however) The real issue may be is that the AA register is never "cleaned" so to speak after putting in the data where it Should (Elemental Immunity) it should then be zeroed and allowed to calculate Evasion on its own merit.
This set of bytes here seem unnecessarily exact. Why would you set a value to Zero, load a new value in, check to see if the value is already there (which it plainly cannot be because you Just Zeroed It) and Store that value. Would it not be as easy to do this...?
The reason the game continues to read evasion into it is because it is never properly reset like every other value I've seen thus far in the code (I wonder if this lack of 00 is part of the problem with the Immunities turning into weaknesses when the Immune equipment is removed...)
Now a new verdict...
An oversight, created likely by a hasty programmer that didn't double check their work, tying both Evasion and Elemental Immunity to one byte is fine in practice, but when you don't include the proper cleaning to old values they can cause issues like this.
:edit: Hmm, it seems as if that set of bytes isn't so useless after all...
Only for the start of this portion is the STZ A9 called to make the value 00, which it could be something else due to earlier variables. Then what these are doing are looking at each instance of armor, checking for Creature Resistance Bytes and adding them to A9 to eventually put into Byte 27 of character data. So I can't use that. I'm not really sure what I can replace to put an STZ AA anywhere.
A smart programmer would have put an STZ AA here at the start as they did with other sections before the looping point. But the lack of room and available bytes makes it a bit of a risky game to do so. All it takes is an STZ AA before this point, but I'm not sure where it could go.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 09, 2013, 11:08:11 AM
Quote
The other 7 bits of AD are Elemental Resistance, Fire, Ice, Bolt, Holy, Dark, Air, Absorb and the game carries them as normal until it reaches the Branch if Minus portion, once it sees that it isn't 80 it leaves that value behind. Though I do have to wonder why it is then saved to A9... instead of AA. Maybe it is an off-by-one error? It wouldn't be the first time that Square had this happen (In this very game!)
25 elemental defense (if immunity bit wasn't set)***
Why it has to jump through loops to put the value into 7E2125, I'm not really sure. More interestingly is what happens to the value in AA...
$03/99A3 A5 AA LDA $AA [$00:00AA] A:0001 X:0005 Y:0026 P:envMxdIzC $03/99A5 91 80 STA ($80),y[$7E:2126] A:0000 X:0005 Y:0026 P:envMxdIZC
26 elemental defense (if immunity bit was set)***
so $2125 is Elemental Resists (as in reduced damage), and $2126 is Elemental Nullifications (as in zero damage)?
Quote
Read one byte of Equipment (Evasion), store it in AA, move on to the next piece of equipment. (Shields are not read here for some reason however)
where is equipment Evasion being read? i don't see code for that. $AD,X was the elemental bits.
and what is $27F3?
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 09, 2013, 11:20:25 AM
I edited my post above, I was off in my "fix" it won't work optimally, it will create a different kind of glitch where only the Armlet Armor would be considered in Creature Resistances because the value is continually overwritten by the new value because of the addition. it also includes the Evasion - acquiring code.
Indeed, Byte 25 and 26 are Elemental Resistance (Half Damage) and Elemental Immunity (One Damage)
7E27F3 is a slot dependent Armor. In this case it's looking for Creature Resistance Byte, which is what that portion of code loops three times to add into one solid number for multiple creature resistances.
:edit: Final Fix (I think)
It seems the key to fixing this is changing this at its core. In otherwords instead of loading Elemental Immunity into AA load it into an unused byte like FE appears to be for this routine.
$03/9987 B5 AD LDA $AD,x [$00:00AD] A:0000 X:0000 Y:0029 P:envMxdIZC - Load A from AD +X. $03/9989 30 06 BMI $06 [$9991] A:0080 X:0000 Y:0029 P:eNvMxdIzC - If minus branch to 039991. ------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------- $03/9991 05 AA ORA $AA [$00:00AA] A:0080 X:0000 Y:0029 P:eNvMxdIzC - Add 80 to AA $03/9993 85 AA STA $AA [$00:00AA] A:0080 X:0000 Y:0029 P:eNvMxdIzC - Store A in AA. $03/9995 E8 INX A:0080 X:0000 Y:0029 P:eNvMxdIzC - +1 to X $03/9996 E0 05 00 CPX #$0005 A:0080 X:0001 Y:0029 P:envMxdIzC - Is X 5? $03/9999 D0 EC BNE $EC [$9987] A:0080 X:0001 Y:0029 P:eNvMxdIzc - If not loop back to 039987.
Change AA to FE and that should do it for this portion, next...
$03/99A3 A5 AA LDA $AA [$00:00AA] A:0001 X:0005 Y:0026 P:envMxdIzC $03/99A5 91 80 STA ($80),y[$7E:2126] A:0000 X:0005 Y:0026 P:envMxdIZC
26 elemental defense (if immunity bit was set)***
Change it to FE and there and it should cause FE to be the new Elemental Immunity Storage.
This looks to be a legitimate fix and I have noticed no problems. Instead of trying to add to the code, it seems like it was just best to work around it.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 09, 2013, 12:16:39 PM
Since we're on the topic of Immunity problems, lets look at x4 Weakness is never removed, eh?
$03/9A78A0 26 00LDY #$0026A:0000X:0003Y:0020P:envMxdIzc - Load 0026 into Y $03/9A7BB1 80LDA ($80),y[$7E:21A6]A:0000X:0003Y:0026P:envMxdIzc - Load A from Index +Y. (Elemental Immunity Byte) $03/9A7D85 A9STA $A9 [$00:00A9]A:0081X:0003Y:0026P:eNvMxdIzc - Store A in A9. $03/9A7F20 A8 9DJSR $9DA8 [$03:9DA8]A:0081X:0003Y:0026P:eNvMxdIzc - Jump to Subroutine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` $03/9DA829 12AND #$12A:0081X:0003Y:0026P:eNvMxdIzc Get rid of inapplicable bits. $03/9DAA4A LSR AA:0000X:0003Y:0026P:envMxdIZc - /2 A. $03/9DAB85 AASTA $AA [$00:00AA]A:0000X:0003Y:0026P:envMxdIZc - Store A in AA $03/9DADA5 A9LDA $A9 [$00:00A9]A:0000X:0003Y:0026P:envMxdIZc - Load A9. $03/9DAF29 09AND #$09A:0081X:0003Y:0026P:eNvMxdIzc - Get rid of inapplicable bits. $03/9DB10A ASL AA:0001X:0003Y:0026P:envMxdIzc - x2 A. $03/9DB205 AAORA $AA [$00:00AA]A:0002X:0003Y:0026P:envMxdIzc - Add to AA. $03/9DB460 RTSA:0002X:0003Y:0026P:envMxdIzc - Return ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $03/9A82F0 07BEQ $07 [$9A8B]A:0002X:0003Y:0026P:envMxdIzc - Branch if 00 to 039A8B ---------------------------------------------------------------------------------------------------------------------------------------- $03/9A84A0 21 00LDY #$0021A:0002X:0003Y:0026P:envMxdIzc - Load 0021 into Y. $03/9A8709 80ORA #$80A:0002X:0003Y:0021P:envMxdIzc - Add 80 to A (if applicable) $03/9A8991 80STA ($80),y[$7E:21A1]A:0082X:0003Y:0021P:eNvMxdIzc - Store A in 80. -------------------------------------------------------------------------------------------------------------------- $03/9A8BA0 22 00LDY #$0022A:0082X:0003Y:0021P:eNvMxdIzc - Move on from here...
Because of the way the game works it will never decrement any bits that come into the x4 Weakness Byte.
Disabling the Very Weakness is an easy matter. Even setting it to just Weakness is a simple process. Just change this...
$03/9A84 A0 21 00 LDY #$0021 A:0002 X:0003 Y:0026 P:envMxdIzc - Load 0021 into Y.
To this...
$03/9A84 A0 20 00 LDY #$0020 A:0002 X:0003 Y:0026 P:envMxdIzc - Load 0020 into Y.
This will make it so it puts it in the Weakness Byte. While it may not do x4 damage it is still considered a weakness and a check actually exists for this which will overwrite the value rather than continue to store them without any additional changes needed.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 09, 2013, 06:28:11 PM
Quote from: Grimoire LD
This looks to be a legitimate fix and I have noticed no problems. Instead of trying to add to the code, it seems like it was just best to work around it.
good work. this definitely seems to be the soundest fix for it.
out of curiosity, what is the top bit of $27F0?
------
Quote
Since we're on the topic of Immunity problems, lets look at x4 Weakness is never removed, eh? ... Because of the way the game works it will never decrement any bits that come into the x4 Weakness Byte.
i'm not following you here. are you saying "Very Weakness" should never be set, or that it's being set for too long? does this have anything to do with Immunity?
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 09, 2013, 08:53:32 PM
Ah, I should clarify that a bit, after finding this section of data I decided to take a closer look...
2780 - List of Equipment Starting from Helmet, Armor, Hand Armor, Weapon, Shield (Equipment Type, Defense, Evasion, Magic Defense, Magic Evade (?/2), Creature Resistance, Equip Index, Bonus Index, Elemental Resistance, Status Byte 1 Resist, Status Byte 2 Resist) 11 (Decimal) Bytes in Total for each piece of equipment. 55 (Decimal) Bytes per character slot then.
On Weapons...
A1 Weapon Bits, A2 Attack Power, A3 Accuracy, A4 Magic Spell, A5 ??, A6 Creature Weakness, A7 Equip Index, A8 Bonus Index, A9 Elemental Attack, AA Status Byte 1, AB Status Byte 2.
So that means that this was looking at the third character's Helmet, and specifically the Evasion byte of that, which makes sense, all things considered. So it doesn't really have any specific bits set. It's just a numerical value in this case.
Very Weakness is only set when one equips a piece of equipment that has a resistance AND they have the Immune bit. So say I have a Fire Shield and the Glass Mask, I would be immune to Ice, but Very Weak to Fire. Normally if I just have a Fire shield I would resist Ice and be weak to fire. I see what they were going for and it would be fine but...
When I remove the Fire Shield, I will no longer have that resistance to Ice, but I will still be Very Weak to Fire because the game never decrements that value properly like it does with ordinary Weakness bytes, hence why I suggested to just move it to the weakness byte. Immunity to one element should not come with such a high price as x4 Weakness, in my opinion in the first place and this prevents the potential problem of being unable to fix the value's issues because of the lack of space.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 09, 2013, 10:59:49 PM
Quote
Immunity to one element should not come with such a high price as x4 Weakness, in my opinion in the first place and this prevents the potential problem of being unable to fix the value's issues because of the lack of space.
eh, now you're mixing and matching reinterpretation/rebalancing with actual bugfixing. i bet you could make space for a fix.
a possible optimization is to move "LDY #$0021" before the $9DA8 call at 03/9A7F. then we can do "INY" at 03/9A8B. just 2 bytes, but it's a start. you've found other inefficiencies elsewhere.
where's the code that undoes normal Weakness after an equip change? does it work by specifically subtracting out the removed equipment's elements, or by zeroing the property, then rebuilding it based on the equipment that's still there? (my guess is the latter.)
if the game calls 03/9A78 after an unequip, and $21A6 indeed holds the right current value, i'm not sure why $21A1 wouldn't in turn wind up with the right value. so i'm not entirely following how the bug occurs code-wise, though your explanation makes sense logically.
also, when Immunity turns Weakness into Very Weakness, is the original element still marked in the Weakness variable as well, or does it get cleared from there?
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Deathlike2 on October 09, 2013, 11:40:37 PM
I've already written in my bugs list, but I'll just reiterate problems with the Immune bug.. some of which is covered here, others... not at all.
1) The Glass Mask and the Adamant Armor are most affected by this, as these pieces of equipment use that bit.
2) The Glass Mask in conjunction with ANY element resistant armor does NOTHING to take advantage of this behavior. Don't ask me why... it happens to be the case.
3) The Adamant Armor as designed is the only piece of equipment that uses the Immune Bit correctly. However, it fails to "clear out the bits", making you weak to all elementals... fire and ice makes you twice as vulnerable (Fire and Ice protection elemental bits magnify the damage, see Protect Ring vs Physical Elemental Attacks).
4) FF4 Advance (GBA port) removes the evasion behavior (possibly including the Wonderswan port) indicating the likely "intended" behavior of the max evasion aspect... which is not to have it at all.
5) I still think the 99% evasion was supposed to be for magic evasion, since it is not possible (at least with the game's own equipment and math) to reach 99% magic evasion. It is easier to each 99% evasion with Kain, Cecil, and Edge... with Rosa+Rydia abusing the Shield bug. Any damage that would have been dealt would have been minimal to a wearer of a Glass Mask (why would you need high evasion to do with the highest defensive helmet in the game?) Someone like Rydia would best benefit from a Glass Mask... being able to have the highest Magic Evasion multiplier is appropriate for a Wizard while having increased physical defense. Although the monster has a terrible defense, it is a wizard of both magics...
Anyways, carry on. The Glass Mask is still a terribly useless piece of equipment as currently constituted. I think it was meant to max out out magic evasion of any character in addition to its immunity property, which doesn't work because it doesn't attach to elemental equipment like the Protect Ring.
An "ultimate armor set" would have actually consisted of the Glass Mask, Adamant Armor, and Protect Ring (well, actually, the Crystal Ring is the best loot).
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 09, 2013, 11:59:54 PM
Indeed, I only thought that for the lack of a better alternative I could think of. I didn't put as much effort as I should have into the Bit unsetting as I should have and I should search to see how its calculated for the ordinary weakness byte to compare and possibly repair the x4 weakness byte.
Also I was completely misunderstanding how the Immune bit works (or doesn't work). The only item in the normal game this glitch affects is the Adamant Armor. As it is specifically that a Very Weak value is written only if the Immune bit has other elements attached with it. I'm not sure where I got the idea that Immune stacked with other Elements. Likely from the Likely intentioned portion of the Glass Helm (which is just the Immune bit, which does nothing at all on its own.
This is how Elemental Weakness is removed... (and also explains how it is added.)
$03/9A69A0 25 00LDY #$0025A:0000X:0003Y:002CP:envMxdIZC - Load 0025 into Y $03/9A6CB1 80LDA ($80),y[$7E:20A5]A:0000X:0003Y:0025P:envMxdIzC - Load A from Elemental Resistance. $03/9A6E85 A9STA $A9 [$00:00A9]A:0002X:0003Y:0025P:envMxdIzC - Store A in A9 $03/9A7020 A8 9DJSR $9DA8 [$03:9DA8]A:0002X:0003Y:0025P:envMxdIzC - Jump to Subroutine (Elemental Weakness Set) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` $03/9DA829 12AND #$12A:0002X:0003Y:0025P:envMxdIzC - Get rid of bits that are multiple of 12. $03/9DAA4A LSR AA:0002X:0003Y:0025P:envMxdIzC - / A by 2. $03/9DAB85 AASTA $AA [$00:00AA]A:0001X:0003Y:0025P:envMxdIzc - Store A in AA $03/9DADA5 A9LDA $A9 [$00:00A9]A:0001X:0003Y:0025P:envMxdIzc - Load A9 into A $03/9DAF29 09AND #$09A:0002X:0003Y:0025P:envMxdIzc - Get rid of bits...? $03/9DB10A ASL AA:0000X:0003Y:0025P:envMxdIZc - / A by 2. $03/9DB205 AAORA $AA [$00:00AA]A:0000X:0003Y:0025P:envMxdIZc - Add this to AA if applicable. $03/9DB460 RTSA:0001X:0003Y:0025P:envMxdIzc - Return ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $03/9A73A0 20 00LDY #$0020A:0001X:0003Y:0025P:envMxdIzc - Load 20 into A. $03/9A7691 80STA ($80),y[$7E:20A0]A:0001X:0003Y:0020P:envMxdIzc Store A in 7E2080 +20. (Elemental Weakness Byte) That is quite markedly different than...
$03/9A78A0 26 00LDY #$0026A:0000X:0003Y:0020P:envMxdIzc - Load 0026 into Y $03/9A7BB1 80LDA ($80),y[$7E:21A6]A:0000X:0003Y:0026P:envMxdIzc - Load A from Index +Y. (Elemental Immunity Byte) $03/9A7D85 A9STA $A9 [$00:00A9]A:0081X:0003Y:0026P:eNvMxdIzc - Store A in A9. $03/9A7F20 A8 9DJSR $9DA8 [$03:9DA8]A:0081X:0003Y:0026P:eNvMxdIzc - Jump to Subroutine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` $03/9DA829 12AND #$12A:0081X:0003Y:0026P:eNvMxdIzc Get rid of inapplicable bits. $03/9DAA4A LSR AA:0000X:0003Y:0026P:envMxdIZc - /2 A. $03/9DAB85 AASTA $AA [$00:00AA]A:0000X:0003Y:0026P:envMxdIZc - Store A in AA $03/9DADA5 A9LDA $A9 [$00:00A9]A:0000X:0003Y:0026P:envMxdIZc - Load A9. $03/9DAF29 09AND #$09A:0081X:0003Y:0026P:eNvMxdIzc - Get rid of inapplicable bits. $03/9DB10A ASL AA:0001X:0003Y:0026P:envMxdIzc - x2 A. $03/9DB205 AAORA $AA [$00:00AA]A:0002X:0003Y:0026P:envMxdIzc - Add to AA. $03/9DB460 RTSA:0002X:0003Y:0026P:envMxdIzc - Return ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $03/9A82F0 07BEQ $07 [$9A8B]A:0002X:0003Y:0026P:envMxdIzc - Branch if 00 to 039A8B ---------------------------------------------------------------------------------------------------------------------------------------- $03/9A84A0 21 00LDY #$0021A:0002X:0003Y:0026P:envMxdIzc - Load 0021 into Y. $03/9A8709 80ORA #$80A:0002X:0003Y:0021P:envMxdIzc - Add 80 to A (if applicable) $03/9A8991 80STA ($80),y[$7E:21A1]A:0082X:0003Y:0021P:eNvMxdIzc - Store A in 80. --------------------------------------------------------------------------------------------------------------------
Oh what a fool I've been! The answer was so simple!
$03/9A82 F0 07 BEQ $07 [$9A8B] A:0002 X:0003 Y:0026 P:envMxdIzc - Branch if 00 to 039A8B
Completely useless, it does nothing but Prevent the byte from being rewritten. It is the singular cause of the bug and nulling it does nothing adverse. Other armor types don't interfere with it as the specifications for where it is drawn is still the same Elemental Immunity Byte. So the easiest answer is...
$03/9A82 EA NOP A:0010 X:0003 Y:0026 P:envMxdIzc $03/9A83 EA NOP A:0010 X:0003 Y:0026 P:envMxdIzc
That will keep the x4 weakness and while it will keep the "Very Weak to" 80 stores in Very Weak, an 80 on its own does nothing and is not necessary to worry about.
I can't believe I missed such a simple solution, oh well. That should do it, hehe.
As seen above it ordinarily just takes the removed equipment's elemental weakness in the same way it puts it on. Loads its specific byte and adds or removes the appropriate byte.
Yes, I thought that the first time DeathLike2, but I found the cause of why it was writing 99 evasion into... well evasion. It was an uncleared value (80 of the Immunity bit, that gets added to Evasion, and finally is truncated down 63.) because Square didn't clean the value that contained it by the time it reached evasion. I fixed this by switching what byte stores the immunity byte for depositing later. Thereby leaving the appropriate byte clean for use by the time it reaches evasion.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 10, 2013, 12:37:20 AM
Quote
Oh what a fool I've been! The answer was so simple!
$03/9A82 F0 07 BEQ $07 [$9A8B] A:0002 X:0003 Y:0026 P:envMxdIzc - Branch if 00 to 039A8B
Completely useless, it does nothing but Prevent the byte from being rewritten. It is the singular cause of the bug and nulling it does nothing adverse. Other armor types don't interfere with it as the specifications for where it is drawn is still the same Elemental Immunity Byte. So the easiest answer is...
$03/9A82 EA NOP A:0010 X:0003 Y:0026 P:envMxdIzc $03/9A83 EA NOP A:0010 X:0003 Y:0026 P:envMxdIzc
That will keep the x4 weakness and while it will keep the "Very Weak to" 80 stores in Very Weak, an 80 on its own does nothing and is not necessary to worry about.
very nice. can $21A1 normally have any of the bottom bits set if the top bit is clear? if so, what happens?
as for Glass Helm/Mask, retooling it would definitely involve changing the order of things. and if it were to make you Very Weak to the "opposite" of anything you Resisted, would it also have the decency to bump up all such Resists to Immunities? doing one without the other seems a bit asymmetrical. it'd be like having dirty bathwater without actually having a baby, or however that expression goes.
-----
EDIT:
Quote
As it is specifically that a Very Weak value is written only if the Immune bit has other elements attached with it. I'm not sure where I got the idea that Immune stacked with other Elements.
so to be sure, Immunity will give Very Weak for "opposites" of Immune elements, but it won't do anything to transform Weak elements into Very Weak? or can gear with Immune transform Fire Shield's Fire weakness into severe Fire weakness, as written earlier?
iow, is $21A1 (as shown in your earlier post) the Very Weak elements, or is it a preliminary value that generates Very Weak after combining with normal Weak?
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 10, 2013, 09:45:31 AM
Oh what a fool I've been! The answer was so simple!
$03/9A82 F0 07 BEQ $07 [$9A8B] A:0002 X:0003 Y:0026 P:envMxdIzc - Branch if 00 to 039A8B
Completely useless, it does nothing but Prevent the byte from being rewritten. It is the singular cause of the bug and nulling it does nothing adverse. Other armor types don't interfere with it as the specifications for where it is drawn is still the same Elemental Immunity Byte. So the easiest answer is...
$03/9A82 EA NOP A:0010 X:0003 Y:0026 P:envMxdIzc $03/9A83 EA NOP A:0010 X:0003 Y:0026 P:envMxdIzc
That will keep the x4 weakness and while it will keep the "Very Weak to" 80 stores in Very Weak, an 80 on its own does nothing and is not necessary to worry about.
Quote
very nice. can $21A1 normally have any of the bottom bits set if the top bit is clear? if so, what happens?
as for Glass Helm/Mask, retooling it would definitely involve changing the order of things. and if it were to make you Very Weak to anything you Resisted, would it also have the decency to bump up all such Resists to Immunities? doing one without the other seems a bit asymmetrical. it'd be like having dirty bathwater without actually having a baby, or however that expression goes.
Yep, it works perfectly. The reason it works this way is because every armor will be going through the "Does the Armor cause Very Weak?" instead of only Armor that have 00 in that regards, so an 80 will be put regardless because it... hmm... well this is interesting. I just tested it and it does nothing. That 80 is completely superfluous on characters. The x4 Weakness just comes by virtue of being in that byte rather than the one next to it, nothing to do with the 80 value, so we can freely erase that +80 part. Since it does nothing.
-----
EDIT:
Quote
As it is specifically that a Very Weak value is written only if the Immune bit has other elements attached with it. I'm not sure where I got the idea that Immune stacked with other Elements.
Quote
so to be sure, Immunity will give Very Weak for "opposites" of Immune elements, but it won't do anything to transform Weak elements into Very Weak? or can gear with Immune transform Fire Shield's Ice weakness into severe Ice weakness, as written earlier?
iow, is $21A1 (as shown in your earlier post) the Very Weak elements, or is it a preliminary value that generates Very Weak after combining with normal Weak?
I was wrong, I'm not really sure why I thought that was the case, likely because it is the way Absorb works. My above example would have worked if I said Cursed Ring instead of Glass Mask, that is what I was thinking about, Equipment with an Absorb Element partners with initial Elemental Values (because they share the same byte) the reason Immune doesn't partner with initial values is because the two bytes are never read with one another.
To make it clear...
1 - Fire 2 - Ice 4 - Bolt 8 - Dark 10 - Holy 20 - Air 40 - Absorb 80 - Immune.
Immune is never written into the normal elemental resistance byte because it is an 80 and a BMI somewhere says it is placed in the Elemental Immunity Byte, not that the Immunity Bit does anything outside of being stored in its own byte. Weakness and Very Weak are kept separate with Very Weak taking precedence where applicable. The Immunity Byte draws its own set of values in Character Byte 21 and so it ignores already laid out weaknesses.
This is where the issue comes in. How do you get one to recognize the other without throwing off the other? The routine says this...
$03/9A78 A0 26 00 LDY #$0026 A:0000 X:0003 Y:0020 P:envMxdIzc - Load 0026 into Y $03/9A7B B1 80 LDA ($80),y[$7E:21A6] A:0000 X:0003 Y:0026 P:envMxdIzc - Load A from Index +Y. (Elemental Immunity Byte) $03/9A7D 85 A9 STA $A9 [$00:00A9] A:0081 X:0003 Y:0026 P:eNvMxdIzc - Store A in A9. $03/9A7F 20 A8 9D JSR $9DA8 [$03:9DA8] A:0081 X:0003 Y:0026 P:eNvMxdIzc - Jump to Subroutine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` $03/9DA8 29 12 AND #$12 A:0081 X:0003 Y:0026 P:eNvMxdIzc Get rid of inapplicable bits. $03/9DAA 4A LSR A A:0000 X:0003 Y:0026 P:envMxdIZc - /2 A. $03/9DAB 85 AA STA $AA [$00:00AA] A:0000 X:0003 Y:0026 P:envMxdIZc - Store A in AA $03/9DAD A5 A9 LDA $A9 [$00:00A9] A:0000 X:0003 Y:0026 P:envMxdIZc - Load A9. $03/9DAF 29 09 AND #$09 A:0081 X:0003 Y:0026 P:eNvMxdIzc - Get rid of inapplicable bits. $03/9DB1 0A ASL A A:0001 X:0003 Y:0026 P:envMxdIzc - x2 A. $03/9DB2 05 AA ORA $AA [$00:00AA] A:0002 X:0003 Y:0026 P:envMxdIzc - Add to AA. $03/9DB4 60 RTS A:0002 X:0003 Y:0026 P:envMxdIzc - Return ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $03/9A82 F0 07 BEQ $07 [$9A8B] A:0002 X:0003 Y:0026 P:envMxdIzc - Branch if 00 to 039A8B ---------------------------------------------------------------------------------------------------------------------------------------- $03/9A84 A0 21 00 LDY #$0021 A:0002 X:0003 Y:0026 P:envMxdIzc - Load 0021 into Y. $03/9A87 09 80 ORA #$80 A:0002 X:0003 Y:0021 P:envMxdIzc - Add 80 to A (if applicable) $03/9A89 91 80 STA ($80),y[$7E:21A1] A:0082 X:0003 Y:0021 P:eNvMxdIzc - Store A in 80. --------------------------------------------------------------------------------------------------------------------
Would switching it from 26 to 25 do the trick? Or wouldn't that create an effect that whenever any element goes through there it would create a x4 Weakness? I'm a little flummoxed on how to proceed from there.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 10, 2013, 11:36:23 AM
i'd be inclined not to mess with it. making it extend to equipment outside of the one with the actual Immunity is a bit overreaching. as is having normal Weaknesses involved.
there's already a nice parallelism (as seen in 03/9A69 and 03/9A78): Resist gives Weak to the "opposite" element, and Immune gives Very Weak to the "opposite" element. greater magnitude in one direction is matched by larger in the other.
(out of curiosity: do they work the same in reverse? will initial Weak give Resist to opposite, or Very Weak provide Immune to opposite?)
i understand the desire to try and "complete" an item like Glass Helm that has a bit set. but it's always possible that it was set for no good reason, or that whatever aborted plan the designers had in mind with it simply can't be discerned from available information.
a couple of items in FF6 -- Paladin Shield and Memento Ring, iirc -- have a mystery bit set that does jack squat. it can be fun to speculate on why it's there, but there's no actionable info. and it's possible that whatever goal the designers had for it was eventually accomplished by one of the items' many other data fields.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Deathlike2 on October 10, 2013, 12:02:26 PM
(out of curiosity: do they work the same in reverse? will initial Weak give Resist to opposite, or Very Weak provide Immune to opposite?)
It does. However, physical elemental attacks operate completely differently than magical elemental attacks.
The FireDog example I use often reflects this. If you give Yang the FireClaw, he will do half damage than normal. If you give him the IceClaw, he will do 4 times as much damage than normal (the target is very weak to Ice). If you equip both the Fire AND Ice Claws, he will expose the monster's elemental weakness, despite having a weapon that reacts to the monster's resistance.
Quote
i understand the desire to try and "complete" an item like Glass Helm that has a bit set. but it's always possible that it was set for no good reason, or that whatever aborted plan the designers had in mind with it simply can't be discerned from available information.
Having seen how the Cursed Ring works, where elemental equipment benefited from the effects of the Cursed Ring (resistance to elemental -> Absorbs elemental), Immune ideally would reflect this. Say you had an Ice Shield + Cursed Ring combo... all Fire elemental magic attacks would be absorbed (think Rubicante). Having an Ice Shield + Flame Armor would allow you to absorb both.
Quote
a couple of items in FF6 -- Paladin Shield and Memento Ring, iirc -- have a mystery bit set that does jack squat. it can be fun to speculate on why it's there, but there's no actionable info. and it's possible that whatever goal the designers had for it was eventually accomplished by one of the items' many other data fields.
It is possible that the Paladin Shield was intended for a small story bit or event bit (perhaps from the guy you get it from)... or perhaps some mechanism to get more Cursed Shields. For the Memento Ring, you figure some story/event thing would occur somewhere along the line... ideally with the fight with Wrexsoul (3rd Memento Ring). Even if you didn't have Locke, the Thief Knife would have provided an opportunity for Shadow to steal it... imagine if the entire Dream World for Cyan changed just a little bit if you had Shadow+Relm involved (and perhaps Strago, for some better context). It would be nice if the 3rd Memento Ring was usable by Strago as a result.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 10, 2013, 05:35:22 PM
i'd be inclined not to mess with it. making it extend to equipment outside of the one with the actual Immunity is a bit overreaching. as is having normal Weaknesses involved.
there's already a nice parallelism (as seen in 03/9A69 and 03/9A78): Resist gives Weak to the "opposite" element, and Immune gives Very Weak to the "opposite" element. greater magnitude in one direction is matched by larger in the other.
(out of curiosity: do they work the same in reverse? will initial Weak give Resist to opposite, or Very Weak provide Immune to opposite?)
i understand the desire to try and "complete" an item like Glass Helm that has a bit set. but it's always possible that it was set for no good reason, or that whatever aborted plan the designers had in mind with it simply can't be discerned from available information.
a couple of items in FF6 -- Paladin Shield and Memento Ring, iirc -- have a mystery bit set that does jack squat. it can be fun to speculate on why it's there, but there's no actionable info. and it's possible that whatever goal the designers had for it was eventually accomplished by one of the items' many other data fields.
I think DeathLike2 explained it in a better way than I could. I still don't fully grasp why Square took this path in particular. The easiest thing to do would have been to make 80 on the normal elemental byte be read as Immune (rather than set up an entirely separate byte for it) and add an exception for it if this Immune bit is triggered to (BMI) instead to use Very Weak instead of Weak elemental figurings. But 80 on the normal elemental byte does nothing.
But no, there is nothing called "Initial: Weak" in FFIV. No piece of equipment will make the player weak to a specific element with having a corresponding resistance. Weakness alone only exists with Monsters and they never deal with Resistance/Immune Weak/Very Weak bytes in the way that characters do. They're just set at the start of battle. There is one interesting exception but its not related to weaknesses. Enemies that are considered weak to Air are always considered Floating, so that's their workaround for that.
I wouldn't mind trying to think up a way to make Glass Mask unique, but I think that may be best to try with an Auto-Reflect, since its gained from the most Reflect intensive foe in the game And it is called "Glass".
There are mystery bits like that in weapons in FFIV as as well. Bit 1 seems to make it impossible to get Critical Hits (and I still have no idea where this is stored), Bit 2 is attached only to Cid's hammer, but again, no noticeable changes. Bit 4 is unknown, Bit 8 is unknown, Bit 10 is unknown, Bit 20 is Long Range, Bit 40 is Throwable, and Bit 80 is Magnetic.
So FFIV has its fair share of "possibly" useless bits. (Granted I think it would be neat to try and hack some purpose in for them)
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Deathlike2 on October 10, 2013, 07:21:48 PM
But no, there is nothing called "Initial: Weak" in FFIV. No piece of equipment will make the player weak to a specific element with having a corresponding resistance. Weakness alone only exists with Monsters and they never deal with Resistance/Immune Weak/Very Weak bytes in the way that characters do. They're just set at the start of battle. There is one interesting exception but its not related to weaknesses. Enemies that are considered weak to Air are always considered Floating, so that's their workaround for that.
Well, technically there is, but it's exposing a bug.
If you have a save file and equip the Adamant Armor on Paladin Cecil (and perhaps Kain as well)... then reset the game. Start a new game.
Fight the Mist Dragon battle and trigger the Cold Mist counterattack. This attack will deal twice as much damage to DK Cecil (and possibly Kain as well). The ColdMist attack is actually an ice elemental attack (like the MomBomb's "explosion" is actually a fire elemental attack).
One of the things that doesn't get cleared out properly is Cecil's natural stats on a reset... (some things may not get reset properly in fact, under such circumstances).
That is besides the point though...
The Ice/Flame Shield/Armor provide an interesting case of trading weakness for resistance. The problem though is that for physical elemental attacks, this becomes a real problem... as the Icebrand or the even the Flametongue are weapons that would deal more damage than they normally should on something that wields the Protect Ring (which protects against both). Fortunately this is addressed in FF4A... I don't believe it was fixed in the Wonderswan version (I'd have to actually check).
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 10, 2013, 07:28:41 PM
Those bytes aren't cleared? What? Bah, Square that's just lazy... in any case the Physical Attack property is an odd one, I wonder if that's part of the reason that enemies don't have any Elemental Physical Attacks in the normal FFII, despite the system fully supporting it? I can't think of any fix to that one either.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Deathlike2 on October 10, 2013, 08:00:36 PM
Those bytes aren't cleared? What? Bah, Square that's just lazy... in any case the Physical Attack property is an odd one, I wonder if that's part of the reason that enemies don't have any Elemental Physical Attacks in the normal FFII, despite the system fully supporting it? I can't think of any fix to that one either.
It is very much the reason. Imagine taking twice as much damage as normal on physical attacks... which are "unexplained" to the trained player.
I abuse this understanding in my hack... giving more meaning to non-elemental protection (sometimes less elemental protection may be preferable). Otherwise it is easy to take minimal physical damage otherwise.
If any armor (particularly the Crystal Armor set) had Holy/Darkness resistance.... imagine how monsters would twist Crystal Armor into "Cecil is my biatch".
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 10, 2013, 08:22:41 PM
That is an interesting idea, not that any enemy ever uses a Dark Elemental attack, but if the Crystal Armor resists Dark it would be weak to Holy, leaving him vulnerable to seven big end-game foes.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 10, 2013, 11:51:14 PM
Having seen how the Cursed Ring works, where elemental equipment benefited from the effects of the Cursed Ring (resistance to elemental -> Absorbs elemental), Immune ideally would reflect this. Say you had an Ice Shield + Cursed Ring combo... all Fire elemental magic attacks would be absorbed (think Rubicante). Having an Ice Shield + Flame Armor would allow you to absorb both.
are the Resists still retained in their original RAM byte? will they still cause Weak to their "opposite" element, or will having been reclassified as Absorb prevent that from happening? iow, order of operations might matter if the answer to the first question is "no".
also, is there any further Penalty for Absorb? e.g. will opposite elements become Very Weak (or instant death ;) )?
------
Quote from: Grimoire LD
I still don't fully grasp why Square took this path in particular. The easiest thing to do would have been to make 80 on the normal elemental byte be read as Immune (rather than set up an entirely separate byte for it) and add an exception for it if this Immune bit is triggered to (BMI) instead to use Very Weak instead of Weak elemental figurings. But 80 on the normal elemental byte does nothing.
that would make things a bit all-or-none, no? suppose you have one piece of equipment that Resists ElementX, and another that is Immune to ElementY. in your scenario, i think that ElementX and ElementY would wind up both being treated as Immune.
ah, maybe that's what you were striving for.
but i see merit to the existing way (with your bugfix to stop lingering Very Weak applied, of course) of having Resists and Immunities alongside one another, along with their varying penalties of Weaks and Very Weaks. obviously, maintaining multiple categories has more precision. and as i mentioned in my prior post, there's a nice parallelism to this system.
i would say that Square took this path because they wanted you to be able to have Resists and Immunities co-existing. it is a departure from what they did with Absorb, but still plenty logical. despite Absorb and Immune starting off as bits in the same data byte, they indeed had different systems employed for their implementation. it's hard to pick one method over the other (though i find the Absorb way less intuitive).
Having seen how the Cursed Ring works, where elemental equipment benefited from the effects of the Cursed Ring (resistance to elemental -> Absorbs elemental), Immune ideally would reflect this. Say you had an Ice Shield + Cursed Ring combo... all Fire elemental magic attacks would be absorbed (think Rubicante). Having an Ice Shield + Flame Armor would allow you to absorb both.
are the Resists still retained in their original RAM byte? will they still cause Weak to their "opposite" element, or will having been reclassified as Absorb prevent that from happening? iow, order of operations might matter if the answer to the first question is "no".
I believe the answer is yes? The order of operations as described in my algo guide is pretty much what shows precedence though...
Quote
also, is there any further Penalty for Absorb? e.g. will opposite elements become Very Weak (or instant death ;) )?
Instant death by elementals can be coded into the monster's script... but actually it also means Drain weaponry (Blood Sword, Blood Lance) or Drain based physical attacks deal half damage (but not the spells based on that behavior, oddly, like Drain and Osmose).
It is technically "possible" to make a monster very weak vs Absorb/Drain attacks... and yet if Drain/Osmose were coded to factor in the Absorb bit, it would be able to resist half the damage (but since it's not coded that way, it doesn't).
------
Quote
Quote from: Grimoire LD
I still don't fully grasp why Square took this path in particular. The easiest thing to do would have been to make 80 on the normal elemental byte be read as Immune (rather than set up an entirely separate byte for it) and add an exception for it if this Immune bit is triggered to (BMI) instead to use Very Weak instead of Weak elemental figurings. But 80 on the normal elemental byte does nothing.
that would make things a bit all-or-none, no? suppose you have one piece of equipment that Resists ElementX, and another that is Immune to ElementY. in your scenario, i think that ElementX and ElementY would wind up both being treated as Immune.
ah, maybe that's what you were striving for.
but i see merit to the existing way (with your bugfix to stop lingering Very Weak applied, of course) of having Resists and Immunities alongside one another, along with their varying penalties of Weaks and Very Weaks. obviously, maintaining multiple categories has more precision. and as i mentioned in my prior post, there's a nice parallelism to this system.
i would say that Square took this path because they wanted you to be able to have Resists and Immunities co-existing. it is a departure from what they did with Absorb, but still plenty logical. despite Absorb and Immune starting off as bits in the same data byte, they indeed had different systems employed for their implementation. it's hard to pick one method over the other (though i find the Absorb way less intuitive).
They don't really coexist though... not in this game. Absorb and Immune have precedence depending on the game port, and whether it is physical and magical. In FF5, FF6, and onwards, there is a distinction intentionally made. Just not this game.
Dragonsbreathren would be a better person to answer this question.
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: assassin on October 11, 2013, 02:59:28 AM
Quote from: Deathlike2
They don't really coexist though... not in this game. Absorb and Immune have precedence depending on the game port, and whether it is physical and magical. In FF5, FF6, and onwards, there is a distinction intentionally made. Just not this game.
i mean they can coexist in that a character will resist ElementX and be immune to ElementY. this is relevant should they be attacked with the two elements separately. that distinction wouldn't be possible with the hypothetical change i was responding to, as both'd simply be Immune.
anyway, i realize it's different when both elements are in one attack. i read about your Ice and Fire Claw example.. that's just weird. are the weapons not treated as separate strikes?
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Grimoire LD on October 11, 2013, 07:43:54 AM
are the Resists still retained in their original RAM byte? will they still cause Weak to their "opposite" element, or will having been reclassified as Absorb prevent that from happening? iow, order of operations might matter if the answer to the first question is "no".
also, is there any further Penalty for Absorb? e.g. will opposite elements become Very Weak (or instant death ;) )?
Having something classified as Absorb does nothing to the corresponding weakness, indeed.
that would make things a bit all-or-none, no? suppose you have one piece of equipment that Resists ElementX, and another that is Immune to ElementY. in your scenario, i think that ElementX and ElementY would wind up both being treated as Immune.
ah, maybe that's what you were striving for.
but i see merit to the existing way (with your bugfix to stop lingering Very Weak applied, of course) of having Resists and Immunities alongside one another, along with their varying penalties of Weaks and Very Weaks. obviously, maintaining multiple categories has more precision. and as i mentioned in my prior post, there's a nice parallelism to this system.
i would say that Square took this path because they wanted you to be able to have Resists and Immunities co-existing. it is a departure from what they did with Absorb, but still plenty logical. despite Absorb and Immune starting off as bits in the same data byte, they indeed had different systems employed for their implementation. it's hard to pick one method over the other (though i find the Absorb way less intuitive).
Indeed, it does make things all or none, but seeing the behavior of the Cursed Ring, I can't help but think that may have been their original intention before they implemented in the Immune system. In any case you bring up a fair point, it is less versatile and the game does respond positively to having multiple resistances and immunities of different sorts.
FFIV:DS uses a slightly altered system which, in my opinion, is more balance oriented and in that game enemies have Elemental Physicals enabled and to my recollection I recall nothing bad about them in that game. I believe they either avoided the origin or just coded it in a different fashion.
We can take a look at my documented Fight Routine and see if that is indeed the case in FFIV though...
$03/C650A9 02LDA #$02A:0000X:0300Y:0000P:envMxdiZC - Load a 02 into A. $03/C6528D FE 38STA $38FE [$7E:38FE]A:0002X:0300Y:0000P:envMxdizC - Store A at 7E38FE (presumably a data altering field x2 (Default) Power) $03/C6558D FF 38STA $38FF [$7E:38FF]A:0002X:0300Y:0000P:envMxdizC - Store A at 7E38FF (as above) $03/C658AD 99 26LDA $2699 [$7E:2699]A:0002X:0300Y:0000P:envMxdizC - Load A from Caster's Attack Elemental Copy Data. $03/C65B8D 00 36STA $3600 [$7E:3600]A:0008X:0300Y:0000P:envMxdizC - Store A in 7E3600. $03/C65E2D 21 27AND $2721 [$7E:2721]A:0008X:0300Y:0000P:envMxdizC - Check the value of A against the Target's Very Weak Elemental. $03/C661F0 07BEQ $07 [$C66A]A:0000X:0300Y:0000P:envMxdiZC - Branch if there is no match to 03C66A. -------------------------------------------------------------------------------------------------------------------------------- $03/C663A9 08LDA #$08A:0008X:0400Y:0000P:envMxdizC - Load a 08 into A. $03/C6658D FE 38STA $38FE [$7E:38FE]A:0008X:0400Y:0000P:envMxdizC - Store A in 7E38FE (Presumably a data altering field - x4 Power) $03/C66880 2BBRA $2B [$C695]A:0008X:0400Y:0000P:envMxdizC - Always Branch to 03C695. -------------------------------------------------------------------------------------------------------------------------------- $03/C66AAD 99 26LDA $2699 [$7E:2699]A:0000X:0300Y:0000P:envMxdiZC - Load Caster's Attack Elemental from Data Copy into A. $03/C66D2D 20 27AND $2720 [$7E:2720]A:0008X:0400Y:0000P:envMxdizC - Check the value of A against the Target's Elemental Weakness. $03/C670F0 07BEQ $07 [$C679]A:0008X:0400Y:0000P:envMxdizC - Branch if there is no match to 03C66A. ------------------------------------------------------------------------------------------------------------------------------- $03/C672A9 04LDA #$04A:0008X:0400Y:0000P:envMxdizC - Load 04 into A. $03/C6748D FE 38STA $38FE [$7E:38FE]A:0004X:0400Y:0000P:envMxdizC Store it at 38FE (x2 Power) $03/C67780 1CBRA $1C [$C695]A:0004X:0400Y:0000P:envMxdizC - Always Branch to 03C695. --------------------------------------------------------------------------------------------------------------------------------- $03/C679AD 99 26LDA $2699 [$7E:2699]A:0000X:0000Y:0000P:envMxdiZC - Load Caster's Elemental Attack from Data Copy into A. $03/C67C2D 26 27AND $2726 [$7E:2726]A:0000X:0000Y:0000P:envMxdiZC - Check it against Target's Elemental Immunity. $03/C67FF0 07BEQ $07 [$C688]A:0000X:0000Y:0000P:envMxdiZC - Branch if there is no match to 03C688. ---------------------------------------------------------------------------------------------------------------------------------- $03/C681A9 00LDA #$00A:0008X:0400Y:0000P:envMxdizC - Load 00 into A. $03/C6838D FE 38STA $38FE [$7E:38FE]A:0000X:0400Y:0000P:envMxdiZC - Store A in 38FE (x0 Power=1 Damage no matter what) $03/C68680 0DBRA $0D [$C695]A:0000X:0400Y:0000P:envMxdiZC - Branch to 03C695. ------------------------------------------------------------------------------------------------------------------------------------ $03/C688AD 99 26LDA $2699 [$7E:2699]A:0000X:0400Y:0000P:envMxdiZC - Load A from Caster's Elemental Attack Data in Data Copy. $03/C68B2D 25 27AND $2725 [$7E:2725]A:0008X:0400Y:0000P:envMxdizC - Check it against the Target's Resistance Byte in Data Copy. $03/C68EF0 05BEQ $05 [$C695]A:0008X:0400Y:0000P:envMxdizC - Branch to 03C695 if there is no match. ------------------------------------------------------------------------------------------------------------------------------------- $03/C690A9 01LDA #$01A:0008X:0400Y:0000P:envMxdizC - Load 01 into A. $03/C6928D FE 38STA $38FE [$7E:38FE]A:0001X:0400Y:0000P:envMxdizC Store it in a damage altering field (x1 (1/2) Power -----------------------------------------------------------------------------------------------------------------------------------
Very Weak/Weak/Immune/Resistance, as has been said.
It would be a very simple matter to reorder these to something more conducive to accurately reflect the order of which it should go. And FFIV has the strange case of branching away whenever it hits upon a certain facet. But to put it plainly. The attacks made by any dual-wielder are calculated together, including their elementals, which is why the Ice and Fireclaw work as they do. The question is, what should be the order these go in?
The Tower of Babil Docs has the way it works with spell in clear portions. (using V1.0 instead of 1.1 as my research has focused on) at the bottom of the page, and that goes Immune(+Absorb)/Resists(+Absorb)/Very Weak/Weak.
http://rb.thundaga.com/tob/spellcode.txt
Absorb Elemental is taken from a very different place in the Fight Routine and is never invoked in relation to Elementals.
[/code]
Title: Re: Immune and 99% Evade, Glitch or Design? - Documentation Within
Post by: Deathlike2 on October 11, 2013, 02:11:28 PM
They don't really coexist though... not in this game. Absorb and Immune have precedence depending on the game port, and whether it is physical and magical. In FF5, FF6, and onwards, there is a distinction intentionally made. Just not this game.
i mean they can coexist in that a character will resist ElementX and be immune to ElementY. this is relevant should they be attacked with the two elements separately. that distinction wouldn't be possible with the hypothetical change i was responding to, as both'd simply be Immune.
Well, in the way it is currently set up for equipment, I guess the technical answer is yes. However, the Adamant Armor covers all the elementals that can be resisted naturally though armor (no armor resists Holy or Darkness, thus difficult to test this with.
:edit: Using FF4A US (GBA) to test with, apparently I could test it... but it's rather different. There is buggy behavior that I'm using, but it's relevent... that some of the weapons are treated as armor, so the "buggy" Dragon Claw that is holy elemental would be treated as Holy resistance. Immune in the GBA port stacks (Yang was dealt 1 damage) when combined with the Adamant Armor. When I equipped the Hero Shield on Yang, Absorb overrode (or took priority over) the Immune bit.
Quote
anyway, i realize it's different when both elements are in one attack. i read about your Ice and Fire Claw example.. that's just weird. are the weapons not treated as separate strikes?
Physical attacks are treated radically different from magical attacks, as far as the game is concerned.
Here's the best example... the Dark Elf.
It is one of the few monsters that is weak vs an element (Holy) and absorbs the same element (Holy).
If you were to use the spell on the monster (which is not normally possible, but just for the sake of discussion), it would get healed from the Holy attack.
If you were to use a Holy elemental sword like the Legend Sword, you would deal twice as damage as you'd normally would.