øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=printpage;topic=580.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index03b2-2.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=580.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index03b2-2.html.zx'†g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ0P] âOKtext/htmlISO-8859-1gzip8:Ö âÿÿÿÿÿÿÿÿTue, 10 Mar 2020 12:37:19 GMT0ó°° ®0®P®€§²ð®'†g^ÿÿÿÿÿÿÿÿ†- â Print Page - FF2 Battle Script That's Different Than FF4

Board of Slick

Library of the Ancients => Final Fantasy IV Research & Development => Topic started by: Deathlike2 on June 02, 2008, 04:07:57 PM

Title: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 02, 2008, 04:07:57 PM
Believe it or not, most people have an ill-concieved notion that FF2's battle script is radically different than FF4 (I'll have a separate thread on FF4ET's battle scripts, just to point it out), but that's simply not the case. However, there is only one script that I know of that is actually different than the original game.

Check out the Last Arm's battle script:

FF2 and FF4ET:

Battle script 0x6F:
Code: [Select]
Always
    Cast Search ($90)
    (End of Turn)
    Cast Magnet ($81)
    (End of Turn)
    Cast Search ($90)
    (End of Turn)
    Cast Beam ($94)

Counter script 0xFB:
Code: [Select]
If Receives a Damage Counter
    Battle Message $76
    Cast Slap ($63)

Note: The parsed counter script is wrong.

It's more like this:
If current HP is lower than 1/8 (aka 2/16) of MaxHP, then cast Fission (this suicide attack that hits all targets equally the amount of HP left). In FF4A, Fission is changed to more of a single targeted Explode attack (someone fucking neutered this for some stupid reason). Amazing eh?

FF4 has it slightly different.

FF4:

Battle script 0x6F:
Code: [Select]
Always
    Cast タ-ゲッティング ($90)
    (End of Turn)
    Cast でんじば ($81)

Counter script 0xFB:
Code: [Select]
If Receives a Damage Counter
    Battle Message $76
    Cast ひらてうち ($63)

Note: The counter script is the same as the original (still parsed wrong, so it's the same reaction).

The only difference is the attack script, which doesn't do the extra targeting and Beam attack.

It's minor, and that's the only change AFAIK. In any case, 99% of the battle code is the same.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 02, 2008, 05:30:13 PM
Quote
If current HP is lower than 1/8 (aka 2/16) of MaxHP

To be exact, the reaction script is "if takes HP damage and HP is less than 1,000, cast Fission."

That's really the only battle script that's changed? That's kind of amazing, considering all the other changes they made. I guess there's no reason why they had to change the scripts, I just assumed they had changed more. What about changing the value of or completely removing a script, like Milon Z.'s Dullsong counter to fire spells?
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 02, 2008, 05:35:49 PM
Quote
If current HP is lower than 1/8 (aka 2/16) of MaxHP

Quote
To be exact, the reaction script is "if takes HP damage and HP is less than 1,000, cast Fission."

I don't think it's 1000.. I believe it's MaxHP proportional based, but I could be totally wrong (I will have to test this out to be sure. There's whole series of them in the Octomammoth battle and I really doubt they would use such a fixed number to test against.

3rd Edit: Hmm.. I've tested this against Kainazzo/Cagnazzo in FF4 and it does seem to use the hardcored HP number. Hmm.. I wonder if they made a separate one for Octomammoth...

Quote
That's really the only battle script that's changed? That's kind of amazing, considering all the other changes they made. I guess there's no reason why they had to change the scripts, I just assumed they had changed more. What about changing the value of or completely removing a script, like Milon Z.'s Dullsong counter to fire spells?

Ah, I forgot about that. Let's go Bio!

Edit: I'd say if there are any actual changes to the battle script, it would be subtle like the Milon-Z/Scamaglione battle.. though I dunno why Slow would dramatically change the outcome of the battle (even though it's the most effective spell, but it makes Poison significantly less effective).

2nd Edit: It looks like the counter script was intentionally omitted for this battle.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 02, 2008, 08:16:52 PM
Quote
I don't think it's 1000.. I believe it's MaxHP proportional based, but I could be totally wrong (I will have to test this out to be sure. There's whole series of them in the Octomammoth battle and I really doubt they would use such a fixed number to test against.

3rd Edit: Hmm.. I've tested this against Kainazzo/Cagnazzo in FF4 and it does seem to use the hardcored HP number. Hmm.. I wonder if they made a separate one for Octomammoth...

I thought the same thing when I was testing last week, but I performed the same tests against Kainazzo and found the same thing. I then found the hex data to support this. All the HP limits are exact number based. Octomamm is actually a special case with no HP checks at all. His attack script is just to attack, it's his reaction script that's interesting. Here's how it works:

Code: [Select]
if HP damage and condition flag is 02
Change to form 05, set speed to index 09, increment condition flag by 01
else if HP damage and condition flag is 04
Change to form 06, set speed to index 08, increment condition flag by 01
else if HP damage and condition flag is 06
Change to form 07, set speed to index 07, increment condition flag by 01
else if HP damage and condition flag is 08
Change to form 08, set speed to index 06, increment condition flag by 01
else if HP damage and condition flag is 0A
Change to form 09, set speed to index 05, increment condition flag by 01
else if HP damage and condition flag is 0C
Change to form 0A, set speed to index 04, increment condition flag by 01, display messages 48 and 49
else if HP damage and condition flag is 0E
Change to form 0B, set speed to index 03, increment condition flag by 01
else if HP damage
Increment condition flag by 01

So basically, Octomamm changes forms every two times he takes HP damage.

Quote
Edit: I'd say if there are any actual changes to the battle script, it would be subtle like the Milon-Z/Scamaglione battle.. though I dunno why Slow would dramatically change the outcome of the battle (even though it's the most effective spell, but it makes Poison significantly less effective).
2nd Edit: It looks like the counter script was intentionally omitted for this battle.

I'm sure it was intentionally omitted, to make the battle easier. As it is, all Milon Z. does is attack. Seems like one of the elemental battles should have a bit more complexity than this.  :finger: If you want to restore the DullSong counter, you can change the data at 73392 to DC0001004200001F8096. I had to sacrifice a byte, though, so I took out his elemental weaknesses. Makes the battle a bit more difficult; though there's no reason to attack with Fire now, it does execute the counter properly. You could remove his spell power byte instead, but I'm not sure how that would impact casting DullSong. Anyway, just a little fix for anyone that's interested.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 02, 2008, 08:31:36 PM
Quote
I don't think it's 1000.. I believe it's MaxHP proportional based, but I could be totally wrong (I will have to test this out to be sure. There's whole series of them in the Octomammoth battle and I really doubt they would use such a fixed number to test against.

3rd Edit: Hmm.. I've tested this against Kainazzo/Cagnazzo in FF4 and it does seem to use the hardcored HP number. Hmm.. I wonder if they made a separate one for Octomammoth...

I thought the same thing when I was testing last week, but I performed the same tests against Kainazzo and found the same thing. I then found the hex data to support this. All the HP limits are exact number based. Octomamm is actually a special case with no HP checks at all. His attack script is just to attack, it's his reaction script that's interesting. Here's how it works:

Code: [Select]
if HP damage and condition flag is 02
Change to form 05, set speed to index 09, increment condition flag by 01
else if HP damage and condition flag is 04
Change to form 06, set speed to index 08, increment condition flag by 01
else if HP damage and condition flag is 06
Change to form 07, set speed to index 07, increment condition flag by 01
else if HP damage and condition flag is 08
Change to form 08, set speed to index 06, increment condition flag by 01
else if HP damage and condition flag is 0A
Change to form 09, set speed to index 05, increment condition flag by 01
else if HP damage and condition flag is 0C
Change to form 0A, set speed to index 04, increment condition flag by 01, display messages 48 and 49
else if HP damage and condition flag is 0E
Change to form 0B, set speed to index 03, increment condition flag by 01
else if HP damage
Increment condition flag by 01

So basically, Octomamm changes forms every two times he takes HP damage.

Hmm, that actually makes some sense.

Quote
Quote
Edit: I'd say if there are any actual changes to the battle script, it would be subtle like the Milon-Z/Scamaglione battle.. though I dunno why Slow would dramatically change the outcome of the battle (even though it's the most effective spell, but it makes Poison significantly less effective).
2nd Edit: It looks like the counter script was intentionally omitted for this battle.

I'm sure it was intentionally omitted, to make the battle easier. As it is, all Milon Z. does is attack. Seems like one of the elemental battles should have a bit more complexity than this.  :finger: If you want to restore the DullSong counter, you can change the data at 73392 to DC0001004200001F8096. I had to sacrifice a byte, though, so I took out his elemental weaknesses. Makes the battle a bit more difficult; though there's no reason to attack with Fire now, it does execute the counter properly. You could remove his spell power byte instead, but I'm not sure how that would impact casting DullSong. Anyway, just a little fix for anyone that's interested.

Well, given that Slow benefits with with the Spell Multiplier, if his spell multiplier is at least greater than 2 (the highest magic defense multiplier  most characters) have at this time is 1x, it always succeeds (he has a spell multiplier of 8, so it's overkill). Killing it gives a decent chance of evasion.. but it will fail a lot more since everyone is targeted... (I'm trying to recall some spell success rules)... I believe now it's a little different between characters and enemies.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: bond697 on June 03, 2008, 02:08:35 AM
if you guys don't mind me asking, HOW did you come up with these battle scripts? was it through interpreting the hex code? or did you disassemble the rom(or parts thereof?) and use the asm? if it's some kind of disassembly, could i get a look at it?

i know it's probably a dumb question, but i'm still learning about this rom hacking thing, and i can't help but wonder. i was also wondering the same thing before about how you discovered yang's oddball battle script that had to do with the pictures i posted on gamefaqs.

if you could explain it a lil bit, or maybe point me to a document that could, i'd really appreciate it. i've been working hard over here reading, etc, and practicing hacking with my hex editor and all the docs i can find, but i'd love to get to the level that you guys are at one day. so, i wanted to know how you do what it is that you're doing.

anyway, thanks in advance either way.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 02:23:07 AM
if you guys don't mind me asking, HOW did you come up with these battle scripts? was it through interpreting the hex code? or did you disassemble the rom(or parts thereof?) and use the asm? if it's some kind of disassembly, could i get a look at it?

Someone did the bulk of the analysis before I did. However, there are some areas that simply make no sense, which the common watching and see mode comes into play.

Quote
i know it's probably a dumb question, but i'm still learning about this rom hacking thing, and i can't help but wonder. i was also wondering the same thing before about how you discovered yang's oddball battle script that had to do with the pictures i posted on gamefaqs.

if you could explain it a lil bit, or maybe point me to a document that could, i'd really appreciate it. i've been working hard over here reading, etc, and practicing hacking with my hex editor and all the docs i can find, but i'd love to get to the level that you guys are at one day. so, i wanted to know how you do what it is that you're doing.

anyway, thanks in advance either way.

Try the links section.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: bond697 on June 03, 2008, 02:32:54 AM

Try the links section.

thanks for the responses.

if i understand you right, then something like this...

Quote
if HP damage and condition flag is 02
   Change to form 05, set speed to index 09, increment condition flag by 01
else if HP damage and condition flag is 04
   Change to form 06, set speed to index 08, increment condition flag by 01
else if HP damage and condition flag is 06
   Change to form 07, set speed to index 07, increment condition flag by 01
else if HP damage and condition flag is 08
   Change to form 08, set speed to index 06, increment condition flag by 01
else if HP damage and condition flag is 0A
   Change to form 09, set speed to index 05, increment condition flag by 01
else if HP damage and condition flag is 0C
   Change to form 0A, set speed to index 04, increment condition flag by 01, display messages 48 and 49
else if HP damage and condition flag is 0E
   Change to form 0B, set speed to index 03, increment condition flag by 01
else if HP damage
   Increment condition flag by 01

was just done through observation, not some method that i'm just not grasping yet?  i guess that i keep thinking that it's more complicated than it is.

edit: i know that i ask what seem to you like dumb questions sometimes(well, usually :) ), but i really do appreciate the time you take to help me out.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 02:48:24 AM
if i understand you right, then something like this...

Quote
if HP damage and condition flag is 02
   Change to form 05, set speed to index 09, increment condition flag by 01
else if HP damage and condition flag is 04
   Change to form 06, set speed to index 08, increment condition flag by 01
else if HP damage and condition flag is 06
   Change to form 07, set speed to index 07, increment condition flag by 01
else if HP damage and condition flag is 08
   Change to form 08, set speed to index 06, increment condition flag by 01
else if HP damage and condition flag is 0A
   Change to form 09, set speed to index 05, increment condition flag by 01
else if HP damage and condition flag is 0C
   Change to form 0A, set speed to index 04, increment condition flag by 01, display messages 48 and 49
else if HP damage and condition flag is 0E
   Change to form 0B, set speed to index 03, increment condition flag by 01
else if HP damage
   Increment condition flag by 01

was just done through observation, not some method that i'm just not grasping yet?  i guess that i keep thinking that it's more complicated than it is.

The changing of forms is actually common to the monster. The Agility is hinted, but you would need to know the internal table to how much much slower the monster gets.

Testing this though.. apparently it takes 3 HP damaging attacks to change the monster's mode initally, and then it works every 2 attacks.. strange. I get the feeling the flag initially starts at 0xFF or the whole system isn't quite a direct if/else if type of mode...
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: bond697 on June 03, 2008, 03:26:05 AM
ok, I'm following you so far. Last question for tonight: how would you know about that table? A hacker having found/ shared it? And then using it, you'd compare the dmg/ speed(agility), etc and the number of turns it takes to advance the octomamm battle?
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 03, 2008, 03:30:23 AM
Quote from: bond697
if you guys don't mind me asking, HOW did you come up with these battle scripts? was it through interpreting the hex code? or did you disassemble the rom(or parts thereof?) and use the asm? if it's some kind of disassembly, could i get a look at it?

I study the battle scripts through the hex code. Someone else (I'm not sure who, originally) worked out what the attack script bytes meant. The condition bytes (the "if...then" statements) I worked through most of myself before I realized Zyrthofar had already done it. I got a few of the interpretations from his editor, and now I have a complete set of what the bytes mean. I just read the hex data and piece it together, then write it out if I'm going to comment on it here. I can post the formatted hex data and the meanings for the attack and condition bytes if you'd like. Let me get them pulled together tonight, and I'll attach them to this thread.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 03:32:50 AM
Edit: Never mind. Brain trauma due to lack of sleep is clouding any logical thoughts.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 03, 2008, 05:13:36 AM
Quote from: Deathlike2
Testing this though.. apparently it takes 3 HP damaging attacks to change the monster's mode initally, and then it works every 2 attacks.. strange

This works with the script. The flag starts at 00, and the reactions go like this:

1. Attack the first: condition flag is incremented to 01.
2. Attack the second: condition flag is incremented to 02.
3. Attack the third: the condition flag is at 02 and there is HP damage, so Octomamm's form changes and the flag is incremented to 03.

After that, it only takes two times:

4. Attack the fourth: the condition flag is incremented to 04.
5. Attack the fifth: the condition flag is at 04 and there is HP damage, so Octomamm's form changes and the flag is incremented to 05.
6. And so on, and so forth
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 03, 2008, 06:08:15 AM
Quote from: bond697
i know it's probably a dumb question, but i'm still learning about this rom hacking thing, and i can't help but wonder. i was also wondering the same thing before about how you discovered yang's oddball battle script that had to do with the pictures i posted on gamefaqs.

if you could explain it a lil bit, or maybe point me to a document that could, i'd really appreciate it. i've been working hard over here reading, etc, and practicing hacking with my hex editor and all the docs i can find, but i'd love to get to the level that you guys are at one day. so, i wanted to know how you do what it is that you're doing.

I'm always glad to be of help, as are the other people on this board. Ask as many questions as you need -- the more you understand the better your hacks will be, and I look forward to seeing what you'll produce. For the enemy attack sequences, you should download the Tower of Bab-il documents (they can be found in Deathlike2's "Useful Links" thread). There's a document in there describing where the data is and what is means. Once you understand that, you can use the three documents I've attached to this thread.

1. First, look up the enemy attack group. It's the 9th of the 10 bytes in the enemy stats data (another Tower of Bab-il document explains this).
2. Once you have this hex number, you can look it up in the Enemy Attack Group document. This will give you a series of 2-byte sets: first is the condition index, then the attack sequence index.
3. Look up the condition index(es) in the Enemy Condition Indices document. This tells you the condition for the following attack sequence byte.
4. Look up the attack sequence index(es) in the Enemy Attack Sequences document. This will give you a series of commands the enemy performs under the previous condition.

Here's an easy example: the Imp. If you look up it's attack group number, it's 00 (in hex). Look this up in the Enemy Attack Group document, and the data there is "55 00 01 02 00 01 FF." This gives you three 2-byte sets. Using the conditions document and the sequences document, you can tell the following:

55 00: Condition 55 is "if self is an egg". Sequence 00 is "E1 FF" which means "do nothing."
01 02: Condition 01 is "if charmed". Sequence 02 is "F9 24 C0 FF" which means "target a random enemy and attack."
00 01: Condition 00 is "no condition" (i.e. "otherwise). Sequence 01 is "C0 FF" which means "attack."

Let me know if the formatting in the documents is funky. I work on a Mac, so I'm not sure how it'll turn up in other OS's.

Edit: I don't think my interpretation of "F2" in the attack sequences is correct. It displays the dialogue, but doesn't do it while performing the next attack. Not sure what the difference is between "F1" and "F2". If anyone knows or figures it out, please share.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: bond697 on June 03, 2008, 01:20:32 PM
thanks for this. i do actually have the tower of babel docs. ever since i've found this place, i've been going through topics archiving any ff2/4/4et/4a data that i can find, so with these 3 text files, i've got quite a bit.

btw, i've been in love with ff2/4 since 91 when it came out (i'm 23 now), so having access to all this data is super-exciting. i've been trying to come up with a good idea for a hack as of late. i have all of this data, and nothing to do with it. :)

edit: i've actually been using zythofar's editor today to look over the battle scripts, now that i realized that you can do that. it's really making things a ton clearer for me. :)
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 01:33:15 PM
Edit: I don't think my interpretation of "F2" in the attack sequences is correct. It displays the dialogue, but doesn't do it while performing the next attack. Not sure what the difference is between "F1" and "F2". If anyone knows or figures it out, please share.

Post an example of those in action, then maybe I can figure something out.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 02:54:48 PM
Odin's lightning-death trigger seems to occur after you take two "Odin" attacks up the ass first. That section of code won't ever execute... though I think you can kinda trigger that out of order at random, but I could be wrong.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 03:53:20 PM
If I hadn't mentioned this before.. but the battle engine suffers a from a bug when changing elemental weaknesses during the elemental battle. When changing from lightning to holy weakness (Kainazzo/Cagnazzo to Valvalis/Barbariccia), lightning weakness is retained for whatever the reason.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Dragonsbrethren on June 03, 2008, 03:54:36 PM
Does that apply to all elements or just those two? If it applies to all, that might explain why lightning works so good on Cagnazzo regardless of his form.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 03:58:42 PM
Does that apply to all elements or just those two? If it applies to all, that might explain why lightning works so good on Cagnazzo regardless of his form.

Just those two.. someone needs to dig into the code to see why that occurs. It's a nice bug/bonus since you are queuing Rydia or FuSoYa to cast that spell.

The original Cagnazzo battle isn't affected by this bug.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 03, 2008, 09:29:59 PM
I finally got around to looking at Odin's script. His attack sequence per turn is:

1. Attack
2. Attack
3. Attack
4. Change graphic
5. Do nothing
6. Use enemy spell "Odin"
7. Attack
8. Attack
9. Change grahic
10. Do nothing
11. Use enemy spell "Odin"
12. Attack
13. Chain: Change graphic, set condition flag to 01
14. Set condition flag to 00 and use enemy spell "Odin"
[repeat from beginning]

His reflex sequence is: if condition flag is 01 and hit by lightning-elemental spell, display message 0x68 ("Thunder struck Odin!") and cast Vanish (instant kill) on self.

So, his script really is funky. You can only hit him with lightning to end the battle on every third time he raises his sword. And, for that one time, there's no pause in between the graphic change and the attack. You have to have pretty good timing (although you should be able to use any lighting spell, even Lit1, which would cast quickly). The weirdness of the script seems like a mistake to me, but perhaps that's how the programmers meant to write it. Anyway, mystery solved.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 09:35:45 PM
Yes, I've seen it and finally understood it after your explanation of the flag system (read earlier posts).

That's a friggen rarely seen message, given that it would be extremely difficult to survive...
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Dragonsbrethren on June 03, 2008, 09:43:55 PM
Yeah, it would make sense if it worked every time he raised his sword, but having to survive two Zantetsukens in a row? I doubt that's possible at any reasonable level you'd fight Odin at.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 09:46:20 PM
Well, assuming you aren't already damage efficent, you could try using Kain and time his Jump to avoid the attack. One of the others would be revived and take the fall for the damage. Rydia is probably the best candidate for this since she has to deal the lightning attack (you could just make Kain use an item instead).
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 03, 2008, 11:07:28 PM
Quote from: Phoenix
Edit: I don't think my interpretation of "F2" in the attack sequences is correct. It displays the dialogue, but doesn't do it while performing the next attack. Not sure what the difference is between "F1" and "F2". If anyone knows or figures it out, please share.
Quote from: Deathlike2
Post an example of those in action, then maybe I can figure something out.

Besides the Dark Elf example I posted, Yang's script and the Officer's script (where he says "Attack!") use F2. The Mist Dragon and Kainazzo's scripts use F1.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 03, 2008, 11:13:00 PM
Maybe it's just me.. but I don't quite see it.. perhaps laying out parts of the battle script and highlighting its use may be more helpful.

I think F2 is used for offensive attacks, while F1 is used by defensive counters.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 04, 2008, 12:03:26 AM
Hmm.. some of the battles need some audio changing/spicing up..
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on June 04, 2008, 01:06:12 AM
Quote
Maybe it's just me.. but I don't quite see it.. perhaps laying out parts of the battle script and highlighting its use may be more helpful.

Yeah, I can't quite figure it out either.

Quote
I think F2 is used for offensive attacks, while F1 is used by defensive counters.

This could be. I'll check out the patterns when I have the time.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on June 04, 2008, 01:10:24 AM
Quote
I think F2 is used for offensive attacks, while F1 is used by defensive counters.

This could be. I'll check out the patterns when I have the time.

Well, here's why I say that.

The Mist Dragon uses it as a counter to any attack in its invincible mist form.

I'm not sure when it is used in Kainazzo, but it has a reaction to Lightning to revert to its original form... and it also has an HP dependant form.

Yang uses it as part of his battle script...

The Officer uses it as part of his battle script...

The Dark Elf uses it in its battle script sequence...

That's a fair conclusion I'm drawing here, hence my response.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on January 19, 2009, 11:26:11 AM
 :bump:

This is worth a bump since I'm totally lost.

The attack sequences I get.. they are linked to a condition index (if charmed, execute script bleh) and whatnot.

I don't quite get the enemy condition index.. the list is understandable, but the stuff before that doesn't quite make sense to me.

Quote
Enemy Condition Indices (76900-76AFF)

[first byte of attack group sets]


00xxyyzz = if xx's status byte yy is status zz
01xx00yy = if xx's HP is less than [index yy of HP table at 76200]
020000xx = if condition flag is xx
020001xx = if reflex flag is xx
03xx0100 = if character xx is dead
040001xx = if enemy xx is dead
050000xx = if current enemy set is Overworld xx
050001xx = if current enemy set is Underground/Moon xx
06000000 = if only enemy type alive
07xxyyzz = if xx does command yy with element zz (00 = any)
08xxyyzz = ?? duplicated 07?
09000000 = ??
0A000000 = if HP damage
0B000000 = if only enemy alive
   Note: for character/enemy xx, values above 16 are xx-1

I kinda get that, but then again, I really don't. There seems to be something I'm totally missing.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Phoenix on January 21, 2009, 11:00:22 PM
Let me see if I can help clear it up. I renamed that little section at the top "Conditions Encoded Data", because it's the actual data that determines the conditions.

The Attack Sequence Groups are in two byte sets, like you said; for example, "If charmed, do such-and-such." The "if charmed" part is condition 01 -- that actual data that determines that is in the Conditions Encoded Data section.

The conditions are encoded in four bytes. Condition 00 is just FF FF FF FF (i.e. "nothing"). Condition 01 (the "if charmed" one) is 00 17 01 08. According to the guide I patched together, that means, "If 17's status byte 01 is status 08...". Since the character/enemy 17 is above 16, the value is 17 -1 = 16. 16 corresponds to "self", as seen in the Enemy Attack Sequences document. Status byte 01 is:
Code: [Select]
Byte Bit Text Notes
---- --- ---- -----
01: 7   Curse
6   Float
5   Paralyze
4   Sleep
3   Charm
2   Berserk
1   Petrify 2/3 petrified
0   D 1/3 petrified

Status 08 of this byte, when done in binary (08 = 00001000) corresponds to Charm. So, the translation is, "If self is charmed..." If you changed that 08 to 10 (in binary: 00010000), then the status would correspond to Sleep, and the condition would be, "If self is sleeping..."

Does all that make sense? Is that what you were asking?
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on January 21, 2009, 11:14:01 PM
Let me see if I can help clear it up. I renamed that little section at the top "Conditions Encoded Data", because it's the actual data that determines the conditions.

The Attack Sequence Groups are in two byte sets, like you said; for example, "If charmed, do such-and-such." The "if charmed" part is condition 01 -- that actual data that determines that is in the Conditions Encoded Data section.

The conditions are encoded in four bytes. Condition 00 is just FF FF FF FF (i.e. "nothing"). Condition 01 (the "if charmed" one) is 00 17 01 08. According to the guide I patched together, that means, "If 17's status byte 01 is status 08...". Since the character/enemy 17 is above 16, the value is 17 -1 = 16. 16 corresponds to "self", as seen in the Enemy Attack Sequences document. Status byte 01 is:
Code: [Select]
Byte Bit Text Notes
---- --- ---- -----
01: 7   Curse
6   Float
5   Paralyze
4   Sleep
3   Charm
2   Berserk
1   Petrify 2/3 petrified
0   D 1/3 petrified

Status 08 of this byte, when done in binary (08 = 00001000) corresponds to Charm. So, the translation is, "If self is charmed..." If you changed that 08 to 10 (in binary: 00010000), then the status would correspond to Sleep, and the condition would be, "If self is sleeping..."

Does all that make sense? Is that what you were asking?

Yes. I'm not entirely able to make head or tails of a number of these, but it would be of great help if the conditions and the internal settings follow each other in the docs, so I can visualize something more creative for them. It's much easier to decypher with examples.. although I don't think I'll use this information in the immediate future...

Although, I wonder if scripts that test sleep/paralysis status will follow its script.. because that opens a huge can of worms... addtionally that would explain a number of the phenomenom on the GBA port (in other words, the original code was already set up for FF4A's Zeromus EG specialized status scripts).
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on January 27, 2009, 11:48:54 PM
Code: [Select]
07 if magically attacked by a character
08 if hit by a character fire-elemental spell
09 if hit by a character ice-elemental spell
0A if hit by a character lightning-elemental spell
0B if magically attacked by a character?
0C if hit by a character fire-elemental spell?
0D if hit by a character ice-elemental spell?
0E if hit by a character lightning-elemental spell?
0F if hit by a character holy-elemental spell

I believe I think I know the difference.

In testing this... I set the Waterbug to switch its reaction counter from magic attacks to lightning attacks (0A)... what that produced was a counter reaction to single targeted Lightning attacks. I tested 0E, and found the monster to react to both single and multitargeted Lightning attacks... so there is an actual difference.

 :edit:

I didn't get a chance to post this earlier, but here's what I understand..

07-0A are used as counters...

08-0A has specific behavior.

1) The monster doesn't react to a multitargeted elemental attack if other units accompany them. For instance, using Ice on the group with only the Ballon monster left will cause one of them to Explode, but if it is accompanied by a Grudger for instance, they don't react.

2) The monster will always react to a single targeted elemental attack.

0B-0F is used in non-counter scripts.

0C-0F has specific behavior.

The Spirit series of monsters follow the "do nothing when ice is used" script ONLY if they are single targeted. I never really knew that was possible.. so you can "freeze" these monsters into doing nothing. It won't be doable if you use the IceRod and attack every unit... you have to use a single target the Ice1 spell.

When 0C-0F is used as a counter script, monsters will react regardless of accompanying units.

08-0A behaves like 0C-0F for non-counter scripts.

Note: These properties used in non-counter scripts seem to hold for the rest of the battle... overriding the Always condition (although, this could change with more than one condition)

Also, 07 and 0B react regardless of the targeting used for the magic attack.

 :edit:

Hmm.. under different formations, the 08-0A doesn't cause the same counter script to work... oh well.
Title: Re: FF2 Battle Script That's Different Than FF4
Post by: Deathlike2 on February 04, 2009, 11:30:36 AM
Ok, I think I now understand it better, but your doc needs to be improved.

All info assumes a headered ROM.

0x76900 is where the condition data lies.. which is fine. However, it's really just the "building blocks" to the complex conditions. These 2-byte sets make up a condition.

0x76800 is where the complex conditions are built. Multiple conditions can be combined here. FF terminates the complex condition. That is where you build off that condition list which has been documented in detail.

It's actually unfortunate that there isn't a lot of space to add onto existing conditions.. rather, space has to be made. Plenty of space can be had if say some of the lamer conditions get removed (pretty much Rubicant's fire-reviving counter script is a good start).  I should be able to improve on stuff based on this knowledge.