Author Topic: [FF8] Ability data and Angel Wing mechanics  (Read 1008 times)

Callisto

  • Crazy poster
  • *
  • Posts: 196
  • Karma: 10
    • View Profile
[FF8] Ability data and Angel Wing mechanics
« on: 2019-02-24 23:53:42 »
Does anyone have an insight into how character Ability effects are encoded within the game's executable? I would like to get rid of HP Bonus, Str Bonus etc and overwrite their effects with something new, like Zero Exp for the character who has the Ability equipped, or Auto-Regen.

The max you can do in Doomtrain tool is swapping the already existing Ability effects around (such as Mug taking Med Data's effect and the like), so I suspect that the actual Ability data is somewhere in the exe. In the case of making a Zero Exp Ability work, for example, I guess it would be helpful to look up what makes the Petrify status cause a character to receive 0 Exp after a battle. Auto-Regen would be likely even easier to implement.

There also seem to be some unused character Abilities as seen in the picture below, but from what I've tested, these do nothing at all. Filling these four slots with something new or overwriting already existing effects as stated above would be super nice. Any help would be much appreciated.

« Last Edit: 2019-03-15 00:38:05 by Callisto »

Callisto

  • Crazy poster
  • *
  • Posts: 196
  • Karma: 10
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #1 on: 2019-03-15 00:37:37 »
One more question, this time about Angel Wing:

I am currently searching for the instruction that restricts Rinoa's spell usage to what she has in her inventory, in hopes of finding a way to disable this, so she can cast any offensive spell.

Would be also interesting to know what determines the probability for each spell being used. I'm pretty sure it's not just weighted based on spell power, as Rinoa would still cast Fire way more often than Ultima, even after setting Fire's spell power to max. Another thing I have observed is that when changing the default target of the Fire spell to own party, it would no longer be used under Angel Wing at all.

I have checked the few unknown bytes in the Magic Data section in kernel.bin, and none didn't seem to have any impact on spell usage under Angel Wing. Also tried searching memory using debugger a bit, but no good results yet. Does anyone know more?

JWP

  • Crazy poster
  • *
  • Posts: 190
  • Karma: 23
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #2 on: 2019-03-16 15:33:23 »
The spell used under Angel Wing is decided in function 0x483D60.
« Last Edit: 2019-03-16 15:37:13 by JWP »

Callisto

  • Crazy poster
  • *
  • Posts: 196
  • Karma: 10
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #3 on: 2019-03-16 16:38:22 »
Thanks, I'll have a look at it.

I generally think that this Limit Break is in dire need of a redesign. There are only the two extremes - either being next to useless when carrying multiple offensive spells, or just broken when leaving Meteor as the only spell. Of course, we could just change Angel Wing's damage multiplier (thanks to your efforts), or just add a status change like Vit 0 to Angel Wing using Doomtrain, but I don't think this alone would be enough. Ignoring the inventory check and setting spell probability would be very helpful to balance this out too.
« Last Edit: 2019-03-16 16:40:07 by Callisto »

JWP

  • Crazy poster
  • *
  • Posts: 190
  • Karma: 23
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #4 on: 2019-03-17 00:56:09 »
I'm not sure where these other places are getting the probabilities from but I see no indication of any magic specific weighting.
The function counts the number of valid magics and if it's not zero, it generates a random number between 0 and 31.
It then selects the magic in this slot, if there is no magic in this slot or the targeting isn't valid, it keeps selecting the next slot until it finds a valid one (and loops around).
This means that if you have a lot of empty magic slots at the end, the first slot ends up being more likely than the others.

It would be possible to create a table of weights for each of the magics but you would either have to make sure that the sum of the weights are <=256 or use a different way of generating random numbers than the one usually used in the battle module.

Easiest way would probably be to make the weights for the 56 spells listed here: https://github.com/alexfilth/doomtrain/wiki/Magic-data
total 256 since it would mean you wouldn't have to worry about evening the outcomes and I could probably whip a patch up if you came up with a table.
« Last Edit: 2019-03-17 18:28:54 by JWP »

Callisto

  • Crazy poster
  • *
  • Posts: 196
  • Karma: 10
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #5 on: 2019-03-17 20:12:45 »
Wow, great findings!

On the one hand, I'm relieved that the mechanics around Angel Wing have been finally demystified, but on the other, the fact that spell selection can be further manipulated by moving them to certain slots is kind of saddening... That means that even more offensive spells other than Meteor can be safely kept to make Rinoa cast Meteor regularly. Removing all offensive spells except Meteor is at least some kind of trade-off, but it doesn't even seem necessary at all... Oh well.

Well anyway, I've prepared a table you could likely put into a code cave, and then hijack the function and make it jump to that table:

Code: [Select]
rnd = [0..255]
if (rnd < 11) {
   Spell ID 3 (Firaga) {
}
else if (rnd < 22) {
   Spell ID 6 (Blizzaga)
}
else if (rnd < 32) {
   Spell ID 9 (Thundaga)
}
else if (rnd < 38) {
   Spell ID 0A (Water)
}
else if (rnd < 44) {
   Spell ID 0C (Bio)
}
else if (rnd < 50) {
   Spell ID 2D (Pain)
}
else if (rnd < 56) {
   Spell ID 31 (Meltdown)
}
else if (rnd < 62) {
   Spell ID 0D (Demi)
}
else if (rnd < 94) {
   Spell ID 12 (Tornado)
}
else if (rnd < 126) {
   Spell ID 11 (Quake)
}
else if (rnd < 174) {
   Spell ID 0F (Flare)
}
else if (rnd < 222) {
   Spell ID 0E (Holy)
}
else if (rnd < 238) {
   Spell ID 10 (Meteor)
}
else {
   Spell ID 13 (Ultima)
}

I'm pretty sure that these 14 spells are the only ones I want to be compatible with Angel Wing - no more pointless Scans, Sleeps etc. If that works, I'll make them all break the damage limit and increase the damage multiplier to 4 or 5 again (it's currently at 3). Let me know if you need more information, and thanks for all your work!

JWP

  • Crazy poster
  • *
  • Posts: 190
  • Karma: 23
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #6 on: 2019-03-17 21:09:48 »
Hmm... so I've managed to get a patch table working as expected, the only problem is that if Rinoa doesn't have the spell in stock, she jumps forward and the spell name appears but nothing is cast.
There must be some sort of other check elsewhere :(.

EDIT:
found where it is and did a hacky patch but I'm not sure the best way to fix it.
« Last Edit: 2019-03-17 21:38:39 by JWP »

JWP

  • Crazy poster
  • *
  • Posts: 190
  • Karma: 23
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #7 on: 2019-03-17 22:07:23 »
From your post, it looks like you want the following weightings:
Code: [Select]
Firaga - 11
Blizzaga - 11
Thundaga - 10
Water - 6
Bio - 6
Pain - 6
Meltdown - 6
Demi - 6
Tornado - 32
Quake - 32
Flare - 48
Holy - 48
Meteor - 16
Ultima - 18

here is a patch that should do the trick:
Code: [Select]
0x483D67 - does the lookup
E8 B4 B2 00 00 25 FF 00 00 00 31 DB 31 C9 31 D2 8A 9A 88 3D 48 00 01 D9 42 39 C1 7E F3 B3 40 EB 70

0x483D88 - spell table
00 00 0B 00 00 0B 00 00 0A 06
00 06 06 30 30 10 20 20 12 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 06 00 00 00 06 00
00 00 00 00 00 00

0x483DC0 - tests for angel wing and skips inventory check if true
05 82 F0 CF 01 8D 2C 52 8D 2C AA C1 E5 04 F6 85 1B 7B D2 01 02 0f 85 65 9A 00 00 E9 27 9A 00 00

0x48D802 - jumps to angel wing test from start of inventory check
E9 B9 65 FF FF

not 100% sure I got the table right but give it a shot.
« Last Edit: 2019-03-18 12:50:52 by JWP »

Callisto

  • Crazy poster
  • *
  • Posts: 196
  • Karma: 10
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #8 on: 2019-03-17 22:13:27 »
Alright, will do, and report back soon.

Weightings look good, but I actually wanted the -aga spells all be at 11, but that was my mistake. I guess I could always change these numbers easily anyway.

I wonder if having a look at Selphie's Slots could help with a better fix? Because the spells that appear there are completely independent from what Selphie has in her inventory. So there should be a way to make Angel Wing spells ignore the inventory check completely as well, at least theoretically.

Just a thought - I don't really know how it's all set up in the exe and if this comparison makes any sense, but Slot is the first thing that came to mind.

JWP

  • Crazy poster
  • *
  • Posts: 190
  • Karma: 23
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #9 on: 2019-03-17 22:41:13 »
Good idea but it didn't seem to work.
Selphie's slots uses attack type 0x10 instead of 0x02 (Magic), I tried changing the attack type and it cast the spell successfully but it soft locked after it finished :(.
You can change the numbers but just make sure they add up to 256 or there's a chance that the game could load an invalid spell.

Also you don't actually need that jump patch since the condition is never true anyway.

If you're curious, the patched code looks like this:

Code: [Select]
00483D67 | E8 B4B20000              | call <ff8_en.battle_random_number>                              | eax = random number [0..255]
00483D6C | 25 FF000000              | and eax,FF                                                      |
00483D71 | 31DB                     | xor ebx,ebx                                                     | ebx = 0
00483D73 | 31C9                     | xor ecx,ecx                                                     | ecx = 0 - used to store running total
00483D75 | 31D2                     | xor edx,edx                                                     | edx = 0 - used to store magic id
label:
00483D77 | 8A9A 883D4800            | mov bl,byte ptr ds:[edx+483D88]                                 | load byte from table to bl (ebx)
00483D7D | 01D9                     | add ecx,ebx                                                     | add byte from table to running total
00483D7F | 42                       | inc edx                                                         |
00483D80 | 39C1                     | cmp ecx,eax                                                     |
00483D82 | 7E F3                    | jle ff8_en.483D77                                               | jump to label if total <= random number
00483D84 | B3 40                    | mov bl,40                                                       | bl is used later to test targeting
00483D86 | EB 70                    | jmp ff8_en.483DF8                                               | jump past table to resume testing targeting stuff

IMPORTANT NOTE: there might be a bug where the total doesn't get to 256 because it's adding to dl rather than (e)dx, I'll have to investigate it.
EDIT: I've fixed the patch in the previous post - the spell table also had to move
EDIT1: Proper test for angel wing has been added to skip the inventory check - see previous post.
« Last Edit: 2019-03-18 02:06:44 by JWP »

Callisto

  • Crazy poster
  • *
  • Posts: 196
  • Karma: 10
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #10 on: 2019-03-18 13:13:31 »
Ok, so I checked out your patch, waited for all table spells to be cast at least once, put Rinoa under several status changes, killed her, revived her etc, all while being under Angel Wing, and I didn't notice anything wrong. The only thing that surprised me was that it took very long for Thundaga to be used, way longer than Demi, Bio etc, but it was most likely just bad luck.

Guess I'll change these probabilities again, making sure the sum is always 256. Really a good idea to implement the table the way you did, so every user can set up the spells they want, and change again any time. Good work!

On another note, does Rinoa actually receive a Speed bonus while under Angel Wing? Some sources state it, some not. Never noticed it myself to be honest, as her ATB bar never seemed to go any faster.

JWP

  • Crazy poster
  • *
  • Posts: 190
  • Karma: 23
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #11 on: 2019-03-18 14:33:43 »
As far as I'm aware, no. The most reliable source is: https://gamefaqs.gamespot.com/ps/197343-final-fantasy-viii/faqs/58936 as it looks like it was compiled from reverse engineering.
I'd probably give Rinoa a 1/256 chance of casting "The End" for entertainment :P.

Kefka

  • Crazy poster
  • *
  • Posts: 177
  • Karma: 10
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #12 on: 2019-05-08 08:25:02 »
here is a patch that should do the trick:
Code: [Select]
0x483D67 - does the lookup
E8 B4 B2 00 00 25 FF 00 00 00 31 DB 31 C9 31 D2 8A 9A 88 3D 48 00 01 D9 42 39 C1 7E F3 B3 40 EB 70

0x483D88 - spell table
00 00 0B 00 00 0B 00 00 0A 06
00 06 06 30 30 10 20 20 12 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 06 00 00 00 06 00
00 00 00 00 00 00

0x483DC0 - tests for angel wing and skips inventory check if true
05 82 F0 CF 01 8D 2C 52 8D 2C AA C1 E5 04 F6 85 1B 7B D2 01 02 0f 85 65 9A 00 00 E9 27 9A 00 00

0x48D802 - jumps to angel wing test from start of inventory check
E9 B9 65 FF FF

not 100% sure I got the table right but give it a shot.

Great work JWP, I love this patch and would like to use it, too. But I'm using the german ff8.exe, and the offsets are a bit different there, so to make sure I'm inserting the patch in the correct places could you give me the original byte sequence that needs to be overwritten by your patch? Thanks.

JWP

  • Crazy poster
  • *
  • Posts: 190
  • Karma: 23
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #13 on: 2019-05-08 20:03:22 »
Sure, here you go:
Code: [Select]
0x483D67 - does the lookup
from: 8D 0C C5 00 00 00 00 BA 20 00 00 00 2B C8 B3 40 8D 34 88 C1 E6 04 81 C6 00 F0 CF 01 33 FF 8D 8E 82
to:   E8 B4 B2 00 00 25 FF 00 00 00 31 DB 31 C9 31 D2 8A 9A 88 3D 48 00 01 D9 42 39 C1 7E F3 B3 40 EB 70

0x483D88 - spell table
from:
00 00 00 8A 01 84 C0 74 11 25
FF 00 00 00 6B C0 3C 84 98 6E
40 CF 01 74 01 47 83 C1 05 4A
75 E3 85 FF 75 07 B8 FF 00 00
00 EB 47 E8 68 B2 00 00 25 FF
00 00 00 8B C8 81
to:
00 00 0B 00 00 0B 00 00 0A 06
00 06 06 30 30 10 20 20 12 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 06 00 00 00 06 00
00 00 00 00 00 00

0x483DC0 - tests for angel wing and skips inventory check if true
from: E1 1F 00 00 80 79 05 49 83 C9 E0 41 8D 54 8E 68 8A 44 11 1A 84 C0 74 10 25 FF 00 00 00 6B C0 3C
to:   05 82 F0 CF 01 8D 2C 52 8D 2C AA C1 E5 04 F6 85 1B 7B D2 01 02 0f 85 65 9A 00 00 E9 27 9A 00 00

0x48D802 - jumps to angel wing test from start of inventory check
from: 05 82 F0 CF 01
to:   E9 B9 65 FF FF

You'll likely run into an issue with the memory offset for the lookup table in the code being wrong (the "88 3D 48 00" bytes in the first section), I think the rest is relative, so you might be all right with the jumps.
« Last Edit: 2019-05-08 20:09:15 by JWP »

Kefka

  • Crazy poster
  • *
  • Posts: 177
  • Karma: 10
    • View Profile
Re: [FF8] Ability data and Angel Wing mechanics
« Reply #14 on: 2019-05-09 07:21:46 »
Awesome, thanks for the answer! Ok, so the "88 3D 48 00" is the pointer referring to the offset of the english exe, so I'll have to change it accordingly to whatever the offset in the german exe is. Thanks a ton, will try it as soon as I reach that point in the game where Angel Wing becomes available.